Sentence Similarity
sentence-transformers
Safetensors
Persian
bert
feature-extraction
loss:CachedMultipleNegativesRankingLoss
text-embeddings-inference
Instructions to use PartAI/Tooka-SBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use PartAI/Tooka-SBERT with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("PartAI/Tooka-SBERT") sentences = [ "درنا از پرندگان مهاجر با پاهای بلند و گردن دراز است.", "درناها با قامتی بلند و بالهای پهن، از زیباترین پرندگان مهاجر به شمار میروند.", "درناها پرندگانی کوچک با پاهای کوتاه هستند که مهاجرت نمیکنند.", "ایران برای بار دیگر توانست به مدال طلا دست یابد." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| language: | |
| - fa | |
| library_name: sentence-transformers | |
| pipeline_tag: sentence-similarity | |
| tags: | |
| - sentence-transformers | |
| - sentence-similarity | |
| - feature-extraction | |
| - loss:CachedMultipleNegativesRankingLoss | |
| widget: | |
| - source_sentence: درنا از پرندگان مهاجر با پاهای بلند و گردن دراز است. | |
| sentences: | |
| - >- | |
| درناها با قامتی بلند و بالهای پهن، از زیباترین پرندگان مهاجر به شمار | |
| میروند. | |
| - درناها پرندگانی کوچک با پاهای کوتاه هستند که مهاجرت نمیکنند. | |
| - ایران برای بار دیگر توانست به مدال طلا دست یابد. | |
| - source_sentence: در زمستان هوای تهران بسیار آلوده است. | |
| sentences: | |
| - تهران هوای پاکی در فصل زمستان دارد. | |
| - مشهد و تهران شلوغترین شهرهای ایران هستند. | |
| - در زمستانها هوای تهران پاک نیست. | |
| - source_sentence: یادگیری زبان خارجی فرصتهای شغلی را افزایش میدهد. | |
| sentences: | |
| - تسلط بر چند زبان، شانس استخدام در شرکتهای بینالمللی را بالا میبرد. | |
| - دانستن زبانهای خارجی تأثیری در موفقیت شغلی ندارد. | |
| - دمای هوا در قطب جنوب به پایینترین حد خود در 50 سال اخیر رسید. | |
| - source_sentence: سفر کردن باعث گسترش دیدگاههای فرهنگی میشود. | |
| sentences: | |
| - بازدید از کشورهای مختلف به درک بهتر تنوع فرهنگی کمک میکند. | |
| - سفر کردن هیچ تأثیری بر دیدگاههای فرهنگی افراد ندارد | |
| - دمای هوا در قطب جنوب به پایینترین حد خود در 50 سال اخیر رسید. | |
| base_model: | |
| - PartAI/TookaBERT-Large | |
| > [!warning] **Important** | |
| > | |
| > We recently released the next generation of this model available at: | |
| > | |
| > [Tooka-SBERT-V2-Small](https://huggingface.co/PartAI/Tooka-SBERT-V2-Small) | |
| > | |
| > [Tooka-SBERT-V2-Large](https://huggingface.co/PartAI/Tooka-SBERT-V2-Large) | |
| # SentenceTransformer | |
| This is a [sentence-transformers](https://www.SBERT.net) model trained. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more. | |
| ## Model Details | |
| ### Model Description | |
| - **Model Type:** Sentence Transformer | |
| - **Base model:** [TookaBERT-Large](https://huggingface.co/PartAI/TookaBERT-Large) | |
| - **Maximum Sequence Length:** 512 tokens | |
| - **Output Dimensionality:** 1024 tokens | |
| - **Similarity Function:** Cosine Similarity | |
| - **Language:** Persian | |
| ## Usage | |
| ### Direct Usage (Sentence Transformers) | |
| First install the Sentence Transformers library: | |
| ```bash | |
| pip install -U sentence-transformers | |
| ``` | |
| Then you can load this model and run inference. | |
| ```python | |
| from sentence_transformers import SentenceTransformer | |
| # Download from the 🤗 Hub | |
| model = SentenceTransformer("PartAI/Tooka-SBERT") | |
| # Run inference | |
| sentences = [ | |
| 'درنا از پرندگان مهاجر با پاهای بلند و گردن دراز است.', | |
| 'درناها با قامتی بلند و بالهای پهن، از زیباترین پرندگان مهاجر به شمار میروند.', | |
| 'درناها پرندگانی کوچک با پاهای کوتاه هستند که مهاجرت نمیکنند.' | |
| ] | |
| embeddings = model.encode(sentences) | |
| print(embeddings.shape) | |
| # [3, 1024] | |
| # Get the similarity scores for the embeddings | |
| similarities = model.similarity(embeddings, embeddings) | |
| print(similarities.shape) | |
| # [3, 3] | |
| ``` | |
| ## Citation | |
| ### BibTeX | |
| #### Sentence Transformers | |
| ```bibtex | |
| @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", | |
| } | |
| ``` | |
| #### CachedMultipleNegativesRankingLoss | |
| ```bibtex | |
| @misc{gao2021scaling, | |
| title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup}, | |
| author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan}, | |
| year={2021}, | |
| eprint={2101.06983}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.LG} | |
| } | |
| ``` |