Faragiri

Learn Building with AI AI

Putting a model in a product goes wrong on either side of the call: the passage never retrieved, and the answer nobody validated. The order that fixes it.

7Sections
6Min read
2Depth

Recommended Before This

0 / 2

Ask a booking system whether you can bring your nephew on Sunday, and the failure that arrives first is not the model's answer. It is that the paragraph about weekends was never put in front of it.

Ayşe Tunç maintains the booking software for four climbing walls around Manchester, and the feature asked for was small: a member types a question in ordinary words and the system answers from the house rules and the timetable. The model was the part that already worked. Everything that went wrong for a month was on either side of it.

The right paragraph, or nothing

The nephew question fetched the passage on membership categories, because the member had written nephew and Sunday and the passage that actually governs it says persons under eighteen and at weekends, sharing not one word with the question. The model then wrote a fluent, courteous and wrong paragraph out of the passage it was handed, which is the only thing it could have done with it.

Retrieval vocabulary

The model received the wrong passage because the query shared zero words

Retrieval fails before generation begins when member query language and rulebook noticeboard vocabulary do not overlap.

Member phone queryCasual conversational phrasing
House rule noticeboardFormal governing conditions
Age and relationnephewpersons under eighteen
Timing constraintSundayat weekends
Selected passageMembership categories (irrelevant)Weekend admission rules (governing)

No language model can rescue an answer if the relevant paragraph is absent from the retrieved excerpts.

Interactive Practice Lab

Edit and run this snippet directly in your browser (zero setup)

Python
prompts = [    {"role": "tutor", "tokens": 42, "grounded": True},    {"role": "reviewer", "tokens": 68, "grounded": True},    {"role": "vague", "tokens": 14, "grounded": False},]valid = [p for p in prompts if p["grounded"]]print(f"Grounded prompts: {len(valid)}/{len(prompts)}")print("Avg tokens:", round(sum(p["tokens"] for p in valid) / len(valid), 1))

Live LLM Temperature, Top-P & Softmax Sampling Lab

Tune Temperature and Nucleus Top-P to see live Softmax probabilities and sample tokens.

If the right passage is not in the top few results, no model can rescue the answer. That is the sentence to keep, because it moves the work: retrieval is judged by whether the correct passage is in the handful you pass along, and that is a search problem with decades of technique behind it, none of which is about models. Ayşe fixed it by indexing each rule twice, once as written and once as the question it answers, which is a piece of writing rather than a piece of engineering.

Hand opening a thick clothbound rulebook with dusty-rose index tabs to pull out one exact governing page while an unused loose sheet lies aside.
Retrieval decides the answer before the model writes a word: hand it the wrong passage and it produces fluent fiction.

Fine tuning teaches a shape, not a fact

Before that, she spent a fortnight fine tuning on 300 past support emails, on the reasonable theory that the system should learn how the walls actually answer. It worked. The replies came back sounding exactly like the front desk, in the house cadence, with the house sign off, and still wrong about Sundays.

Model adaptation

Fine tuning teaches house style rather than changing factual rules

Training adjusts tone and cadence while dynamic facts must be retrieved at the exact moment of answering.

Modification mechanism

Style and tone (fine tuning)Changing facts (retrieval)
  1. House sign-off and cadenceLearned from past support emails and baked into model weights
  2. Conversational formatAdopts the polite, courteous tone of front desk replies
  3. Weekly schedule updatesMust be retrieved dynamically from external timetable systems
  4. Weekend admission rulesGoverning facts that must be supplied in context rather than stored in weights

Fine tuning makes incorrect replies sound persuasive without improving factual accuracy on weekly rules.

Fine tuning teaches a shape, not a fact. It moves the style, the format and the kind of thing produced, which is worth having when the output has to look a particular way every time. It is the wrong instrument for getting a specific paragraph right, and the failure it produces is the expensive kind, because the answers get more convincing while staying just as wrong. A fact that changes weekly belongs in something read at the moment of answering, never in the weights.

The eval set that told her nothing

She had written an eval set, which was the one thing done in the right order. Write the eval set before the feature, because a demo cannot fail: a demo is a question chosen after the system existed, and it selects for what already works, every time, without anybody deciding to cheat.

Evaluation design

An eval set must include known failure cases to measure progress

A test suite populated solely with plausible queries that already pass measures execution rather than correctness.

Evaluation suite standards

  1. YesDerived from actual production failuresIncludes real queries that failed in service like the nephew inquiryYes
  2. YesHuman-written ground truth with exact rule quotedStates no under eighteens on Saturday or Sunday and quotes rule textYes
  3. NoComposed exclusively of demo queries that pass immediatelyUnconsciously selects for paths that succeed and teaches nothing about failureNo
  4. NoTreated as a final polish step rather than a development toolCannot guide retrieval changes or fine tuning without prior baseline evalsNo

An evaluation set with no failing cases only confirms that the pipeline ran without throwing an exception.

The first version still taught her nothing. Twelve questions, all of them things a member plausibly asks, all of them answered correctly on the first afternoon. An eval with no wrong answers in it measures only that the thing runs. The set that earned its keep was the second one, built from the questions the system had got wrong that month, with the nephew question first and the expected answer written out by a person: no under eighteens on Saturday or Sunday, and the rule quoted rather than paraphrased.

Which is the shape of the whole discipline below. A system that does not answer the same way twice cannot be debugged by looking at it, so tests for a system that does not answer the same way twice is not the tidy last step, it is the instrument every other step is read through.

The two sides of the call are both yours

Every call is a network call, so it fails the way network calls fail: slowly, intermittently, and at the worst moment. It also bills. A retry on a timeout can charge twice and answer once, and a retry on a request that already booked a slot is a duplicate booking rather than a duplicate paragraph.

Where the work is

Everything narrows to one request, and the request is the part you did not write

Four things are squeezed into a single call, and three consequences fall out of it. The call itself is a few lines.

  1. The member's questionTyped the way a person types on a phone
  2. The house rulesNine pages, written for a noticeboard
  3. The timetableChanging weekly, and living in another system
  4. The standing instructionWho the answer is for, and what may not be invented
One request, one answerReplaceable by a different vendor in an afternoon, which is the clue about where the value is not
  1. A parsed answerOr a rejection, kept for next month's eval set
  2. A booking, or a refusalA row in a database that is awkward to take back
  3. Somebody's SundayWhere a paragraph nobody retrieved finally arrives

The two cones are the system and the waist is the vendor. A drawing that made the waist the biggest part would be a picture of the demo rather than of the thing in service.

On the way out, treat the model's output like a form a stranger filled in. It is not markup you wrote and it is not a value from your own database; it is text produced under influences you cannot fully enumerate, and it is about to be rendered on a page, put in a query, or handed to a booking function. Parse it against a declared type, reject what does not fit, and keep the rejection, because the rejects are next month's eval cases.

Two matte-black network junction boxes with braided dark cords beside two identical stamped paper booking slips on dark slate.
Every model request is a billable network call. Retrying blindly on a timeout can charge twice or book the same slot twice.

The order, and the step everyone skips

Make the call first, at the request, the response and the parts that surprise you, which takes an evening and settles what the thing costs and how it fails. Write the eval set second. Third, giving the model your data at the moment it answers, which is where most of the work turns out to be. Fourth and rarely, teaching a model a style or a task. Then everything between a demo and a service.

The order

The second tread is the one everybody steps over

A staircase rather than a list: the fourth step cannot be judged without the second, and the third cannot be debugged without it either.

  1. 01Make the callAn evening. It settles the cost and the failure modes
  2. 02Write the eval setBefore the feature exists, and with wrong answers in it
  3. 03Give it your dataRetrieval, and it is a search problem first
  4. 04Change the shapeFine tuning, and only against the second step
  5. 05Put it in front of strangersTimeouts, retries, cost, and output nobody wrote

Skipping the second tread is invisible for about six weeks, because everything above it still runs. What is missing is not correctness, it is the ability to tell whether anything changed.

The second step is the one that gets skipped, and skipping it is not visible for about six weeks. Without it, step three cannot be debugged, because nothing distinguishes a retrieval that improved from one that changed. Step four cannot be justified at all, since the only claim fine tuning ever makes is comparative. A team that reaches the fourth step without the second one has bought an expensive change it has no way to evaluate, and will keep it, because it sounds better.

The stall is improving by feel

The stall here arrives after the thing ships. The system answers most questions, the obvious failures are gone, and every change from then on gets judged by trying it: a different chunk size, a rewritten instruction, a newer model, each followed by three questions and a verdict. The activity never slows down, which is why nobody notices that the improving has stopped.

Regression verification

Prompt and retrieval tweaks require systematic test runs over spot checks

Evaluating changes with three hand-picked questions creates an illusion of ongoing improvement while hiding regressions.

How is a prompt or chunking modification evaluated?
  • Ad-hoc trial using three questions picked on the spot
    Stalled subjective loopThe author tests cases held in mind during editing, quietly selecting for queries that already pass
  • Automated run against accumulated historical failures
    Grounded regression testEvaluates known difficult cases like weekend admission rules to verify genuine system improvement

Without testing against past real-world failures, tweaking parameters feels like progress while fixing nothing.

What makes it a stall rather than a habit is who picks the three questions. They are picked by the person who just made the change, minutes after making it, out of the cases that were in mind while making it. Ayşe's second eval set exists because the nephew question was never one of the three and never would have been. Nobody writes a test out of a case they have not thought of yet, which is why the cases have to come from what went wrong rather than from what might.

Neat five-by-four grid of twenty plain white test evaluation cards lined up on dark charcoal beside a pen and brass mechanical tally counter.
Improving by feel stops working right after launch; real progress requires a fixed test set scored consistently after every change.

What to open in 2026

pgvector puts the embeddings in the Postgres already under the application, as of 2026, and it replaced standing up a second database purely to hold vectors. Free and open source. It is the right default because the retrieval that works usually needs a filter beside the similarity search, and a member question about Sunday wants the rules for this wall, currently in force, ranked by both.

Tooling in 2026

Three open tools anchor evaluation, schema validation, and hybrid search

Replacing manual checks and separate vector stores with integrated database indexing and typed boundaries.

  1. promptfoo regression testingRuns test suites automatically across changes to detect answer driftevaluation
  2. Pydantic response validationEnforces declared schema types before downstream databases process outputvalidation
  3. PostgreSQL with pgvectorCombines vector similarity with relational metadata filtering in one storestorage

Modern application stacks rely on schema validation and automated eval files rather than ad-hoc checks.

Pydantic validates what came back against a declared type before anything downstream sees it, free and open source as of 2026, and it replaced parsing prose with a regular expression and hoping the shape held.

promptfoo runs a file of cases against a prompt on every change and reports which answers moved, as of 2026, free and open source. It replaced trying the same three questions by hand after each edit, which is the method everybody uses first and which quietly selects for the three questions that already work.

All of which leaves the question underneath the month Ayşe lost. Nothing in the retrieval failure was about models: it was a rule written for a noticeboard, indexed by the words it happened to contain. That is getting it, cleaning it, and finding out what it says, arriving in a costume, and the version of this problem that has a name and a literature is getting code off your machine and keeping it running, which had timeouts and retries and rollbacks long before any of this.

Alongside this

Above this