Sentence Similarity
sentence-transformers
Safetensors
English
modernbert
colbert
late-interaction
retrieval
pylate
multi-vector
text-embeddings-inference
Instructions to use chungimungi/GLInt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use chungimungi/GLInt with sentence-transformers:
from sentence_transformers import MultiVectorEncoder model = MultiVectorEncoder("chungimungi/GLInt") queries = ["Which planet is known as the Red Planet?"] documents = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage
#1
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -40,6 +40,41 @@ objective, while a false-negative-masked InfoNCE term preserves a direct retriev
|
|
| 40 |
|
| 41 |
## Usage
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
```python
|
| 44 |
from pylate import models
|
| 45 |
|
|
|
|
| 40 |
|
| 41 |
## Usage
|
| 42 |
|
| 43 |
+
### Sentence Transformers
|
| 44 |
+
|
| 45 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector
|
| 46 |
+
(ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
pip install "sentence-transformers>=6.0.0"
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from sentence_transformers import MultiVectorEncoder
|
| 54 |
+
|
| 55 |
+
model = MultiVectorEncoder("chungimungi/GLInt")
|
| 56 |
+
|
| 57 |
+
query = "Which planet is known as the Red Planet?"
|
| 58 |
+
documents = [
|
| 59 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 60 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 61 |
+
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
|
| 62 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
query_embeddings = model.encode_query(query)
|
| 66 |
+
document_embeddings = model.encode_document(documents)
|
| 67 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 68 |
+
# torch.Size([12, 128]) torch.Size([18, 128])
|
| 69 |
+
|
| 70 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 71 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 72 |
+
print(scores)
|
| 73 |
+
# tensor([[11.6192, 11.7344, 11.6513, 11.7105]], device='cuda:0')
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### PyLate
|
| 77 |
+
|
| 78 |
```python
|
| 79 |
from pylate import models
|
| 80 |
|