Hey,
I’m in an internship and I’ve been using HuggingFace for 3 months now.
I’ve been making dirty scripts that made it to the point, but now I would like to better understand the library.
As far as I read in the docs, I should be able to encode an input and then pass it to a model (in my case a mBART, BARThez), then decoding the output, for my input to be better suited to my problem.
However, when I run this very simple code on Colab (with or without GPU) :
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
print("Tokenizer loading...")
tokenizer = AutoTokenizer.from_pretrained("moussaKam/barthez-orangesum-abstract")
print("Model loading...")
model = AutoModelForSeq2SeqLM.from_pretrained("/content/drive/MyDrive/Colab Notebooks/models/trained_on_datcha")
sentence = "J'aime beaucoup les courgettes"
inputs = tokenizer.encode(sentence, padding=True, truncation=True, max_length=400)
outputs = model(inputs)
decoded = tokenizer.decode(outputs)
print(decoded)
It ends either with a RAM issue crashing my Notebook, or just an error.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-59d9ac7f77ce> in <module>()
8 sentence = "J'aime beaucoup les courgettes"
9 inputs = tokenizer.encode(sentence, padding=True, truncation=True, max_length=400)
---> 10 outputs = model(inputs)
11 decoded = tokenizer.decode(outputs)
12 print(decoded)
4 frames
/usr/local/lib/python3.7/dist-packages/transformers/models/mbart/modeling_mbart.py in shift_tokens_right(input_ids, pad_token_id)
77 have a single `decoder_start_token_id` in contrast to other Bart-like models.
78 """
---> 79 prev_output_tokens = input_ids.clone()
80
81 if pad_token_id is None:
AttributeError: 'list' object has no attribute 'clone'
I would like to know what I’m doing wrong, since I’ve troubles understanding how the library works…
Thank you in advance