👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
tokenizer转换字符串得到的input_ids列表长度不对
计算交叉函数时出现错误:ValueError: (InvalidArgument) Input(Logits) and Input(Label) should in same shape in dimensions except axis. [Hint: Expected logits_dims[i] == labels_dims[i], but received logits_dims[i]:46 != labels_dims[i]:45.] (at ..\paddle\phi\infermeta\binary.cc:940)。 后来调试的时候感觉可能是使用tokenizer转换时出现问题,使用ernie-1.0的tokenizer转换时,获取到的input_ids列表长度比输入文字列表长度多3,正常应该是多2吧? 这是其中一条,我认为未转换正确的数据: 输入数据:金 华 市 婺 城 区 宾 虹 西 路 1564 号 美 保 工 具 电 商 中 心 input ids:1 192 403 99 4501 257 121 1468 2321 213 216 4340 9488 500 188 161 35 248 128 278 12 111 2 labels:46 12 13 13 14 15 15 6 7 7 7 8 9 16 17 17 17 17 17 17 17 46
创建的tokenizer
tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0')
转换函数
def convert_example(example, tokenizer, label_vocab): tokens, labels = example tokenized_input = tokenizer( tokens, return_length=True, is_split_into_words=True)
Token '[CLS]' and '[SEP]' will get label 'O'