Model reference · open weights
Colbert is an open-weight embedding model from Crystalcareai. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | Crystalcareai |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Context | 512 tokens |
| Runs with | transformers |
| Released | 2024-01-06 |
| Popularity | 2k downloads / month |
| Licence | Open weights |
About
As Figure 1 illustrates, ColBERT relies on fine-grained contextual late interaction: it encodes each passage into a matrix of token-level embeddings (shown above in blue). Then at search time, it embeds every query into another matrix (shown in green) and efficiently finds passages that contextually match the query using scalable vector-similarity (MaxSim) operators.
These rich interactions allow ColBERT to surpass the quality of single-vector representation models, while scaling efficiently to large corpora. You can read more in our papers:
The ColBERTv1 code from the SIGIR'20 paper is in the colbertv1 branch. See here for more information on other branches.
ColBERT requires Python 3.7+ and Pytorch 1.9+ and uses the Hugging Face Transformers library.
We strongly recommend creating a conda environment using the commands below. (If you don't have conda, follow the official conda installation guide.)
We have also included a new environment file specifically for CPU-only environments (conda_env_cpu.yml), but note that if you are testing CPU execution on a machine that includes GPUs you might need to specify CUDA_VISIBLE_DEVICES="" as part of your command. Note that a GPU is required for training and indexing.
conda env create -f conda_env[_cpu].yml
conda activate colbert
If you face any problems, please open a new issue and we'll help you promptly!
Using ColBERT on a dataset typically involves the following steps.
Step 0: Preprocess your collection. At its simplest, ColBERT works with tab-separated (TSV) files: a file (e.g., collection.tsv) will contain all passages and another (e.g., queries.tsv) will contain a set of queries for searching the collection.
Step 1: Download the pre-trained ColBERTv2 checkpoint. This checkpoint has been trained on the MS MARCO Passage Ranking task. You can also optionally train your own ColBERT model.
Step 2: Index your collection. Once you have a trained ColBERT model, you need to index your collection to permit fast retrieval. This step encodes all passages into matrices, stores them on disk, and builds data structures for efficient search.
Step 3: Search the collection with your queries. Given the model and index, you can issue queries over the collection to retrieve the top-k passages for each query.
Below, we illustrate these steps via an example run on the MS MARCO Passage Ranking task.
This Jupyter notebook docs/intro.ipynb notebook illustrates using the key features of ColBERT with the new Python API.
It includes how to download the ColBERTv2 model checkpoint trained on MS MARCO Passage Ranking and how to download our new LoTTE benchmark.
This repository works directly with a simple tab-separated file format to store queries, passages, and top-k ranked lists.
qid \t query text.pid \t passage text.qid \t pid \t rank.This works directly with the data format of the MS MARCO Passage Ranking dataset. You will need the training triples (triples.train.small.tar.gz), the official top-1000 ranked lists for the dev set queries (top1000.dev), and the dev set relevant passages (qrels.dev.small.tsv). For indexing the full collection, you will also need the list of passages (collection.tar.gz).
For fast retrieval, indexing precomputes the ColBERT representations of passages.
Example usage:
from colbert.infra import Run, RunConfig, ColBERTConfig
from colbert import Indexer
if __name__=='__main__':
with Run().context(RunConfig(nranks=1, experiment="msmarco")):
config = ColBERTConfig(
nbits=2,
root="/path/to/experiments",
)
indexer = Indexer(checkpoint="/path/to/checkpoint", config=config)
indexer.index(name="msmarco.nbits=2", collection="/path/to/MSMARCO/collection.tsv")
We typically recommend that you use ColBERT for end-to-end retrieval, where it directly finds its top-k passages from the full collection:
from colbert.data import Queries
from colbert.infra import Run, RunConfig, ColBERTConfig
from colbert import Searcher
if __name__=='__main__':
with Run().context(RunConfig(nranks=1, experiment="msmarco")):
config = ColBERTConfig(
root="/path/to/experiments",
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys crystalcareai-colbert for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (crystalcareai-colbert below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"crystalcareai-colbert","input":"text to embed"}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.