How to build an LLM evaluation dataset from your own data
How to build an evaluation dataset for LLM tests: a held-out gold set, split by document, so no leakage inflates your scores and you can trust the result.
Updated
To build an evaluation dataset for an LLM, collect real inputs from the task, have someone who knows the work write the correct output for each one, and keep that set out of training. Split the set by document, not by chunk, so no document appears on both sides of the line.
What a golden dataset is for
A golden dataset, also called a gold set or held-out test set, is a fixed list of inputs with trusted answers. You run every model you are considering against the same inputs and score them the same way. Without one, you are choosing a model on impressions, and the model that reads well in a demo often loses on your documents. Our contract exam on 102 held-out documents is one public example of this setup.
The set has one job: to tell you how a model will do on work it has not seen. That only holds if the set stays fixed. If you change rows after seeing the scores, the comparison stops meaning anything. Keep a dated version and write down every change.
How many examples do you need?
There is no universal count. Start with a few dozen inputs that cover the common cases and the hard ones. Score the current model, then add rows until the score stops moving when you add more.
The smaller the gap you want to detect, the more rows you need. Take a hypothetical set of 40 rows, where the new model gets 34 right and the current model gets 31. A three-row gap on a set that size is within the noise, so you would add rows before deciding. A large gap on the same set would be far easier to trust.
How to create ground truth
Ground truth is the correct output for each input. A person who does the job writes it, following a written rule for every field. Vague instructions produce labels that disagree with each other, and then the score measures the labelers instead of the model.
Work through it in this order:
- Write the output schema first: the fields, their format, and what counts as empty.
- Write rules for the ambiguous cases, such as a date defined relative to another date, or an address split across two pages.
- Label every row, and have a second person label a sample. Measure how often they agree.
- Where they disagree, settle the rule, apply it to every row, and re-check the rows labeled before the rule existed.
- Record where each label came from. A label copied from another system’s output is not ground truth.
For extraction, decide whether the answer must be an exact quote from the source. Exact quotes are easy to check against the source text. Loose matching can hide errors that a reviewer would catch right away.
Split by document, not by chunk
This is the step that is easiest to get wrong. A long document gets cut into chunks, and the chunks are split at random into train and test. Now a clause from a contract sits in training, and a neighboring clause from the same contract sits in the test. The model has already seen that document’s wording, names and layout. The score looks high, and it does not measure new work.
Split by document ID instead. Assign each document to train, validation or test once, using a fixed seed, and keep that assignment. Every chunk from a document goes to the same side. Commit the split file so the next person can see which documents were held out. Do not regenerate it later, because every earlier result would stop being comparable.
Where leakage hides
Leakage also comes from places that are less obvious:
- Near-duplicate documents, such as one template filled in for many clients.
- Prompt examples copied from the test set into the instructions.
- Preprocessing fit on the whole dataset, such as a vocabulary or normalization step run before the split.
- Re-running experiments until one split looks good, then reporting only that split.
When a score jumps and you cannot explain why, check for leakage first.
A quick check catches the worst cases. Take the first sentence of each test document and search the training file for it. Any exact hit means that document leaked, and its score should not count until you move it to one side of the split.
What a test set does not settle
A test set does not make a model fit for a regulated decision. The model assists the people who review its output, and those people stay responsible for the result. Keep a human review step wherever a wrong answer is costly, and keep your own controls over where the data goes.
A fine-tuned model is also the wrong choice in some cases. If your inputs change every week, or you have too few labeled documents to split by document, a hosted model with a clean evaluation may be the better answer for now. A narrow task with stable inputs and good labels is where training pays off. For a wider view of how to read model comparisons, see cross-validation for LLMs and whether a new model is really better.
Own Weights runs this process for one high-volume task. We audit the AI spend, build the test from your data, score the current model first, and only deploy a trained model that beats it on that test. The free AI cost audit is a good first step to find which task to test, or you can book a call and we will go through your split and labels together.
Questions
How many examples do I need to evaluate an LLM?
There is no fixed count. Keep adding rows until the score stops moving, and add more when the gap between two models is small. A few dozen rows can show a large difference, but not a narrow one.
What is a golden dataset for LLM evaluation?
It is a fixed set of real inputs, each paired with a correct output that someone who knows the work has checked. Every model under test runs against the same rows and gets scored the same way. It stays out of training so it measures work the model has not seen.
How do I create ground truth for AI evaluation?
Write the output format and the rules for ambiguous cases before anyone labels. Have two people label a sample and measure how often they agree, then fix the rules wherever they split. Record where each label came from.
What is data leakage in LLM evaluation?
Leakage is when test information reaches the model during training or tuning, so the score comes out too high. Common routes are chunks of one document landing on both sides of the split, near-duplicate files, and test examples pasted into prompts.
How do I split data for fine-tuning?
Split by document ID with a fixed random seed, assign each document to one side only, and keep the assignment in version control. Every chunk from a document then lands in train, validation or test, never in more than one.