zjunlp / KnowPrompt

[WWW 2022] KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction
MIT License
194 stars 34 forks source link

ValueError: too many values to unpack (expected 4) #13

Closed xiaohou1112 closed 1 year ago

xiaohou1112 commented 1 year ago

你好! 我使用自己标注的数据集,格式处理为这样 {'token': ['地', '面', '状', '况', '不', '良', '导', '致', '位', '置', '偏', '移', '。'], 'h': {'name': '位置偏移', 'pos': [8, 12]}, 't': {'name': '地面状况不良', 'pos': [0, 6]}, 'relation': '因果关系'} (不知道格式这样是否正确。。 然后运行后,得到这个报错。

File "D:\re\knowprompt2\KnowPrompt\lit_models\transformer.py", line 210, in validation_step input_ids, attentionmask, labels, = batch ValueError: too many values to unpack (expected 4)

代码没有改动。我不知道是我格式的问题还是其他问题。 盼回复!谢谢!

CheaSim commented 1 year ago

For BERT model, tokenizer will return input_ids, attention_mask, token_type_ids. So you should use the code below like ..

input_ids, attention_mask, token_type_ids, labels, _ = batch

And input the model with the additional token_type_ids.