You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-nq")
retriever = RagRetriever.from_pretrained("facebook/rag-sequence-nq", index_name="exact", use_dummy_dataset=True)
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever)
input_dict = tokenizer.prepare_seq2seq_batch("how many countries are in europe", return_tensors="pt")
generated = model.generate(input_ids=input_dict["input_ids"])
print(tokenizer.batch_decode(generated, skip_special_tokens=True)[0])
The tasks I am working on is:
I am trying to ran the sample code from above. Note that this same error occurs also when finetuning rag with the official code in transformers/examples/research_projects/rag/finetune_rag.sh
To reproduce
Steps to reproduce the behavior:
run the sample code above
The error is:
Traceback (most recent call last):
File "prova_rag.py", line 5, in <module>
model = RagSequenceForGeneration.from_pretrained("facebook/rag-sequence-nq", retriever=retriever, _fast_init=False)
File "/nlu/users/giovanni_bonetta/transformers/src/transformers/modeling_utils.py", line 1208, in from_pretrained
model, state_dict, pretrained_model_name_or_path
File "/nlu/users/giovanni_bonetta/transformers/src/transformers/modeling_utils.py", line 1278, in _load_state_dict_into_model
model._init_weights(module)
File "/nlu/users/giovanni_bonetta/miniconda2/envs/hf_venv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 948, in __getattr__
type(self).__name__, name))
AttributeError: 'RagSequenceForGeneration' object has no attribute '_init_weights'
Looking at last commits i suppose that the error was introduced in "Pytorch - Lazy initialization of models #11471" a couple of weeks ago, where the line model._init_weights(module) was introduced.
Expected behavior
It should initialize the model without errors.
The text was updated successfully, but these errors were encountered:
Environment info
transformers
version: 4.6.0.dev0Who can help
rag: @patrickvonplaten, @lhoestq
Models:
RAG model
Information
Model I am using RAG
The problem arises when using the official example scripts from https://huggingface.co/facebook/rag-sequence-nq, which I copied here:
The tasks I am working on is:
I am trying to ran the sample code from above. Note that this same error occurs also when finetuning rag with the official code in transformers/examples/research_projects/rag/finetune_rag.sh
To reproduce
Steps to reproduce the behavior:
The error is:
Looking at last commits i suppose that the error was introduced in "Pytorch - Lazy initialization of models #11471" a couple of weeks ago, where the line
model._init_weights(module)
was introduced.Expected behavior
It should initialize the model without errors.
The text was updated successfully, but these errors were encountered: