AI Security

Perplexity Calculator

Convert between a language model cross-entropy loss and perplexity, a core measure of how well a model predicts text.

Last reviewed by the Radiatus Cloud team

Convert between language-model cross-entropy loss and perplexity.

Securing AI in production?

We build guardrails, governance & compliance for AI systems.

Talk to an AI advisor

Convert loss and perplexity

Perplexity is a standard measure of how well a language model predicts text, and it is the exponential of the cross-entropy loss. This tool converts between the two: given a cross-entropy loss in nats, it computes the perplexity as e raised to that loss, and given a perplexity, it recovers the loss as the natural logarithm. A cross-entropy loss of two nats corresponds to a perplexity of about 7.4.

Intuitively, a perplexity of N means the model is, on average, as uncertain about the next token as if it were choosing uniformly among N equally likely options.

Why perplexity matters

Perplexity is widely reported when training and comparing language models, with a lower value meaning the model predicts the text more confidently and accurately. Because loss is what the model optimises during training while perplexity is the more interpretable number, converting between them is a routine task. The tool also shows the loss in bits, which is the base-two version sometimes used instead of nats.

Perplexity is only comparable across models evaluated on the same data and tokenisation, so treat absolute values with care. All calculation happens locally in your browser.

Related tools

Frequently Asked Questions

What is perplexity?

It is the exponential of the cross-entropy loss, measuring how uncertain a language model is about the next token, with lower being better.

How are loss and perplexity related?

Perplexity equals e raised to the cross-entropy loss in nats, and the loss equals the natural logarithm of the perplexity.

What does a perplexity of N mean?

The model is on average as uncertain as if choosing uniformly among N equally likely options for each token.

What is the difference between nats and bits?

Nats use the natural logarithm and bits use base two. Loss in bits equals loss in nats divided by the natural log of two.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Enter a cross-entropy loss to get perplexity, or vice versa.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.