Hallucination Entropy Analyzer
Estimate uncertainty from token probability distributions, entirely in your browser
About
Enter top-k token probabilities to inspect uncertainty with deterministic metrics and an SVG entropy graph. Includes confident, uncertain, and uniform scenarios. No data leaves your device.
Examples
Uniform four-way split
analyzeTokenDistributions([{ token: "x", probabilities: four 0.25 entries }]).metrics[0]{ entropy: 2, perplexity: 4 }log2(4) equals 2 bits of entropy and 2^2 gives a perplexity of 4.
Rejected probabilities
analyzeTokenDistributions([{ token: "x", probabilities: [{ token: "a", probability: 0.7 }] }]){ valid: false, errors: ["Token 1: probabilities must sum to 1 ..."] }A 0.7 total misses 1 by more than epsilon, so the position is invalid with zero entropy.
About this tool
Hallucination Entropy Analyzer scores top-k token distributions with analyzeTokenDistributions(distributions): each position's Shannon entropy (−Σ p·log2 p), perplexity (2^entropy), and surprise are computed, with cumulative and average entropy rolled up across valid positions.
Validation is strict and deterministic: every probability must be finite within 0–1 and each position must sum to 1 within 1e-9, otherwise the position reports entropy 0 with an explanatory error and the overall result sets valid false.
Example inputs come from scenarioDistributions(kind) — confident, uncertain, or uniform presets with fixed probability tables — so the same kind always analyzes to identical metrics.
How to use this tool
Supply distributions
Pass token positions with probability lists that sum to 1 — e.g. four 0.25 entries for maximum spread.
Read per-token metrics
Use entropy for uncertainty, perplexity for effective vocabulary size, and valid/error for rejected positions.
Compare scenarios
Run scenarioDistributions confident versus uncertain to see low versus high cumulative entropy side by side.
Use cases
Flagging uncertain generations
Treat high per-token entropy as a signal that the model is guessing between alternatives.
Comparing decoding settings
Contrast cumulative entropy across temperatures or prompts with identical distribution shapes.
Teaching entropy basics
Show log2(k) for uniform splits versus 0 for deterministic picks in an interactive demo.
Common mistakes
Mistake:Passing raw logits or unnormalized scores.
Fix:Normalize each position to sum to 1 first — anything else fails validation with a sum-to-1 error.
Mistake:Reading cumulative perplexity as a sum.
Fix:cumulativePerplexity is 2^cumulativeEntropy, not the sum of per-token perplexities.
Frequently asked questions
What does this tool do?
It scores top-k token distributions with analyzeTokenDistributions — per-token entropy, perplexity, and surprise plus cumulative totals — and ships confident, uncertain, and uniform presets via scenarioDistributions.
What do entropy and perplexity mean here?
Entropy is −Σ p·log2 p bits (2 for a uniform four-way split, 0 for a certain token) and perplexity is 2^entropy, the effective number of live alternatives.
Is my model output uploaded or stored?
No. Distribution math and validation run fully client-side.
Why was my distribution rejected?
Every probability must be finite within 0–1 and each position must sum to 1 within 1e-9 — otherwise the position is invalid with a sum-to-1 error, and an empty list is always invalid.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML