sbertimbau large nli sts
ricardo-filhoSBERTIMBAU-LARGE-NLI-STS
Introduction
SBERTIMBAU-LARGE-NLI-STS is a sentence-transformers model that maps sentences and paragraphs to a 1024-dimensional dense vector space. It is useful for tasks such as clustering and semantic search.
Architecture
The model is based on the SentenceTransformer architecture, which includes:
- A transformer model, specifically a
BertModel
, with a configuration ofmax_seq_length
set to 64 anddo_lower_case
set to False. - A pooling layer that performs mean pooling on the token embeddings.
Training
The model was trained using a DataLoader
with a batch size of 16, utilizing a random sampler. The training process involved:
- A loss function:
CosineSimilarityLoss
. - Training for 4 epochs.
- An optimizer:
AdamW
, with a learning rate of 2e-05. - A
WarmupLinear
scheduler with 143 warmup steps. - A weight decay of 0.01.
Guide: Running Locally
To use SBERTIMBAU-LARGE-NLI-STS locally, follow these steps:
Using Sentence-Transformers
- Install the library:
pip install -U sentence-transformers
- Use the model:
from sentence_transformers import SentenceTransformer model = SentenceTransformer('{MODEL_NAME}') sentences = ["This is an example sentence", "Each sentence is converted"] embeddings = model.encode(sentences) print(embeddings)
Using Hugging Face Transformers
- Install the
transformers
library andtorch
:pip install transformers torch
- Use the model:
from transformers import AutoTokenizer, AutoModel import torch def mean_pooling(model_output, attention_mask): token_embeddings = model_output[0] input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float() return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9) tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}') model = AutoModel.from_pretrained('{MODEL_NAME}') sentences = ['This is an example sentence', 'Each sentence is converted'] encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt') with torch.no_grad(): model_output = model(**encoded_input) sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask']) print(sentence_embeddings)
Suggestion
For better performance, consider using cloud GPUs such as those available on AWS, Google Cloud, or Azure.
License
The specific licensing details for SBERTIMBAU-LARGE-NLI-STS should be checked on the model's homepage or repository for compliance and usage rights.