Concepts / Extracting Model Responses from Generated Text

Extracting Model Responses from Generated Text

A model response is evaluated by placing it next to the correct answer for the same instruction and checking what the instruction asked for.

  • Programming

Why a Reasonable-Sounding Answer Is Not Enough

Once a model has produced an output for each test instruction, the natural next question is whether those outputs are any good. The practical way to answer it is to place each model response beside the correct answer written for the same instruction and look at the pair. This article follows one such comparison from start to finish.

The comparison begins with a tempting shortcut that does not hold up: the idea that any answer which sounds reasonable must be right. A response is not correct simply because it is related to the right idea. Suppose a question is about thunderstorms and the response names a cloud connected to thunderstorms. At a glance that response can look successful. Checking it against the correct answer shows whether it really does what the instruction asked.

What do you think happens?

The instruction asks what type of cloud is typically associated with thunderstorms. The model answers that the type is a cumulus cloud. Is that answer right?

  • Yes, because cumulus clouds are connected to thunderstorms

  • No, because the type typically associated with thunderstorms is a different cloud

  • It depends on the wording of the answer

Reveal answer
Answer:

No, the answer is close but not entirely accurate. The type typically associated with thunderstorms is cumulonimbus, not cumulus.

The response names a cloud that is linked to the topic, which is why it looks plausible. The comparison matters because the specific cloud named is the part the instruction asked for.

Separating the Response from the Generated Text

Before any comparison can happen, the model's response has to be separated from the text around it. The generate function returns the input and the output together as one combined string. The model's part is not available on its own, so it has to be pulled out of that string.

  1. 1
    Receive the combined string returned by the generate function, which holds the input and the output together.
  2. 2
    Slice the string to isolate the portion that belongs to the model's output.
  3. 3
    Use the .replace() method on the generated text to remove the material that is not part of the response.
  4. 4
    Keep the result, which is the response alone, ready to print next to the correct answer.

The point of this step is to make the comparison fair. If the instruction or surrounding text were left in place, the reader would be comparing the correct answer against a block of text that contains more than the model's answer, and any real difference would be harder to see.

Laying Out the Evidence in a Fixed Order

The printed comparison presents the evidence in a fixed order: the instruction text first, then the correct response, then the model response, followed by a separator line. Because the two answers always appear in the same place for every example, your eye can move straight from the correct answer to the model answer and notice any gap.

Instructionthe test promptModel outputinput and output combinedSlice and replaceisolate the responsePrint side by sideinstruction, reference,responseFind divergencewhere does it differVerdictacceptable, close, orcorrectgenerateseparatepair with referenceread the pairjudge
What are the sequential steps from receiving the instruction to producing a verdict on the model response?

The diagram shows the flow in order. The model output is first separated into the response alone, then placed in the fixed layout beside the reference, and only then is the verdict formed by looking at where the two diverge.

Tracing the Three Test Triples

The test set in this example contains three instructions. Each one has a correct response written for it and a model response to compare. Working through all three shows how different verdicts arise from the same comparison procedure.

Worked example

Checking the three triples

For each instruction, compare the model response to the reference and decide whether the response is correct, acceptable with different wording, or close but not entirely accurate.

  1. 1
    Triple 1: rewrite with a simile

    The reference is 'The car is as fast as lightning.' The model writes 'The car is as fast as a bullet.' The words differ, but both are valid similes comparing the car's speed to something fast. The source judges this clearly correct.

  2. 2
    Triple 2: cloud type for thunderstorms

    The reference is cumulonimbus. The model says cumulus cloud. The cloud is connected to the topic, but it is not the type typically associated with thunderstorms, so the source judges the response close but not entirely accurate.

  3. 3
    Triple 3: author of Pride and Prejudice

    Both the reference and the model response say Jane Austen. The responses match, so the model is correct.

Result

Triple 1 is acceptable with different wording, triple 2 is close but not entirely accurate, and triple 3 is correct.

Locating Where the Cloud Answer Diverges

