I am trying to get the following pretrained huggingface model to work: https://huggingface.co/mmoradi/Robust-Biomed-RoBERTa-RelationClassification
I use the following code:
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("mmoradi/Robust-Biomed-RoBERTa-RelationClassification")
model = AutoModel.from_pretrained("mmoradi/Robust-Biomed-RoBERTa-RelationClassification")
inputs = tokenizer("""The colorectal cancer was caused by mutations in angina""")
outputs = model(**inputs)
For some reason, I get the following error when trying to produce outputs, so in the last line of my code:
--> 796 input_shape = input_ids.size() 797 elif inputs_embeds is not None: 798 input_shape = inputs_embeds.size()[:-1]
AttributeError: 'list' object has no attribute 'size'
The inputs look like this:
{'input_ids': [0, 133, 11311, 1688, 3894, 337, 1668, 21, 1726, 30, 28513, 11, 1480, 347, 2], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
I have no idea how to go about debugging this, so any help or hints are welcomed!
You have to specify the type of tensor that you want in return for tokenizer
. If you don't, it will return a dictionary with two lists (input_ids
and attention_mask
):
inputs = tokenizer("""The colorectal cancer was caused by mutations in angina""", return_tensors="pt")