esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

How Do You Prepare a Fine-Tuning Dataset?

How to collect, clean and split the examples you train a model on, with a bank example and a runnable script, for your AI interview.

In short

Collect real examples that look like the requests the live app gets, clean them, and remove duplicates and personal data. Then split by group, such as ticket thread, and keep a sealed test set so the score stays honest.

11 min readIntermediateVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A fine-tuning dataset is example prompts with the answers you want back. I would collect real past replies from the team that owns the process, then clean them: drop empty and repeated rows, and remove personal data such as card numbers. I would split by ticket thread, so replies from one case never sit in both training and test, and keep the test set sealed. I would start with about 50 careful examples and add rows only where the model fails.

What is a fine-tuning dataset, in plain words?

Fine-tuning means training an existing model a little more on your own examples, so it picks up your format or task. The fine-tuning dataset is that pile of examples. Each one is a prompt and the answer you want back.

Think of a new claims handler at an insurer. They learn the job from a folder of past claims and how each was handled. A messy folder teaches bad habits, and a model learns the same way from its dataset.

Key words

Fine-tuning
Extra training on your own examples, after the base model is built.
Training set
The examples the model actually learns from.
Validation set
Examples used to check progress while training runs.
Test set
Examples kept back and scored at the end, for an honest check.

A real case: a mid-size bank wants its dispute-reply assistant to write in the bank's tone and format. It has 18 months of agent replies to learn from. Most of the work is in choosing and cleaning those replies, and the training run is the small step at the end.

What should each training example look like?

Start with the content of each row. OpenAI's guide sets the bar clearly.

  • “Whatever prompts and outputs you expect in your application, as realistic as possible”

    OpenAI's supervised fine-tuning guide

  • Same prompts as the live app

    Include the instructions the app sends along with each request.

  • Answers checked by experts

    Write or check each answer with the people who know the job.

  • Real logs, if clean

    Use logged data only where it is clean enough to train on.

Format matters too. OpenAI asks for JSON Lines, a text file with one complete JSON record on every line (JSON is a structured data format). The guide says the minimum is 10 examples and recommends starting with 50 well-crafted demonstrations.

Tip

Asked how many rows you need? Say you start with about 50 careful examples, measure, then add rows only where the model fails. More rows of the same mistake do not help.

How do you clean and split the data?

Cleaning and splitting happen before any training. The chart shows the order, with one loop back when a score is weak.

From raw replies to a scored dataset

Past agent replies

18 months of real agent replies

Clean the rows

Drop empty and repeat rows

empty answers and repeated pairs go

Remove card numbers

personal data is out before training

Split by ticket thread

one thread, one set, never both

Fine-tune

learns from the train set only

Score on validation set

wrong answers go back to cleaning

  1. 1Start from the raw export of past replies.
  2. 2Rows that pass move on to the card check.
  3. 3Clean rows move on to the thread split.
  4. 4Only the train rows go forward to training.
  5. 5Train on the train set, then score on the validation set.
  6. 6Weak scores send the data back for cleaning.
Past replies pass through cleaning and a split by ticket thread before training. The validation set is scored each round, and weak results send the data back for fixing. The test set is not drawn here; it waits for one final check.

Cleaning removes empty answers, repeated pairs and personal data. Card numbers come out first. Google's Sensitive Data Protection service lists a credit card number as sensitive data, so treat any card-like digits as a removal case. Check the answers too: one row in the bank's data says a block lifts at closure, and another says it stays. Both cannot be right.

  • Random row split

    Near-copies in both sets

    Near-copies, such as two replies from one ticket, can land in train and test, so the test score looks better than it is.

  • Thread split

    Whole threads, one set

    The test set holds cases the model never trained on, so its score is a fairer guess at how the live app will do.

  • “A good test set is statistically significant, representative of the dataset and real-world data, and contains no duplicates from the training set.”

    Google's machine learning crash course

The same crash course says a transform applied to the training set must also be applied to the validation and test sets. It also warns that validation and test sets wear out with repeated use, so keep fresh data for the final check.

Can you see the cleaning in code?

Here is a made-up set of eight rows from the bank's dispute chats, cleaned with the standard library only. It drops empty answers, repeated pairs and card-like digits, then splits by thread.

