Update README.md
Browse files
README.md
CHANGED
|
@@ -22,7 +22,23 @@ It achieves the following results on the evaluation set:
|
|
| 22 |
|
| 23 |
## Model description
|
| 24 |
|
| 25 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Intended uses & limitations
|
| 28 |
|
|
|
|
| 22 |
|
| 23 |
## Model description
|
| 24 |
|
| 25 |
+
'''
|
| 26 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
| 27 |
+
from transformers import pipeline
|
| 28 |
+
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained("jinhybr/distilroberta-ConLL2003")
|
| 30 |
+
model = AutoModelForTokenClassification.from_pretrained("jinhybr/distilroberta-ConLL2003")
|
| 31 |
+
|
| 32 |
+
nlp = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
|
| 33 |
+
example = "My name is Tao Jin and live in Canada"
|
| 34 |
+
ner_results = nlp(example)
|
| 35 |
+
print(ner_results)
|
| 36 |
+
|
| 37 |
+
[{'entity_group': 'PER', 'score': 0.99686015, 'word': ' Tao Jin', 'start': 11, 'end': 18}, {'entity_group': 'LOC', 'score': 0.9996836, 'word': ' Canada', 'start': 31, 'end': 37}]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
'''
|
| 42 |
|
| 43 |
## Intended uses & limitations
|
| 44 |
|