đ sentence-bert-base-italian-xxl-cased
This is a sentence-transformers model that maps sentences and paragraphs to a 768-dimensional dense vector space. It can be used for tasks such as clustering or semantic search. It is derived from dbmdz/bert-base-italian-xxl-uncased. Check its model card for more information.
đ Quick Start
đĻ Installation
There are multiple ways to install and use this model depending on the library you choose.
Install with Sentence-Transformers
pip install -U sentence-transformers
Install with FastEmbed
pip install fastembed
đģ Usage Examples
Basic Usage with Sentence-Transformers
from sentence_transformers import SentenceTransformer
sentences = ["Una ragazza si acconcia i capelli.", "Una ragazza si sta spazzolando i capelli."]
model = SentenceTransformer('nickprock/sentence-bert-base-italian-xxl-uncased')
embeddings = model.encode(sentences)
print(embeddings)
Advanced Usage with FastEmbed
from fastembed import TextEmbedding
from fastembed.common.model_description import PoolingType, ModelSource
sentences = ["Una ragazza si acconcia i capelli.", "Una ragazza si sta spazzolando i capelli."]
TextEmbedding.add_custom_model(
model="nickprock/sentence-bert-base-italian-xxl-uncased",
pooling=PoolingType.MEAN,
normalization=True,
sources=ModelSource(hf="nickprock/sentence-bert-base-italian-xxl-uncased"),
dim=768,
model_file="onnx/model_qint8_avx512_vnni.onnx",
)
model = TextEmbedding(model_name="nickprock/sentence-bert-base-italian-xxl-uncased")
embeddings = list(model.embed(sentences))
print(embeddings)
Advanced Usage with HuggingFace Transformers
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 = ['Una ragazza si acconcia i capelli.', 'Una ragazza si sta spazzolando i capelli.']
tokenizer = AutoTokenizer.from_pretrained('nickprock/sentence-bert-base-italian-xxl-uncased')
model = AutoModel.from_pretrained('nickprock/sentence-bert-base-italian-xxl-uncased')
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, see the Sentence Embeddings Benchmark: https://seb.sbert.net
Training
The model was trained with the following parameters:
DataLoader:
torch.utils.data.dataloader.DataLoader
of length 360 with parameters:
{'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
Loss:
sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss
Parameters of the fit()-Method:
{
"epochs": 10,
"evaluation_steps": 500,
"evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
"max_grad_norm": 1,
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": 1500,
"warmup_steps": 360,
"weight_decay": 0.01
}
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, '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
This model is licensed under the MIT license.
Property |
Details |
Pipeline Tag |
sentence-similarity |
Tags |
sentence-transformers, feature-extraction, sentence-similarity, transformers |
License |
MIT |
Datasets |
stsb_multi_mt |
Language |
Italian |
Library Name |
sentence-transformers |