lavis-nlp / spert

PyTorch code for SpERT: Span-based Entity and Relation Transformer
MIT License
685 stars 146 forks source link

Can't make predictions following the example #52

Closed xegulon closed 3 years ago

xegulon commented 3 years ago

I'm, thanks for the code

I've tried to run the predictions mode following this: https://github.com/lavis-nlp/spert#examples.

I have downloaded the spacy model, but I get the following error:

OSError: Can't load tokenizer for 'data/models/conll04'. Make sure that: ...

How can I solve it?

markus-eberts commented 3 years ago

Did you fetch the preprocessed datasets and models first? There should be a conll04 model under /data/models. If not, try this: bash ./scripts/fetch_datasets.sh bash ./scripts/fetch_models.sh

xegulon commented 3 years ago

Yeah I've already done this, the download went well:

image

markus-eberts commented 3 years ago

It works for me. Did you navigate into the root SpERT folder (with the spert.py file) and executed 'python ./spert.py predict --config configs/example_predict.conf'? Which transformers version are you using?

xegulon commented 3 years ago

Finally it works. My mistake was that I ran the script from elsewhere than the root folder. Thanks!

xegulon commented 3 years ago

However, I can't make predictions with raw .txt files. I get a JSON error.

markus-eberts commented 3 years ago

Yes, the code currently supports only JSON input files in one of the three formats shown in 'conll04_prediction_example.json'

markus-eberts commented 3 years ago

For example, you can convert sentences of your .txt file into the following format (list of sentences) and save it as a JSON file: [ "In 1822, the 18th president of the United States, Ulysses S. Grant, was born in Point Pleasant, Ohio.", "Sentence 2", "Sentence 3", ...]

xegulon commented 3 years ago

Ow I see thanks a lot! What about using it for inference like what I asked there https://github.com/lavis-nlp/spert/issues/51 ?