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.

Exact Match, Accuracy and F1 for LLM Tasks

How exact match, accuracy and F1 score an LLM's answers, where each one misleads, and how to report them, for your AI interview.

In short

Exact match checks whether an LLM's answer equals the expected answer word for word, after tidy-up. Accuracy is the share of right labels, and token F1 gives partial credit by balancing precision and recall. Use the score that fits the task, and report two of them.

12 min readBeginnerCommon · 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.

Exact match, accuracy and F1 are three ways to score an LLM's answers against a gold answer. Exact match is strict: the words must match after tidy-up. Accuracy counts the share of right labels, which can look great even when a rare case is always missed. Token F1 gives partial credit for shared words, and balances precision and recall. I'd report at least two of them, and read the gap between them.

What are exact match, accuracy and F1, in plain words?

When a model answers a test question, you need a rule that says whether the answer is right. Exact match, accuracy and F1 are three common rules. Each one counts a different kind of right.

Exact match asks whether the answer is the same as the expected answer, after small tidy-ups such as case and extra spaces. Accuracy is the share of answers that are right, and it fits when every answer is one label from a list. Token F1 gives partial credit for shared words, so a close answer scores more than a wrong one.

Think of a claims clerk at an insurer checking a settlement letter. A strict check accepts only the exact figure. A fair check gives credit for each line that matches and marks the lines that are missing.

An LLM that reads 500 vendor contracts and returns the notice period needs one of these rules to score it. The rule you pick decides what you think is working.

Key words

Gold answer
The answer your team agreed is correct. It is the expected output in a test case.
Token
A unit the scorer compares. In token F1 it is a word here, not the model's sub-word piece.
Label
One choice from a fixed list, such as billing, refund or complaint.
F1 score
One number that combines two checks: precision (the share of the words given that were right) and recall (the share of the needed words that were found).

How do exact match and accuracy work, and where do they break?

Exact match is the simplest score. For each test case you compare the model's answer with the gold answer. An equal pair scores 1, and anything else scores 0. The score for the whole test set is the share of cases that scored 1.

  1. 1

    Tidy both sides

    Lower-case the text and remove extra spaces and stray punctuation, so "60 days." and "60 days" compare as equal.

  2. 2

    Compare word for word

    A match scores 1. Anything else scores 0, even when the meaning is right.

  3. 3

    Average the test set

    Add the 1s and 0s and divide by the number of cases. That is your exact match rate.

  • “Exact match evals measure whether the model's output matches a predefined correct answer, typically after normalizing whitespace and case.”

    Anthropic

  • “Accuracy is the proportion of all classifications that were correct, whether positive or negative.”

    Google, machine learning course

Accuracy is the same test counted over labels. It fits one label from a fixed list, such as a ticket's category.

Accuracy has one trap. Suppose only three in every hundred emails in a support inbox are urgent (made-up numbers). A model that never flags anything scores 97 percent accuracy, and it is useless for the urgent ones. That is why accuracy alone is a weak check for rare cases.

Here is a made-up check on five vendor contracts. The model pulls out the notice period, and we score its answers with exact match and with F1.

Python
# Scoring an LLM that pulls the notice period out of five vendor contracts (made-up outputs).
import re
from collections import Counter

def words(s):
    return re.sub(r"[^a-z0-9 ]", "", s.lower()).split()

def exact_match(pred, gold):
    return words(pred) == words(gold)
def token_f1(pred, gold):
    p, g = words(pred), words(gold)
    common = sum((Counter(p) & Counter(g)).values())
    if common == 0:
        return 0.0
    precision, recall = common / len(p), common / len(g)
    return 2 * precision * recall / (precision + recall)

cases = [
    ("60 days", "60 days."),
    ("Sixty (60) days", "60 days"),
    ("90 days after written notice", "90 days"),
    ("30 days", "60 days"),
    ("Not specified", "90 days"),
]
em = [exact_match(p, g) for p, g in cases]
f1 = [token_f1(p, g) for p, g in cases]
print(f"exact match   {sum(em) / len(em):.0%}")
print(f"token F1      {sum(f1) / len(f1):.2f}")
for (p, g), e, f in zip(cases, em, f1):
    print(f"{p!r:32} vs {g!r:12} EM={int(e)} F1={f:.2f}")

Output

exact match   20%
token F1      0.57
'60 days'                        vs '60 days.'   EM=1 F1=1.00
'Sixty (60) days'                vs '60 days'    EM=0 F1=0.80
'90 days after written notice'   vs '90 days'    EM=0 F1=0.57
'30 days'                        vs '60 days'    EM=0 F1=0.50
'Not specified'                  vs '90 days'    EM=0 F1=0.00

Exact match scores 20 percent, and token F1 scores 0.57. Exact match credits only the first case. The second means the same thing, and the third is right but adds 'after written notice'. That gap is the lesson: a strict score counts wording, while a partial score counts shared words and can still miss meaning.

