Updates README.md with demo
Browse filesSigned-off-by: Giovani <[email protected]>
README.md
CHANGED
@@ -30,15 +30,14 @@ the **ASSIN (Avaliação de Similaridade Semântica e Inferência textual)** cor
|
|
30 |
- **Model type:** Transformer-based text classifier
|
31 |
- **Language(s) (NLP):** Portuguese
|
32 |
- **License:** mit
|
33 |
-
- **Finetuned from model [
|
34 |
|
35 |
-
### Model Sources
|
36 |
|
37 |
<!-- Provide the basic links for the model. -->
|
38 |
|
39 |
- **Repository:** [Natural-Portuguese-Language-Inference](https://github.com/giogvn/Natural-Portuguese-Language-Inference)
|
40 |
-
- **Paper
|
41 |
-
- **Demo [optional]:** [More Information Needed]
|
42 |
|
43 |
## Uses
|
44 |
|
@@ -72,6 +71,27 @@ Therefore, **this fine-tuned version of [XLM-RoBERTa-base](https://huggingface.c
|
|
72 |
|
73 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
### Recommendations
|
76 |
|
77 |
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
@@ -170,7 +190,7 @@ More information on how such mapping is performed can be found in [Modelos para
|
|
170 |
### Metrics
|
171 |
|
172 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
173 |
-
The model's performance metrics for each test dataset are presented separately. Accuracy, f1 score, precision and recall were the metrics used to every evaluation performed. Such metrics are reported below. More information on such metrics them
|
174 |
|
175 |
### Results
|
176 |
|
@@ -182,11 +202,11 @@ The model's performance metrics for each test dataset are presented separately.
|
|
182 |
## Model Examination
|
183 |
|
184 |
<!-- Relevant interpretability work for the model goes here -->
|
185 |
-
Some interpretability work
|
186 |
|
187 |
-
|
188 |
|
189 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly
|
190 |
|
191 |
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
192 |
|
@@ -194,11 +214,11 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
194 |
- **Hours used:** [More Information Needed]
|
195 |
- **Cloud Provider:** [More Information Needed]
|
196 |
- **Compute Region:** [More Information Needed]
|
197 |
-
- **Carbon Emitted:** [More Information Needed]
|
198 |
|
199 |
-
## Citation
|
200 |
|
201 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section.
|
202 |
|
203 |
**BibTeX:**
|
204 |
|
@@ -209,12 +229,12 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
209 |
pages = {x--y},
|
210 |
year = {2023}
|
211 |
}
|
212 |
-
```
|
213 |
|
214 |
## References
|
215 |
|
216 |
[1][Salvatore, F. S. (2020). Analyzing Natural Language Inference from a Rigorous Point of View (pp. 1-2).](https://www.teses.usp.br/teses/disponiveis/45/45134/tde-05012021-151600/publico/tese_de_doutorado_felipe_salvatore.pdf)
|
217 |
|
218 |
-
[2][Andrade, G. T. (2023) Modelos para Inferência em Linguagem Natural que entendem a Língua Portuguesa (train_assin_xlmr_base_results PAGES GO HERE)](https://linux.ime.usp.br/~giovani/)
|
219 |
|
220 |
-
[3][Andrade, G. T. (2023) Modelos para Inferência em Linguagem Natural que entendem a Língua Portuguesa (train_assin_xlmr_base_conclusions PAGES GO HERE)](https://linux.ime.usp.br/~giovani/)
|
|
|
30 |
- **Model type:** Transformer-based text classifier
|
31 |
- **Language(s) (NLP):** Portuguese
|
32 |
- **License:** mit
|
33 |
+
- **Finetuned from model** [XLM-RoBERTa-base](https://huggingface.co/xlm-roberta-base)
|
34 |
|
35 |
+
### Model Sources
|
36 |
|
37 |
<!-- Provide the basic links for the model. -->
|
38 |
|
39 |
- **Repository:** [Natural-Portuguese-Language-Inference](https://github.com/giogvn/Natural-Portuguese-Language-Inference)
|
40 |
+
- **Paper:** This is an ongoing research. We are currently writing a paper where we fully describe our experiments.
|
|
|
41 |
|
42 |
## Uses
|
43 |
|
|
|
71 |
|
72 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
73 |
|
74 |
+
|
75 |
+
## Demo
|
76 |
+
|
77 |
+
```python
|
78 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
79 |
+
import torch
|
80 |
+
|
81 |
+
model_path = "giotvr/portuguese-nli-3-labels"
|
82 |
+
premise = "As mudanças climáticas são uma ameaça séria para a biodiversidade do planeta."
|
83 |
+
hypothesis ="A biodiversidade do planeta é seriamente ameaçada pelas mudanças climáticas."
|
84 |
+
tokenizer = XLMRobertaTokenizer.from_pretrained(model_path, use_auth_token=True)
|
85 |
+
input_pair = tokenizer(premise, hypothesis, return_tensors="pt",padding=True, truncation=True)
|
86 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path, use_auth_token=True)
|
87 |
+
|
88 |
+
with torch.no_grad():
|
89 |
+
logits = model(**input_pair).logits
|
90 |
+
probs = torch.nn.functional.softmax(logits, dim=-1)
|
91 |
+
probs, sorted_indices = torch.sort(probs, descending=True)
|
92 |
+
for i, score in enumerate(probs[0]):
|
93 |
+
print(f"Class {sorted_indices[0][i]}: {score.item():.4f}")
|
94 |
+
```
|
95 |
### Recommendations
|
96 |
|
97 |
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
|
|
190 |
### Metrics
|
191 |
|
192 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
193 |
+
The model's performance metrics for each test dataset are presented separately. Accuracy, f1 score, precision and recall were the metrics used to every evaluation performed. Such metrics are reported below. More information on such metrics them will be available in our ongoing research paper.
|
194 |
|
195 |
### Results
|
196 |
|
|
|
202 |
## Model Examination
|
203 |
|
204 |
<!-- Relevant interpretability work for the model goes here -->
|
205 |
+
Some interpretability work is being done in order to understand the model's behavior. Such details will be available in the previoulsy referred paper.
|
206 |
|
207 |
+
<!--## Environmental Impact
|
208 |
|
209 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly
|
210 |
|
211 |
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
212 |
|
|
|
214 |
- **Hours used:** [More Information Needed]
|
215 |
- **Cloud Provider:** [More Information Needed]
|
216 |
- **Compute Region:** [More Information Needed]
|
217 |
+
- **Carbon Emitted:** [More Information Needed] -->
|
218 |
|
219 |
+
<!-- ## Citation
|
220 |
|
221 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section.
|
222 |
|
223 |
**BibTeX:**
|
224 |
|
|
|
229 |
pages = {x--y},
|
230 |
year = {2023}
|
231 |
}
|
232 |
+
``` -->
|
233 |
|
234 |
## References
|
235 |
|
236 |
[1][Salvatore, F. S. (2020). Analyzing Natural Language Inference from a Rigorous Point of View (pp. 1-2).](https://www.teses.usp.br/teses/disponiveis/45/45134/tde-05012021-151600/publico/tese_de_doutorado_felipe_salvatore.pdf)
|
237 |
|
238 |
+
<!--[2][Andrade, G. T. (2023) Modelos para Inferência em Linguagem Natural que entendem a Língua Portuguesa (train_assin_xlmr_base_results PAGES GO HERE)](https://linux.ime.usp.br/~giovani/)
|
239 |
|
240 |
+
[3][Andrade, G. T. (2023) Modelos para Inferência em Linguagem Natural que entendem a Língua Portuguesa (train_assin_xlmr_base_conclusions PAGES GO HERE)](https://linux.ime.usp.br/~giovani/) -->
|