rasa: Rasa train nlu, bert, finetuned weight, Error: from_pt set to False

Description of Problem:

The rasa cli does not support loading a bert model that is trained from pytorch. It gives the following error OSError: Error no file named ['pytorch_model.bin', 'tf_model.h5'] found in directory ..\model\deploy_transformer or from_pt set to False

My config yml: - name: HFTransformersNLP model_weights: "C:\\work_directory\\nlp\\model\\transformers\bert" model_name: "bert"

My directory in the model folder:

  • config.json
  • model.ckpt.data-00000-of-00001
  • model.ckpt.index
  • model.ckpt.meta
  • vocab.txt
  • pytorch_model.bin

Overview of the Solution:

I now need to add “from_pt=True” manually in the rasa/nlu/utils/hugging_face/hf_transformers.py : 84 in order to use pytorch model. A better solution is to be able to do so in the config.yml file

Examples (if relevant):

Blockers (if relevant):

Definition of Done:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Certo! Aqui: imagem

Dito isso, isso foi antes de eu migrar o projeto para o rasa 2.0. Depois disso eu só usaria o espaço, então não sei se ainda funciona. Apparently, HFTransformersNLP is deprecated in rasa version 3.0, but I adjusted to use rasa 2.8 and transformers 2.11.0, and BERT model without HFTransformers component. In this case, I had some difficulties loading weights and model, as we trained using config.yml which specifies cache_dir (cache_path) and model_weights (bert-base-cased-multilingual, for example), but when I try to load this model, it doesn’t finds the files and is all lost. To solve this I needed to rename the key “cache_dir” and “model_weights” in the metadata.json of model.tar.gz (generated from training) to configure the absolute path of cache_dir and model… Because if I take the model.tar.gz and the weights, put them in another folder other than the training one, the model is already lost to load. I didn’t find anything documented. So if I use a container docker that changes a workdir, the transformer library doesn’t find the model with cache_path and model_name used in training. But renaming it worked. Thanks for sharing, I appreciate it.

Sure! Here: image

That said this was before I migrated the project to rasa 2.0. After that I’d only use spacy, so I don’t know if it still works.

Thx @dakshvar22 That was the wrong script which use .ckpt This is the right script

Btw, for those may have the same problem. The transformer scripts have bugs. Please refer to this and this to fix.