Sentence Similarity
sentence-transformers
Safetensors
bert
feature-extraction
Generated from Trainer
dataset_size:100231
loss:MultipleNegativesRankingLoss
text-embeddings-inference
Instructions to use srinivasanAI/bge-small-my-qna-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use srinivasanAI/bge-small-my-qna-model with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("srinivasanAI/bge-small-my-qna-model") sentences = [ "Represent this sentence for searching relevant passages: where do the chances live on raising hope", "Raising Hope James \"Jimmy\" Chance is a 23-year old, living in the surreal fictional town of Natesville, who impregnates a serial killer during a one-night stand. Earning custody of his daughter, Hope, after the mother is sentenced to death, Jimmy relies on his oddball but well-intentioned family for support in raising the child.", "Quadripoint A quadripoint is a point on the Earth that touches the border of four distinct territories.[1][2] The term has never been in common use—it may not have been used before 1964 when it was possibly invented by the Office of the Geographer of the United States Department of State.[3][n 1] The word does not appear in the Oxford English Dictionary or Merriam-Webster Online dictionary, but it does appear in the Encyclopædia Britannica,[4] as well as in the World Factbook articles on Botswana, Namibia, Zambia, and Zimbabwe, dating as far back as 1990.[5]", "Show Me the Way to Go Home The song was recorded by several artists in the 1920s, including radio personalities The Happiness Boys,[2] Vincent Lopez and his Orchestra,[2] and the California Ramblers.[3] Throughout the twentieth into the twenty-first century it has been recorded by numerous artists." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
updated
Browse files
README.md
CHANGED
|
@@ -169,12 +169,17 @@ SentenceTransformer(
|
|
| 169 |
)
|
| 170 |
```
|
| 171 |
|
| 172 |
-
#
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
|
| 177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
from sentence_transformers import SentenceTransformer, util
|
| 179 |
|
| 180 |
# Load the fine-tuned model from the Hub
|
|
@@ -201,11 +206,12 @@ passage_embeddings = model.encode(passages)
|
|
| 201 |
similarities = util.cos_sim(query_embedding, passage_embeddings)
|
| 202 |
|
| 203 |
# 4. Print the results
|
| 204 |
-
print(f"Query: {query.replace(instruction, '')}\n")
|
| 205 |
for i, passage in enumerate(passages):
|
| 206 |
print(f"Similarity: {similarities[0][i]:.4f} | Passage: {passage}")
|
| 207 |
```
|
| 208 |
|
|
|
|
| 209 |
<!--
|
| 210 |
### Direct Usage (Transformers)
|
| 211 |
|
|
|
|
| 169 |
)
|
| 170 |
```
|
| 171 |
|
| 172 |
+
# Fine-Tuned BGE-Small Model for Q&A
|
| 173 |
|
| 174 |
+
This is a `BAAI/bge-small-en-v1.5` model that has been fine-tuned for a specific Question & Answering task using the `MultipleNegativesRankingLoss` in the `sentence-transformers` library.
|
| 175 |
|
| 176 |
+
It has been trained on a private dataset of 100,000+ question-answer pairs. Its primary purpose is to be the retriever model in a Retrieval-Augmented Generation (RAG) system. It excels at mapping questions to the passages that contain their answers.
|
| 177 |
|
| 178 |
+
## How to Use (Practical Inference Example)
|
| 179 |
+
|
| 180 |
+
The primary use case is to find the most relevant passage for a given query.
|
| 181 |
+
|
| 182 |
+
```python
|
| 183 |
from sentence_transformers import SentenceTransformer, util
|
| 184 |
|
| 185 |
# Load the fine-tuned model from the Hub
|
|
|
|
| 206 |
similarities = util.cos_sim(query_embedding, passage_embeddings)
|
| 207 |
|
| 208 |
# 4. Print the results
|
| 209 |
+
print(f"Query: {query.replace(instruction, '')}\\n")
|
| 210 |
for i, passage in enumerate(passages):
|
| 211 |
print(f"Similarity: {similarities[0][i]:.4f} | Passage: {passage}")
|
| 212 |
```
|
| 213 |
|
| 214 |
+
|
| 215 |
<!--
|
| 216 |
### Direct Usage (Transformers)
|
| 217 |
|