Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:AnswerDotAI RAGatouille RAGPretrainedModel From Pretrained

From Leeroopedia
Knowledge Sources
Domains NLP, Information_Retrieval, Model_Loading
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete tool for loading a pretrained ColBERT model from a checkpoint or HuggingFace Hub provided by the RAGatouille library.

Description

The RAGPretrainedModel.from_pretrained() class method is the primary entry point for initializing a ColBERT model. It creates a new RAGPretrainedModel instance and configures the underlying ColBERT object with the specified model checkpoint, GPU settings, and index root directory. The method delegates to ColBERT.__init__() which loads the configuration from the checkpoint, initializes the inference checkpoint (for encoding), and sets up the run context.

Usage

Import this class when you need to initialize a ColBERT model for any retrieval task: indexing documents, searching an index, encoding documents in memory, or reranking candidates. This is the standard entry point for all RAGatouille workflows that start from a pretrained model.

Code Reference

Source Location

  • Repository: RAGatouille
  • File: ragatouille/RAGPretrainedModel.py
  • Lines: L51-74

Signature

@classmethod
def from_pretrained(
    cls,
    pretrained_model_name_or_path: Union[str, Path],
    n_gpu: int = -1,
    verbose: int = 1,
    index_root: Optional[str] = None,
) -> "RAGPretrainedModel":
    """Load a ColBERT model from a pre-trained checkpoint.

    Parameters:
        pretrained_model_name_or_path (str): Local path or huggingface model name.
        n_gpu (int): Number of GPUs to use. -1 means use all available GPUs or none.
        verbose (int): The level of ColBERT verbosity. 1 filters most internal logs.
        index_root (Optional[str]): Root directory for indexes. Default '.ragatouille/'.

    Returns:
        RAGPretrainedModel: Initialized instance with model ready for inference.
    """

Import

from ragatouille import RAGPretrainedModel

I/O Contract

Inputs

Name Type Required Description
pretrained_model_name_or_path Union[str, Path] Yes Local path to a ColBERT checkpoint or a HuggingFace model identifier (e.g. "colbert-ir/colbertv2.0")
n_gpu int No Number of GPUs to use. -1 (default) auto-detects available GPUs
verbose int No Verbosity level. 1 (default) filters most internal ColBERT logs
index_root Optional[str] No Root directory where indexes will be stored. Defaults to ".ragatouille/"

Outputs

Name Type Description
return RAGPretrainedModel Initialized instance with self.model set to a ColBERT object containing inference_ckpt, config, and run_context

Usage Examples

Basic Model Loading

from ragatouille import RAGPretrainedModel

# Load ColBERTv2 from HuggingFace Hub
RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")

Loading with Custom Settings

from ragatouille import RAGPretrainedModel

# Load with specific GPU count and custom index root
RAG = RAGPretrainedModel.from_pretrained(
    "colbert-ir/colbertv2.0",
    n_gpu=1,
    verbose=0,
    index_root="./my_indexes/",
)

Loading a Local Checkpoint

from ragatouille import RAGPretrainedModel

# Load from a locally saved model checkpoint
RAG = RAGPretrainedModel.from_pretrained("/path/to/my/colbert/checkpoint")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment