# Generate legal fine-tuning data

Use [Dataset Generation](dataset-generation.md) to generate training or evaluation data from legal material and sample rules.

1. Select the source material.
2. Set the dataset goal and sample format, such as question-answer pairs.
3. Define question scope, answer requirements, and source constraints in the generation rules.
4. Define output fields, such as question and answer, and select a save location.
5. Run the workflow. Check provisions, applicable conditions, and quotations against the originals before using reviewed samples for training or evaluation.

## Prepare sources and scope

Choose legal material with identifiable sources and versions, recording scope and publication date. Define question coverage to avoid mixing provisions from different versions into one answer.

This page describes data preparation. Review generated content against the originals before treating it as a training label or legal guidance.

## Configure samples

| Setting | Example requirement |
| --- | --- |
| Dataset goal | Fine-tuning or evaluation according to actual use |
| Sample format | Question-answer or instruction samples matching the schema |
| Rules | Restrict sources, retain applicable conditions, and do not invent provisions |
| Output schema | Question, answer, and source fields, or required instruction/input/output fields |
| Sample count | Start small; actual counts come from the result |

Keep combined generation initially. Per-document mode also requires saving changes for multiple results.

## Review generated results

1. Check that the specified source answers the question.
2. Verify provisions, conditions, exceptions, and citations.
3. Remove samples whose sources do not support the answer.
4. Remove duplicates or contradictions and count usable samples.
5. Convert and validate fields for the training or evaluation system.

When separating training and evaluation sets, check for similar samples derived from the same source across both. Retain output files and rules for later review.

[Back to workflow templates](index.md)
