【发布时间】:2022-01-04 18:41:06
【问题描述】:
我有以下代码:
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
tokenizer = AutoTokenizer.from_pretrained("sagorsarker/codeswitch-spaeng-lid-lince")
model = AutoModelForTokenClassification.from_pretrained("sagorsarker/codeswitch-spaeng-lid-lince")
pipeline = pipeline('ner', model=model, tokenizer=tokenizer)
sentence = "some example sentence here"
results = pipeline(sentence)
这很好用。但不是str,我不想传递list 的令牌。我该怎么做?
我想这样做的原因是,我的句子已经被标记化并且简单的" ".join() 不能正确地重现句子。例如,isn't 已被标记为 is 和 n't。但是一个简单的" ".join() 会产生is n't
【问题讨论】:
-
您最初是如何对输入进行标记化的?
-
它是由其他研究人员以 CONLL 格式发表的。
标签: nlp tokenize huggingface-transformers huggingface-tokenizers huggingface-datasets