Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,98 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- it
|
5 |
+
widget:
|
6 |
+
- text: "Mi chiamo Marco Rossi, vivo a Roma e lavoro per l'Agenzia Spaziale Italiana"
|
7 |
+
example_title: "Example 1"
|
8 |
---
|
9 |
+
|
10 |
+
--------------------------------------------------------------------------------------------------
|
11 |
+
|
12 |
+
<body>
|
13 |
+
<span class="vertical-text" style="background-color:lightgreen;border-radius: 3px;padding: 3px;"> </span>
|
14 |
+
<br>
|
15 |
+
<span class="vertical-text" style="background-color:orange;border-radius: 3px;padding: 3px;"> Task: Named Entity Recognition</span>
|
16 |
+
<br>
|
17 |
+
<span class="vertical-text" style="background-color:lightblue;border-radius: 3px;padding: 3px;"> Model: BERT</span>
|
18 |
+
<br>
|
19 |
+
<span class="vertical-text" style="background-color:tomato;border-radius: 3px;padding: 3px;"> Lang: IT</span>
|
20 |
+
<br>
|
21 |
+
<span class="vertical-text" style="background-color:lightgrey;border-radius: 3px;padding: 3px;"> </span>
|
22 |
+
<br>
|
23 |
+
<span class="vertical-text" style="background-color:#CF9FFF;border-radius: 3px;padding: 3px;"> </span>
|
24 |
+
</body>
|
25 |
+
|
26 |
+
--------------------------------------------------------------------------------------------------
|
27 |
+
|
28 |
+
<h3>Model description</h3>
|
29 |
+
|
30 |
+
This is a <b>BERT</b> <b>[1]</b> cased model for the <b>Italian</b> language, fine-tuned for <b>Named Entity Recognition</b> (<b>Person</b>, <b>Location</b>, <b>Organization</b> and <b>Miscellanea</b> classes) on the [WikiNER](https://figshare.com/articles/dataset/Learning_multilingual_named_entity_recognition_from_Wikipedia/5462500) dataset <b>[2]</b>, using <b>BERT-ITALIAN</b> ([bert-base-italian-cased](https://huggingface.co/osiria/bert-base-italian-cased)) as a pre-trained model.
|
31 |
+
|
32 |
+
<h3>Training and Performances</h3>
|
33 |
+
|
34 |
+
The model is trained to perform entity recognition over 4 classes: <b>PER</b> (persons), <b>LOC</b> (locations), <b>ORG</b> (organizations), <b>MISC</b> (miscellanea, mainly events, products and services). It has been fine-tuned for Named Entity Recognition, using the WikiNER Italian dataset plus an additional custom dataset of manually annotated Wikipedia paragraphs.
|
35 |
+
The WikiNER dataset has been splitted in 102.352 training instances and 25.588 test instances.
|
36 |
+
|
37 |
+
The performances on the test set are reported in the following table:
|
38 |
+
|
39 |
+
| Recall | Precision | F1 |
|
40 |
+
| ------ | ------ | ------ |
|
41 |
+
| 93.35 | 92.22 | 92.78 |
|
42 |
+
|
43 |
+
The metrics have been computed at the token level and then macro-averaged over the 4 classes.
|
44 |
+
|
45 |
+
Then, since WikiNER is an automatically annotated (silver standard) dataset, which sometimes contains imperfect annotations, an additional fine-tuning on ~3.500 manually annotated paragraphs has been performed.
|
46 |
+
|
47 |
+
<h3>Quick usage</h3>
|
48 |
+
|
49 |
+
```python
|
50 |
+
from transformers import BertTokenizerFast, BertForTokenClassification
|
51 |
+
|
52 |
+
tokenizer = BertTokenizerFast.from_pretrained("osiria/bert-italian-cased-ner")
|
53 |
+
model = BertForTokenClassification.from_pretrained("osiria/bert-italian-cased-ner")
|
54 |
+
|
55 |
+
from transformers import pipeline
|
56 |
+
ner = pipeline("ner", model = model, tokenizer = tokenizer, aggregation_strategy="first")
|
57 |
+
|
58 |
+
ner("Mi chiamo Marco Rossi, vivo a Roma e lavoro per l'Agenzia Spaziale Italiana nella missione Prisma")
|
59 |
+
|
60 |
+
[{'entity_group': 'PER',
|
61 |
+
'score': 0.99910736,
|
62 |
+
'word': 'Marco Rossi',
|
63 |
+
'start': 10,
|
64 |
+
'end': 21},
|
65 |
+
{'entity_group': 'LOC',
|
66 |
+
'score': 0.9973786,
|
67 |
+
'word': 'Roma',
|
68 |
+
'start': 30,
|
69 |
+
'end': 34},
|
70 |
+
{'entity_group': 'ORG',
|
71 |
+
'score': 0.9987071,
|
72 |
+
'word': 'Agenzia Spaziale Italiana',
|
73 |
+
'start': 50,
|
74 |
+
'end': 75},
|
75 |
+
{'entity_group': 'MISC',
|
76 |
+
'score': 0.9625836,
|
77 |
+
'word': 'Prisma',
|
78 |
+
'start': 91,
|
79 |
+
'end': 97}]
|
80 |
+
```
|
81 |
+
|
82 |
+
You can also try the model online using this web app: https://huggingface.co/spaces/osiria/bert-italian-cased-ner
|
83 |
+
|
84 |
+
<h3>References</h3>
|
85 |
+
|
86 |
+
[1] https://arxiv.org/abs/1810.04805
|
87 |
+
|
88 |
+
[2] https://www.sciencedirect.com/science/article/pii/S0004370212000276
|
89 |
+
|
90 |
+
<h3>Limitations</h3>
|
91 |
+
|
92 |
+
This model is mainly trained on Wikipedia, so it's particularly suitable for natively digital text from the world wide web, written in a correct and fluent form (like wikis, web pages, news, etc.). However, it may show limitations when it comes to chaotic text, containing errors and slang expressions
|
93 |
+
(like social media posts) or when it comes to domain-specific text (like medical, financial or legal content).
|
94 |
+
|
95 |
+
<h3>License</h3>
|
96 |
+
|
97 |
+
The model is released under <b>Apache-2.0</b> license
|
98 |
+
|