TTimur commited on
Commit
84c721b
0 Parent(s):

Duplicate from TTimur/xlm-roberta-base-kyrgyzNER

Browse files
.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: xlm-roberta-base
4
+ tags:
5
+ - generated_from_trainer
6
+ metrics:
7
+ - precision
8
+ - recall
9
+ - f1
10
+ - accuracy
11
+ model-index:
12
+ - name: xlm-roberta-base-kyrgyzNER
13
+ results: []
14
+ language:
15
+ - ky
16
+ ---
17
+
18
+
19
+
20
+ # kyrgyzNER model (xlm-roberta-base) by The_Cramer_Project
21
+
22
+
23
+ - The original repository: https://github.com/Akyl-AI/KyrgyzNER
24
+ - Paper will be uploaded soon
25
+ - KyrgyzNER dataset and Codes will be uploaded soon
26
+
27
+
28
+ This model is a fine-tuned version of [xlm-roberta-base](https://huggingface.co/xlm-roberta-base) on the KyrgyzNER dataset.
29
+ It achieves the following results on the evaluation set:
30
+ - Loss: 0.3273
31
+ - Precision: 0.7090
32
+ - Recall: 0.6946
33
+ - F1: 0.7017
34
+ - Accuracy: 0.9119
35
+
36
+
37
+ ## How to use
38
+ You can use this model with the Transformers pipeline for NER.
39
+
40
+ ```python
41
+ from transformers import AutoTokenizer, AutoModelForTokenClassification, AutoConfig
42
+ from transformers import pipeline
43
+
44
+ id2label = {
45
+ 'LABEL_0': 'B-NATIONAL',
46
+ 'LABEL_1': 'I-PLANT',
47
+ 'LABEL_2': 'I-ORGANISATION',
48
+ 'LABEL_3': 'B-ORGANISATION',
49
+ 'LABEL_4': 'B-MEDIA',
50
+ 'LABEL_5': 'I-ARTIFACT',
51
+ 'LABEL_6': 'B-AWARD',
52
+ 'LABEL_7': 'B-UNKNOWN',
53
+ 'LABEL_8': 'I-LOCATION',
54
+ 'LABEL_9': 'B-PERSON',
55
+ 'LABEL_10': 'I-LEGAL',
56
+ 'LABEL_11': 'B-BUSINESS',
57
+ 'LABEL_12': 'B-ACRONYM',
58
+ 'LABEL_13': 'I-PERIOD',
59
+ 'LABEL_14': 'B-INSTITUTION',
60
+ 'LABEL_15': 'I-MEASURE',
61
+ 'LABEL_16': 'B-CREATION',
62
+ 'LABEL_17': 'I-ACRONYM',
63
+ 'LABEL_18': 'I-AWARD',
64
+ 'LABEL_19': 'I-WEBSITE',
65
+ 'LABEL_20': 'B-PERIOD',
66
+ 'LABEL_21': 'I-PERSON',
67
+ 'LABEL_22': 'I-PERSON_TYPE',
68
+ 'LABEL_23': 'B-SUBSTANCE',
69
+ 'LABEL_24': 'O',
70
+ 'LABEL_25': 'B-PLANT',
71
+ 'LABEL_26': 'I-INSTITUTION',
72
+ 'LABEL_27': 'I-SUBSTANCE',
73
+ 'LABEL_28': 'I-INSTALLATION',
74
+ 'LABEL_29': 'B-CONCEPT',
75
+ 'LABEL_30': 'B-TITLE',
76
+ 'LABEL_31': 'I-EVENT',
77
+ 'LABEL_32': 'B-ARTIFACT',
78
+ 'LABEL_33': 'B-MEASURE',
79
+ 'LABEL_34': 'B-LOCATION',
80
+ 'LABEL_35': 'I-BUSINESS',
81
+ 'LABEL_36': 'B-ANIMAL',
82
+ 'LABEL_37': 'B-PERSON_TYPE',
83
+ 'LABEL_38': 'B-INSTALLATION',
84
+ 'LABEL_39': 'I-TITLE',
85
+ 'LABEL_40': 'B-IDENTIFIER',
86
+ 'LABEL_41': 'I-IDENTIFIER',
87
+ 'LABEL_42': 'B-LEGAL',
88
+ 'LABEL_43': 'I-MEDIA',
89
+ 'LABEL_44': 'I-CONCEPT',
90
+ 'LABEL_45': 'I-UNKNOWN',
91
+ 'LABEL_46': 'B-EVENT',
92
+ 'LABEL_47': 'B-WEBSITE',
93
+ 'LABEL_48': 'I-NATIONAL',
94
+ 'LABEL_49': 'I-CREATION',
95
+ 'LABEL_50': 'I-ANIMAL'}
96
+
97
+ model_ckpt = "TTimur/xlm-roberta-base-kyrgyzNER"
98
+
99
+ config = AutoConfig.from_pretrained(model_ckpt)
100
+ tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
101
+ model = AutoModelForTokenClassification.from_pretrained(model_ckpt, config = config)
102
+
103
+ # aggregation_strategy = "none"
104
+ nlp = pipeline("ner", model = model, tokenizer = tokenizer, aggregation_strategy = "none")
105
+
106
+ example = "Кыргызстан Орто Азиянын түндүк-чыгышында орун алган мамлекет."
107
+ ner_results = nlp(example)
108
+ for result in ner_results:
109
+ result.update({'entity': id2label[result['entity']]})
110
+ print(result)
111
+
112
+ # output:
113
+ # {'entity': 'B-LOCATION', 'score': 0.95103735, 'index': 1, 'word': '▁Кыргызстан', 'start': 0, 'end': 10}
114
+ # {'entity': 'B-LOCATION', 'score': 0.79447913, 'index': 2, 'word': '▁Ор', 'start': 11, 'end': 13}
115
+ # {'entity': 'I-LOCATION', 'score': 0.8703734, 'index': 3, 'word': 'то', 'start': 13, 'end': 15}
116
+ # {'entity': 'I-LOCATION', 'score': 0.942387, 'index': 4, 'word': '▁Азия', 'start': 16, 'end': 20}
117
+ # {'entity': 'I-LOCATION', 'score': 0.8542615, 'index': 5, 'word': 'нын', 'start': 20, 'end': 23}
118
+ # {'entity': 'I-LOCATION', 'score': 0.70930535, 'index': 6, 'word': '▁түн', 'start': 24, 'end': 27}
119
+ # {'entity': 'I-LOCATION', 'score': 0.6540094, 'index': 7, 'word': 'дүк', 'start': 27, 'end': 30}
120
+ # {'entity': 'I-LOCATION', 'score': 0.63446337, 'index': 8, 'word': '-', 'start': 30, 'end': 31}
121
+ # {'entity': 'I-LOCATION', 'score': 0.6204858, 'index': 9, 'word': 'чы', 'start': 31, 'end': 33}
122
+ # {'entity': 'I-LOCATION', 'score': 0.6786872, 'index': 10, 'word': 'г', 'start': 33, 'end': 34}
123
+ # {'entity': 'I-LOCATION', 'score': 0.64190257, 'index': 11, 'word': 'ыш', 'start': 34, 'end': 36}
124
+ # {'entity': 'O', 'score': 0.64438057, 'index': 12, 'word': 'ында', 'start': 36, 'end': 40}
125
+ # {'entity': 'O', 'score': 0.9916931, 'index': 13, 'word': '▁орун', 'start': 41, 'end': 45}
126
+ # {'entity': 'O', 'score': 0.9953047, 'index': 14, 'word': '▁алган', 'start': 46, 'end': 51}
127
+ # {'entity': 'O', 'score': 0.9901377, 'index': 15, 'word': '▁мамлекет', 'start': 52, 'end': 60}
128
+ # {'entity': 'O', 'score': 0.99605453, 'index': 16, 'word': '.', 'start': 60, 'end': 61}
129
+
130
+
131
+ token = ""
132
+ label_list = []
133
+ token_list = []
134
+
135
+ for result in ner_results:
136
+ if result["word"].startswith("▁"):
137
+ if token:
138
+ token_list.append(token.replace("▁", ""))
139
+ token = result["word"]
140
+ label_list.append(result["entity"])
141
+ else:
142
+ token += result["word"]
143
+
144
+ token_list.append(token.replace("▁", ""))
145
+
146
+ for token, label in zip(token_list, label_list):
147
+ print(f"{token}\t{label}")
148
+
149
+
150
+ # output:
151
+ # Кыргызстан B-LOCATION
152
+ # Орто B-LOCATION
153
+ # Азиянын I-LOCATION
154
+ # түндүк-чыгышында I-LOCATION
155
+ # орун O
156
+ # алган O
157
+ # мамлекет. O
158
+
159
+ # aggregation_strategy = "simple"
160
+ nlp = pipeline("ner", model = model, tokenizer = tokenizer, aggregation_strategy = "simple")
161
+ example = "Кыргызстан Орто Азиянын түндүк-чыгышында орун алган мамлекет."
162
+
163
+ ner_results = nlp(example)
164
+ for result in ner_results:
165
+ result.update({'entity_group': id2label[result['entity_group']]})
166
+ print(result)
167
+
168
+ # output:
169
+ # {'entity_group': 'B-LOCATION', 'score': 0.87275827, 'word': 'Кыргызстан Ор', 'start': 0, 'end': 13}
170
+ # {'entity_group': 'I-LOCATION', 'score': 0.73398614, 'word': 'то Азиянын түндүк-чыгыш', 'start': 13, 'end': 36}
171
+ # {'entity_group': 'O', 'score': 0.92351407, 'word': 'ында орун алган мамлекет.', 'start': 36, 'end': 61}
172
+
173
+ ```
174
+
175
+
176
+ # NE classes
177
+
178
+ **PERSON**, **LOCATION** , **MEASURE** , **INSTITUTION** , **PERIOD** , **ORGANISATION** , **MEDIA** , **TITLE** , **BUSINESS** , **LEGAL** , **EVENT** , **ARTIFACT** , **INSTALLATION** , **PERSON_TYPE**, **NATIONAL**, **CONCEPT**, **CREATION**, **WEBSITE**, **SUBSTANCE**, **ACRONYM**, **IDENTIFIER**, **UNKNOWN**, **AWARD**, **ANIMAL**
config.json ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "xlm-roberta-base",
3
+ "architectures": [
4
+ "XLMRobertaForTokenClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "LABEL_0",
15
+ "1": "LABEL_1",
16
+ "2": "LABEL_2",
17
+ "3": "LABEL_3",
18
+ "4": "LABEL_4",
19
+ "5": "LABEL_5",
20
+ "6": "LABEL_6",
21
+ "7": "LABEL_7",
22
+ "8": "LABEL_8",
23
+ "9": "LABEL_9",
24
+ "10": "LABEL_10",
25
+ "11": "LABEL_11",
26
+ "12": "LABEL_12",
27
+ "13": "LABEL_13",
28
+ "14": "LABEL_14",
29
+ "15": "LABEL_15",
30
+ "16": "LABEL_16",
31
+ "17": "LABEL_17",
32
+ "18": "LABEL_18",
33
+ "19": "LABEL_19",
34
+ "20": "LABEL_20",
35
+ "21": "LABEL_21",
36
+ "22": "LABEL_22",
37
+ "23": "LABEL_23",
38
+ "24": "LABEL_24",
39
+ "25": "LABEL_25",
40
+ "26": "LABEL_26",
41
+ "27": "LABEL_27",
42
+ "28": "LABEL_28",
43
+ "29": "LABEL_29",
44
+ "30": "LABEL_30",
45
+ "31": "LABEL_31",
46
+ "32": "LABEL_32",
47
+ "33": "LABEL_33",
48
+ "34": "LABEL_34",
49
+ "35": "LABEL_35",
50
+ "36": "LABEL_36",
51
+ "37": "LABEL_37",
52
+ "38": "LABEL_38",
53
+ "39": "LABEL_39",
54
+ "40": "LABEL_40",
55
+ "41": "LABEL_41",
56
+ "42": "LABEL_42",
57
+ "43": "LABEL_43",
58
+ "44": "LABEL_44",
59
+ "45": "LABEL_45",
60
+ "46": "LABEL_46",
61
+ "47": "LABEL_47",
62
+ "48": "LABEL_48",
63
+ "49": "LABEL_49",
64
+ "50": "LABEL_50"
65
+ },
66
+ "initializer_range": 0.02,
67
+ "intermediate_size": 3072,
68
+ "label2id": {
69
+ "LABEL_0": 0,
70
+ "LABEL_1": 1,
71
+ "LABEL_10": 10,
72
+ "LABEL_11": 11,
73
+ "LABEL_12": 12,
74
+ "LABEL_13": 13,
75
+ "LABEL_14": 14,
76
+ "LABEL_15": 15,
77
+ "LABEL_16": 16,
78
+ "LABEL_17": 17,
79
+ "LABEL_18": 18,
80
+ "LABEL_19": 19,
81
+ "LABEL_2": 2,
82
+ "LABEL_20": 20,
83
+ "LABEL_21": 21,
84
+ "LABEL_22": 22,
85
+ "LABEL_23": 23,
86
+ "LABEL_24": 24,
87
+ "LABEL_25": 25,
88
+ "LABEL_26": 26,
89
+ "LABEL_27": 27,
90
+ "LABEL_28": 28,
91
+ "LABEL_29": 29,
92
+ "LABEL_3": 3,
93
+ "LABEL_30": 30,
94
+ "LABEL_31": 31,
95
+ "LABEL_32": 32,
96
+ "LABEL_33": 33,
97
+ "LABEL_34": 34,
98
+ "LABEL_35": 35,
99
+ "LABEL_36": 36,
100
+ "LABEL_37": 37,
101
+ "LABEL_38": 38,
102
+ "LABEL_39": 39,
103
+ "LABEL_4": 4,
104
+ "LABEL_40": 40,
105
+ "LABEL_41": 41,
106
+ "LABEL_42": 42,
107
+ "LABEL_43": 43,
108
+ "LABEL_44": 44,
109
+ "LABEL_45": 45,
110
+ "LABEL_46": 46,
111
+ "LABEL_47": 47,
112
+ "LABEL_48": 48,
113
+ "LABEL_49": 49,
114
+ "LABEL_5": 5,
115
+ "LABEL_50": 50,
116
+ "LABEL_6": 6,
117
+ "LABEL_7": 7,
118
+ "LABEL_8": 8,
119
+ "LABEL_9": 9
120
+ },
121
+ "layer_norm_eps": 1e-05,
122
+ "max_position_embeddings": 514,
123
+ "model_type": "xlm-roberta",
124
+ "num_attention_heads": 12,
125
+ "num_hidden_layers": 12,
126
+ "output_past": true,
127
+ "pad_token_id": 1,
128
+ "position_embedding_type": "absolute",
129
+ "torch_dtype": "float32",
130
+ "transformers_version": "4.35.2",
131
+ "type_vocab_size": 1,
132
+ "use_cache": true,
133
+ "vocab_size": 250002
134
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:825a899432c24c62b1430f2bad2c3a5b37a76ccc4e9eaf7ab818300be4bd6a98
3
+ size 1109993156
runs/Feb17_18-51-14_24317775ef61/events.out.tfevents.1708195877.24317775ef61.13761.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:030612b965576e2e38ad236ffd59c8729c1f478f220d857416a6956891bbd7d5
3
+ size 11640
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a4661b2cb6b8a1007906509fe18cbfbc03062a086102bf7b80cfedb80f16c37
3
+ size 17082854
tokenizer_config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "model_max_length": 512,
50
+ "pad_token": "<pad>",
51
+ "sep_token": "</s>",
52
+ "tokenizer_class": "XLMRobertaTokenizer",
53
+ "unk_token": "<unk>"
54
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e9e1d454a8e2cdffcb175d293b4fbf7ed3b7ee03c3cea766485fa493c950f84
3
+ size 4600