UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
14.95k stars 2.44k forks source link

How to extract and load zip model #580

Open ankitkr3 opened 3 years ago

ankitkr3 commented 3 years ago

Hi guys, Thanks for continuous support, i have saved my model in zip at s3 and want to extract and load at the runtime. How can I extract and load it at runtime without writing it into the hard memory?

nreimers commented 3 years ago

Currently this is not implemented, it loads the individual files from the unzipped file from disc.

ankitkr3 commented 3 years ago

@nreimers is there any code to implement this or extract the files from zip?

ankitkr3 commented 3 years ago

@nreimers i somehow extracted the model files and loading it into the param model = SentenceTransformer('E:/distiluse-base-multilingual-cased') but it is giving an error -- ValueError: Unrecognized model in E:/distiluse-base-multilingual-cased\0_DistilBERT. Should have a model_type key in its config.json, or contain one of the following strings in its name: retribert, t5, mobilebert, distilbert, albert, bert-generation, camembert, xlm-roberta, pegasus, marian, mbart, bart, reformer, longformer, roberta, flaubert, fsmt, bert, openai-gpt, gpt2, transfo-xl, xlnet, xlm, ctrl, electra, encoder-decoder, funnel, lxmert, dpr, layoutlm, rag

ankitkr3 commented 3 years ago

@nreimers i somehow extracted the model files and loading it into the param model = SentenceTransformer('E:/distiluse-base-multilingual-cased') but it is giving an error -- ValueError: Unrecognized model in E:/distiluse-base-multilingual-cased\0_DistilBERT. Should have a model_type key in its config.json, or contain one of the following strings in its name: retribert, t5, mobilebert, distilbert, albert, bert-generation, camembert, xlm-roberta, pegasus, marian, mbart, bart, reformer, longformer, roberta, flaubert, fsmt, bert, openai-gpt, gpt2, transfo-xl, xlnet, xlm, ctrl, electra, encoder-decoder, funnel, lxmert, dpr, layoutlm, rag

@nreimers also i never got this error before, i used to load the model from my local in the same fashion.

nreimers commented 3 years ago

Try it with the most recent version: https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/v0.2/distiluse-base-multilingual-cased-v2.zip

If you still have an error, check if the config.json in E:/distiluse-base-multilingual-cased\0_DistilBERT has a key:

  "model_type": "distilbert",
ankitkr3 commented 3 years ago

@nreimers thanks!

thaitrinh commented 2 years ago

Hi Nils, I have the same question: Is it possible now to load the model from a zip file? The problem with using cloud is that one cannot refers to a folder in cloud. One can only get the url of a certain object (file). Thank you!

fabioselau077 commented 1 year ago

Hi Nils, I have the same question: Is it possible now to load the model from a zip file? The problem with using cloud is that one cannot refers to a folder in cloud. One can only get the url of a certain object (file). Thank you!

same question