One answer, scored two ways

Sixty (60) days

its answer to: notice period?

Two scores

Exact match: 0

the words differ from 60 days

Token F1: 0.80

two of three words match

Report both

read the gap between them

  1. 1The answer goes to the strict word-for-word check.
  2. 2The same answer goes to the shared-words check.
  3. 3The strict result, 0, goes into the final report.
  4. 4The 0.80 score goes into the final report.
The same answer, scored two ways. Exact match gives 0 because the words differ, while token F1 gives 0.80 for the two words that match. Report both, so the gap shows what to fix.

What is F1, and when should you use it?

F1 checks how much of the answer is right, in both directions. Classification F1, the score scikit-learn calculates, applies this formula to a model's right and wrong labels. Token F1 is this page's name for the same formula, applied to the words an answer shares with the gold answer. Precision asks: of the words the model wrote, how many were right? Recall asks: of the words the gold answer needs, how many did the model give? F1 combines the two, so it is only high when both are high.

Token F1 suits answers that are spans of a document, such as a clause or a date pulled from a contract. The SQuAD reading benchmark from 2016 used this kind of answer, a segment of text from a passage, and its abstract reports an F1 score of 51.0% for a logistic regression model.

  • “The F1 score can be interpreted as a harmonic mean of the precision and recall, where an F1 score reaches its best value at 1 and worst score at 0.”

    scikit-learn, the F1 score

  • “This metric balances the importance of precision and recall, and is preferable to accuracy for class-imbalanced datasets.”

    Google, machine learning course

  • Exact match

    Right or wrong

    Strict. Good for a date, an ID or a fixed phrase. Too harsh for a sentence that says the same thing in other words.

  • Accuracy

    Share of labels right

    Fits one label from a list. Misleads when one label is rare.

  • Token F1

    Partial credit

    Counts shared words. Still blind to meaning: 'refundable' and 'not refundable' share a word, so they get partial credit.

Tip

Name the metric and why in one breath: for ticket labels, say you track accuracy and per-class recall, since the refund class is rare.

When an answer can be worded many ways, no single string score is enough. Teams then grade meaning with a judge model or with people. See LLM-as-a-judge in this kit.

How would you report scores for a contract-extraction model?

You have a model that pulls the notice period from vendor contracts. A product owner asks for one number. Here is a plan that keeps the number honest.

  1. 1

    Write the tidy-up rules first

    Decide whether "60 days" and "sixty days" count as the same. Write the rule down, or the score moves when the rules move.

  2. 2

    Report exact match and token F1 together

    The gap shows where answers differ only in wording. Partial credit can hide a wrong number: '30 days' against '60 days' still scores 0.50 F1, so read the misses by hand.

  3. 3

    Read the misses by hand

    Ten misses show whether the model is wrong or the grader is too strict. Fix whichever is the real cause.

  4. 4

    Add a meaning check for free text

    Use a judge or people for answers that can be worded many ways.

  5. 5

    Keep a hidden test set

    Do not tune prompts on the cases you report. Otherwise the score flatters the model.

What does the interviewer want to hear?

A strong answer covers

  • The three scores, each in one plain sentence.
  • Which score fits which task: strict for IDs and dates, F1 for extracted phrases, accuracy for labels.
  • Why accuracy misleads when a case is rare.
  • What exact match and F1 miss: meaning, which needs a judge or people.
  • Reporting two scores and reading the gap between them.
  • Tidy-up rules written down, and a test set kept hidden from tuning.

Common traps

  • Trap"Accuracy is the best metric for everything."

    BetterIt hides rare failures. Pair it with recall or F1 when one class is rare.

  • Trap"Exact match is wrong, so ignore it."

    BetterIt is right for dates, IDs and fixed labels. Keep it there, and add a softer score for free text.

  • Trap"An F1 of 0.8 means the model is 80% correct."

    BetterF1 balances two ratios. It is not a percentage right, so say what it counts.

Can you spot the scoring problem?

Spot the scoring problem

A team reports 97% accuracy for a model that flags urgent emails. Only about 3 in 100 emails are urgent (made-up numbers). What is the problem?

Quick check

A model pulls the due date from invoices. Which score is the best first check?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q252BLEU and ROUGE, and their limits?10 min
  2. Q248What is a golden dataset, and how do you build one?11 min
  3. Q249What is LLM-as-a-judge?12 min
  4. Q254Faithfulness vs relevance?10 min
  5. Q257How do you regression-test prompts?12 min
  6. Q420Precision, recall and F1?10 min

Learn it in depth

Last updated on 26 November 2026

Scoring an LLM feature that has no single right answer?

I design and build AI products and agents, including the tests and scores behind them. Book a short call and tell me what the output needs to get right.