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

Troubles encountered to make it work properly, some updates needed #7

Open
djowalker opened this issue Dec 22, 2021 · 3 comments
Open

Comments

@djowalker
Copy link

Due to version mismatch, it seems like tock-flair is no more working.

I use python 3.8 on venv.

Some changes made to progress in installation :

#before
torch==1.3.1
torchvision==0.4.2
numpy==1.18.1
#now
numpy==1.20.0
torch==1.4.0
torchvision==0.5.0

I had to get the models from now from :

curl https://flair.informatik.hu-berlin.de/resources/models/ner-fast/en-ner-fast-conll03-v0.4.pt -o models/en-ner-fast-conll03-v0.4.pt
curl https://flair.informatik.hu-berlin.de/resources/models/fr-ner/fr-ner-wikiner-0.4.pt -o models/fr-ner-wikiner-0.4.pt

When i launch the server i have the following error wich seems to come from the torch package that evolved since 1.3.1 (no more existing and minimum 1.4.0) :

Traceback (most recent call last):
  File "application.py", line 2, in <module>
    from ner import get_flair, evaluate
  File "/home/djowalker/tock/tock-flair/ner.py", line 18, in <module>
    flair_fr = load_flair_fr()
  File "/home/djowalker/tock/tock-flair/ner.py", line 11, in load_flair_fr
    return SequenceTagger.load(path.join(Path.cwd(), 'models/fr-ner-wikiner-0.4.pt'))
  File "/home/djowalker/Arkea/tock/tock-flair/venv/lib/python3.8/site-packages/flair/nn.py", line 86, in load
    model = cls._init_model_with_state_dict(state)
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/flair/models/sequence_tagger_model.py", line 238, in _init_model_with_state_dict
    model = SequenceTagger(
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/flair/models/sequence_tagger_model.py", line 201, in __init__
    self.to(flair.device)
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 443, in to
    return self._apply(convert)
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 203, in _apply
    module._apply(fn)
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 203, in _apply
    module._apply(fn)
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 203, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/rnn.py", line 149, in _apply
    self._flat_weights = [(lambda wn: getattr(self, wn) if hasattr(self, wn) else None)(wn) for wn in self._flat_weights_names]
  File "/home/djowalker/tock/tock-flair/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 593, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'LSTM' object has no attribute '_flat_weights_names'

So the parsing is not working properly.

@djowalker djowalker reopened this Dec 22, 2021
@djowalker
Copy link
Author

Sems to be ok after upgrading the following :

update download_modules.sh

curl https://flair.informatik.hu-berlin.de/resources/models/ner-fast/en-ner-fast-conll03-v0.4.pt -o models/en-ner-fast-conll03-v0.4.pt
curl https://flair.informatik.hu-berlin.de/resources/models/fr-ner/fr-ner-wikiner-0.4.pt -o models/fr-ner-wikiner-0.4.pt

update requirements/commont.txt

before

bpemb==0.3.0
flair==0.4.4
importlib-metadata==1.3.0
torch==1.3.1
torchvision==0.4.2
numpy==1.18.1
packaging==20.0
requests==2.22.0
sentencepiece==0.1.85
torch==1.3.1
torchvision==0.4.2
transformers==2.3.0

after

bpemb==0.3.2
flair==0.10
importlib-metadata==3.7.0
numpy==1.20.0
packaging==20.9
torch==1.4.0
torchvision==0.5.0
requests==2.25.1
sentencepiece==0.1.95
torch==1.5.0
torchvision==0.6.0
transformers==4.0.0

djowalker pushed a commit to djowalker/tock-flair that referenced this issue Dec 22, 2021
@djowalker
Copy link
Author

djowalker commented Apr 28, 2023

Updated with #15

The models are available directly in the code, no need to download them like before.

@djowalker
Copy link
Author

@auroredea
@vsct-jburet
Any chances to update and release the recent PR update to recent versions ?

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

1 participant