Adding doc
Browse files
README.md
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
pipeline_tag: zero-shot-classification
|
3 |
+
tags:
|
4 |
+
- zero-shot-classification
|
5 |
+
- nli
|
6 |
+
language:
|
7 |
+
- es
|
8 |
+
datasets:
|
9 |
+
- hackathon-pln-es/nli-es
|
10 |
+
widget:
|
11 |
+
- text: "El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo"
|
12 |
+
candidate_labels: "cultura, sociedad, economia, salud, deportes"
|
13 |
+
---
|
14 |
+
|
15 |
+
|
16 |
+
# A zero-shot classifier based on bertin-roberta-base-finetuning-esnli
|
17 |
+
|
18 |
+
This is a [sentence-transformers](https://www.SBERT.net) model trained on a
|
19 |
+
collection of NLI tasks for Spanish. It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
20 |
+
|
21 |
+
Based around the siamese networks approach from [this paper](https://arxiv.org/pdf/1908.10084.pdf).
|
22 |
+
|
23 |
+
## Usage (HuggingFace Transformers)
|
24 |
+
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.
|
25 |
+
|
26 |
+
```python
|
27 |
+
from transformers import pipeline
|
28 |
+
classifier = pipeline("zero-shot-classification",
|
29 |
+
model="hackathon-pln-es/bertin-roberta-base-zeroshot-esnli")
|
30 |
+
|
31 |
+
classifier(
|
32 |
+
"El autor se perfila, a los 50 años de su muerte, como uno de los grandes de su siglo",
|
33 |
+
candidate_labels=["cultura", "sociedad", "economia", "salud", "deportes"],
|
34 |
+
hypothesis_template="Este ejemplo es {}."
|
35 |
+
)
|
36 |
+
```
|
37 |
+
|
38 |
+
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.**
|
39 |
+
|
40 |
+
## Training
|
41 |
+
The model was trained with the parameters:
|
42 |
+
|
43 |
+
**Dataset**
|
44 |
+
|
45 |
+
We used a collection of datasets of Natural Language Inference as training data:
|
46 |
+
- [ESXNLI](https://raw.githubusercontent.com/artetxem/esxnli/master/esxnli.tsv), only the part in spanish
|
47 |
+
- [SNLI](https://nlp.stanford.edu/projects/snli/), automatically translated
|
48 |
+
- [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/), automatically translated
|
49 |
+
|
50 |
+
The whole dataset used is available [here](https://huggingface.co/datasets/hackathon-pln-es/ESnli).
|
51 |
+
|
52 |
+
## Full Model Architecture
|
53 |
+
```
|
54 |
+
SentenceTransformer(
|
55 |
+
(0): Transformer({'max_seq_length': 514, 'do_lower_case': False}) with Transformer model: RobertaModel
|
56 |
+
(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})
|
57 |
+
)
|
58 |
+
```
|
59 |
+
|
60 |
+
## Authors
|
61 |
+
|
62 |
+
- [Anibal Pérez](https://huggingface.co/Anarpego)
|
63 |
+
- [Emilio Tomás Ariza](https://huggingface.co/medardodt)
|
64 |
+
- [Lautaro Gesuelli](https://huggingface.co/Lautaro)
|
65 |
+
- [Mauricio Mazuecos](https://huggingface.co/mmazuecos)
|