Free guide

How Perplexity Works (the Number OpenAI Wants Every Lab to Track)

OpenAI's chief scientist wants every AI lab to agree on limits measured by perplexity. It doesn't grade answers, it measures surprise. Here's how it works, step by step, and how to measure it on your own text.

By Beau Johnson·
The Short this guide goes with: How Perplexity Works (the Number OpenAI Wants Every Lab to Track)

Quick answer

Perplexity measures how well a language model predicts the next token on text it has never seen. For every token, you take the probability the model gave the real token, turn it into a surprise score (the negative log), and average those scores. That average is log-perplexity, also called cross-entropy loss, and lower is better. OpenAI reports about 0.99 for GPT-3.5, about 0.91 for GPT-4, and below 0.8 for its newest models.

The short version

  • Perplexity scores prediction, not answers: before each token the model spreads probability over what could come next, and the score is how surprised it was by what actually came.
  • OpenAI tracks log-perplexity on held-out text from its own internal codebase: about 0.99 for GPT-3.5, about 0.91 for GPT-4, below 0.8 now.
  • Jakub Pachocki proposes that labs agree on common limits based on perplexity and other measurements. It's a proposal, and no limit value has been set.

How it actually works

Step 1: text the model has never seen

You need a held-out set: text that was not in the training data, so the model can't just remember it. OpenAI says the main held-out sets it has used since GPT-3.5 come from its own internal codebase, and that's where its published numbers come from.

Step 2: the model bets before every token

Before each token, the model gives every possible next token a probability. In the video those are bet chips on cards: for "the cat sat on the ___" most of the chips go on mat. The bets in the video are an illustration. A real chat model is often far more sure: in our own test, gpt-4o-mini put 99.99% on mat.

Step 3: the real token lands, and you score the surprise

When the real next token shows up, you look at how much the model bet on it. A big bet means a small surprise, a tiny bet means a big surprise. The surprise is the negative log of that probability, so a bet near 100% scores near zero and a bet near 0% scores very high.

Step 4: average it, and that's the dial

Average the surprise over every token in the held-out set and you get log-perplexity, also called cross-entropy loss. Raise e (or 2) to that power and you get perplexity itself. Lower is better. A fair k-sided die has perplexity k, so you can read perplexity as how many equally likely options the model is torn between.

The floor nobody can see

OpenAI says a loss of 0 is not reachable, because text is never fully predictable, and nobody knows where the real floor (the data's own entropy) is. As models get closer to it, the numbers move more slowly, but OpenAI expects smaller drops to mean bigger leaps in ability.

How to set it up

  1. 1.Read OpenAI's numbers in context

    In the post, GPT-3.5 sits at about 0.99 log-perplexity, GPT-4 at about 0.91, and the newest models below 0.8, where OpenAI says it saw new abilities in math and cybersecurity. It also expects more around 0.68 to 0.7. These are measured on OpenAI's own internal code, so don't compare them to another lab's numbers.

  2. 2.See a model's bets with logprobs

    The OpenAI Chat Completions API returns the log probability of each output token when you set logprobs to true, and top_logprobs (0 to 20) adds the most likely alternatives at each position. Turn a logprob into a percent with exp(logprob). Not every model returns them: in our test gpt-4o-mini did, gpt-4.1-mini through OpenRouter did not.

    curl https://api.openai.com/v1/chat/completions \
      -H "Authorization: Bearer $OPENAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "gpt-4o-mini",
        "messages": [
          {"role": "system", "content": "Continue the user'\''s text with the next word only."},
          {"role": "user", "content": "The cat sat on the"}
        ],
        "max_tokens": 2,
        "logprobs": true,
        "top_logprobs": 5
      }'
  3. 3.Turn the bets into a surprise score

    Each token's surprise is minus its logprob. Average them and you have log-perplexity for that stretch of text; exp() of it is the perplexity. This scores the model's own output, which is a quick way to see where it was unsure.

    import math
    lps = [t.logprob for t in resp.choices[0].logprobs.content]
    log_ppl = -sum(lps) / len(lps)
    print("log-perplexity", round(log_ppl, 3), "perplexity", round(math.exp(log_ppl), 2))
  4. 4.Measure perplexity on your own text with an open model

    To score text you choose (not the model's own output), run an open model locally. Hugging Face's Transformers docs walk through it with GPT-2 large on WikiText-2: pass the text as both input and labels, the loss that comes back is the average negative log-likelihood, and exp(loss) is the perplexity. They use a sliding window so long text fits; with stride 1024 they get 19.44, with stride 512 they get 16.44.

    pip install torch transformers datasets
    
    import torch
    from transformers import AutoModelForCausalLM, AutoTokenizer
    mid = "openai-community/gpt2-large"
    tok = AutoTokenizer.from_pretrained(mid)
    model = AutoModelForCausalLM.from_pretrained(mid)
    ids = tok("Paste a paragraph of your own text here.", return_tensors="pt").input_ids
    with torch.no_grad():
        loss = model(ids, labels=ids).loss
    print("perplexity", torch.exp(loss).item())
  5. 5.Use it the right way: same text, same tokenizer

    Perplexity only compares fairly on the same held-out text, and ideally the same tokenizer. A good use at work: score a base model and your fine-tuned version on the same set of your own documents that neither trained on. Lower means it predicts your kind of text better. It won't tell you whether answers are right.

The fine print

  • Pachocki's limits are a proposal. No lab has agreed to a specific limit and no value has been set.
  • OpenAI's numbers are on held-out data from its own internal codebase, so they can't be compared directly with other labs' numbers. OpenAI lists this as a challenge.
  • Chain-of-thought reasoning makes models much more capable without lowering perplexity, so perplexity misses gains that come after pretraining.
  • Chat models are tuned to sound sure, so their logprobs are often close to 100% and are not the same as a base model's perplexity on held-out text.
  • Running GPT-2 large locally downloads a few gigabytes of weights. The API costs money per token; check OpenAI's pricing page.

FAQ

What is perplexity in AI, in plain words?

It's how surprised a language model is by text it has never seen, averaged over every token. Lower means the model predicted the text better.

What's the difference between perplexity and log-perplexity?

Log-perplexity is the average surprise (the average negative log probability), also called cross-entropy loss. Perplexity is e (or 2) raised to that number. OpenAI's published numbers like 0.99 and 0.91 are log-perplexity.

What numbers did OpenAI publish?

About 0.99 for GPT-3.5, about 0.91 for GPT-4, below 0.8 for its newest models, about 0.76 when its models started producing big math results, and it expects new abilities around 0.68 to 0.7. All on OpenAI's own internal code.

Can perplexity reach zero?

No. Zero would mean predicting the text perfectly, and real text has randomness in it. OpenAI says nobody knows where the floor is, and that near it small drops should mean big jumps in ability.

Can I compare perplexity across different models?

Only on the same text with the same tokenizer. Different eval sets or tokenizers give numbers that don't line up, which is the main challenge OpenAI lists for using it across labs.

Sources

2026-11-23 23:40 PT against OpenAI's Perplexity and Intelligence post, the OpenAI API reference, the Hugging Face perplexity docs, Wikipedia, and our own logprobs run (gpt-4o-mini via OpenRouter).

Want help building with tools like this?

Join the Shipping Skool community free. Paid members get live bootcamp calls every week and weekly-updated courses.

Join Shipping Skool

More free guides