File size: 2,354 Bytes
dc1d80d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
pipeline_tag: zero-shot-classification
tags:
- zero-shot-classification
- nli
language:
- es
datasets:
- hackathon-pln-es/nli-es
widget:
- text: "El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo"
  candidate_labels: "cultura, sociedad, economia, salud, deportes"
---


# A zero-shot classifier based on bertin-roberta-base-finetuning-esnli

## Usage (HuggingFace Transformers)
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

```python
from transformers import pipeline
classifier = pipeline("zero-shot-classification", 
                       model="hackathon-pln-es/bertin-roberta-base-zeroshot-esnli")

classifier(
    "El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo",
    candidate_labels=["cultura", "sociedad", "economia", "salud", "deportes"],
    hypothesis_template="Este ejemplo es {}."
)
```

The `hypothesis_template` parameter is important and should be in Spanish. **In the widget on the right, this parameter is set to its default value: "This example is {}.", so different results are expected.**

## Training

**Dataset**

We used a collection of datasets of Natural Language Inference as training data:
 - [ESXNLI](https://raw.githubusercontent.com/artetxem/esxnli/master/esxnli.tsv), only the part in spanish
 - [SNLI](https://nlp.stanford.edu/projects/snli/), automatically translated
 - [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/), automatically translated

The whole dataset used is available [here](https://huggingface.co/datasets/hackathon-pln-es/ESnli).

## Full Model Architecture
```
SentenceTransformer(
  (0): Transformer({'max_seq_length': 514, 'do_lower_case': False}) with Transformer model: RobertaModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
```

## Authors

- [Anibal Pérez](https://huggingface.co/Anarpego)
- [Emilio Tomás Ariza](https://huggingface.co/medardodt)
- [Lautaro Gesuelli](https://huggingface.co/Lautaro)
- [Mauricio Mazuecos](https://huggingface.co/mmazuecos)