Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load pre-trained model #4

Closed
flipz357 opened this issue Jun 12, 2020 · 4 comments
Closed

Cannot load pre-trained model #4

flipz357 opened this issue Jun 12, 2020 · 4 comments

Comments

@flipz357
Copy link

flipz357 commented Jun 12, 2020

Hi Deng,

thanks for the awesome work. I am interested in parsing arbitrary sentence. I took your advice with appending the sentences with dummy-AMRs to the test. The preprocessing worked fine so far, however, when I want to apply the pre-trained model to predict using work.sh (with adapted file path for pre-trained model), I get the following error:

File "/xxxxx/AMR-gs/parser/work.py", line 94, in
model_args = torch.load(fname)['args']
....
File "/zzzzzr/lib/python3.6/site-packages/torch/serialization.py", line 563, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\x00'

The path in work.sh looks as follows:

--load_path amr2.0.bert.gr \

Previously I had downloaded your pre-trained model in the main directory and used tar -xvzf to extract. Did I make any error in the extraction process? My amr2.0.bert.gr contains a file "ckpt.pt" and a directory "vocabs".

@jcyk
Copy link
Owner

jcyk commented Jun 13, 2020

the --load_path should only point to the ckpt.pt file, not the whole directory. The vocab files should be placed to the directory specified by model_args, see

AMR-gs/parser/work.py

Lines 101 to 109 in b9c0043

vocabs['tok'] = Vocab(model_args.tok_vocab, 5, [CLS])
vocabs['lem'] = Vocab(model_args.lem_vocab, 5, [CLS])
vocabs['pos'] = Vocab(model_args.pos_vocab, 5, [CLS])
vocabs['ner'] = Vocab(model_args.ner_vocab, 5, [CLS])
vocabs['predictable_concept'] = Vocab(model_args.predictable_concept_vocab, 5, [DUM, END])
vocabs['concept'] = Vocab(model_args.concept_vocab, 5, [DUM, END])
vocabs['rel'] = Vocab(model_args.rel_vocab, 50, [NIL])
vocabs['word_char'] = Vocab(model_args.word_char_vocab, 100, [CLS, END])
vocabs['concept_char'] = Vocab(model_args.concept_char_vocab, 100, [CLS, END])

I am sorry for this inconvenience.

@flipz357
Copy link
Author

flipz357 commented Jun 13, 2020

Thanks, Deng, it works now!

@jcyk
Copy link
Owner

jcyk commented Jun 13, 2020

It seems to me that the result is good, except for that you did not do the post-processing step so the result is incomplete. please let me know your point so I can help --). @fliegenpilz357

@flipz357
Copy link
Author

flipz357 commented Jun 13, 2020

Oh, stupid me! This is completely right, I did not run the post processing. Thank you for your patience and the quick answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants