Views
No views yet
1>>> from transformers import pipeline
2>>> tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
3>>> model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
4>>> classifier = pipeline("ner", model=model, tokenizer=tokenizer)
5>>> classifier("Alya told Jasmine that Andrew could pay with cash..")
6[{'end': 2,
7 'entity': 'I-PER',
8 'index': 1,
9 'score': 0.9997861,
10 'start': 0,
11 'word': '▁Al'},
12 {'end': 4,
13 'entity': 'I-PER',
14 'index': 2,
15 'score': 0.9998591,
16 'start': 2,
17 'word': 'ya'},
18 {'end': 16,
19 'entity': 'I-PER',
20 'index': 4,
21 'score': 0.99995816,
22 'start': 10,
23 'word': '▁Jasmin'},
24 {'end': 17,
25 'entity': 'I-PER',
26 'index': 5,
27 'score': 0.9999584,
28 'start': 16,
29 'word': 'e'},
30 {'end': 29,
31 'entity': 'I-PER',
32 'index': 7,
33 'score': 0.99998057,
34 'start': 23,
35 'word': '▁Andrew'}]1@article{conneau2019unsupervised,
2 title={Unsupervised Cross-lingual Representation Learning at Scale},
3 author={Conneau, Alexis and Khandelwal, Kartikay and Goyal, Naman and Chaudhary, Vishrav and Wenzek, Guillaume and Guzm{\'a}n, Francisco and Grave, Edouard and Ott, Myle and Zettlemoyer, Luke and Stoyanov, Veselin},
4 journal={arXiv preprint arXiv:1911.02116},
5 year={2019}
6}1>>> from transformers import AutoTokenizer, AutoModelForTokenClassification
2>>> from transformers import pipeline
3>>> tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
4>>> model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
5>>> classifier = pipeline("ner", model=model, tokenizer=tokenizer)
6>>> classifier("Hello I'm Omar and I live in Zürich.")
7
8[{'end': 14,
9 'entity': 'I-PER',
10 'index': 5,
11 'score': 0.9999175,
12 'start': 10,
13 'word': '▁Omar'},
14 {'end': 35,
15 'entity': 'I-LOC',
16 'index': 10,
17 'score': 0.9999906,
18 'start': 29,
19 'word': '▁Zürich'}]