đ gemasphi/laprador_pt
This model, based on sentence-transformers, maps sentences and paragraphs into a 768-dimensional dense vector space. It's applicable for tasks such as clustering and semantic search.
đ Quick Start
This section provides two ways to use the gemasphi/laprador_pt
model, with and without the sentence-transformers
library.
⨠Features
- Maps sentences and paragraphs to a 768-dimensional dense vector space.
- Suitable for clustering and semantic search tasks.
đĻ Installation
To use this model, you first need to install the sentence-transformers
library. You can do this by running the following command:
pip install -U sentence-transformers
đģ Usage Examples
Basic Usage
If you have the sentence-transformers library installed, using the model is straightforward:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('gemasphi/laprador_pt')
embeddings = model.encode(sentences)
print(embeddings)
Advanced Usage
Without the sentence-transformers library, you can use the model as follows. First, pass your input through the transformer model, and then apply the appropriate pooling operation on the contextualized word embeddings:
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)
sentences = ['This is an example sentence', 'Each sentence is converted']
tokenizer = AutoTokenizer.from_pretrained('gemasphi/laprador_pt')
model = AutoModel.from_pretrained('gemasphi/laprador_pt')
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:")
print(sentence_embeddings)
đ Documentation
Evaluation Results
For an automated evaluation of this model, refer to the Sentence Embeddings Benchmark: https://seb.sbert.net
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 350, 'do_lower_case': False}) with Transformer model: BertModel
(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})
)
đ License
The README does not provide license information.