I want to use “grouped_entities” in the huggingface pipeline for ner task, how to do that?

折月煮酒 提交于 2021-01-29 19:00:56

问题


I want to use "grouped_entities" in the huggingface pipeline for ner task. However having issues doing that.

I do look the following link on git but this did not help: https://github.com/huggingface/transformers/pull/4987


回答1:


I got the answer its very straight forward in the transformer v4.0.0. Previously I was using older version of transformer package. example:

from transformers import AutoTokenizer, 
 AutoModelForTokenClassification,TokenClassificationPipeline

 from transformers import pipeline 

tokenizer = AutoTokenizer.from_pretrained("fine_tune_model_path")
model = AutoModelForTokenClassification.from_pretrained("fine_tune_model_path")
nlp=pipeline(task='ner',model=model,
 tokenizer=tokenizer,grouped_entities=True)


来源:https://stackoverflow.com/questions/65353104/i-want-to-use-grouped-entities-in-the-huggingface-pipeline-for-ner-task-how-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!