oobabooga/textgen · error · ValueError
`mirostat` has to be a an integer 2, but is {mirostat_mode}
Error message
`mirostat` has to be a an integer 2, but is {mirostat_mode} What it means
Error "`mirostat` has to be a an integer 2, but is {mirostat_mode}" thrown in oobabooga/textgen.
Source
Thrown at modules/sampler_hijack.py:427
if next_token in match_lengths:
match_lengths[next_token] = max(match_length, match_lengths[next_token])
else:
match_lengths[next_token] = match_length
# Apply penalties.
for token, match_length in match_lengths.items():
if match_length >= self.allowed_length:
penalty = self.multiplier * self.base ** (match_length - self.allowed_length)
scores_row[token] -= penalty
return scores
class MirostatLogitsWarper(LogitsProcessor):
def __init__(self, mirostat_mode: int, mirostat_tau: float, mirostat_eta: float, filter_value: float = -float("Inf"), min_tokens_to_keep: int = 1):
if mirostat_mode not in [2]:
raise ValueError(f"`mirostat` has to be a an integer 2, but is {mirostat_mode}")
self.mirostat_mode = mirostat_mode
self.mirostat_eta = mirostat_eta
self.mirostat_tau = mirostat_tau
self.filter_value = filter_value
self.min_tokens_to_keep = min_tokens_to_keep
self.mu = 2 * self.mirostat_tau
self.e = 0
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
logits = scores[0]
sorted_logits, sorted_indices = torch.sort(logits, descending=True)
prob_original = torch.softmax(sorted_logits, dim=-1).tolist() # candidates
# Truncate the words with surprise values greater than mu
for i, candidate in enumerate(prob_original):
if candidate > 0 and -math.log2(candidate) > self.mu:
if (i == 0):View on GitHub (pinned to ed888c71f2)
Solutions
- Set mirostat mode to 0 (disabled), 1 (Mirostat 1.0), or 2 (Mirostat 2.0).
When it happens
Trigger: Raised during sampler validation when `mirostat` mode is not the integer 2. This build only supports mirostat mode 2; triggers when mirostat is set to 1, or a non-integer value is supplied.
Common situations: See trigger scenarios.
AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15).
Data as JSON: /api/errors/2490320c2502e6dc.
Report an issue: GitHub.