File size: 2,412 Bytes
772218c 0053d5b 772218c 0053d5b 772218c 361ce1c 772218c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
---
inference: false
language: pt
datasets:
- ruanchaves/porsimplessent
---
# mDeBERTa v3 base for Text Simplification
This is the [microsoft/mdeberta-v3-base](https://huggingface.co/microsoft/mdeberta-v3-base) model finetuned for
Text Simplification with the [PorSimplesSent](https://huggingface.co/ruanchaves/porsimplessent) dataset.
This model is suitable for Portuguese.
- Git Repo: [Evaluation of Portuguese Language Models](https://github.com/ruanchaves/eplm).
- Demo: [Hugging Face Space: Portuguese Text Simplification](https://ruanchaves-portuguese-text-simplification.hf.space)
### **Labels**:
* 0 : Sentence A is more simple than Sentence B.
* 1 : The two sentences are equally simple.
* 2 : Sentence B is more simple than Sentence A.
## Full classification example
```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer, AutoConfig
import numpy as np
import torch
from scipy.special import softmax
model_name = "ruanchaves/mdeberta-v3-base-porsimplessent"
s1 = "O preço para instalar um DVD player no carro fica entre R$ 2 mil e R$ 5 mil."
s2 = "Instalar um DVD player no carro tem preço médio entre R$ 2 mil e R$ 5 mil."
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
config = AutoConfig.from_pretrained(model_name)
model_input = tokenizer(*([s1], [s2]), padding=True, return_tensors="pt")
with torch.no_grad():
output = model(**model_input)
scores = output[0][0].detach().numpy()
scores = softmax(scores)
ranking = np.argsort(scores)
ranking = ranking[::-1]
for i in range(scores.shape[0]):
l = config.id2label[ranking[i]]
s = scores[ranking[i]]
print(f"{i+1}) Label: {l} Score: {np.round(float(s), 4)}")
```
## Citation
Our research is ongoing, and we are currently working on describing our experiments in a paper, which will be published soon.
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):
```
@software{Chaves_Rodrigues_eplm_2023,
author = {Chaves Rodrigues, Ruan and Tanti, Marc and Agerri, Rodrigo},
doi = {10.5281/zenodo.7781848},
month = {3},
title = {{Evaluation of Portuguese Language Models}},
url = {https://github.com/ruanchaves/eplm},
version = {1.0.0},
year = {2023}
}
``` |