ЁЯЪА MahaSBERT-STS
A MahaSBERT model (l3cube-pune/marathi-sentence-bert-nli) fine-tuned on STS dataset. This model maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for tasks like clustering or semantic search.
ЁЯЪА Quick Start
This is a sentence-transformers model. It can be used for tasks such as clustering or semantic search by mapping sentences and paragraphs into a 768-dimensional dense vector space.
ЁЯУж Installation
Using this model becomes easy when you have sentence-transformers installed:
pip install -U sentence-transformers
ЁЯТ╗ Usage Examples
Basic Usage
If you have sentence-transformers installed, you can use the model like this:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('{MODEL_NAME}')
embeddings = model.encode(sentences)
print(embeddings)
Advanced Usage
Without sentence-transformers, you can use the model as follows: First, pass your input through the transformer model, and then apply the appropriate pooling operation on top of 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('{MODEL_NAME}')
model = AutoModel.from_pretrained('{MODEL_NAME}')
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
This model is a fine - tuned version of the MahaSBERT model (l3cube - pune/marathi - sentence - bert - nli) on the STS dataset. It is released as part of the project MahaNLP: https://github.com/l3cube-pune/MarathiNLP.
A multilingual version of this model supporting major Indic languages and cross - lingual sentence similarity is shared here indic - sentence - similarity - sbert .
More details on the dataset, models, and baseline results can be found in our paper.
@article{joshi2022l3cubemahasbert,
title={L3Cube-MahaSBERT and HindSBERT: Sentence BERT Models and Benchmarking BERT Sentence Representations for Hindi and Marathi},
author={Joshi, Ananya and Kajale, Aditi and Gadre, Janhavi and Deode, Samruddhi and Joshi, Raviraj},
journal={arXiv preprint arXiv:2211.11187},
year={2022}
}
Related Papers
Other Monolingual Similarity Models
Other Monolingual Indic Sentence BERT Models
ЁЯУД License
This model is released under the cc - by - 4.0 license.
Widget Examples
The following are some widget examples for testing sentence similarity:
{
"pipeline_tag": "sentence-similarity",
"tags": [
"sentence-transformers",
"feature-extraction",
"sentence-similarity",
"transformers"
],
"license": "cc-by-4.0",
"language": "mr",
"widget": [
{
"source_sentence": "рд╢реЗрддрдХрд▒реНрдпрд╛рдВрдЪреЗ рдбреЛрд│реЗ рдЖрдХрд╛рд╢рд╛рдХрдбреЗ рд▓рд╛рдЧрд▓реЗ рдЖрд╣реЗрдд",
"sentences": [
"рдЖрддрд╛ рд╢реЗрддрдХрд▒реНрдпрд╛рдВрдЪреЗ рдбреЛрд│реЗ рдЖрднрд╛рд│рд╛рдХрдбреЗ рд▓рд╛рдЧрд▓реЗ рдЖрд╣реЗрдд",
"рдЕрдиреНрдирдзрд╛рдиреНрдп рдЙрддреНрдкрд╛рджрдирд╛рд╕рд╛рдареА рд╢реЗрддрдХрд░реА рдХрд╖реНрдЯ рдХрд░рддрд╛рдд",
"рд╢рд╣рд░рд╛рдд рдХрдЪрд▒реНрдпрд╛рдЪреЗ рдвреАрдЧ рджрд┐рд╕рддрд╛рдд"
],
"example_title": "Example 1"
},
{
"source_sentence": "рдШрдЯрдиреЗрдЪреА рдорд╛рд╣рд┐рддреА рдорд┐рд│рддрд╛рдЪ рдкреЛрд▓рд┐рд╕рд╛рдВрдЪрд╛ рддрд╛рдлрд╛ рддреЗрдереЗ рдкреЛрд╣реЛрдЪрд▓рд╛",
"sentences": [
"рдкреЛрд▓рд┐рд╕рд╛рдВрдирд╛ рдШрдЯрдиреЗрдЪреА рдорд╛рд╣рд┐рддреА рдорд┐рд│рддрд╛рдЪ рддреНрдпрд╛рдВрдЪреЗ рдкрдердХ рдШрдЯрдирд╛рд╕реНрдерд│реА рдкреЛрд╣реЛрдЪрд▓реЗ",
"рддреЗрд╡реНрд╣рд╛ рдкреЛрд▓рд┐рд╕рд╛рдВрдиреА рддреНрдпрд╛рдВрдЪреНрдпрд╛ рддрдХреНрд░рд╛рд░реАрдЪреА рджрдЦрд▓ рдШреЗрддрд▓реА рдирд╛рд╣реА",
"рджрд┐рд╡рд╕рд╛рдЪрд╛ рдЙрддреНрддрд░рд╛рд░реНрдз рдХреБрдЯреБрдВрдмрд╛рд╕реЛрдмрдд рдореМрдЬрдордЬреЗрдд рдШрд╛рд▓рд╡рд╛рд▓"
],
"example_title": "Example 2"
},
{
"source_sentence": "рдкрд╣рд┐рд▓реНрдпрд╛ рдкрд╛рдЪ рдХрд┐рд▓реЛрдореАрдЯрд░ рдЕрдВрддрд░рд╛рд╕рд╛рдареА рдкрд╛рдЪ рд░реБрдкрдпреЗ рджрд░ рдЖрдХрд╛рд░рдгреНрдпрд╛рдд рдпреЗрдд рдЖрд╣реЗ",
"sentences": [
"рдкрд╛рдЪ рд░реБрдкрдпрд╛рдВрдд рдкрд╛рдЪ рдХрд┐рдореА рдкреНрд░рд╡рд╛рд╕ рдХрд░рд╛",
"рджреЛрди рдард┐рдХрд╛рдгрд╛рдВрдордзрд▓реЗ рдореЛрдареЗ рдЕрдВрддрд░ рдкреНрд░рд╡рд╛рд╕ рдХрд░рдгреЗ рдХрдВрдЯрд╛рд│рд╡рд╛рдгреЗ рдЖрд╣реЗ",
"рдиреБрдХрддреНрдпрд╛рдЪ рдЭрд╛рд▓реЗрд▓реНрдпрд╛ рдкрд╛рд╡рд╕рд╛рдореБрд│реЗ рд╣рд┐рд░рд╡рд│ рджрд┐рд╕рдд рдЖрд╣реЗ"
],
"example_title": "Example 3"
}
]
}