# PyLate

> Python library for fine-tuning, inference, and retrieval with ColBERT late interaction models, built on Sentence Transformers.

PyLate is an open-source Python library from LightOn, built on top of Sentence Transformers, for training and using ColBERT-style late interaction models. It covers fine-tuning on single or multiple GPUs, encoding queries and documents, indexing, retrieval, and reranking. The latest release listed is v1.6.0, and the library is MIT licensed.

## What It Is

PyLate is a library for building and running late interaction retrieval models. It lets users construct ColBERT models from most pre-trained language models; when the base model is not already a ColBERT model, a linear layer is added to the encoder. Models are loaded and saved through the `models.ColBERT` class, and training uses the Sentence Transformers trainer.

## Training Workflows

The docs show two training approaches. Contrastive training uses triplet datasets (query, positive, negative, with support for multiple negatives per query) and offers a configurable temperature, a cached contrastive loss based on GradCache to emulate larger batch sizes, and gathering across devices in multi-GPU setups. Knowledge distillation trains from the scores of a stronger teacher model using query, document, and score datasets. Hugging Face Datasets are supported, and a NanoBEIR evaluator is available for quick validation of English retrieval models.

## Retrieval and Reranking

For retrieval, users encode documents and queries, add document embeddings to an index, and retrieve top-k results with scores. The default index uses FastPLAID. A WARP backend is available for XTR-trained models, and a TACHIOM backend provides CPU multi-vector retrieval. Without building an index, `rank.rerank` can rerank first-stage results using query and document embeddings.

## Features
- Fine-tuning ColBERT models on single or multiple GPUs
- Contrastive training with temperature, GradCache-based cached loss, and cross-device gathering
- Knowledge distillation training from teacher scores
- Hugging Face Datasets support with multiple negatives per query
- NanoBEIR evaluator
- FastPLAID index for retrieval
- Optional WARP and TACHIOM index backends
- Reranking without building an index
- Construct ColBERT models from most pre-trained language models

## Integrations
Sentence Transformers, Hugging Face Datasets, FastPLAID, WARP, TACHIOM, NanoBEIR, Weights & Biases

## Platforms
API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
v1.6.0

## Links
- Website: https://lightonai.github.io/pylate/
- Documentation: https://lightonai.github.io/pylate/documentation/training/
- Repository: https://github.com/lightonai/pylate
- EveryDev.ai: https://www.everydev.ai/tools/pylate
