m3hrdadfi commited on
Commit
17ac338
1 Parent(s): 6caa882

Initialize

Browse files
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: fa
3
+ ---
4
+
5
+
6
+ # RobertaNER
7
+
8
+ This model fine-tuned for the Named Entity Recognition (NER) task on a mixed NER dataset collected from [ARMAN](https://github.com/HaniehP/PersianNER), [PEYMA](http://nsurl.org/2019-2/tasks/task-7-named-entity-recognition-ner-for-farsi/), and [WikiANN](https://elisa-ie.github.io/wikiann/) that covered ten types of entities:
9
+
10
+ - Date (DAT)
11
+ - Event (EVE)
12
+ - Facility (FAC)
13
+ - Location (LOC)
14
+ - Money (MON)
15
+ - Organization (ORG)
16
+ - Percent (PCT)
17
+ - Person (PER)
18
+ - Product (PRO)
19
+ - Time (TIM)
20
+
21
+
22
+ ## Dataset Information
23
+
24
+ | | Records | B-DAT | B-EVE | B-FAC | B-LOC | B-MON | B-ORG | B-PCT | B-PER | B-PRO | B-TIM | I-DAT | I-EVE | I-FAC | I-LOC | I-MON | I-ORG | I-PCT | I-PER | I-PRO | I-TIM |
25
+ |:------|----------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|--------:|
26
+ | Train | 29133 | 1423 | 1487 | 1400 | 13919 | 417 | 15926 | 355 | 12347 | 1855 | 150 | 1947 | 5018 | 2421 | 4118 | 1059 | 19579 | 573 | 7699 | 1914 | 332 |
27
+ | Valid | 5142 | 267 | 253 | 250 | 2362 | 100 | 2651 | 64 | 2173 | 317 | 19 | 373 | 799 | 387 | 717 | 270 | 3260 | 101 | 1382 | 303 | 35 |
28
+ | Test | 6049 | 407 | 256 | 248 | 2886 | 98 | 3216 | 94 | 2646 | 318 | 43 | 568 | 888 | 408 | 858 | 263 | 3967 | 141 | 1707 | 296 | 78 |
29
+
30
+
31
+ ## Evaluation
32
+
33
+ The following tables summarize the scores obtained by model overall and per each class.
34
+
35
+ **Overall**
36
+
37
+ | Model | accuracy | precision | recall | f1 |
38
+ |:----------:|:--------:|:---------:|:--------:|:--------:|
39
+ | Roberta | 0.994849 | 0.949816 | 0.960235 | 0.954997 |
40
+
41
+
42
+ **Per entities**
43
+
44
+ | | number | precision | recall | f1 |
45
+ |:---: |:------: |:---------: |:--------: |:--------: |
46
+ | DAT | 407 | 0.844869 | 0.869779 | 0.857143 |
47
+ | EVE | 256 | 0.948148 | 1.000000 | 0.973384 |
48
+ | FAC | 248 | 0.957529 | 1.000000 | 0.978304 |
49
+ | LOC | 2884 | 0.965422 | 0.968100 | 0.966759 |
50
+ | MON | 98 | 0.937500 | 0.918367 | 0.927835 |
51
+ | ORG | 3216 | 0.943662 | 0.958333 | 0.950941 |
52
+ | PCT | 94 | 1.000000 | 0.968085 | 0.983784 |
53
+ | PER | 2646 | 0.957030 | 0.959562 | 0.958294 |
54
+ | PRO | 318 | 0.963636 | 1.000000 | 0.981481 |
55
+ | TIM | 43 | 0.739130 | 0.790698 | 0.764045 |
56
+
57
+
58
+ ## How To Use
59
+ You use this model with Transformers pipeline for NER.
60
+
61
+ ### Installing requirements
62
+
63
+ ```bash
64
+ pip install transformers
65
+ ```
66
+
67
+ ### How to predict using pipeline
68
+
69
+ ```python
70
+ from transformers import AutoTokenizer
71
+ from transformers import AutoModelForTokenClassification # for pytorch
72
+ from transformers import TFAutoModelForTokenClassification # for tensorflow
73
+ from transformers import pipeline
74
+
75
+
76
+ model_name_or_path = "HooshvareLab/roberta-fa-zwnj-base-ner"
77
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
78
+ model = AutoModelForTokenClassification.from_pretrained(model_name_or_path) # Pytorch
79
+ # model = TFAutoModelForTokenClassification.from_pretrained(model_name_or_path) # Tensorflow
80
+
81
+ nlp = pipeline("ner", model=model, tokenizer=tokenizer)
82
+ example = "در سال ۲۰۱۳ درگذشت و آندرتیکر و کین برای او مراسم یادبود گرفتند."
83
+
84
+ ner_results = nlp(example)
85
+ print(ner_results)
86
+ ```
87
+
88
+
89
+ ## Questions?
90
+ Post a Github issue on the [ParsNER Issues](https://github.com/hooshvare/parsner/issues) repo.
config.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForTokenClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "eos_token_id": 2,
8
+ "finetuning_task": "ner",
9
+ "gradient_checkpointing": false,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "O",
15
+ "1": "B-DAT",
16
+ "2": "B-EVE",
17
+ "3": "B-FAC",
18
+ "4": "B-LOC",
19
+ "5": "B-MON",
20
+ "6": "B-ORG",
21
+ "7": "B-PCT",
22
+ "8": "B-PER",
23
+ "9": "B-PRO",
24
+ "10": "B-TIM",
25
+ "11": "I-DAT",
26
+ "12": "I-EVE",
27
+ "13": "I-FAC",
28
+ "14": "I-LOC",
29
+ "15": "I-MON",
30
+ "16": "I-ORG",
31
+ "17": "I-PCT",
32
+ "18": "I-PER",
33
+ "19": "I-PRO",
34
+ "20": "I-TIM"
35
+ },
36
+ "initializer_range": 0.02,
37
+ "intermediate_size": 3072,
38
+ "label2id": {
39
+ "B-DAT": 1,
40
+ "B-EVE": 2,
41
+ "B-FAC": 3,
42
+ "B-LOC": 4,
43
+ "B-MON": 5,
44
+ "B-ORG": 6,
45
+ "B-PCT": 7,
46
+ "B-PER": 8,
47
+ "B-PRO": 9,
48
+ "B-TIM": 10,
49
+ "I-DAT": 11,
50
+ "I-EVE": 12,
51
+ "I-FAC": 13,
52
+ "I-LOC": 14,
53
+ "I-MON": 15,
54
+ "I-ORG": 16,
55
+ "I-PCT": 17,
56
+ "I-PER": 18,
57
+ "I-PRO": 19,
58
+ "I-TIM": 20,
59
+ "O": 0
60
+ },
61
+ "layer_norm_eps": 1e-12,
62
+ "max_position_embeddings": 514,
63
+ "model_type": "roberta",
64
+ "num_attention_heads": 12,
65
+ "num_hidden_layers": 12,
66
+ "pad_token_id": 1,
67
+ "position_embedding_type": "absolute",
68
+ "transformers_version": "4.5.0.dev0",
69
+ "type_vocab_size": 1,
70
+ "use_cache": true,
71
+ "vocab_size": 42000
72
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12b5dbde0fd2e2cdabb99cf07b95d241643031398bbd310cf7bdf1adaf86239f
3
+ size 470984439
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "unk_token": "<unk>",
5
+ "sep_token": "</s>",
6
+ "pad_token": "<pad>",
7
+ "cls_token": "<s>",
8
+ "mask_token": {
9
+ "content": "<mask>",
10
+ "single_word": false,
11
+ "lstrip": true,
12
+ "rstrip": false,
13
+ "normalized": false
14
+ }
15
+ }
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a36362f6ea7a50a303318bbd8df420227bf2c665e0dca9cc07ab9815ecf77b9e
3
+ size 471165616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
tokenizer_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "unk_token": "<unk>",
3
+ "bos_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "add_prefix_space": true,
6
+ "errors": "replace",
7
+ "sep_token": "</s>",
8
+ "cls_token": "<s>",
9
+ "pad_token": "<pad>",
10
+ "mask_token": "<mask>",
11
+ "model_max_length": 512,
12
+ "special_tokens_map_file": null,
13
+ "name_or_path": "HooshvareLab/roberta-fa-zwnj-base"
14
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff