VOOZH about

URL: https://huggingface.co/lightonai/GTE-ModernColBERT-v1

⇱ lightonai/GTE-ModernColBERT-v1 · Hugging Face


👁 Image

GTE-ModernColBERT-v1

PyLate model based on Alibaba-NLP/gte-modernbert-base

This is a PyLate model trained on the ms-marco-en-bge-gemma dataset. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.

Model Details

Model Description

  • Model Type: PyLate model
  • Base model: Alibaba-NLP/gte-modernbert-base
  • Document Length: 300 tokens
  • Query Length: 32 tokens
  • Output Dimensionality: 128 dimensions
  • Similarity Function: MaxSim
  • Training Dataset:
  • Language: English
  • License: Apache 2.0

Document length

GTE-ModernColBERT has been trained with knowledge distillation on MS MARCO with a document length of 300 tokens, explaining its default value for documents length.

However, as illustrated in the ModernBERT paper, ColBERT models can generalize to documents lengths way beyond their training length and GTE-ModernColBERT actually yields results way above SOTA in long-context embedding benchmarks, see LongEmbed results.

Simply change adapt the document length parameter to your needs when loading the model:

model = models.ColBERT(
 model_name_or_path=lightonai/GTE-ModernColBERT-v1,
 document_length=8192,
)

ModernBERT itself has only been trained on 8K context length, but it seems that GTE-ModernColBERT can generalize to even bigger context sizes, though it is not guaranteed so please perform your own benches!

Model Sources

Full Model Architecture

