Sentence Similarity
Safetensors
sentence-transformers
Korean
PyLate
modernbert
ColBERT
feature-extraction
Generated from Trainer
text-embeddings-inference
Instructions to use yjoonjang/colbert-ko-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use yjoonjang/colbert-ko-v1 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="yjoonjang/colbert-ko-v1") queries_emb = model.encode(queries, is_query=True) docs_emb = model.encode(documents, is_query=False) - Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage
#2
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- ColBERT
|
|
|
|
| 4 |
- PyLate
|
| 5 |
- sentence-transformers
|
| 6 |
- sentence-similarity
|
|
@@ -20,7 +21,7 @@ language:
|
|
| 20 |
## Model Details
|
| 21 |
|
| 22 |
### Model Description
|
| 23 |
-
- **Model Type:**
|
| 24 |
- **Document Length:** 1024 tokens
|
| 25 |
- **Query Length:** 32 tokens
|
| 26 |
- **Output Dimensionality:** 128 tokens
|
|
@@ -61,6 +62,39 @@ We omit MIRACLRetrieval and MrTidyRetrieval in evalution due to our device condi
|
|
| 61 |
| [jina-colbert-v2](https://huggingface.co/jinaai/jina-colbert-v2) | 0.5B | 0.7518 | 0.0888 | 0.6671 | 0.1577 |
|
| 62 |
|
| 63 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
### PyLate for reranking
|
| 65 |
|
| 66 |
If you only want to use the colbert model to perform reranking on top of your first-stage retrieval pipeline without building an index, you can simply use rank function and pass the queries and documents to rerank:
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- ColBERT
|
| 4 |
+
- multi-vector
|
| 5 |
- PyLate
|
| 6 |
- sentence-transformers
|
| 7 |
- sentence-similarity
|
|
|
|
| 21 |
## Model Details
|
| 22 |
|
| 23 |
### Model Description
|
| 24 |
+
- **Model Type:** Multi-vector embedding model
|
| 25 |
- **Document Length:** 1024 tokens
|
| 26 |
- **Query Length:** 32 tokens
|
| 27 |
- **Output Dimensionality:** 128 tokens
|
|
|
|
| 62 |
| [jina-colbert-v2](https://huggingface.co/jinaai/jina-colbert-v2) | 0.5B | 0.7518 | 0.0888 | 0.6671 | 0.1577 |
|
| 63 |
|
| 64 |
## Usage
|
| 65 |
+
|
| 66 |
+
### Sentence Transformers
|
| 67 |
+
|
| 68 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
pip install "sentence-transformers>=6.0.0"
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
from sentence_transformers import MultiVectorEncoder
|
| 76 |
+
|
| 77 |
+
model = MultiVectorEncoder("yjoonjang/colbert-ko-v1")
|
| 78 |
+
|
| 79 |
+
query = "๋ถ์ ํ์ฑ์ผ๋ก ์๋ ค์ง ํ์ฑ์ ๋ฌด์์ธ๊ฐ์?"
|
| 80 |
+
documents = [
|
| 81 |
+
"๊ธ์ฑ์ ํฌ๊ธฐ์ ๊ทผ์ ์ฑ์ด ๋น์ทํ์ฌ ์ข
์ข
์ง๊ตฌ์ ์๋ฅ์ด๋ผ๊ณ ๋ถ๋ฆฐ๋ค.",
|
| 82 |
+
"ํ์ฑ์ ๋ถ์ ๊ฒ๋ชจ์ต ๋๋ฌธ์ ์ข
์ข
๋ถ์ ํ์ฑ์ด๋ผ๊ณ ๋ถ๋ฆฐ๋ค.",
|
| 83 |
+
"ํ์๊ณ์์ ๊ฐ์ฅ ํฐ ํ์ฑ์ธ ๋ชฉ์ฑ์๋ ๋๋ ทํ ๋ถ์ ๋ฐ์ ์ด ์๋ค.",
|
| 84 |
+
"๊ณ ๋ฆฌ๋ก ์ ๋ช
ํ ํ ์ฑ์ ๋๋๋ก ๋ถ์ ํ์ฑ์ผ๋ก ์ค์ธ๋๋ค.",
|
| 85 |
+
]
|
| 86 |
+
|
| 87 |
+
query_embeddings = model.encode_query(query)
|
| 88 |
+
document_embeddings = model.encode_document(documents)
|
| 89 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 90 |
+
# (32, 128) (19, 128)
|
| 91 |
+
|
| 92 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 93 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 94 |
+
print(scores)
|
| 95 |
+
# tensor([[10.9423, 22.7836, 19.7410, 22.4239]])
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
### PyLate for reranking
|
| 99 |
|
| 100 |
If you only want to use the colbert model to perform reranking on top of your first-stage retrieval pipeline without building an index, you can simply use rank function and pass the queries and documents to rerank:
|