Maux-GTE-Embeddings
Collection
Embedding models finetuned for persian. • 4 items • Updated
How to use xmanii/maux-gte-persian with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("xmanii/maux-gte-persian", trust_remote_code=True)
sentences = [
"انقلاب صنعتی چگونه جامعه را تغییر داد؟",
"انقلاب صنعتی منجر به شهرنشینی شد زیرا مردم به شهرها نقل مکان کردند تا در کارخانهها کار کنند.",
"انقلاب صنعتی منجر به شهرنشینی شد زیرا مردم به شهرها نقل مکان کردند تا در کارخانهها کار کنند.",
"انقلاب صنعتی چگونه جامعه را تغییر داد؟"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from Alibaba-NLP/gte-multilingual-base. It maps Persian (Farsi) sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more in the Persian language.
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: NewModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("xmanii/maux-gte-persian")
# Run inference
sentences = [
'شخصیت\u200cهای اصلی در جنبش کوبیسم چه کسانی بودند؟',
'لئوناردو داوینچی به خاطر مشارکت\u200cهایش در رنسانس شناخته می\u200cشود، نه کوبیسم.',
'شخصیت\u200cهای اصلی در جنبش کوبیسم چه کسانی بودند؟',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05warmup_ratio: 0.1fp16: True@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
Base model
Alibaba-NLP/gte-multilingual-base