Upload README.md
Browse files
README.md
CHANGED
|
@@ -31,7 +31,7 @@ language:
|
|
| 31 |
|
| 32 |
# Introduction
|
| 33 |
|
| 34 |
-
`mdbr-leaf-mt-asym` is a
|
| 35 |
|
| 36 |
This model is the asymmetric variant of `mdbr-leaf-mt`, which uses [`MongoDB/mdbr-leaf-mt`](https://huggingface.co/MongoDB/mdbr-leaf-mt) for queries and [`mixedbread-ai/mxbai-embed-large-v1`](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1) for documents.
|
| 37 |
|
|
@@ -118,7 +118,10 @@ See [here](https://huggingface.co/MongoDB/mdbr-leaf-mt/blob/main/transformers_ex
|
|
| 118 |
|
| 119 |
## Asymmetric Retrieval Setup
|
| 120 |
|
| 121 |
-
`mdbr-leaf-mt` is *aligned* to [`mxbai-embed-large-v1`](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1), the model it has been distilled from.
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
To use exclusively the leaf model, use [`mdbr-leaf-mt`](https://huggingface.co/MongoDB/mdbr-leaf-mt).
|
| 124 |
|
|
@@ -151,8 +154,8 @@ Good initial values are -1.0 and +1.0.
|
|
| 151 |
from sentence_transformers.quantization import quantize_embeddings
|
| 152 |
import torch
|
| 153 |
|
| 154 |
-
query_embeds = model.
|
| 155 |
-
doc_embeds = model.
|
| 156 |
|
| 157 |
# Quantize embeddings to int8 using -1.0 and +1.0
|
| 158 |
ranges = torch.tensor([[-1.0], [+1.0]]).expand(2, query_embeds.shape[1]).cpu().numpy()
|
|
@@ -169,8 +172,8 @@ print(f"* Similarities:\n{similarities}")
|
|
| 169 |
# After quantization:
|
| 170 |
# * Embeddings type: int8
|
| 171 |
# * Similarities:
|
| 172 |
-
# [[
|
| 173 |
-
# [
|
| 174 |
```
|
| 175 |
|
| 176 |
# Evaluation
|
|
@@ -200,3 +203,7 @@ This model is released under Apache 2.0 License.
|
|
| 200 |
# Contact
|
| 201 |
|
| 202 |
For questions or issues, please open an issue or pull request. You can also contact the MongoDB ML research team at [email protected].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Introduction
|
| 33 |
|
| 34 |
+
`mdbr-leaf-mt-asym` is a high-performance text embedding model designed for classification, clustering, semantic sentence similarity and summarization tasks.
|
| 35 |
|
| 36 |
This model is the asymmetric variant of `mdbr-leaf-mt`, which uses [`MongoDB/mdbr-leaf-mt`](https://huggingface.co/MongoDB/mdbr-leaf-mt) for queries and [`mixedbread-ai/mxbai-embed-large-v1`](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1) for documents.
|
| 37 |
|
|
|
|
| 118 |
|
| 119 |
## Asymmetric Retrieval Setup
|
| 120 |
|
| 121 |
+
`mdbr-leaf-mt` is *aligned* to [`mxbai-embed-large-v1`](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1), the model it has been distilled from.
|
| 122 |
+
This enables flexible architectures in which, for example, documents are encoded using the larger model,
|
| 123 |
+
while queries can be encoded faster and more efficiently with the compact `leaf` model.
|
| 124 |
+
This usually outperforms the symmetric setup in which both queries and documents are encoded with `leaf`.
|
| 125 |
|
| 126 |
To use exclusively the leaf model, use [`mdbr-leaf-mt`](https://huggingface.co/MongoDB/mdbr-leaf-mt).
|
| 127 |
|
|
|
|
| 154 |
from sentence_transformers.quantization import quantize_embeddings
|
| 155 |
import torch
|
| 156 |
|
| 157 |
+
query_embeds = model.encode_query(queries)
|
| 158 |
+
doc_embeds = model.encode_document(documents)
|
| 159 |
|
| 160 |
# Quantize embeddings to int8 using -1.0 and +1.0
|
| 161 |
ranges = torch.tensor([[-1.0], [+1.0]]).expand(2, query_embeds.shape[1]).cpu().numpy()
|
|
|
|
| 172 |
# After quantization:
|
| 173 |
# * Embeddings type: int8
|
| 174 |
# * Similarities:
|
| 175 |
+
# [[11392 9204]
|
| 176 |
+
# [8256 10470]]
|
| 177 |
```
|
| 178 |
|
| 179 |
# Evaluation
|
|
|
|
| 203 |
# Contact
|
| 204 |
|
| 205 |
For questions or issues, please open an issue or pull request. You can also contact the MongoDB ML research team at [email protected].
|
| 206 |
+
|
| 207 |
+
# Acknowledgments
|
| 208 |
+
|
| 209 |
+
This model version was created by @tomaarsen - we thank him for his contribution to this project.
|