Initialize
Browse files- README.md +90 -0
- config.json +70 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +7 -0
- tf_model.h5 +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +13 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: fa
|
3 |
+
---
|
4 |
+
|
5 |
+
|
6 |
+
# DistilbertNER
|
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 |
+
| Distilbert | 0.994534 | 0.946326 | 0.95504 | 0.950663 |
|
40 |
+
|
41 |
+
|
42 |
+
**Per entities**
|
43 |
+
|
44 |
+
| | number | precision | recall | f1 |
|
45 |
+
|:---: |:------: |:---------: |:--------: |:--------: |
|
46 |
+
| DAT | 407 | 0.812048 | 0.828010 | 0.819951 |
|
47 |
+
| EVE | 256 | 0.955056 | 0.996094 | 0.975143 |
|
48 |
+
| FAC | 248 | 0.972549 | 1.000000 | 0.986083 |
|
49 |
+
| LOC | 2884 | 0.968403 | 0.967060 | 0.967731 |
|
50 |
+
| MON | 98 | 0.925532 | 0.887755 | 0.906250 |
|
51 |
+
| ORG | 3216 | 0.932095 | 0.951803 | 0.941846 |
|
52 |
+
| PCT | 94 | 0.936842 | 0.946809 | 0.941799 |
|
53 |
+
| PER | 2645 | 0.959818 | 0.957278 | 0.958546 |
|
54 |
+
| PRO | 318 | 0.963526 | 0.996855 | 0.979907 |
|
55 |
+
| TIM | 43 | 0.760870 | 0.813953 | 0.786517 |
|
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/distilbert-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,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation": "gelu",
|
3 |
+
"architectures": [
|
4 |
+
"DistilBertForTokenClassification"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.1,
|
7 |
+
"dim": 768,
|
8 |
+
"dropout": 0.1,
|
9 |
+
"finetuning_task": "ner",
|
10 |
+
"hidden_dim": 3072,
|
11 |
+
"id2label": {
|
12 |
+
"0": "O",
|
13 |
+
"1": "B-DAT",
|
14 |
+
"2": "B-EVE",
|
15 |
+
"3": "B-FAC",
|
16 |
+
"4": "B-LOC",
|
17 |
+
"5": "B-MON",
|
18 |
+
"6": "B-ORG",
|
19 |
+
"7": "B-PCT",
|
20 |
+
"8": "B-PER",
|
21 |
+
"9": "B-PRO",
|
22 |
+
"10": "B-TIM",
|
23 |
+
"11": "I-DAT",
|
24 |
+
"12": "I-EVE",
|
25 |
+
"13": "I-FAC",
|
26 |
+
"14": "I-LOC",
|
27 |
+
"15": "I-MON",
|
28 |
+
"16": "I-ORG",
|
29 |
+
"17": "I-PCT",
|
30 |
+
"18": "I-PER",
|
31 |
+
"19": "I-PRO",
|
32 |
+
"20": "I-TIM"
|
33 |
+
},
|
34 |
+
"initializer_range": 0.02,
|
35 |
+
"label2id": {
|
36 |
+
"B-DAT": 1,
|
37 |
+
"B-EVE": 2,
|
38 |
+
"B-FAC": 3,
|
39 |
+
"B-LOC": 4,
|
40 |
+
"B-MON": 5,
|
41 |
+
"B-ORG": 6,
|
42 |
+
"B-PCT": 7,
|
43 |
+
"B-PER": 8,
|
44 |
+
"B-PRO": 9,
|
45 |
+
"B-TIM": 10,
|
46 |
+
"I-DAT": 11,
|
47 |
+
"I-EVE": 12,
|
48 |
+
"I-FAC": 13,
|
49 |
+
"I-LOC": 14,
|
50 |
+
"I-MON": 15,
|
51 |
+
"I-ORG": 16,
|
52 |
+
"I-PCT": 17,
|
53 |
+
"I-PER": 18,
|
54 |
+
"I-PRO": 19,
|
55 |
+
"I-TIM": 20,
|
56 |
+
"O": 0
|
57 |
+
},
|
58 |
+
"max_position_embeddings": 512,
|
59 |
+
"model_type": "distilbert",
|
60 |
+
"n_heads": 12,
|
61 |
+
"n_layers": 6,
|
62 |
+
"output_past": true,
|
63 |
+
"pad_token_id": 0,
|
64 |
+
"qa_dropout": 0.1,
|
65 |
+
"seq_classif_dropout": 0.2,
|
66 |
+
"sinusoidal_pos_embds": false,
|
67 |
+
"tie_weights_": true,
|
68 |
+
"transformers_version": "4.5.0.dev0",
|
69 |
+
"vocab_size": 42000
|
70 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:851d3497622637fc228341fb644311988fee7c48011174e86599ecda829862ae
|
3 |
+
size 300818949
|
special_tokens_map.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"unk_token": "[UNK]",
|
3 |
+
"sep_token": "[SEP]",
|
4 |
+
"pad_token": "[PAD]",
|
5 |
+
"cls_token": "[CLS]",
|
6 |
+
"mask_token": "[MASK]"
|
7 |
+
}
|
tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f5ef9e2e137ae4d41c50ef03eeb33b02c9274653e22d251386897f7e7604052
|
3 |
+
size 300903008
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_lower_case": false,
|
3 |
+
"unk_token": "[UNK]",
|
4 |
+
"sep_token": "[SEP]",
|
5 |
+
"pad_token": "[PAD]",
|
6 |
+
"cls_token": "[CLS]",
|
7 |
+
"mask_token": "[MASK]",
|
8 |
+
"tokenize_chinese_chars": true,
|
9 |
+
"strip_accents": false,
|
10 |
+
"model_max_length": 512,
|
11 |
+
"special_tokens_map_file": null,
|
12 |
+
"name_or_path": "HooshvareLab/distilbert-fa-zwnj-base"
|
13 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|