--- pipeline_tag: sentence-similarity tags: - sentence-transformers - feature-extraction - sentence-similarity - language: es --- # bertin-roberta-base-finetuning-esnli This is a [sentence-transformers](https://www.SBERT.net) model trained on a collection of NLI tasks for Spanish. It maps sentences & paragraphs to a 512 dimensional dense vector space and can be used for tasks like clustering or semantic search. Based around the siamese networks approach from [this paper](https://arxiv.org/pdf/1908.10084.pdf). ## Usage (Sentence-Transformers) Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed: ``` pip install -U sentence-transformers ``` Then you can use the model like this: ```python from sentence_transformers import SentenceTransformer sentences = ["Este es un ejemplo", "Cada oración es transformada"] model = SentenceTransformer('hackathon-pln-es/bertin-roberta-base-finetuning-esnli') embeddings = model.encode(sentences) print(embeddings) ``` ## Evaluation Results Our model was evaluated on the task of Semantic Textual Similarity using the [SemEval-2015 Task](https://alt.qcri.org/semeval2015/task2/) for [Spanish](http://alt.qcri.org/semeval2015/task2/data/uploads/sts2015-es-test.zip). | | [BETO STS](https://huggingface.co/espejelomar/sentece-embeddings-BETO) | BERTIN STS (this model) | Relative improvement | |-------------------:|---------:|-----------:|---------------------:| | cosine_pearson | 0.609803 | 0.670862 | +10.01 | | cosine_spearman | 0.528776 | 0.598593 | +13.20 | | euclidean_pearson | 0.590613 | 0.675257 | +14.33 | | euclidean_spearman | 0.526529 | 0.604656 | +14.84 | | manhattan_pearson | 0.589108 | 0.676706 | +14.87 | | manhattan_spearman | 0.525910 | 0.606461 | +15.32 | | dot_pearson | 0.544078 | 0.586429 | +7.78 | | dot_spearman | 0.460427 | 0.495614 | +7.64 | ## Training The model was trained with the parameters: **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/hackathon-pln-es/coming-soon). **DataLoader**: `sentence_transformers.datasets.NoDuplicatesDataLoader.NoDuplicatesDataLoader` of length 1127 with parameters: ``` {'batch_size': 64} ``` **Loss**: `sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters: ``` {'scale': 20.0, 'similarity_fct': 'cos_sim'} ``` Parameters of the fit()-Method: ``` { "epochs": 20, "evaluation_steps": 0, "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator", "max_grad_norm": 1, "optimizer_class": "", "optimizer_params": { "lr": 2e-05 }, "scheduler": "WarmupLinear", "steps_per_epoch": null, "warmup_steps": 1127, "weight_decay": 0.01 } ``` ## 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}) (2): Dense({'in_features': 768, 'out_features': 512, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'}) ) ``` ## Authors Coming soon.