Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xiaohou1112 opened this issue Sep 15, 2022 · 1 comment
Closed

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

xiaohou1112 opened this issue Sep 15, 2022 · 1 comment

Comments

@xiaohou1112
Copy link

你好!
我使用自己标注的数据集,格式处理为这样
{'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, attention_mask, labels, _ = batch
ValueError: too many values to unpack (expected 4)

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

@CheaSim
Copy link
Contributor

CheaSim commented Sep 18, 2022

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.

@CheaSim CheaSim closed this as completed Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants