Context-grounded fine-tuning

Train models to access and retrieve information from external knowledge bases during inference.

Supported on
UI
API
SDK

Context-grounded fine-tuning trains models to effectively use external knowledge bases during inference. Rather than embedding knowledge into model parameters, this approach teaches models to retrieve, evaluate, and synthesize information from provided context.

How it works

The training process teaches models three key capabilities:

  1. Relevance assessment: Distinguishing between relevant and irrelevant retrieved documents
  2. Information extraction: Identifying and extracting pertinent information from relevant context
  3. Grounded synthesis: Generating responses that accurately reflect the provided context while avoiding hallucination

Models learn these skills through training examples that pair queries with retrieved context and correct responses. The training emphasizes staying faithful to provided information rather than relying on parametric knowledge.

When to use context-grounded fine-tuning

Context-grounded fine-tuning provides value when:

  • Working with dynamic information that requires real-time updates without model retraining
  • Maintaining current data accuracy across large, frequently changing knowledge bases
  • Building systems where information sources need regular updates or replacements
  • Requiring explicit source attribution for generated responses
  • Combining retrieval-augmented generation (RAG) with specialized retrieval behaviors

Training requirements

Effective context-grounded fine-tuning requires:

  • Retrieval integration: Access to the retrieval system and knowledge base used during training and inference
  • Representative context: Training examples with realistic retrieved context, including both relevant and irrelevant documents
  • Grounding emphasis: Examples that demonstrate proper use of provided context and appropriate responses when context is insufficient
  • Consistency: Alignment between training retrieval patterns and production retrieval behavior

Comparison with other methods

Unlike instruction fine-tuning, context-grounded fine-tuning doesn't embed domain knowledge into parameters. This makes it ideal for dynamic information but requires retrieval infrastructure at inference time.

Context-grounded fine-tuning can be combined with LoRA for parameter-efficient training of retrieval behaviors. The adapter learns retrieval-specific patterns while the base model provides general language capabilities.

This approach works well with RAG systems by teaching models to better utilize retrieved context. The fine-tuning optimizes how models process and synthesize retrieved information.

Model deployment

Context-grounded models are deployed with retrieval systems that provide relevant context at inference time. The model endpoint receives both the query and retrieved context, generating responses grounded in the provided information.