Python
# A made-up bank's past dispute replies: clean them, then split by ticket thread.
import hashlib
RAW = [
    ("T-101", "Two charges for one flight. Can one be refunded?", "We have raised a reversal for the second charge."),
    ("T-101", "Two charges for one flight. Can one be refunded?", "We have raised a reversal for the second charge."),
    ("T-101", "Two charges for one flight. Did the airline get paid twice?", "Yes. The second charge is reversed, and the airline keeps one payment."),
    ("T-102", "Why is my dispute still open after 40 days?", ""),
    ("T-103", "My card 4111 1111 1111 1111 was declined abroad.", "Please check the card block settings in the app."),
    ("T-104", "Is my card blocked while a dispute is open?", "No. The block lifts when the case closes."),
    ("T-105", "Is my card blocked while a dispute is open?", "Yes, it stays blocked until the case closes."),
    ("T-106", "Can I dispute a hotel charge after checkout?", "Yes, within 120 days of the statement date."),
]
seen, kept = set(), []
dropped = {"empty": 0, "duplicate": 0, "card-like digits": 0}
for thread, question, answer in RAW:
    if not answer.strip():
        dropped["empty"] += 1
    elif (question, answer) in seen:
        dropped["duplicate"] += 1
    elif sum(c.isdigit() for c in question + answer) >= 13:
        dropped["card-like digits"] += 1
    else:
        seen.add((question, answer))
        kept.append((thread, question, answer))
def split(thread):
    # Same thread id, same set: replies from one case never leak into the test set.
    return "test" if int(hashlib.sha256(thread.encode()).hexdigest(), 16) % 10 < 2 else "train"
sets = [split(thread) for thread, _, _ in kept]
print("kept", len(kept), "dropped", dropped)
print("train", sets.count("train"), "test", sets.count("test"))

Output

kept 5 dropped {'empty': 1, 'duplicate': 1, 'card-like digits': 1}
train 4 test 1

The output shows three drops, then a split of five kept rows into four for training and one for testing. Eight rows is a small size, so read the counts as a pattern. With real data the same steps run over thousands of rows. The script makes only two sets to stay short. A real pipeline carves a validation set the same way, from the same thread id.

Notice what the code missed. The two rows about the blocked card disagree, and both were kept. Code catches mechanical problems but cannot judge a wrong answer, so a person must still read a sample.

How would you start with no past data?

Begin by deciding how you will judge the model. OpenAI's guide says to set up evals (scored tests of the model's answers) before you invest in fine-tuning.

  1. 1

    Agree what good looks like

    Work with the bank's dispute team on the rules, then write about 50 careful examples yourself.

  2. 2

    Score the base model

    Run the same examples through the model without training, and record where it fails.

  3. 3

    Add rows for real failures

    Write more examples only for the failures you saw, then retrain and score again.

  4. 4

    Seal the test set

    Hold back examples the team never edits, and use them for one final check.

Tip

If 50 good examples barely move the score, fix the task or the prompt before adding more training data.

What does the interviewer want to hear?

A strong answer covers

  • Good rows look like real requests from the live app, with answers checked by experts.
  • Clean first: drop duplicates, empty answers and personal data.
  • Split by group, such as the ticket thread, so replies from one case do not leak across sets.
  • Keep a test set that the training never touches.
  • Start small, read the failures, then add rows where they happen.
  • Treat the dataset as something that changes with the product.

Common traps

  • Trap"Bigger data is always better."

    BetterBad rows teach bad habits. Clean and check them first, then add more.

  • Trap"A random split is fine, we have lots of rows."

    BetterReplies from one ticket leak into the test set and flatter the score.

  • Trap"Let the model learn from the test set too."

    BetterThen the score means nothing. The test set stays sealed until the final check.

Can you spot the problem in the data?

Spot the personal data

A reviewer reads four rows from the bank's dataset. Which one must come out before training?

Quick check

A bank fine-tunes a model on its dispute replies. Which change most reduces the chance that the test score is inflated?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q295How much data do you need?9 min
  2. Q296What is catastrophic forgetting?12 min
  3. Q297How do you spot overfitting during fine-tuning?11 min
  4. Q299Synthetic data for fine-tuning?10 min
  5. Q300How do you evaluate a fine-tuned model?11 min
  6. Q248What is a golden dataset, and how do you build one?11 min

Learn it in depth

Last updated on 26 November 2026

Building a model on your own data?

I design and build AI products and agents, the interface and the system behind it. Book a short call and tell me what data you have and what you need the model to do.