IntermediateAbout 17 min

    Evaluation Metrics: Perplexity & Similarity

    Read the full article on Substack

    7 min read.

    Compute cross-entropy and perplexity from a predicted probability, then run four adversarial reference/output pairs through exact match, lexical overlap and embedding similarity and watch the three metrics disagree with each other and with a human.

    Think of it this way: Marking an essay by counting how many of the model answer's words appear in it. It works surprisingly often, fails completely on a good paraphrase, and fails silently — and dangerously — on an answer that says the exact opposite in the same vocabulary.

    Reference
    The refund will arrive in three to five business days.
    Model output
    You should see the money back within 3-5 working days.
    A person says
    Correct
    MetricScoreSaysAgrees?
    Exact match
    0.00
    WrongNo
    Word overlap F1
    0.20
    WrongNo
    Embedding cosine
    0.91
    CorrectYes

    Fooled: Exact match, Word overlap F1. A human marks this correct instantly. Exact match says 0. Word overlap is poor because every content word was swapped for a synonym. Only the embedding notices they mean the same thing.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    What is this metric measuring?

    Sort

    Sort each metric by what it compares.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Token overlap with a reference

    Drop items here

    Meaning, via embeddings

    Drop items here

    The model’s own confidence

    Drop items here
    6 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    Perplexity is defined as:

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going