osiria commited on
Commit
fc10a48
1 Parent(s): d239e81

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +120 -1
README.md CHANGED
@@ -1,3 +1,122 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: mit
3
+ language:
4
+ - it
5
+ datasets:
6
+ - squad_it
7
+ widget:
8
+ - text: Quale libro fu scritto da Alessandro Manzoni?
9
+ context: Alessandro Manzoni pubblicò la prima versione dei Promessi Sposi nel 1827
10
+ - text: In quali competizioni gareggia la Ferrari?
11
+ context: La Scuderia Ferrari è una squadra corse italiana di Formula 1 con sede a Maranello
12
+ - text: Quale sport è riferito alla Serie A?
13
+ context: Il campionato di Serie A è la massima divisione professionistica del campionato italiano di calcio maschile
14
+ model-index:
15
+ - name: osiria/deberta-italian-question-answering
16
+ results:
17
+ - task:
18
+ type: question-answering
19
+ name: Question Answering
20
+ dataset:
21
+ name: squad_it
22
+ type: squad_it
23
+ metrics:
24
+ - type: exact-match
25
+ value: 0.6880
26
+ name: Exact Match
27
+ - type: f1
28
+ value: 0.8008
29
+ name: F1
30
+ pipeline_tag: question-answering
31
  ---
32
+
33
+ --------------------------------------------------------------------------------------------------
34
+
35
+ <body>
36
+ <span class="vertical-text" style="background-color:lightgreen;border-radius: 3px;padding: 3px;"> </span>
37
+ <br>
38
+ <span class="vertical-text" style="background-color:orange;border-radius: 3px;padding: 3px;">    Task: Question Answering</span>
39
+ <br>
40
+ <span class="vertical-text" style="background-color:lightblue;border-radius: 3px;padding: 3px;">    Model: DeBERTa</span>
41
+ <br>
42
+ <span class="vertical-text" style="background-color:tomato;border-radius: 3px;padding: 3px;">    Lang: IT</span>
43
+ <br>
44
+ <span class="vertical-text" style="background-color:lightgrey;border-radius: 3px;padding: 3px;">  </span>
45
+ <br>
46
+ <span class="vertical-text" style="background-color:#CF9FFF;border-radius: 3px;padding: 3px;"> </span>
47
+ </body>
48
+
49
+ --------------------------------------------------------------------------------------------------
50
+
51
+ <h3>Model description</h3>
52
+
53
+ This is a <b>DeBERTa</b> <b>[1]</b> model for the <b>Italian</b> language, fine-tuned for Extractive Question Answering on the [SQuAD-IT](https://huggingface.co/datasets/squad_it) dataset <b>[2]</b>, using <b>DeBERTa-ITALIAN</b> ([deberta-base-italian](https://huggingface.co/osiria/deberta-base-italian)) as a pre-trained model.
54
+
55
+ <h3>Training and Performances</h3>
56
+
57
+ The model is trained to perform question answering, given a context and a question (under the assumption that the context contains the answer to the question). It has been fine-tuned for Extractive Question Answering, using the SQuAD-IT dataset, for 2 epochs with a linearly decaying learning rate starting from 3e-5, maximum sequence length of 384 and document stride of 128.
58
+ <br>The dataset includes 54.159 training instances and 7.609 test instances
59
+
60
+ The performances on the test set are reported in the following table:
61
+
62
+ | EM | F1 |
63
+ | ------ | ------ |
64
+ | 68.80 | 80.08 |
65
+
66
+ Testing notebook: https://huggingface.co/osiria/deberta-italian-question-answering/blob/main/osiria_deberta_italian_qa_evaluation.ipynb
67
+
68
+ <h3>Quick usage</h3>
69
+
70
+ In order to get the best possible outputs from the model, it is recommended to use the following pipeline
71
+
72
+ ```python
73
+ from transformers import DebertaV2TokenizerFast, DebertaV2ForQuestionAnswering
74
+ import re
75
+ import string
76
+ from transformers.pipelines import QuestionAnsweringPipeline
77
+
78
+ tokenizer = DebertaV2TokenizerFast.from_pretrained("osiria/deberta-italian-question-answering")
79
+ model = DebertaV2ForQuestionAnswering.from_pretrained("osiria/deberta-italian-question-answering")
80
+
81
+ class osiria_qa(QuestionAnsweringPipeline):
82
+
83
+ def __init__(self, punctuation = ',;.:!?()[\]{}', **kwargs):
84
+
85
+ QuestionAnsweringPipeline.__init__(self, **kwargs)
86
+ self.post_regex_left = "^[\s" + punctuation + "]+"
87
+ self.post_regex_right = "[\s" + punctuation + "]+$"
88
+
89
+ def postprocess(self, output):
90
+
91
+ output = QuestionAnsweringPipeline.postprocess(self, model_outputs=output)
92
+ output_length = len(output["answer"])
93
+ output["answer"] = re.sub(self.post_regex_left, "", output["answer"])
94
+ output["start"] = output["start"] + (output_length - len(output["answer"]))
95
+ output_length = len(output["answer"])
96
+ output["answer"] = re.sub(self.post_regex_right, "", output["answer"])
97
+ output["end"] = output["end"] - (output_length - len(output["answer"]))
98
+
99
+ return output
100
+
101
+ pipeline_qa = osiria_qa(model = model, tokenizer = tokenizer)
102
+ pipeline_qa(context = "Alessandro Manzoni è nato a Milano nel 1785",
103
+ question = "Dove è nato Manzoni?")
104
+
105
+ # {'score': 0.9892834424972534, 'start': 28, 'end': 34, 'answer': 'Milano'}
106
+ ```
107
+
108
+ <h3>References</h3>
109
+
110
+ [1] https://arxiv.org/abs/2006.03654
111
+
112
+ [2] https://link.springer.com/chapter/10.1007/978-3-030-03840-3_29
113
+
114
+ <h3>Limitations</h3>
115
+
116
+ This model was trained SQuAD-IT which is mainly a machine translated version of the original SQuAD v1.1. This means that the quality of the training set is limited by the machine translation.
117
+ Moreover, the model is meant to answer questions under the assumption that the required information is actually contained in the given context (which is the underlying assumption of SQuAD v1.1).
118
+ If the assumption is violated, the model will try to return an answer in any case, which is going to be incorrect.
119
+
120
+ <h3>License</h3>
121
+
122
+ The model is released under <b>MIT</b> license