LLM
Generates output samples from each source sample using a chat-completion model. The system and user prompts are Jinja templates with the source sample available as source, and the output shape is described by sample_properties. Use it for open-ended, model-driven generation. For purpose-built QA generation, use the Question Answering synthesizer.
Output
One or more output samples per source sample, matching sample_properties.
Prompt vs. File Inputs
Provide exactly one of user_prompt_template or file_ids_field, not both. When file_ids_field is used the user message carries file content instead of text, so system_prompt is required as the only text channel to instruct the model.
Examples
Example: City/language QA. Uses an LLM to synthesize QA samples for the city/language specified in the input sample.
LLM Synthesizer
# ...
config_spec:
# ...
- key: "synthesizer_model_key"
type: "model"
display_name: "Synthesizer Model"
description: "Model used to generate QA samples."
definition:
# ...
synthesizers:
- type: "llm"
model_key: "<< config.synthesizer_model_key >>"
use_structured_outputs: true
system_prompt: "You are a helpful dataset generator."
user_prompt_template: >
Generate a question-answer pair about {{ source.city }},
the capital of {{ source.country }}, written in
{{ source.language }}.
sample_properties:
question:
type: string
answer:
type: stringFor the source sample {"country": "Germany", "city": "Berlin", "language": "English"}, the model fills in the two sample_properties fields, which are added to the columns of the source sample:
{
"country": "Germany",
"city": "Berlin",
"language": "English",
"question": "Which river flows through Berlin?",
"answer": "The Spree."
}The question and answer values are produced by the model, so they differ on every generation. Only their names and types are fixed by sample_properties.
Configuration
Properties
type Literal “llm” required
The type of the synthesizer.
model_key TemplateValue required
The key of the chat completion model to be used as a synthesizer.
system_prompt string, TemplateValue
The Jinja template used to create the system prompt. The source sample is available in the Jinja context as source. If not provided, no system message is sent and format instructions are appended to the user prompt. The system prompt must be provided if file_ids_field is used, as it is the only text channel available to instruct the model.
Default: None
user_prompt_template string, TemplateValue
The Jinja template used to create the user prompt. The source sample is available in the Jinja context as source. Not used when file_ids_field is provided.
Default: None
file_ids_field string, TemplateValue
The name of the field in the source sample that contains file IDs. If provided, the user message will use file content type instead of text. The field value should be a list of strings. The model must be chat-completion-compatible to support file content messages.
Default: None
sample_properties object required
The ‘properties’ field of the JSON schema for the output samples.
format_instructions string, TemplateValue
Instructions that control the expected output format. When use_structured_outputs is False (default), they are appended to the system prompt if one is provided, or to the user prompt otherwise. When use_structured_outputs is True, they are placed in response_format.json_schema.description instead. If not provided, they will be derived from the sample_properties. When parsing non-structured output, the model output is expected to be valid JSON contained in
Default: None
use_structured_outputs boolean
Whether to use structured outputs. Defaults to False. It is recommended to enable structured outputs if the model supports it.
Default: False