Up nextNext guide
Repetition Penalty and Decoding Controls
Language AI
Language AI GUIDE
Mirostat is a feedback-based decoding algorithm that aims to regulate the average surprisal of generated tokens toward a target.
Listen to this guideAI-narrated · ~2 min
In its standard formulation tau specifies a target cross-entropy in bits, corresponding to perplexity 2^tau; it adjusts a truncation threshold, without guaranteeing every passage’s perplexity or factual correctness.
Standard top-k and top-p decoding apply fixed cutoffs, while the predictability of generated text can vary across a passage. Mirostat, proposed by Basu and colleagues in 2020, treats decoding as a feedback-control problem. In the standard formulation, tau is a target average surprisal or cross-entropy in bits; the corresponding perplexity is 2^tau. The sampler measures token surprisal and adjusts a truncation threshold based on the difference from the target. If generated tokens are less surprising than the target, the threshold can be loosened; if they are more surprising, it can be tightened. This aims to regulate average surprise over generation and does not require each token or passage to match the target exactly. It does not measure factual correctness.
Keeping long story or roleplay generations in local LLM apps like KoboldAI from collapsing into repetitive loops.
Exposed in llama.cpp and Ollama as mirostat settings (mode 1 or 2, tau, eta) for hobbyists tuning output quality.
Stabilizing chatbot responses so they neither repeat phrases nor veer into incoherent tangents over a long session.
Used by writers who want a consistent level of creativity across an entire generated passage rather than fluctuating quality.
Mirostat options are exposed in some local inference tools; llama.cpp, for example, documents mode, tau and eta parameters. Availability and behavior depend on the runtime and version. Its control-theoretic framing is inspiring further adaptive decoders that regulate other signals like factuality or diversity. As long-form generation grows, expect feedback-driven sampling to be combined with retrieval and repetition penalties, and possibly auto-tuned tau values that adapt to genre, replacing manual perplexity targets.
Free newsletter
One short email each weekday with the three AI stories that actually matter. Free forever, no ads.
One email each weekday. Unsubscribe in one click. We never sell or share your address.
Test yourself
Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.
Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation
Mirostat is a feedback-based decoding algorithm that aims to regulate the average surprisal of generated tokens toward a target. In its standard formulation tau specifies a target cross-entropy in bits, corresponding to perplexity 2^tau; it adjusts a truncation threshold, without guaranteeing every passage’s perplexity or factual correctness.
Mirostat uses feedback to adjust its sampling threshold toward a target surprise or perplexity level.
Top-k and top-p apply a fixed threshold, while Mirostat continuously adjusts its truncation based on observed surprise, like a control system.
Eta is the learning rate; it scales how strongly the control variable mu is updated in response to the error between observed and target surprisal.
Mirostat 2 removes reliance on Zipf's-law assumptions used in version 1, making the algorithm simpler and more broadly reliable across models.
llama.cpp documents a Mirostat mode plus tau and eta parameters for its sampling implementation.
Keep learning
More guides picked for this topic
Up nextNext guide
Repetition Penalty and Decoding Controls
Language AI