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

Use pre-trained model without Internet connection #651

Closed
zhh210 opened this issue Apr 9, 2019 · 9 comments
Closed

Use pre-trained model without Internet connection #651

zhh210 opened this issue Apr 9, 2019 · 9 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@zhh210
Copy link

zhh210 commented Apr 9, 2019

My network admin blocked any connection to aws so downloading pre-trained embeddings/models will fail due to network error. Is it possible to let flair point to the local directory where the embeddings/models were downloaded? Thanks.

@zhh210 zhh210 added the question Further information is requested label Apr 9, 2019
@alanakbik
Copy link
Collaborator

Hello @zhh210 - yes, you can pass the full model path to initialize most embeddings and taggers. For instance, if you have a tagging model downloaded to 'home/taggers/tagger.pt', you can initialize a SequenceTagger like this:

tagger = SequenceTagger.load_from_file('home/taggers/tagger.pt')

If you want to initialize embeddings with downloaded model, you can do this by passing the full path to the default constructor, e.g.:

FlairEmbeddings('path/to/downloaded/model.pt')

@zhh210
Copy link
Author

zhh210 commented Apr 10, 2019

The example I was trying to use is glove. The download from is failing to connect aws (alan-nlp/resources/embeddings/glove.gensim) so I created copy in my local folder and in python when I was loading:
WordEmbeddings('/mydir/glove.gensim.vectors.npy')

It got an error saying:

UnpicklingError: STACK_GLOBAL requires str.

Similary when I point BytePairEmbeddings to a local folder containing en.wiki.bpe.vs100000.model, it gives error of:

Unknown language identifier

@alanakbik
Copy link
Collaborator

Hi @zhh210 can you try loading with WordEmbeddings('/mydir/glove.gensim') instead?

@TorusHHH
Copy link

TorusHHH commented May 6, 2019

@zhh210 老哥,需要下载两个文件,一个是glove.gensim.vectors.npy,一个是glove.gensim,然后放在同意目录下,然后用WordEmbeddings('/mydir/glove.gensim.vectors.npy')就行。

@Nicozwy
Copy link

Nicozwy commented Aug 14, 2019

你好,@TorusHHH 这两个 glove.gensim.vectors.npy,和glove.gensim在哪里可以下载?可否给个链接

@builtfordeve
Copy link

@TorusHHH 同问,哪里才能下载到glove.gensim和glove.gensim.vectors.npy这两个文件啊?

@Carolyn95
Copy link

你好,@TorusHHH 这两个 glove.gensim.vectors.npy,和glove.gensim在哪里可以下载?可否给个链接

可以用一台可以access internet的电脑,用flair自动下载好了然后从$HOME/.flair/embeddings中复制过去。

@stale
Copy link

stale bot commented Dec 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 4, 2020
@stale stale bot closed this as completed Dec 11, 2020
@B0rner
Copy link

B0rner commented Dec 7, 2023

Is this example still valid:
tagger = SequenceTagger.load_from_file('home/taggers/tagger.pt')
??

I'm trying to run flair SequenceTagger oflline.
First I run the sctipt with internet connection to automatic download the files, unsing the following environment parameter: FLAIR_CACHE_ROOT=/models.
I created an tagger instance using: tagger = Classifier.load('flair/ner-english-ontonotes-large')

This works fine.

On the nex run, I disabled internet connection and rerun the script but using tagger = SequenceTagger.load_from_file('/models/ner-english..../pytorch_model.bin). The scrips runs into that error:

AttributeError: type object 'SequenceTagger' has no attribute 'load_from_file'

I know that site: https://flairnlp.github.io/docs but an class/methode - API documentation is missing. So I allways have to read endless lines of code to (sometimes) find which methods or parameters are valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

7 participants