yeshpanovrustem commited on
Commit
fef9186
1 Parent(s): c49a73d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -2
README.md CHANGED
@@ -40,11 +40,22 @@ from transformers import pipeline
40
  tokenizer = AutoTokenizer.from_pretrained("yeshpanovrustem/xlm-roberta-large-ner-kazakh")
41
  model = AutoModelForTokenClassification.from_pretrained("yeshpanovrustem/xlm-roberta-large-ner-kazakh")
42
 
43
- nlp = pipeline("ner", model = model, tokenizer = tokenizer)
 
44
  example = "Қазақстан Республикасы — Шығыс Еуропа мен Орталық Азияда орналасқан мемлекет."
45
 
46
  ner_results = nlp(example)
47
- print(ner_results)
 
 
 
 
 
 
 
 
 
 
48
 
49
  token = ""
50
  label_list = []
@@ -63,6 +74,28 @@ token_list.append(token.replace("▁", ""))
63
 
64
  for token, label in zip(token_list, label_list):
65
  print(f"{token}\t{label}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ```
67
 
68
  ## Evaluation results on the validation and test sets
 
40
  tokenizer = AutoTokenizer.from_pretrained("yeshpanovrustem/xlm-roberta-large-ner-kazakh")
41
  model = AutoModelForTokenClassification.from_pretrained("yeshpanovrustem/xlm-roberta-large-ner-kazakh")
42
 
43
+ # aggregation_strategy = "none"
44
+ nlp = pipeline("ner", model = model, tokenizer = tokenizer, aggregation_strategy = "none")
45
  example = "Қазақстан Республикасы — Шығыс Еуропа мен Орталық Азияда орналасқан мемлекет."
46
 
47
  ner_results = nlp(example)
48
+ for result in ner_results:
49
+ print(result)
50
+
51
+ # output:
52
+ # {'entity': 'B-GPE', 'score': 0.9995646, 'index': 1, 'word': '▁Қазақстан', 'start': 0, 'end': 9}
53
+ # {'entity': 'I-GPE', 'score': 0.9994935, 'index': 2, 'word': '▁Республикасы', 'start': 10, 'end': 22}
54
+ # {'entity': 'B-LOCATION', 'score': 0.99906737, 'index': 4, 'word': '▁Шығыс', 'start': 25, 'end': 30}
55
+ # {'entity': 'I-LOCATION', 'score': 0.999153, 'index': 5, 'word': '▁Еуропа', 'start': 31, 'end': 37}
56
+ # {'entity': 'B-LOCATION', 'score': 0.9991597, 'index': 7, 'word': '▁Орталық', 'start': 42, 'end': 49}
57
+ # {'entity': 'I-LOCATION', 'score': 0.9991725, 'index': 8, 'word': '▁Азия', 'start': 50, 'end': 54}
58
+ # {'entity': 'I-LOCATION', 'score': 0.9992299, 'index': 9, 'word': 'да', 'start': 54, 'end': 56}
59
 
60
  token = ""
61
  label_list = []
 
74
 
75
  for token, label in zip(token_list, label_list):
76
  print(f"{token}\t{label}")
77
+
78
+ # output:
79
+ # Қазақстан B-GPE
80
+ # Республикасы I-GPE
81
+ # Шығыс B-LOCATION
82
+ # Еуропа I-LOCATION
83
+ # Орталық B-LOCATION
84
+ # Азияда I-LOCATION
85
+
86
+ # aggregation_strategy = "simple"
87
+ nlp = pipeline("ner", model = model, tokenizer = tokenizer, aggregation_strategy = "simple")
88
+ example = "Қазақстан Республикасы — Шығыс Еуропа мен Орталық Азияда орналасқан мемлекет."
89
+
90
+ ner_results = nlp(example)
91
+ for result in ner_results:
92
+ print(result)
93
+
94
+ # output:
95
+ # {'entity_group': 'GPE', 'score': 0.999529, 'word': 'Қазақстан Республикасы', 'start': 0, 'end': 22}
96
+ # {'entity_group': 'LOCATION', 'score': 0.9991102, 'word': 'Шығыс Еуропа', 'start': 25, 'end': 37}
97
+ # {'entity_group': 'LOCATION', 'score': 0.9991874, 'word': 'Орталық Азияда', 'start': 42, 'end': 56}
98
+
99
  ```
100
 
101
  ## Evaluation results on the validation and test sets