🚀 sentence-BERTino-v2-mmarco-4m
This is a sentence-transformers model that maps sentences and paragraphs into a 768-dimensional dense vector space. It can be applied to tasks such as clustering or semantic search. It is a fine - tuned sentence - BERTino - v2 - pt model based on approximately 4 million mmarco examples.
Use query:
and passage:
as prefix identifiers for questions and documents respectively.
- Loss: MultipleNegativesRankingLoss
- Infrastructure: A100 80GB
If you find this project useful, consider supporting its development:

🚀 Quick Start
This section will guide you through the basic steps of using the sentence - BERTino - v2 - mmarco - 4m
model.
✨ Features
- Maps sentences and paragraphs to a 768 - dimensional dense vector space.
- Applicable to tasks like clustering and semantic search.
- Fine - tuned on ~4m mmarco examples.
📦 Installation
If you want to use this model, you need to install sentence - transformers first:
pip install -U sentence-transformers
💻 Usage Examples
Basic Usage
Using Sentence - Transformers
When you have sentence - transformers installed, using this model is straightforward:
from sentence_transformers import SentenceTransformer
sentences = [
"query: Questo è un esempio di frase",
"passage: Questo è un ulteriore esempio"
]
model = SentenceTransformer('efederici/sentence-BERTino-v2-mmarco-4m')
embeddings = model.encode(sentences)
print(embeddings)
Using HuggingFace Transformers
Without sentence - transformers, you can use the model as follows:
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 = [
"query: Questo è un esempio di frase",
"passage: Questo è un ulteriore esempio"
]
tokenizer = AutoTokenizer.from_pretrained('efederici/sentence-BERTino-v2-mmarco-4m')
model = AutoModel.from_pretrained('efederici/sentence-BERTino-v2-mmarco-4m')
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
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: DistilBertModel
(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
This project is licensed under the apache - 2.0
license.