

# `retrieval-mpnet-bn`

This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like **clustering** or **semantic search**.

<!--- Describe your model here -->

## Model Details

- Model name: retrieval-mpnet-bn
- Model version: 1.0
- Architecture: Sentence Transformer
- Language: Multilingual ( fine-tuned for Bengali Language)


## Training

The model was fine-tuned using  **Multilingual Knowledge Distillation** method. We selected [multi-qa-mpnet-base-cos-v1](https://huggingface.co/sentence-transformers/multi-qa-mpnet-base-cos-v1) model and added a `mean tokens pooling` layer  as the teacher model
```
from sentence_transformers import models, SentenceTransformer

mpnet_model = models.Transformer('sentence-transformers/multi-qa-mpnet-base-cos-v1')

pooling_model = models.Pooling(mpnet_model.get_word_embedding_dimension(),
                               pooling_mode_mean_tokens=True, 
                               pooling_mode_cls_token=False, 
                               pooling_mode_max_tokens=False)

teacher = SentenceTransformer(modules=[mpnet_model, pooling_model])
``` 
and  `xlm-roberta-large` as the student model hence it's a multilingual model and works relatively well for Bengali . 

![image](https://i.ibb.co/8Xrgnfr/sentence-transformer-model.png)

## Intended Use:
Our model is intented to be used for semantic search: It encodes queries / questions and text paragraphs in a dense vector space. It finds relevant documents for the given passages.

Note that there is a limit of 512 word pieces: Text longer than that will be truncated. Further note that the model was just trained on input text up to 250 word pieces. It might not work well for longer text.

- **Primary Use Case:** 
  - **Open-domain question answering:** Answering natural language questions using a large text corpus.
  - **Document retrieval:** Finding relevant documents based on user queries.
  - **Information retrieval tasks:** Building other information retrieval systems that require efficient passage retrieval
- **Potential Use Cases:** Semantic Similarity, Recommendation systems, Chatbot systems , FAQ system

## Usage

### Using Sentence-Transformers

Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:

```
pip install -U sentence-transformers
```

Then you can use the model like this:

```python
from sentence_transformers import SentenceTransformer, util

query = "আফগানিস্তান কত রান করেছিল"
docs = ["ম্যাচটা সিকান্দার রাজারই ছিল। অন্তত রান তাড়ায় নামা শ্রীলঙ্কার ইনিংসের ১৫ ওভার পর্যন্ত অবশ্যই। কিন্তু ব্যাটে বলে দারুণ খেলা জিম্বাবুয়ে অধিনায়ককে হাসতে দিলেন না শ্রীলঙ্কার দুই অভিজ্ঞ ক্রিকেটার। অ্যাঞ্জেলো ম্যাথুস-দাসুন শানাকার সপ্তম উইকেট জুটি ম্যাচ বের করে নেয় জিম্বাবুয়ের নাগাল থেকে। ম্যাথুস অবশ্য দলকে জিতিয়ে ফিরতে পারেননি। তিনি যখন আউট হন, ২ বলে ৬ রান দরকার শ্রীলঙ্কার। দুষ্মন্ত চামিরা ৪ ও ২ রান নিয়ে শেষ বলে গড়ানো ম্যাচে জয় এনে দলকে। ",
"অক্ষর প্যাটেল ও অর্শদীপ সিংয়ের দারুণ বোলিংয়ের পর যশস্বী জয়সোয়াল ও শিবম দুবের জোড়া অর্ধশতকে ইন্দোরে সহজ জয়ে এক ম্যাচ বাকি থাকতেই সিরিজ জিতেছে ভারত। ইন্দোরে তিনে নামা গুলবদিন নাইবের ৩৫ বলে ৫৭ রানের ইনিংসে আফগানিস্তান তুলেছিল ১৭২ রান, কিন্তু ভারত সেটি পেরিয়ে গেছে ২৬ বল ও ৬ উইকেট বাকি রেখেই।",
"এদিন প্রথম থেকে আক্রমণ ও বল দখলে এগিয়ে ছিল মিসরই। প্রতিযোগিতার সবচেয়ে সফল দলটির এগিয়ে যেতে সময় লাগে মাত্র ২ মিনিট। বাঁ পাশ থেকে আসা ক্রসে সালাহ চেষ্টা করেও ঠিকঠাক সংযোগ ঘটাতে পারেননি। তবে তাঁর পায়ের ছোঁয়ায় বল আসে মোস্তফা মোহাম্মদের কাছে। ভুল করেননি এই ফরোয়ার্ড। দারুণ ফিনিশিংয়ে গোল করে এগিয়ে দেন দলকে।"]
# Load the model
model = SentenceTransformer('afschowdhury/retrieval-mpnet-bn')
# Encode the query and documents
query_emb = model.encode(query)
doc_emb = model.encode(docs)

#Compute dot score between query and all document embeddings
scores = util.dot_score(query_emb, doc_emb)[0].cpu().tolist()

#Combine docs & scores
doc_score_pairs = list(zip(docs, scores))

#Sort by decreasing score
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)

#Output passages & scores
for doc, score in doc_score_pairs:
    print(score, doc)
```

### Using HuggingFace Transformers

Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

```python
from transformers import AutoTokenizer, AutoModel
import torch
import torch.nn.functional as F

#Mean Pooling - Take average of all tokens
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output.last_hidden_state #First element of model_output contains all token embeddings
    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)


#Encode text
def encode(texts):
    # Tokenize sentences
    encoded_input = tokenizer(texts, padding=True, truncation=True, return_tensors='pt')

    # Compute token embeddings
    with torch.no_grad():
        model_output = model(**encoded_input, return_dict=True)

    # Perform pooling
    embeddings = mean_pooling(model_output, encoded_input['attention_mask'])

    # Normalize embeddings
    embeddings = F.normalize(embeddings, p=2, dim=1)
    
    return embeddings


# Sentences we want sentence embeddings for
query = "আফগানিস্তান কত রান করেছিল"
docs = ["ম্যাচটা সিকান্দার রাজারই ছিল। অন্তত রান তাড়ায় নামা শ্রীলঙ্কার ইনিংসের ১৫ ওভার পর্যন্ত অবশ্যই। কিন্তু ব্যাটে বলে দারুণ খেলা জিম্বাবুয়ে অধিনায়ককে হাসতে দিলেন না শ্রীলঙ্কার দুই অভিজ্ঞ ক্রিকেটার। অ্যাঞ্জেলো ম্যাথুস-দাসুন শানাকার সপ্তম উইকেট জুটি ম্যাচ বের করে নেয় জিম্বাবুয়ের নাগাল থেকে। ম্যাথুস অবশ্য দলকে জিতিয়ে ফিরতে পারেননি। তিনি যখন আউট হন, ২ বলে ৬ রান দরকার শ্রীলঙ্কার। দুষ্মন্ত চামিরা ৪ ও ২ রান নিয়ে শেষ বলে গড়ানো ম্যাচে জয় এনে দলকে। ",
"অক্ষর প্যাটেল ও অর্শদীপ সিংয়ের দারুণ বোলিংয়ের পর যশস্বী জয়সোয়াল ও শিবম দুবের জোড়া অর্ধশতকে ইন্দোরে সহজ জয়ে এক ম্যাচ বাকি থাকতেই সিরিজ জিতেছে ভারত। ইন্দোরে তিনে নামা গুলবদিন নাইবের ৩৫ বলে ৫৭ রানের ইনিংসে আফগানিস্তান তুলেছিল ১৭২ রান, কিন্তু ভারত সেটি পেরিয়ে গেছে ২৬ বল ও ৬ উইকেট বাকি রেখেই।",
"এদিন প্রথম থেকে আক্রমণ ও বল দখলে এগিয়ে ছিল মিসরই। প্রতিযোগিতার সবচেয়ে সফল দলটির এগিয়ে যেতে সময় লাগে মাত্র ২ মিনিট। বাঁ পাশ থেকে আসা ক্রসে সালাহ চেষ্টা করেও ঠিকঠাক সংযোগ ঘটাতে পারেননি। তবে তাঁর পায়ের ছোঁয়ায় বল আসে মোস্তফা মোহাম্মদের কাছে। ভুল করেননি এই ফরোয়ার্ড। দারুণ ফিনিশিংয়ে গোল করে এগিয়ে দেন দলকে।"]

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained("afschowdhury/retrieval-mpnet-bn")
model = AutoModel.from_pretrained("afschowdhury/retrieval-mpnet-bn")

#Encode query and docs
query_emb = encode(query)
doc_emb = encode(docs)

#Compute dot score between query and all document embeddings
scores = torch.mm(query_emb, doc_emb.transpose(0, 1))[0].cpu().tolist()

#Combine docs & scores
doc_score_pairs = list(zip(docs, scores))

#Sort by decreasing score
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)

#Output passages & scores
for doc, score in doc_score_pairs:
    print(score, doc)

```

## Technical Details
In the following some technical details how this model must be used:
| Setting                        | Value                                       |
| ------------------------------ | ------------------------------------------- |
| Dimensions                     | 768                                         |
| Produces normalized embeddings | No                                         |
| Pooling-Method                 | Mean pooling                                |
| Suitable score functions       | dot-product (`util.dot_score`), cosine-similarity (`util.cos_sim`), or euclidean distance |

----
**Note:** When loaded with sentence-transformers, this model doesn;t produces normalized embeddings like it's base model as while training , we didn't added the normalzed layer in student model's architecture.  In that case, dot-product and cosine-similarity aren't equivalent. However, for retrieval applications, the performance difference is negligible. For similarity search, we recommend to use cosine-similarity as score function.


<!-- write a background section -->

<!-- write  about training data and training procedure and losses -->

## Full Model Architecture

```
SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel 
  (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})
)
```

### Point of Contact
**Asif Faisal Chowdhury**  
E-mail: [afschowdhury@gmail.com](mailto:afschowdhury@gmail.com) | Linked-in: [afschowdhury](https://www.linkedin.com/in/afschowdhury)
{"language": ["bn"], "tags": ["sentence-transformers", "feature-extraction", "sentence-similarity", "transformers", "dense-passage-retrieval", "mpnet"], "pipeline_tag": "sentence-similarity", "widget": [{"source_sentence": "\u0986\u09ab\u0997\u09be\u09a8\u09bf\u09b8\u09cd\u09a4\u09be\u09a8 \u0995\u09a4 \u09b0\u09be\u09a8 \u0995\u09b0\u09c7\u099b\u09bf\u09b2", "sentences": ["\u09ae\u09cd\u09af\u09be\u099a\u099f\u09be \u09b8\u09bf\u0995\u09be\u09a8\u09cd\u09a6\u09be\u09b0 \u09b0\u09be\u099c\u09be\u09b0\u0987 \u099b\u09bf\u09b2\u0964 \u0985\u09a8\u09cd\u09a4\u09a4 \u09b0\u09be\u09a8 \u09a4\u09be\u09dc\u09be\u09df \u09a8\u09be\u09ae\u09be \u09b6\u09cd\u09b0\u09c0\u09b2\u0999\u09cd\u0995\u09be\u09b0 \u0987\u09a8\u09bf\u0982\u09b8\u09c7\u09b0 \u09e7\u09eb \u0993\u09ad\u09be\u09b0 \u09aa\u09b0\u09cd\u09af\u09a8\u09cd\u09a4 \u0985\u09ac\u09b6\u09cd\u09af\u0987\u0964 \u0995\u09bf\u09a8\u09cd\u09a4\u09c1 \u09ac\u09cd\u09af\u09be\u099f\u09c7 \u09ac\u09b2\u09c7 \u09a6\u09be\u09b0\u09c1\u09a3 \u0996\u09c7\u09b2\u09be \u099c\u09bf\u09ae\u09cd\u09ac\u09be\u09ac\u09c1\u09df\u09c7 \u0985\u09a7\u09bf\u09a8\u09be\u09df\u0995\u0995\u09c7 \u09b9\u09be\u09b8\u09a4\u09c7 \u09a6\u09bf\u09b2\u09c7\u09a8 \u09a8\u09be \u09b6\u09cd\u09b0\u09c0\u09b2\u0999\u09cd\u0995\u09be\u09b0 \u09a6\u09c1\u0987 \u0985\u09ad\u09bf\u099c\u09cd\u099e \u0995\u09cd\u09b0\u09bf\u0995\u09c7\u099f\u09be\u09b0\u0964 \u0985\u09cd\u09af\u09be\u099e\u09cd\u099c\u09c7\u09b2\u09cb \u09ae\u09cd\u09af\u09be\u09a5\u09c1\u09b8-\u09a6\u09be\u09b8\u09c1\u09a8 \u09b6\u09be\u09a8\u09be\u0995\u09be\u09b0 \u09b8\u09aa\u09cd\u09a4\u09ae \u0989\u0987\u0995\u09c7\u099f \u099c\u09c1\u099f\u09bf \u09ae\u09cd\u09af\u09be\u099a \u09ac\u09c7\u09b0 \u0995\u09b0\u09c7 \u09a8\u09c7\u09df \u099c\u09bf\u09ae\u09cd\u09ac\u09be\u09ac\u09c1\u09df\u09c7\u09b0 \u09a8\u09be\u0997\u09be\u09b2 \u09a5\u09c7\u0995\u09c7\u0964 \u09ae\u09cd\u09af\u09be\u09a5\u09c1\u09b8 \u0985\u09ac\u09b6\u09cd\u09af \u09a6\u09b2\u0995\u09c7 \u099c\u09bf\u09a4\u09bf\u09df\u09c7 \u09ab\u09bf\u09b0\u09a4\u09c7 \u09aa\u09be\u09b0\u09c7\u09a8\u09a8\u09bf\u0964 \u09a4\u09bf\u09a8\u09bf \u09af\u0996\u09a8 \u0986\u0989\u099f \u09b9\u09a8, \u09e8 \u09ac\u09b2\u09c7 \u09ec \u09b0\u09be\u09a8 \u09a6\u09b0\u0995\u09be\u09b0 \u09b6\u09cd\u09b0\u09c0\u09b2\u0999\u09cd\u0995\u09be\u09b0\u0964 \u09a6\u09c1\u09b7\u09cd\u09ae\u09a8\u09cd\u09a4 \u099a\u09be\u09ae\u09bf\u09b0\u09be \u09ea \u0993 \u09e8 \u09b0\u09be\u09a8 \u09a8\u09bf\u09df\u09c7 \u09b6\u09c7\u09b7 \u09ac\u09b2\u09c7 \u0997\u09dc\u09be\u09a8\u09cb \u09ae\u09cd\u09af\u09be\u099a\u09c7 \u099c\u09df \u098f\u09a8\u09c7 \u09a6\u09b2\u0995\u09c7\u0964 ", "\u0985\u0995\u09cd\u09b7\u09b0 \u09aa\u09cd\u09af\u09be\u099f\u09c7\u09b2 \u0993 \u0985\u09b0\u09cd\u09b6\u09a6\u09c0\u09aa \u09b8\u09bf\u0982\u09df\u09c7\u09b0 \u09a6\u09be\u09b0\u09c1\u09a3 \u09ac\u09cb\u09b2\u09bf\u0982\u09df\u09c7\u09b0 \u09aa\u09b0 \u09af\u09b6\u09b8\u09cd\u09ac\u09c0 \u099c\u09df\u09b8\u09cb\u09df\u09be\u09b2 \u0993 \u09b6\u09bf\u09ac\u09ae \u09a6\u09c1\u09ac\u09c7\u09b0 \u099c\u09cb\u09dc\u09be \u0985\u09b0\u09cd\u09a7\u09b6\u09a4\u0995\u09c7 \u0987\u09a8\u09cd\u09a6\u09cb\u09b0\u09c7 \u09b8\u09b9\u099c \u099c\u09df\u09c7 \u098f\u0995 \u09ae\u09cd\u09af\u09be\u099a \u09ac\u09be\u0995\u09bf \u09a5\u09be\u0995\u09a4\u09c7\u0987 \u09b8\u09bf\u09b0\u09bf\u099c \u099c\u09bf\u09a4\u09c7\u099b\u09c7 \u09ad\u09be\u09b0\u09a4\u0964 \u0987\u09a8\u09cd\u09a6\u09cb\u09b0\u09c7 \u09a4\u09bf\u09a8\u09c7 \u09a8\u09be\u09ae\u09be \u0997\u09c1\u09b2\u09ac\u09a6\u09bf\u09a8 \u09a8\u09be\u0987\u09ac\u09c7\u09b0 \u09e9\u09eb \u09ac\u09b2\u09c7 \u09eb\u09ed \u09b0\u09be\u09a8\u09c7\u09b0 \u0987\u09a8\u09bf\u0982\u09b8\u09c7 \u0986\u09ab\u0997\u09be\u09a8\u09bf\u09b8\u09cd\u09a4\u09be\u09a8 \u09a4\u09c1\u09b2\u09c7\u099b\u09bf\u09b2 \u09e7\u09ed\u09e8 \u09b0\u09be\u09a8, \u0995\u09bf\u09a8\u09cd\u09a4\u09c1 \u09ad\u09be\u09b0\u09a4 \u09b8\u09c7\u099f\u09bf \u09aa\u09c7\u09b0\u09bf\u09df\u09c7 \u0997\u09c7\u099b\u09c7 \u09e8\u09ec \u09ac\u09b2 \u0993 \u09ec \u0989\u0987\u0995\u09c7\u099f \u09ac\u09be\u0995\u09bf \u09b0\u09c7\u0996\u09c7\u0987\u0964", "\u098f\u09a6\u09bf\u09a8 \u09aa\u09cd\u09b0\u09a5\u09ae \u09a5\u09c7\u0995\u09c7 \u0986\u0995\u09cd\u09b0\u09ae\u09a3 \u0993 \u09ac\u09b2 \u09a6\u0996\u09b2\u09c7 \u098f\u0997\u09bf\u09df\u09c7 \u099b\u09bf\u09b2 \u09ae\u09bf\u09b8\u09b0\u0987\u0964 \u09aa\u09cd\u09b0\u09a4\u09bf\u09af\u09cb\u0997\u09bf\u09a4\u09be\u09b0 \u09b8\u09ac\u099a\u09c7\u09df\u09c7 \u09b8\u09ab\u09b2 \u09a6\u09b2\u099f\u09bf\u09b0 \u098f\u0997\u09bf\u09df\u09c7 \u09af\u09c7\u09a4\u09c7 \u09b8\u09ae\u09df \u09b2\u09be\u0997\u09c7 \u09ae\u09be\u09a4\u09cd\u09b0 \u09e8 \u09ae\u09bf\u09a8\u09bf\u099f\u0964 \u09ac\u09be\u0981 \u09aa\u09be\u09b6 \u09a5\u09c7\u0995\u09c7 \u0986\u09b8\u09be \u0995\u09cd\u09b0\u09b8\u09c7 \u09b8\u09be\u09b2\u09be\u09b9 \u099a\u09c7\u09b7\u09cd\u099f\u09be \u0995\u09b0\u09c7\u0993 \u09a0\u09bf\u0995\u09a0\u09be\u0995 \u09b8\u0982\u09af\u09cb\u0997 \u0998\u099f\u09be\u09a4\u09c7 \u09aa\u09be\u09b0\u09c7\u09a8\u09a8\u09bf\u0964 \u09a4\u09ac\u09c7 \u09a4\u09be\u0981\u09b0 \u09aa\u09be\u09df\u09c7\u09b0 \u099b\u09cb\u0981\u09df\u09be\u09df \u09ac\u09b2 \u0986\u09b8\u09c7 \u09ae\u09cb\u09b8\u09cd\u09a4\u09ab\u09be \u09ae\u09cb\u09b9\u09be\u09ae\u09cd\u09ae\u09a6\u09c7\u09b0 \u0995\u09be\u099b\u09c7\u0964 \u09ad\u09c1\u09b2 \u0995\u09b0\u09c7\u09a8\u09a8\u09bf \u098f\u0987 \u09ab\u09b0\u09cb\u09df\u09be\u09b0\u09cd\u09a1\u0964 \u09a6\u09be\u09b0\u09c1\u09a3 \u09ab\u09bf\u09a8\u09bf\u09b6\u09bf\u0982\u09df\u09c7 \u0997\u09cb\u09b2 \u0995\u09b0\u09c7 \u098f\u0997\u09bf\u09df\u09c7 \u09a6\u09c7\u09a8 \u09a6\u09b2\u0995\u09c7\u0964", "\u0986\u09ac\u09b9\u09be\u0993\u09df\u09be \u09ac\u09c7\u09b2\u09c1\u09a8\u099f\u09bf \u09a2\u09be\u0995\u09be \u09a5\u09c7\u0995\u09c7 \u09e7\u09e8\u09e6 \u0995\u09bf\u09b2\u09cb\u09ae\u09bf\u099f\u09be\u09b0 \u09a6\u09c2\u09b0\u09c7 \u0995\u09c1\u09ae\u09bf\u09b2\u09cd\u09b2\u09be\u09df \u0985\u0995\u09cd\u09b7\u09a4 \u0985\u09ac\u09b8\u09cd\u09a5\u09be\u09df \u0985\u09ac\u09a4\u09b0\u09a3 \u0995\u09b0\u09c7\u0964 \u0986\u09ac\u09b9\u09be\u0993\u09df\u09be \u09aa\u09b0\u09cd\u09af\u09ac\u09c7\u0995\u09cd\u09b7\u09a3 \u09ac\u09c7\u09b2\u09c1\u09a8\u099f\u09bf \u09ac\u09be\u09df\u09c1\u09ae\u09a3\u09cd\u09a1\u09b2\u09c7\u09b0 \u09ac\u09bf\u09ad\u09bf\u09a8\u09cd\u09a8 \u0989\u099a\u09cd\u099a\u09a4\u09be\u09df \u09a4\u09be\u09aa\u09ae\u09be\u09a4\u09cd\u09b0\u09be, \u0986\u09b0\u09cd\u09a6\u09cd\u09b0\u09a4\u09be, \u09ac\u09be\u09a4\u09be\u09b8\u09c7\u09b0 \u0997\u09a4\u09bf \u098f\u09ac\u0982 \u09ac\u09be\u09df\u09c1\u09ae\u09a3\u09cd\u09a1\u09b2\u09c7\u09b0 \u0985\u09ac\u09b8\u09cd\u09a5\u09be \u09aa\u09b0\u09bf\u09ae\u09be\u09aa \u0995\u09b0\u09be\u09b0 \u099c\u09a8\u09cd\u09af \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09be \u09b9\u09df\u09c7\u099b\u09c7\u0964 \u098f\u0995 \u09b8\u0982\u09ac\u09be\u09a6 \u09ac\u09bf\u099c\u09cd\u099e\u09aa\u09cd\u09a4\u09bf\u09a4\u09c7 \u098f \u09a4\u09a5\u09cd\u09af \u099c\u09be\u09a8\u09bf\u09df\u09c7\u099b\u09c7 \u098f\u0986\u0987\u0987\u0989\u09ac\u09bf\u0964"], "example_title": "Bengali Question Mixed Context"}, {"source_sentence": "How many runs did Afghanistan score?", "sentences": ["The match belonged to Sikandar Raja. At least run chase down to 15 overs of Sri Lanka's innings. But the two experienced Sri Lankan cricketers did not let the Zimbabwean captain smile with the bat. Angelo Mathews-Dasun Shanaka's seventh-wicket partnership took the match out of Zimbabwe's reach. Mathews, however, could not win the team back. When he got out, Sri Lanka needed 6 runs from 2 balls. Dushman Chamira won the match with 4 and 2 runs in the last ball.", "\u0985\u0995\u09cd\u09b7\u09b0 \u09aa\u09cd\u09af\u09be\u099f\u09c7\u09b2 \u0993 \u0985\u09b0\u09cd\u09b6\u09a6\u09c0\u09aa \u09b8\u09bf\u0982\u09df\u09c7\u09b0 \u09a6\u09be\u09b0\u09c1\u09a3 \u09ac\u09cb\u09b2\u09bf\u0982\u09df\u09c7\u09b0 \u09aa\u09b0 \u09af\u09b6\u09b8\u09cd\u09ac\u09c0 \u099c\u09df\u09b8\u09cb\u09df\u09be\u09b2 \u0993 \u09b6\u09bf\u09ac\u09ae \u09a6\u09c1\u09ac\u09c7\u09b0 \u099c\u09cb\u09dc\u09be \u0985\u09b0\u09cd\u09a7\u09b6\u09a4\u0995\u09c7 \u0987\u09a8\u09cd\u09a6\u09cb\u09b0\u09c7 \u09b8\u09b9\u099c \u099c\u09df\u09c7 \u098f\u0995 \u09ae\u09cd\u09af\u09be\u099a \u09ac\u09be\u0995\u09bf \u09a5\u09be\u0995\u09a4\u09c7\u0987 \u09b8\u09bf\u09b0\u09bf\u099c \u099c\u09bf\u09a4\u09c7\u099b\u09c7 \u09ad\u09be\u09b0\u09a4\u0964 \u0987\u09a8\u09cd\u09a6\u09cb\u09b0\u09c7 \u09a4\u09bf\u09a8\u09c7 \u09a8\u09be\u09ae\u09be \u0997\u09c1\u09b2\u09ac\u09a6\u09bf\u09a8 \u09a8\u09be\u0987\u09ac\u09c7\u09b0 \u09e9\u09eb \u09ac\u09b2\u09c7 \u09eb\u09ed \u09b0\u09be\u09a8\u09c7\u09b0 \u0987\u09a8\u09bf\u0982\u09b8\u09c7 \u0986\u09ab\u0997\u09be\u09a8\u09bf\u09b8\u09cd\u09a4\u09be\u09a8 \u09a4\u09c1\u09b2\u09c7\u099b\u09bf\u09b2 \u09e7\u09ed\u09e8 \u09b0\u09be\u09a8, \u0995\u09bf\u09a8\u09cd\u09a4\u09c1 \u09ad\u09be\u09b0\u09a4 \u09b8\u09c7\u099f\u09bf \u09aa\u09c7\u09b0\u09bf\u09df\u09c7 \u0997\u09c7\u099b\u09c7 \u09e8\u09ec \u09ac\u09b2 \u0993 \u09ec \u0989\u0987\u0995\u09c7\u099f \u09ac\u09be\u0995\u09bf \u09b0\u09c7\u0996\u09c7\u0987\u0964", "From the beginning of the day, Egypt was ahead in attack and possession of the ball. The most successful team in the competition takes only 2 minutes to advance. Salah tried to cross from the left but could not connect properly. But the ball came to Mustafa Mohammad at the touch of his feet. This forward did not make a mistake. He scored a great finish to advance the team.", "\u0986\u09ac\u09b9\u09be\u0993\u09df\u09be \u09ac\u09c7\u09b2\u09c1\u09a8\u099f\u09bf \u09a2\u09be\u0995\u09be \u09a5\u09c7\u0995\u09c7 \u09e7\u09e8\u09e6 \u0995\u09bf\u09b2\u09cb\u09ae\u09bf\u099f\u09be\u09b0 \u09a6\u09c2\u09b0\u09c7 \u0995\u09c1\u09ae\u09bf\u09b2\u09cd\u09b2\u09be\u09df \u0985\u0995\u09cd\u09b7\u09a4 \u0985\u09ac\u09b8\u09cd\u09a5\u09be\u09df \u0985\u09ac\u09a4\u09b0\u09a3 \u0995\u09b0\u09c7\u0964 \u0986\u09ac\u09b9\u09be\u0993\u09df\u09be \u09aa\u09b0\u09cd\u09af\u09ac\u09c7\u0995\u09cd\u09b7\u09a3 \u09ac\u09c7\u09b2\u09c1\u09a8\u099f\u09bf \u09ac\u09be\u09df\u09c1\u09ae\u09a3\u09cd\u09a1\u09b2\u09c7\u09b0 \u09ac\u09bf\u09ad\u09bf\u09a8\u09cd\u09a8 \u0989\u099a\u09cd\u099a\u09a4\u09be\u09df \u09a4\u09be\u09aa\u09ae\u09be\u09a4\u09cd\u09b0\u09be, \u0986\u09b0\u09cd\u09a6\u09cd\u09b0\u09a4\u09be, \u09ac\u09be\u09a4\u09be\u09b8\u09c7\u09b0 \u0997\u09a4\u09bf \u098f\u09ac\u0982 \u09ac\u09be\u09df\u09c1\u09ae\u09a3\u09cd\u09a1\u09b2\u09c7\u09b0 \u0985\u09ac\u09b8\u09cd\u09a5\u09be \u09aa\u09b0\u09bf\u09ae\u09be\u09aa \u0995\u09b0\u09be\u09b0 \u099c\u09a8\u09cd\u09af \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09be \u09b9\u09df\u09c7\u099b\u09c7\u0964 \u098f\u0995 \u09b8\u0982\u09ac\u09be\u09a6 \u09ac\u09bf\u099c\u09cd\u099e\u09aa\u09cd\u09a4\u09bf\u09a4\u09c7 \u098f \u09a4\u09a5\u09cd\u09af \u099c\u09be\u09a8\u09bf\u09df\u09c7\u099b\u09c7 \u098f\u0986\u0987\u0987\u0989\u09ac\u09bf\u0964"], "example_title": "English Question Mixed Context"}]}
sentence-transformers pytorch xlm-roberta feature-extraction sentence-similarity transformers dense-passage-retrieval mpnet bn endpoints_compatible region:us
TAGS
#sentence-transformers #pytorch #xlm-roberta #feature-extraction #sentence-similarity #transformers #dense-passage-retrieval #mpnet #bn #endpoints_compatible #region-us 

'retrieval-mpnet-bn'
====================


This is a sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.


Model Details
-------------


* Model name: retrieval-mpnet-bn
* Model version: 1.0
* Architecture: Sentence Transformer
* Language: Multilingual ( fine-tuned for Bengali Language)


Training
--------


The model was fine-tuned using Multilingual Knowledge Distillation method. We selected multi-qa-mpnet-base-cos-v1 model and added a 'mean tokens pooling' layer as the teacher model


and 'xlm-roberta-large' as the student model hence it's a multilingual model and works relatively well for Bengali .


!image


Intended Use:
-------------


Our model is intented to be used for semantic search: It encodes queries / questions and text paragraphs in a dense vector space. It finds relevant documents for the given passages.


Note that there is a limit of 512 word pieces: Text longer than that will be truncated. Further note that the model was just trained on input text up to 250 word pieces. It might not work well for longer text.


* Primary Use Case:
	+ Open-domain question answering: Answering natural language questions using a large text corpus.
	+ Document retrieval: Finding relevant documents based on user queries.
	+ Information retrieval tasks: Building other information retrieval systems that require efficient passage retrieval
* Potential Use Cases: Semantic Similarity, Recommendation systems, Chatbot systems , FAQ system


Usage
-----


### Using Sentence-Transformers


Using this model becomes easy when you have sentence-transformers installed:


Then you can use the model like this:


### Using HuggingFace Transformers


Without sentence-transformers, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.


Technical Details
-----------------


In the following some technical details how this model must be used:





---


Note: When loaded with sentence-transformers, this model doesn;t produces normalized embeddings like it's base model as while training , we didn't added the normalzed layer in student model's architecture. In that case, dot-product and cosine-similarity aren't equivalent. However, for retrieval applications, the performance difference is negligible. For similarity search, we recommend to use cosine-similarity as score function.


Full Model Architecture
-----------------------


### Point of Contact


Asif Faisal Chowdhury  

E-mail: afschowdhury@URL | Linked-in: afschowdhury



### Using Sentence-Transformers


Using this model becomes easy when you have sentence-transformers installed:


Then you can use the model like this: ### Using HuggingFace Transformers


Without sentence-transformers, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.


Technical Details
-----------------


In the following some technical details how this model must be used:





---


Note: When loaded with sentence-transformers, this model doesn;t produces normalized embeddings like it's base model as while training , we didn't added the normalzed layer in student model's architecture. In that case, dot-product and cosine-similarity aren't equivalent. However, for retrieval applications, the performance difference is negligible. For similarity search, we recommend to use cosine-similarity as score function.


Full Model Architecture
----------------------- ### Point of Contact


Asif Faisal Chowdhury  

E-mail: afschowdhury@URL | Linked-in: afschowdhury
TAGS
#sentence-transformers #pytorch #xlm-roberta #feature-extraction #sentence-similarity #transformers #dense-passage-retrieval #mpnet #bn #endpoints_compatible #region-us 
 ### Using Sentence-Transformers


Using this model becomes easy when you have sentence-transformers installed:


Then you can use the model like this: ### Using HuggingFace Transformers


Without sentence-transformers, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.


Technical Details
-----------------


In the following some technical details how this model must be used:





---


Note: When loaded with sentence-transformers, this model doesn;t produces normalized embeddings like it's base model as while training , we didn't added the normalzed layer in student model's architecture. In that case, dot-product and cosine-similarity aren't equivalent. However, for retrieval applications, the performance difference is negligible. For similarity search, we recommend to use cosine-similarity as score function.


Full Model Architecture
----------------------- ### Point of Contact


Asif Faisal Chowdhury  

E-mail: afschowdhury@URL | Linked-in: afschowdhury