Template
Renders output samples from a Jinja template combined with a grid of placeholder values. Each combination of fields values produces one output sample, with the source sample available in the Jinja context as source. Use it for deterministic, combinatorial generation without a model. For model-driven generation, use the LLM synthesizer.
Output
One output sample per combination of the values listed in fields.
Examples
Example: City distance prompts. Renders a prompt for every combination of the city placeholder values.
Template Synthesizer
# ...
definition:
# ...
synthesizers:
- type: "template"
template: |
I'm in {{ source.city }}, the capital of {{ source.country }}.
I want to travel {{ source.distance }} in the {direction} direction.
What is the name of the city I will arrive at?
fields:
direction:
- "north"
- "south"
- "east"
- "west"Configuration
Properties
type Literal “template” required
The type of the synthesizer.
template string, TemplateValue, array[string, TemplateValue] required
The template string used for synthesis.
The following jinja context is available:
- source: The sample for which the template is being rendered. Individual fields can be accessed using the jinja
{ source.field_name }syntax. - individual fields: The individual fields of the source sample. These can be accessed using the python string formatting
{field_name}syntax.
fields object required
A dictionary where keys are placeholder names in the template string, and values are lists of possible values for those placeholders.