Principle:Confident ai Deepeval Golden Generation from Contexts
| Knowledge Sources | |
|---|---|
| Domains | |
| Last Updated | 2026-02-14 09:00 GMT |
Overview
Golden generation from contexts is the process of generating evaluation goldens from pre-prepared text contexts rather than raw document files. It is designed for scenarios where contexts have already been extracted, curated, or constructed through a custom pipeline.
Description
Unlike golden generation from documents, which handles the entire pipeline from file loading to golden output, generation from contexts starts with pre-chunked and pre-organized text. This approach is useful when:
- Contexts are manually curated -- subject matter experts have selected and organized the most relevant passages for evaluation.
- Custom chunking is required -- the application uses a proprietary or domain-specific chunking strategy that differs from the default pipeline.
- Contexts come from external sources -- the text passages originate from APIs, databases, or other systems rather than static files.
- Rapid iteration is needed -- skipping document loading and chunking accelerates the golden generation cycle during iterative dataset development.
Each context is provided as a list of strings (representing one or more text passages), and the system generates evaluation queries and expected answers conditioned on these context passages.
Usage
Golden generation from contexts is used when evaluation contexts are already available and the user wants to bypass the document loading and chunking stages. It provides a more direct path to golden generation for teams that manage their own context extraction workflows.
Theoretical Basis
This approach builds on the same theoretical foundations as document-based generation but eliminates the retrieval stage:
- Context-conditioned question generation -- the LLM generates questions that are directly answerable from the provided context passages, without needing to perform similarity search or context construction.
- Answer synthesis -- expected outputs are generated by conditioning the LLM on the provided context, producing answers that are grounded in the given text.
The abstract process follows this pattern:
GOLDEN_GENERATION_FROM_CONTEXTS(contexts, llm, config):
1. FOR each context group in contexts (List[List[str]]):
a. GENERATE up to max_goldens_per_context evaluation queries
b. IF include_expected_output: SYNTHESIZE expected answers from context
c. CREATE Golden(input, expected_output, context)
2. RETURN List[Golden]
Key properties:
- Flexibility -- accepts any pre-prepared context format, decoupling golden generation from document processing.
- Deterministic input -- since contexts are provided directly, the generation is reproducible given the same contexts and LLM configuration.
- Reduced pipeline complexity -- fewer stages mean fewer potential failure points and faster execution.