Sentence Similarity
ONNX
Safetensors
sentence-transformers
English
PyLate
modernbert
ColBERT
multi-vector
feature-extraction
Generated from Trainer
dataset_size:100521
loss:CachedContrastive
Eval Results
text-embeddings-inference
Instructions to use lightonai/Reason-ModernColBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lightonai/Reason-ModernColBERT with sentence-transformers:
from pylate import models queries = [ "Which planet is known as the Red Planet?", "What is the largest planet in our solar system?", ] documents = [ ["Mars is the Red Planet.", "Venus is Earth's twin."], ["Jupiter is the largest planet.", "Saturn has rings."], ] model = models.ColBERT(model_name_or_path="lightonai/Reason-ModernColBERT") queries_emb = model.encode(queries, is_query=True) docs_emb = model.encode(documents, is_query=False) - Inference
- Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage
#5
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -3,6 +3,7 @@ language:
|
|
| 3 |
- en
|
| 4 |
tags:
|
| 5 |
- ColBERT
|
|
|
|
| 6 |
- PyLate
|
| 7 |
- sentence-transformers
|
| 8 |
- sentence-similarity
|
|
@@ -25,14 +26,14 @@ It achieves extremely competitive performance on the [BRIGHT benchmark](https://
|
|
| 25 |
|
| 26 |
# License
|
| 27 |
Unfortunately, since the [ReasonIR data](https://huggingface.co/datasets/reasonir/reasonir-data) has been released under a cc-by-nc-4.0 license, we cannot release this model under an Apache 2.0 license. However, the authors of ReasonIR [released code to generate the data](https://github.com/facebookresearch/ReasonIR/tree/main/synthetic_data_generation). Anyone willing to reproduce the data could then easily reproduce this model under an Apache 2.0 license by running a fine-tuning lasting lower than 2 hours using [this boilerplate](https://gist.github.com/NohTow/d563244596548bf387f19fcd790664d3).
|
| 28 |
-
#
|
| 29 |
|
| 30 |
-
This is a
|
| 31 |
|
| 32 |
## Model Details
|
| 33 |
|
| 34 |
### Model Description
|
| 35 |
-
- **Model Type:**
|
| 36 |
- **Base model:** [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1) <!-- at revision 78d50a162b04dfdc45c3af6b4294ba77c24888a3 -->
|
| 37 |
- **Document Length:** 8192 tokens
|
| 38 |
- **Query Length:** 128 tokens
|
|
@@ -59,6 +60,41 @@ ColBERT(
|
|
| 59 |
```
|
| 60 |
|
| 61 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
First install the PyLate library:
|
| 63 |
|
| 64 |
```bash
|
|
|
|
| 3 |
- en
|
| 4 |
tags:
|
| 5 |
- ColBERT
|
| 6 |
+
- multi-vector
|
| 7 |
- PyLate
|
| 8 |
- sentence-transformers
|
| 9 |
- sentence-similarity
|
|
|
|
| 26 |
|
| 27 |
# License
|
| 28 |
Unfortunately, since the [ReasonIR data](https://huggingface.co/datasets/reasonir/reasonir-data) has been released under a cc-by-nc-4.0 license, we cannot release this model under an Apache 2.0 license. However, the authors of ReasonIR [released code to generate the data](https://github.com/facebookresearch/ReasonIR/tree/main/synthetic_data_generation). Anyone willing to reproduce the data could then easily reproduce this model under an Apache 2.0 license by running a fine-tuning lasting lower than 2 hours using [this boilerplate](https://gist.github.com/NohTow/d563244596548bf387f19fcd790664d3).
|
| 29 |
+
# Multi-vector embedding model based on lightonai/GTE-ModernColBERT-v1
|
| 30 |
|
| 31 |
+
This is a multi-vector (ColBERT-style late interaction) embedding model finetuned from [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1) on the [reasonir-hq](https://huggingface.co/datasets/reasonir/reasonir-data) dataset. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
|
| 32 |
|
| 33 |
## Model Details
|
| 34 |
|
| 35 |
### Model Description
|
| 36 |
+
- **Model Type:** Multi-vector embedding model
|
| 37 |
- **Base model:** [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1) <!-- at revision 78d50a162b04dfdc45c3af6b4294ba77c24888a3 -->
|
| 38 |
- **Document Length:** 8192 tokens
|
| 39 |
- **Query Length:** 128 tokens
|
|
|
|
| 60 |
```
|
| 61 |
|
| 62 |
## Usage
|
| 63 |
+
|
| 64 |
+
### Sentence Transformers
|
| 65 |
+
|
| 66 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
pip install "sentence-transformers>=6.0.0"
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
from sentence_transformers import MultiVectorEncoder
|
| 74 |
+
|
| 75 |
+
model = MultiVectorEncoder("lightonai/Reason-ModernColBERT")
|
| 76 |
+
|
| 77 |
+
query = "Which planet is known as the Red Planet?"
|
| 78 |
+
documents = [
|
| 79 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 80 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 81 |
+
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
|
| 82 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 83 |
+
]
|
| 84 |
+
|
| 85 |
+
query_embeddings = model.encode_query(query)
|
| 86 |
+
document_embeddings = model.encode_document(documents)
|
| 87 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 88 |
+
# (12, 128) (18, 128)
|
| 89 |
+
|
| 90 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 91 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 92 |
+
print(scores)
|
| 93 |
+
# tensor([[9.0512, 10.1842, 9.1238, 9.3910]])
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### PyLate
|
| 97 |
+
|
| 98 |
First install the PyLate library:
|
| 99 |
|
| 100 |
```bash
|