File size: 477 Bytes
79eafb6 0daa457 79eafb6 c0768f3 79eafb6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("Babelscape/wikineural-multilingual-ner")
model = AutoModelForTokenClassification.from_pretrained("Babelscape/wikineural-multilingual-ner")
nlp = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
example = "张伟和李娜去北京旅行。"
ner_results = nlp(example)
print(example)
print(ner_results)
|