When a response is judged wrong, the useful question is where it departs from the expected answer. In the cloud example, the topic is right: both answers concern thunderstorms and both name a cloud. The departure is in the name of the cloud itself. The reference names cumulonimbus, while the model names cumulus.

ThunderstormstopicThunderstormstopicCumulonimbuscorrect cloud typeCumulus cloudnamed cloudmatchesdiverges
At which exact part of the comparison does the model response stop matching the correct answer, and how do the two line up?

Reading the pair line by line, the topic lines up and the first difference appears at the cloud name. That single point of divergence is what separates a response that is close from one that is fully right. It also suggests a diagnosis: the model has the subject area right but has chosen a related term where the instruction asked for a specific one.

Wording Changes Versus Meaning Changes

A response can differ from the reference in wording and still be clearly correct. The simile example shows this. The reference uses lightning and the model uses a bullet, and the words are different. Both still compare the car's speed to something fast, so the task is done. The departure from the reference does not change whether the instruction was fulfilled.

as fast aslightningreferenceClearly correctverdictCumulonimbusreferenceClose but notaccurateverdictas fast as a bulletmodel responseCumulus cloudmodel responsesame task donewrong type named
Which differences between the model response and the reference change the meaning, and which only change the wording?
Key point

Ask one question at the point of divergence: does the difference change what the instruction asked for? If it only changes the phrasing, the response can be acceptable. If it changes the specific thing being asked for, the response is close but not entirely accurate.

Mistakes Beginners Make When Judging Responses

  • Common mistake

    Accepting any response that is related to the right idea

    What it looks like

    A thunderstorm answer that names a cloud linked to thunderstorms looks successful at a glance.

    Why it fails

    Being related to the topic is not the same as answering what the instruction asked for. The source shows the cloud answer is judged not entirely accurate.

    Do this instead

    Check the specific item the instruction asks for and compare it with the reference.

  • Common mistake

    Rejecting a response only because its wording differs from the reference

    What it looks like

    The simile 'as fast as a bullet' differs from 'as fast as lightning' but is still a valid simile.

    Why it fails

    Different words can still complete the same task. Wording alone does not decide correctness.

    Do this instead

    Look at whether the meaning and the task are preserved, not whether the words match.

  • Common mistake

    Comparing against text that still contains the prompt or template

    Why it fails

    The generate function returns input and output together, so unsliced text makes the comparison unfair.

    Do this instead

    Separate the model's response first, then compare only that part with the reference.

Judging Performance Across Several Triples

A single verdict describes one instruction. An overall picture comes from combining the verdicts across several instruction, reference, and model response triples. In the three-triple example, one response is clearly correct, one is acceptable despite different wording, and one is close but not entirely accurate.

TripleInstruction focusVerdictWhere it diverges
Simile rewriteUse a simileClearly correctWording only
Thunderstorm cloudName the cloud typeClose but not entirely accurateThe name of the cloud
Pride and PrejudiceName the authorCorrectNo divergence

Verdicts for the three triples in the test set

Read together, the table suggests that this model handles the task type well in the cases where the answer is a recognizable fact or a simple rewrite, but it has a specific weakness where the question requires one precise term among related ones. Three triples is a very small set, so this is a rough picture rather than a reliable measure. Reading the pattern of divergences is more informative than counting correct verdicts alone.

MEDIUM

Take a new triple: the instruction asks for the capital of a country, the reference names the capital, and the model names a major city in the same country. Decide whether the response is correct, acceptable, or close but not entirely accurate, and state the exact point where it diverges.

Hints
  • Ask whether the model named the specific item the instruction asked for.
  • Compare the words and then decide whether the difference changes the task.

Key Takeaways

  • A model response is evaluated by placing it beside the correct answer for the same instruction and checking what the instruction asked for.
  • Wording that differs from the reference can still be clearly correct when the task is still accomplished, as the simile example shows.
  • A response that names something related to the right answer, such as a cumulus cloud for a thunderstorm question, can be close but not entirely accurate.
  • The point of divergence shows whether the model misread the task or chose different valid words.
  • Overall performance is judged from the pattern of verdicts across several instruction, reference, and response triples.

More concepts starting with E