ColBERT(
 (0): Transformer({'max_seq_length': 299, 'do_lower_case': False}) with Transformer model: ModernBertModel 
 (1): Dense({'in_features': 768, 'out_features': 128, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
)

Usage

First install the PyLate library:

pip install -U pylate

Retrieval

PyLate provides a streamlined interface to index and retrieve documents using ColBERT models. The index leverages the Voyager HNSW index to efficiently handle document embeddings and enable fast retrieval.

Indexing documents

First, load the ColBERT model and initialize the Voyager index, then encode and index your documents:

from pylate import indexes, models, retrieve

# Step 1: Load the ColBERT model
model = models.ColBERT(
 model_name_or_path=pylate_model_id,
)

# Step 2: Initialize the Voyager index
index = indexes.Voyager(
 index_folder="pylate-index",
 index_name="index",
 override=True, # This overwrites the existing index if any
)

# Step 3: Encode the documents
documents_ids = ["1", "2", "3"]
documents = ["document 1 text", "document 2 text", "document 3 text"]

documents_embeddings = model.encode(
 documents,
 batch_size=32,
 is_query=False, # Ensure that it is set to False to indicate that these are documents, not queries
 show_progress_bar=True,
)

# Step 4: Add document embeddings to the index by providing embeddings and corresponding ids
index.add_documents(
 documents_ids=documents_ids,
 documents_embeddings=documents_embeddings,
)

Note that you do not have to recreate the index and encode the documents every time. Once you have created an index and added the documents, you can re-use the index later by loading it:

# To load an index, simply instantiate it with the correct folder/name and without overriding it
index = indexes.Voyager(
 index_folder="pylate-index",
 index_name="index",
)

Retrieving top-k documents for queries

Once the documents are indexed, you can retrieve the top-k most relevant documents for a given set of queries. To do so, initialize the ColBERT retriever with the index you want to search in, encode the queries and then retrieve the top-k documents to get the top matches ids and relevance scores:

# Step 1: Initialize the ColBERT retriever
retriever = retrieve.ColBERT(index=index)

# Step 2: Encode the queries
queries_embeddings = model.encode(
 ["query for document 3", "query for document 1"],
 batch_size=32,
 is_query=True, # # Ensure that it is set to False to indicate that these are queries
 show_progress_bar=True,
)

# Step 3: Retrieve top-k documents
scores = retriever.retrieve(
 queries_embeddings=queries_embeddings, 
 k=10, # Retrieve the top 10 matches for each query
)

Reranking

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:

from pylate import rank, models

queries = [
 "query A",
 "query B",
]

documents = [
 ["document A", "document B"],
 ["document 1", "document C", "document B"],
]

documents_ids = [
 [1, 2],
 [1, 3, 2],
]

model = models.ColBERT(
 model_name_or_path=pylate_model_id,
)

queries_embeddings = model.encode(
 queries,
 is_query=True,
)

documents_embeddings = model.encode(
 documents,
 is_query=False,
)

reranked_documents = rank.rerank(
 documents_ids=documents_ids,
 queries_embeddings=queries_embeddings,
 documents_embeddings=documents_embeddings,
)

Evaluation

Metrics

BEIR Benchmark

GTE-ModernColBERT is the first model to outpeform ColBERT-small on the BEIR benchmark. As reproduction in the IR domain is challenging, we worked closely with Benjamin Clavié, the author of ColBERT-small to reproduce the evaluation setup of this model. Despite all these efforts and reducing to the maximum the difference in scores in most of the datasets, some are still a bit different. For this reason, we also report the results of ColBERT-small in the same setup we used to evaluate GTE-ModernColBERT for completness and fair comparison.

Model Average FiQA2018 NFCorpus TREC-COVID Touche2020 ArguAna QuoraRetrieval SCIDOCS SciFact NQ ClimateFEVER HotpotQA DBPedia CQADupstack FEVER MSMARCO
GTE-ModernColBERT 54.67 45.28 37.93 83.59 31.23 48.51 86.61 19.06 76.34 61.8 30.62 77.32 48.03 41 87.44 45.32
ColBERT-small (reported) 53.79 41.15 37.3 84.59 25.69 50.09 87.72 18.42 74.77 59.1 33.07 76.11 45.58 38.75 90.96 43.5
JinaColBERT-v2 40.8 34.6 83.4 27.4 36.6 88.7 18.6 67.8 64 23.9 76.6 47.1 80.5
ColBERT-small (rerunned) 53.35 41.01 36.86 83.14 24.95 46.76 87.89 18.72 74.02 59.42 32.83 76.88 46.36 39.36 88.66 43.44

LongEmbed Benchmark

GTE-ModernColBERT has been trained with knowledge distillation on MS MARCO with a document length of 300 tokens, explaining its default value for documents length. However, as illustrated in the ModernBERT paper, ColBERT models can generalize to documents lengths way beyond their training length and GTE-ModernColBERT actually yields results way above SOTA (almost 10 points above previous SOTA) in long-context embedding benchmark:

Model Mean LEMBNarrativeQARetrieval LEMBNeedleRetrieval LEMBPasskeyRetrieval LEMBQMSumRetrieval LEMBSummScreenFDRetrieval LEMBWikimQARetrieval
GTE-ModernColBERT (with 32k document length) 88.39 78.82 92.5 92 72.17 94.98 99.87
voyage-multilingual-2 79.17 64.694 75.25 97 51.495 99.105 87.489
inf-retriever-v1 73.19 60.702 61.5 78.75 55.072 97.387 85.751
snowflake-arctic-embed-l-v2,0 63.73 43.632 50.25 77.25 40.04 96.383 74.843
gte-multilingual-base 62.12 52.358 42.25 55.5 43.033 95.499 84.078
jasper_en_vision_language_v1 60.93 37.928 55 62.25 41.186 97.206 72.025
bge-m3 58.73 45.761 40.25 59 35.543 94.089 77.726
jina-embeddings-v3 55.66 34.297 64 38 39.337 92.334 66.018
e5-base-4k 54.51 30.03 37.75 65.25 31.268 93.868 68.875
gte-Qwen2-7B-instruct 47.24 45.46 31 38.5 31.272 76.08 61.151

ModernBERT itself has only been trained on 8K context length, but it seems that GTE-ModernColBERT can generalize to even bigger context sizes, though it is not guaranteed so please perform your own benches!

PyLate Information Retrieval

  • Datasets: NanoClimateFEVER, NanoDBPedia, NanoFEVER, NanoFiQA2018, NanoHotpotQA, NanoMSMARCO, NanoNFCorpus, NanoNQ, NanoQuoraRetrieval, NanoSCIDOCS, NanoArguAna, NanoSciFact and NanoTouche2020
  • Evaluated with pylate.evaluation.pylate_information_retrieval_evaluator.PyLateInformationRetrievalEvaluator
Metric NanoClimateFEVER NanoDBPedia NanoFEVER NanoFiQA2018 NanoHotpotQA NanoMSMARCO NanoNFCorpus NanoNQ NanoQuoraRetrieval NanoSCIDOCS NanoArguAna NanoSciFact NanoTouche2020
MaxSim_accuracy@1 0.36 0.88 0.92 0.56 0.92 0.54 0.56 0.64 0.96 0.48 0.3 0.74 0.7755
MaxSim_accuracy@3 0.62 0.94 0.98 0.66 1.0 0.68 0.68 0.82 1.0 0.74 0.62 0.86 0.9388
MaxSim_accuracy@5 0.78 0.96 0.98 0.74 1.0 0.74 0.74 0.86 1.0 0.78 0.7 0.9 0.9796
MaxSim_accuracy@10 0.86 0.98 1.0 0.8 1.0 0.92 0.76 0.9 1.0 0.84 0.82 0.94 0.9796
MaxSim_precision@1 0.36 0.88 0.92 0.56 0.92 0.54 0.56 0.64 0.96 0.48 0.3 0.74 0.7755
MaxSim_precision@3 0.2333 0.7133 0.36 0.3267 0.58 0.2267 0.4333 0.2867 0.4 0.4 0.2067 0.3 0.6599
MaxSim_precision@5 0.208 0.656 0.216 0.256 0.36 0.148 0.392 0.18 0.256 0.292 0.14 0.196 0.6571
MaxSim_precision@10 0.128 0.572 0.11 0.152 0.186 0.092 0.304 0.1 0.134 0.194 0.082 0.104 0.5184
MaxSim_recall@1 0.1833 0.118 0.8567 0.3092 0.46 0.54 0.0664 0.61 0.8473 0.1007 0.3 0.715 0.0518
MaxSim_recall@3 0.289 0.2307 0.96 0.4784 0.87 0.68 0.102 0.78 0.9453 0.2467 0.62 0.83 0.1362
MaxSim_recall@5 0.4157 0.2962 0.96 0.5752 0.9 0.74 0.1284 0.82 0.9693 0.2997 0.7 0.885 0.2193
MaxSim_recall@10 0.4957 0.4146 0.98 0.6412 0.93 0.92 0.1566 0.88 0.9893 0.3967 0.82 0.93 0.334
MaxSim_ndcg@10 0.4148 0.7296 0.9452 0.567 0.9012 0.7089 0.3957 0.7645 0.9691 0.3987 0.5609 0.8372 0.5927
MaxSim_mrr@10 0.5266 0.9169 0.9522 0.6359 0.96 0.6447 0.627 0.739 0.9767 0.6137 0.4775 0.8117 0.8629
MaxSim_map@100 0.3347 0.5884 0.9271 0.5032 0.8592 0.6496 0.1918 0.7239 0.9552 0.3163 0.4824 0.8049 0.4257

Nano BEIR

  • Dataset: NanoBEIR_mean
  • Evaluated with pylate.evaluation.nano_beir_evaluator.NanoBEIREvaluator
Metric Value
MaxSim_accuracy@1 0.6643
MaxSim_accuracy@3 0.8107
MaxSim_accuracy@5 0.8584
MaxSim_accuracy@10 0.9077
MaxSim_precision@1 0.6643
MaxSim_precision@3 0.3943
MaxSim_precision@5 0.3044
MaxSim_precision@10 0.2059
MaxSim_recall@1 0.3968
MaxSim_recall@3 0.5514
MaxSim_recall@5 0.6084
MaxSim_recall@10 0.6837
MaxSim_ndcg@10 0.6758
MaxSim_mrr@10 0.7496
MaxSim_map@100 0.5971

Training Details

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • learning_rate: 3e-05
  • bf16: True

All Hyperparameters

Training Logs

Framework Versions

  • Python: 3.11.10
  • Sentence Transformers: 3.5.0.dev0
  • Transformers: 4.48.2
  • PyTorch: 2.5.1+cu124
  • Accelerate: 1.1.1
  • Datasets: 2.21.0
  • Tokenizers: 0.21.0

Citation

BibTeX

Sentence Transformers

@inproceedings{reimers-2019-sentence-bert,
 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
 author = "Reimers, Nils and Gurevych, Iryna",
 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
 month = "11",
 year = "2019",
 publisher = "Association for Computational Linguistics",
 url = "https://arxiv.org/abs/1908.10084"
}

PyLate

@misc{PyLate,
title={PyLate: Flexible Training and Retrieval for Late Interaction Models},
author={Chaffin, Antoine and Sourty, Raphaël},
url={https://github.com/lightonai/pylate},
year={2024}
}

GTE-ModernColBERT

@misc{GTE-ModernColBERT,
title={GTE-ModernColBERT},
author={Chaffin, Antoine},
url={https://huggingface.co/lightonai/GTE-ModernColBERT-v1},
year={2025}
}
Downloads last month
77,453
Safetensors
Model size
0.1B params
Tensor type
F32
·

Model tree for lightonai/GTE-ModernColBERT-v1

Quantized
(11)
this model
Finetunes
13 models

Spaces using lightonai/GTE-ModernColBERT-v1 11

Collections including lightonai/GTE-ModernColBERT-v1

Paper for lightonai/GTE-ModernColBERT-v1

Articles mentioning lightonai/GTE-ModernColBERT-v1

Evaluation results