Coder Social home page Coder Social logo

yzhangcs / crfsrl Goto Github PK

View Code? Open in Web Editor NEW
61.0 4.0 7.0 92.83 MB

[COLING'22] Code for "Semantic Role Labeling as Dependency Parsing: Exploring Latent Tree Structures Inside Arguments".

Home Page: https://aclanthology.org/2022.coling-1.370/

License: MIT License

Shell 22.26% Python 77.74%
semantic-role-labeling span-based treecrf coling2022

crfsrl's Introduction

Hi there ๐Ÿ‘‹

My name is Yu Zhang ([jy tสƒษ‘ล‹], ๅผตๅฎ‡/ๅผ ๅฎ‡ in traditional/simplified Chinese).

  • ๐Ÿ”ญ I'm currently a first-year PhD student at SUDA-HLT, fortunately advised by Zhenghua Li.
  • ๐ŸŒฑ My main research interest focuses on structured prediction, e.g., sequence labeling, syntactic (dependency/constituency) parsing, and semantic parsing, etc.
  • ๐Ÿ“ซ You can reach me via outlook and foxmail.
github contribution grid snake animation

crfsrl's People

Contributors

yzhangcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

crfsrl's Issues

RuntimeError while using the train script

Hi,

I have preprocessed the Conll05 data and am trying to train the SRL model using your train scripts but I am bumping into a RuntimeError. Here's the stack trace:

  self._train(train.loader)
  File "/home/sanchit/crfsrl/crfsrl/parser.py", line 133, in _train
    s_edge, s_role = self.model(words, feats)
  File "/home/sanchit/crfsrl/.venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/sanchit/crfsrl/crfsrl/model.py", line 162, in forward
    s_role = self.role_attn(role_d, role_h).permute(0, 2, 3, 1)
RuntimeError: number of dims don't match in permute

So I printed the s_role's shape ([1, 26, 26]) before permuting it and it's a 3d tensor, unlike the operation that is being performed above. Can you have a look at this?
Thanks a lot!

Error while generating ConLL dataset objects for training the model

Hi,

I have been getting an assertion error when trying to generate data for the ConLL training.

Converting data/conll05/train.prop to conllu format
  0%|                                                                          | 49/989860 [00:01<9:20:53, 29.41it/s]
Traceback (most recent call last):
  File "scripts/prop2conllu.py", line 76, in <module>
    process(args.prop, args.file)
  File "scripts/prop2conllu.py", line 61, in process
    sentences.append(prop2conllu(lines[start:i]))
  File "scripts/prop2conllu.py", line 41, in prop2conllu
    assert len(prds) == len(args)
AssertionError

Can you please have a look at this?
The command that I used to run the script: bash scripts/conll05.sh PTB=ptb SRL=data

Predict mode with --prob option throws RuntimeError

Hello, @yzhangcs.
Thank you for sharing your great work!!
After training a model, I'm trying to get probabilities of each answers on "predict" mode.
But, I got an error shown below from File "/crfsrl/crfsrl/parser.py", line 272, in _predict.
I tried to cast the lens tensor into another type but it doesn't work.
Would it be possible to get any advices to fix this ??

preds['probs'].extend([prob[1:i, :i].cpu() for i, prob in zip(lens.softmax(-1).unbind())])
RuntimeError: "host_softmax" not implemented for 'Long' 

There is no 'INIT', 'CACHE' in your library

In crf.py, and crf2o.py,

from supar.cmds.cmd import init
from supar.utils.common import CACHE

but init and CACHE not existing. in any installable version of pypi, how can I solve this?

Error when training with conll12

When I run the following command,

python -u crf.py train -b -c configs/conll12.crf.srl.bert.ini -d 0 -p exp/conll12.crf.srl.bert/model --batch-size=1000 --encoder bert --bert bert-large-cased --cache --binarize

I suffer from the error below:

tdteach@tdteach-u2004:~/workspace/crfsrl$ python -u crf.py train -b -c configs/conll12.crf.srl.bert.ini -d 0 -p exp/conll12.crf.srl.bert/model --batch-size=1000 --encoder bert --bert bert-large-cased --cache --binarize
2022-07-16 17:21:18 INFO
---------------------+-------------------------------
Param | Value
---------------------+-------------------------------
bert | bert-large-cased
n_bert_layers | 4
mix_dropout | 0.0
bert_pooling | mean
encoder_dropout | 0.1
n_edge_mlp | 500
n_role_mlp | 100
mlp_dropout | 0.1
lr | 5e-05
lr_rate | 20
mu | 0.9
nu | 0.9
eps | 1e-12
weight_decay | 0
clip | 5.0
min_freq | 2
fix_len | 20
epochs | 10
warmup | 0.1
update_steps | 1
batch_size | 1000
prd | False
mode | train
path | exp/conll12.crf.srl.bert/model
device | 0
seed | 1
threads | 16
workers | 0
cache | True
binarize | True
amp | False
feat | None
build | True
checkpoint | False
finetune | False
encoder | bert
max_len | None
buckets | 32
train | /home/tdteach/.cache/supar/data/srl/conll12/train.conllu
dev | /home/tdteach/.cache/supar/data/srl/conll12/dev.conllu
test | /home/tdteach/.cache/supar/data/srl/conll12/test.conllu
embed | glove-6b-100
---------------------+-------------------------------

2022-07-16 17:21:18 INFO Building the fields
Using bos_token, but it is not set yet.
2022-07-16 17:21:19 INFO CoNLL(
(words): SubwordField(vocab_size=28996, pad=[PAD], unk=[UNK], bos=[CLS])
(edges): ChartField(use_vocab=False)
(roles): ChartField(vocab_size=1, unk=O)
(spans): RawField()
)
2022-07-16 17:21:19 INFO Building the model
2022-07-16 17:21:25 INFO CRFSemanticRoleLabelingModel(
(encoder): TransformerEmbedding(bert-large-cased, n_layers=4, n_out=1024, stride=256, pooling=mean, pad_index=0, finetune=True)
(encoder_dropout): Dropout(p=0.1, inplace=False)
(edge_mlp_d): MLP(n_in=1024, n_out=500, dropout=0.1)
(edge_mlp_h): MLP(n_in=1024, n_out=500, dropout=0.1)
(role_mlp_d): MLP(n_in=1024, n_out=100, dropout=0.1)
(role_mlp_h): MLP(n_in=1024, n_out=100, dropout=0.1)
(edge_attn): Biaffine(n_in=500, bias_x=True)
(role_attn): Biaffine(n_in=100, bias_x=True, bias_y=True)
)

2022-07-16 17:21:27 INFO Loading the data
2022-07-16 17:21:27 INFO Seeking to cache the data to /home/tdteach/.cache/supar/data/srl/conll12/train.conllu.pt first
Traceback (most recent call last):
File "crf.py", line 43, in
main()
File "crf.py", line 39, in main
init(parser)
File "/media/tdteach/LinuxWork/workspace/crfsrl/supar/cmds/cmd.py", line 34, in init
parse(0 if torch.cuda.is_available() else -1, args)
File "/media/tdteach/LinuxWork/workspace/crfsrl/supar/cmds/cmd.py", line 54, in parse
parser.train(**args)
File "/media/tdteach/LinuxWork/workspace/crfsrl/crfsrl/parser.py", line 72, in train
train = Dataset(self.transform, args.train, **args).build(batch_size, buckets, True, dist.is_initialized(), workers)
File "/media/tdteach/LinuxWork/workspace/crfsrl/supar/utils/data.py", line 160, in build
with cache(self.transform.load(self.data, **self.kwargs)) as chunks, mp.Pool(32) as pool:
File "/home/tdteach/anaconda3/envs/allennlp/lib/python3.8/contextlib.py", line 113, in enter
return next(self.gen)
File "/media/tdteach/LinuxWork/workspace/crfsrl/supar/utils/data.py", line 145, in cache
sentences = binarize({'sentences': progress_bar(sentences)}, fs)[1]['sentences']
KeyError: 'sentences'

Trained model

Hi! I was wondering if you plan to release a trained model any time soon? I do not have direct access to Ontonotes so training the model would be impossible for me :(

Comparison with predpatt?

Hi, I truly believe dependency parsing has a huge potential for semantic role labeling/information extraction.
Predpatt is some intersting prior work and I wonder how they compare on precision/recall, please benchmark!
https://www.cs.jhu.edu/~s.zhang/assets/pdf/iwcs17.pdf

Moreover, regarding a way to further increase accuracy, I wonder if you could leverage Enhanced dependencies which predpatt unfortunately do not make use of.. despite their impressive expressive power.
@yzhangcs

Syntax errors while running script to extract data

Hi,
I get the following error while running the first script to extract the data:

[dnagaraj@tir crfsrl]$ bash scripts/conll05.sh PTB=/projects/tir1/corpora/treebank_3 SRL=data
PTB: /projects/tir1/corpora/treebank_3
SRL: data
Extracting evaluation files
Converting data/conll05/train.prop to conllu format
File "scripts/prop2conllu.py", line 30
rels[start-1] = '|'.join((rels[start-1], f'{prd}:B-{label}'))
^
SyntaxError: invalid syntax
Converting data/conll05/dev.prop to conllu format
File "scripts/prop2conllu.py", line 30
rels[start-1] = '|'.join((rels[start-1], f'{prd}:B-{label}'))
^
SyntaxError: invalid syntax
Converting data/conll05/test.prop to conllu format
File "scripts/prop2conllu.py", line 30
rels[start-1] = '|'.join((rels[start-1], f'{prd}:B-{label}'))
^

Please could you let me know why this is the case and what should I do to resolve this error.
Thanks in advance :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.