我想在 NER 任务中使用 BERT 模型找到单词的相似性。我有自己的数据集,所以我不想使用预训练模型。我执行以下操作:
from transformers import BertModel
hidden_reps, cls_head = BertModel(token_ids , attention_mask = attn_mask , token_type_ids = seg_ids)
在哪里
token_ids with Shape : [1, 4, 47]
attn_mask with Shape : [1, 4, 47]
seg_ids with Shape : [1, 4, 47]
但我有一个错误:
TypeError Traceback (most recent call last)
<ipython-input-74-5fa632122cc7> in <module>()
1 from transformers import BertModel
----> 2 hidden_reps, cls_head = BertModel(token_ids , attention_mask = attn_mask , token_type_ids = seg_ids)
TypeError: __init__() got an unexpected keyword argument 'attention_mask'
我该如何解决这个错误?
以及如何使用此模型找到给定单词的单词嵌入和相似度?
我找不到此任务的任何教程或类似代码。