π‘ ConceptsΒΆ
This page defines the core vocabulary used throughout the MMIRAGE documentation. Read it before diving into the pipeline or configuration details.
Dataset and samplesΒΆ
A dataset is any collection of data samples that MMIRAGE reads as input. MMIRAGE supports two dataset formats:
JSONL β a plain text file where each line is a JSON object representing one sample.
Loadable β a HuggingFace-compatible dataset directory saved with
save_to_disk.
Each sample is one record in the dataset, typically a JSON object with fields like
question, answer, conversations, image_path, or whatever your data contains.
State directoryΒΆ
The state directory is a folder that tracks the status of each shard.
After a shard finishes, MMIRAGE writes a status.json file there recording
whether the shard succeeded or failed, and how many attempts it took.
The state directory enables:
Resume β skip already-succeeded shards when re-running.
Retry β automatically resubmit failed shards.
Set the state directory with loading_params.state_dir.
Input variablesΒΆ
An input variable is a named value extracted from each data sample.
Variables are defined in processing_params.inputs and extracted using
JMESPath expressions.
For example:
inputs:
- name: question
key: conversations[0].content
- name: answer
key: conversations[1].content
- name: image
key: image_path
type: image
The key field is a JMESPath expression applied to each sample.
Image variables (type: image) are automatically resolved to PIL Images
or absolute file paths, using image_base_path if set.
Output variablesΒΆ
An output variable is the result of running the processor on a prompt.
Output variables are defined in processing_params.outputs.
Each output variable specifies:
a name β how it is referenced in the output schema
a type β the processor that produces it (
llm,batch_api,image_genfor LLM-driven image generation, orcustomfor your own Python function)an output_type β
plainfor raw text,JSONfor parsed JSONa prompt β a Jinja2 template that constructs the message sent to the model
outputs:
- name: formatted_answer
type: llm
output_type: plain
prompt: |
Reformat this answer in Markdown:
{{ answer }}
Inside the prompt, you can reference any input variable by name using {{ variable }}.
With output_type: JSON, an output variable also declares an output_schema
listing the fields the model must produce, optionally with per-field types and
numeric bounds that constrain generation. See
Configuration for the full field reference.
JMESPathΒΆ
JMESPath is a query language for extracting values from JSON.
MMIRAGE uses it in inputs[*].key to pull fields out of each sample.
Common patterns:
Expression |
Meaning |
|---|---|
|
Top-level field named |
|
Nested field access |
|
First element of a list, then a subfield |
|
Last element of a list |
MMIRAGE compiles and caches JMESPath expressions at startup to avoid recompilation on every sample.
Jinja2 templatesΒΆ
Jinja2 is a templating language used in two places in MMIRAGE:
Prompts (
outputs[*].prompt) β to construct the message sent to the model.Output schema (
processing_params.output_schema) β to render the final saved sample.
In both cases, extracted input variables and generated output variables are
available as template variables using {{ variable_name }}.
Simple {{ var }} references in the output schema bypass Jinja2 rendering
to preserve non-string types (e.g. PIL Images, lists, dicts).
Output schemaΒΆ
The output schema defines the structure of each saved sample.
It is a YAML object under processing_params.output_schema that uses
Jinja2 {{ variable }} references.
For example:
output_schema:
conversations:
- role: user
content: "{{ question }}"
- role: assistant
content: "{{ formatted_answer }}"
image_path: "{{ image }}"
The output schema controls exactly what fields end up in the processed dataset.
Fields not listed in the schema are dropped unless remove_columns: false is set,
in which case all original fields are kept alongside the new outputs.
ProcessorΒΆ
A processor is the component that computes an output variable.
Each entry in processing_params.outputs names a processor via its type.
llmβ starts an SGLang engine on the current machine (or SLURM node).image_genβ starts a Diffusers pipeline for text-to-image generation on the current machine (or SLURM node).batch_apiβ sends requests asynchronously to a provider batch API (see Batch API).CUSTOMβ runs your own Python function over each row in an isolated process pool β for CPU-bound work such as parsing, cleaning, or scoring rather than inference. See Custom Module.
Execution modesΒΆ
localβ runs a single shard in the current Python environment (defaults to shard 0). Usemmirage run --shard-id Nto select a shard; use--force-retry(orexecution_params.retry: true) to iterate over all shards locally.slurmβ MMIRAGE generates and submits ansbatcharray job. Each array task processes one shard on a dedicated node.
See SLURM & Cluster Deployment for details on the SLURM workflow.
Retry and mergeΒΆ
After processing, MMIRAGE can automatically:
Retry failed shards up to
max_retriestimes (setretry: true).Merge all shard outputs into a single dataset directory at
<output_dir>/merged/(setmerge: true).
Both options are controlled under execution_params.
See alsoΒΆ
Pipeline β step-by-step walkthrough of the data flow
Configuration Reference β complete parameter reference
Quickstart β run a first pipeline with these concepts in practice