colbert-retrieval
БесплатноБез исполняемых скриптовНе проверенColBERT / ColBERTv2 late interaction as a first-stage retriever — not just a reranker. MaxSim scoring, PLAID index, Ragatouille for deployment, storage cost…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
ColBERT Retrieval
Late Interaction in One Picture
Bi-encoders compress a document into one vector. Cross-encoders score each (query, doc) pair from scratch. ColBERT sits in between: it stores one vector per token, and scores at query time with MaxSim.
score(q, d) = sum over q_tokens i of max over d_tokens j of q_i dot d_j
Each query token finds its best-matching document token. You keep bi-encoder speed at indexing time and cross-encoder-like quality at query time.
When ColBERT Wins
| Scenario | Dense + rerank | ColBERT |
|---|---|---|
| Out-of-domain corpus (legal, medical, code) | Often needs rerank to recover recall | Strong out-of-box |
| Long documents (> 512 tokens) | Single vector loses detail | Token-level keeps detail |
| Low-latency single-stage retrieval | Needs two stages | One stage suffices |
| Huge corpus (> 50M docs) on commodity disk | Cheap | Storage becomes the bottleneck |
| Multilingual with one model | Works with multilingual encoders | Only if you use a multilingual base |
Pick ColBERT when document-level single vectors lose too much, and you cannot afford a reranker pass on every query.
Storage Cost
A typical 1024-d dense vector is ~4 KB. ColBERTv2 stores ~128-d vectors per token, compressed via PLAID residual codecs. In practice:
| Index | Bytes/token | Bytes per 500-token doc |
|---|---|---|
| Single dense 1024-d | n/a | 4 KB |
| ColBERTv2 uncompressed 128-d fp16 | 256 | ~128 KB |
| ColBERTv2 PLAID 2-bit residual | ~36 | ~18 KB |
PLAID 2-bit brings ColBERT to ~4x single-vector index size — tolerable for many deployments.
Ragatouille: Easiest Deployment
Ragatouille wraps ColBERTv2 with a sane high-level API. It uses PLAID under the hood.
# pip install ragatouille
from ragatouille import RAGPretrainedModel
rag = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")
documents = [
"OAuth 2.0 uses refresh tokens to get a new access token without re-prompting the user.",
"PKCE protects the authorization code flow for public clients.",
"OpenID Connect adds an id_token on top of OAuth 2.0.",
]
rag.index(
collection=documents,
document_ids=[f"doc-{i}" for i in range(len(documents))],
document_metadatas=[{"source": "auth-docs"} for _ in documents],
index_name="auth-kb",
max_document_length=256,
split_documents=True,
)
results = rag.search(query="how do I refresh a token without asking the user again", k=5)
for r in results:
print(r["score"], r["content"][:80], r["document_id"])
split_documents=True respects max_document_length. For long docs, ColBERT quality stays high because every chunk retains its token vectors.
Index Rebuild / Add New Documents
rag = RAGPretrainedModel.from_index(".ragatouille/colbert/indexes/auth-kb")
rag.add_to_index(
new_collection=["Device Code Flow is for input-constrained devices."],
new_document_ids=["doc-3"],
new_document_metadatas=[{"source": "auth-docs"}],
)
PLAID indexes are compact but rebuilding is cheaper than you might fear — benchmark before optimizing incremental updates.
Using ColBERT as a Reranker Over Any Retriever
candidates = hybrid_retriever.invoke("token refresh 403")
passages = [d.page_content for d in candidates]
reranked = rag.rerank(query="token refresh 403", documents=passages, k=5)
top = [candidates[r["result_index"]] for r in reranked]
Use this when you already have a strong first-stage retriever and want a fast self-hosted reranker that competes with Cohere Rerank without a network hop.
Native ColBERT in Qdrant (multi-vector)
If you already run Qdrant, skip Ragatouille's index and store ColBERT vectors as a multi-vector field.
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333", prefer_grpc=True)
client.create_collection(
"colbert-docs",
vectors_config={
"colbert": models.VectorParams(
size=128,
distance=models.Distance.COSINE,
multivector_config=models.MultiVectorConfig(
comparator=models.MultiVectorComparator.MAX_SIM,
),
),
},
)
# doc_token_vectors: (num_tokens, 128) numpy array
client.upsert(
"colbert-docs",
points=[
models.PointStruct(
id=1,
vector={"colbert": doc_token_vectors.tolist()},
payload={"source": "auth-docs"},
),
],
)
client.query_points(
"colbert-docs",
query=query_token_vectors.tolist(), # (q_tokens, 128)
using="colbert",
limit=10,
)
Qdrant evaluates MaxSim server-side. See vector-stores/qdrant-advanced for tuning.
Two-Stage Dense -> ColBERT (Rescoring)
# Cheap dense ANN shortlists 200, ColBERT rescores to 10
client.query_points(
"hybrid-kb",
prefetch=models.Prefetch(query=dense_q.tolist(), using="dense", limit=200),
query=query_token_vectors.tolist(),
using="colbert",
limit=10,
)
Установить colbert-retrieval в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл colbert-retrieval?
ColBERT / ColBERTv2 late interaction as a first-stage retriever — not just a reranker. MaxSim scoring, PLAID index, Ragatouille for deployment, storage cost of token-level embeddings, when to pick ColBERT over dense-plus-rerank, and fine-tuning for domain. USE WHEN: user mentions "ColBERT", "ColBERTv2", "late interaction", "MaxSim", "PLAID", "Ragatouille", "token-level embeddings", "multi-vector retrieval" DO NOT USE FOR: single-vector dense retrieval - use `vector-stores/qdrant-advanced` or similar; cross-encoder reranking - use `rag/reranking`; SPLADE sparse - use `retrieval/splade-deep`; cross-encoder fine-tuning - use `retrieval/cross-encoder-training`
Как установить скилл colbert-retrieval?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл colbert-retrieval запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic