neulab / neural-lpcfg

The Return of Lexical Dependencies: Neural Lexicalized PCFGs (TACL)
https://arxiv.org/abs/2007.15135
Other
33 stars 1 forks source link

Missing Dependency: cfg2dep #2

Open kushalarora opened 3 years ago

kushalarora commented 3 years ago

Hello,

First of all, I would like to congratulate you on this paper. I really enjoyed reading it and am planning to build on top of it.

I was trying to run your code but encountered an issue due to a missing dependency on cfg2dep. I am not sure if this is due to a missing package or a piece of code that was not committed.

Here is the stack trace of the error.

Checking validation perf...
Traceback (most recent call last):
  File "train.py", line 459, in <module>
    main(args)
  File "train.py", line 330, in main
    val_ppl, val_f1 = eval(val_data, model)
  File "train.py", line 385, in eval
    gold_tree.append(get_span2head(gold_spans[j], heads[j], gold_actions=gold_actions[j], gold_tags=gold_tags[j]))
  File "/lustre03/project/6004852/karora/neural-lpcfg/utils.py", line 452, in get_span2head
    from cfg2dep import parse_line
ModuleNotFoundError: No module named 'cfg2dep'

I also tried to run the program without --evaluate_dep flag but encountered the following error.

Checking validation perf...
Traceback (most recent call last):
  File "train.py", line 459, in <module>
    main(args)
  File "train.py", line 330, in main
    val_ppl, val_f1 = eval(val_data, model)
  File "train.py", line 384, in eval
    for j in range(len(heads)):
UnboundLocalError: local variable 'heads' referenced before assignment

Let me know if I am doing something wrong. I installed torch==1.5.1, nltk, and amp before running the code.

Regards, Kushal

ProKil commented 3 years ago

Hi Kushal,

Thanks for pointing out these two problems. For the former one, I have uploaded cfg2dep.py. For the latter one, I will take a look and support the negative evaluate_dep argument.

Best, Hao

kushalarora commented 3 years ago

Thank you Hao for the quick response.

I ran the code with cfg2dep.py but I am still facing some issues. Here is the attached stacktrace.

Checking validation perf...
Traceback (most recent call last):
  File "train.py", line 459, in <module>
    main(args)
  File "train.py", line 330, in main
    val_ppl, val_f1 = eval(val_data, model)
  File "train.py", line 406, in eval
    tp_by_cat, all_by_cat = get_stats_by_cat(span_b_set, gold_b_set, gold_tree[b])
  File "/lustre03/project/6004852/karora/neural-lpcfg/utils.py", line 145, in get_stats_by_cat
    all_[gold_tree[span][1]] += 1
KeyError: (0, 1)

Let me know if you need more information from my side.