sentence-transformers
ONNX
Safetensors
English
bert
ColBERT
multi-vector
RAGatouille
passage-retrieval
Instructions to use answerdotai/answerai-colbert-small-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use answerdotai/answerai-colbert-small-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("answerdotai/answerai-colbert-small-v1") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage
Browse files
README.md
CHANGED
|
@@ -4,6 +4,8 @@ language:
|
|
| 4 |
- en
|
| 5 |
tags:
|
| 6 |
- ColBERT
|
|
|
|
|
|
|
| 7 |
- RAGatouille
|
| 8 |
- passage-retrieval
|
| 9 |
---
|
|
@@ -18,6 +20,38 @@ For more information about this model or how it was trained, head over to the [a
|
|
| 18 |
|
| 19 |
## Usage
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
### Installation
|
| 22 |
|
| 23 |
This model was designed with the upcoming RAGatouille overhaul in mind. However, it's compatible with all recent ColBERT implementations!
|
|
|
|
| 4 |
- en
|
| 5 |
tags:
|
| 6 |
- ColBERT
|
| 7 |
+
- multi-vector
|
| 8 |
+
- sentence-transformers
|
| 9 |
- RAGatouille
|
| 10 |
- passage-retrieval
|
| 11 |
---
|
|
|
|
| 20 |
|
| 21 |
## Usage
|
| 22 |
|
| 23 |
+
### Sentence Transformers
|
| 24 |
+
|
| 25 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
pip install "sentence-transformers>=6.0.0"
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
from sentence_transformers import MultiVectorEncoder
|
| 33 |
+
|
| 34 |
+
model = MultiVectorEncoder("answerdotai/answerai-colbert-small-v1")
|
| 35 |
+
|
| 36 |
+
query = "Which planet is known as the Red Planet?"
|
| 37 |
+
documents = [
|
| 38 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 39 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 40 |
+
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
|
| 41 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
query_embeddings = model.encode_query(query)
|
| 45 |
+
document_embeddings = model.encode_document(documents)
|
| 46 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 47 |
+
# (32, 96) (17, 96)
|
| 48 |
+
|
| 49 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 50 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 51 |
+
print(scores)
|
| 52 |
+
# tensor([[30.5692, 31.4895, 31.3029, 31.3072]])
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
### Installation
|
| 56 |
|
| 57 |
This model was designed with the upcoming RAGatouille overhaul in mind. However, it's compatible with all recent ColBERT implementations!
|