ruanchaves
commited on
Commit
·
2b470fa
1
Parent(s):
3e53e7b
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
language: pt
|
4 |
+
datasets:
|
5 |
+
- ruanchaves/faquad-nli
|
6 |
+
---
|
7 |
+
|
8 |
+
|
9 |
+
# BERTimbau large for Question Answering
|
10 |
+
|
11 |
+
This is the [neuralmind/bert-large-portuguese-cased](https://huggingface.co/neuralmind/bert-large-portuguese-cased) model finetuned for
|
12 |
+
Text Simplification with the [FaQUaD-NLI](https://huggingface.co/ruanchaves/faquad-nli) dataset.
|
13 |
+
This model is suitable for Portuguese.
|
14 |
+
|
15 |
+
- Git Repo: [Evaluation of Portuguese Language Models](https://github.com/ruanchaves/eplm).
|
16 |
+
- Demo: [Hugging Face Space: Question Answering](https://ruanchaves-portuguese-text-simplification.hf.space)
|
17 |
+
|
18 |
+
### **Labels**:
|
19 |
+
* 0 : The answer is not suitable for the provided question.
|
20 |
+
* 1 : The answer is suitable for the provided question.
|
21 |
+
|
22 |
+
|
23 |
+
## Full classification example
|
24 |
+
|
25 |
+
```python
|
26 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer, AutoConfig
|
27 |
+
import numpy as np
|
28 |
+
import torch
|
29 |
+
from scipy.special import softmax
|
30 |
+
|
31 |
+
model_name = "ruanchaves/bert-large-portuguese-cased-faquad-nli"
|
32 |
+
s1 = "Qual a montanha mais alta do mundo?"
|
33 |
+
s2 = "Monte Everest é a montanha mais alta do mundo."
|
34 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
36 |
+
config = AutoConfig.from_pretrained(model_name)
|
37 |
+
model_input = tokenizer(*([s1], [s2]), padding=True, return_tensors="pt")
|
38 |
+
with torch.no_grad():
|
39 |
+
output = model(**model_input)
|
40 |
+
scores = output[0][0].detach().numpy()
|
41 |
+
scores = softmax(scores)
|
42 |
+
ranking = np.argsort(scores)
|
43 |
+
ranking = ranking[::-1]
|
44 |
+
for i in range(scores.shape[0]):
|
45 |
+
l = config.id2label[ranking[i]]
|
46 |
+
s = scores[ranking[i]]
|
47 |
+
print(f"{i+1}) Label: {l} Score: {np.round(float(s), 4)}")
|
48 |
+
```
|
49 |
+
|
50 |
+
## Citation
|
51 |
+
|
52 |
+
Our research is ongoing, and we are currently working on describing our experiments in a paper, which will be published soon.
|
53 |
+
In the meanwhile, if you would like to cite our work or models before the publication of the paper, please cite our [GitHub repository](https://github.com/ruanchaves/eplm):
|
54 |
+
|
55 |
+
```
|
56 |
+
@software{Chaves_Rodrigues_eplm_2023,
|
57 |
+
author = {Chaves Rodrigues, Ruan and Tanti, Marc and Agerri, Rodrigo},
|
58 |
+
doi = {10.5281/zenodo.7781848},
|
59 |
+
month = {3},
|
60 |
+
title = ,
|
61 |
+
url = {https://github.com/ruanchaves/eplm},
|
62 |
+
version = {1.0.0},
|
63 |
+
year = {2023}
|
64 |
+
}
|
65 |
+
```
|