Character-Level Plausibility Constraints for Byte-Level Decoding

Language models that tokenize raw bytes can read any script. They can also write broken text. A single Chinese character or emoji is often split across two or three vocabulary entries, and each piece is a byte fragment that is not a character on its own. The model chooses these pieces one at a time. It can pick a fragment that no later piece completes, or it can pick pieces that assemble into a valid but wrong character. The same flaw surfaces during streaming, where fragments are sent to the user as they are produced. This note proposes deciding at the level of whole characters instead. At each step, the decoder sums probability over all the token paths that spell each possible next character. It then applies a "plausibility floor" to those character-level probabilities: any character much less likely than the most likely one is discarded before sampling or steering. Because the decoder only releases complete characters, streamed output is always valid UTF-8 and identical to batch output.

The motivation is a byte-level version of what the multimodal literature calls the understanding–generation gap: a model that recognizes something correctly but fails to produce it. We conjecture that byte-level models already "know" the right rare character, meaning they rank it highest when asked to score complete candidates. Free generation fails to produce it because fragment-by-fragment choices spread and misplace probability. If this conjecture holds, part of the rare-character failure is a decoding artifact that can be fixed at inference time without retraining. If it does not hold, we learn that the failure lives in the model's knowledge, and the proposal should say so quickly.

Core Claim

Our first claim is diagnostic. On rare and multi-byte characters, a model's scoring accuracy (the gold character outranks same-length distractors under teacher forcing) substantially exceeds its generation accuracy (free decoding produces the gold character).

Our second claim is causal. Two token-level mechanisms produce much of this difference. First, the probability of the correct character is split across a shared leading fragment and many possible completions. Second, the standard fixes hurt in specific ways. A token-level plausibility floor, as in DoLa and DIRECTER, compares a fragment's probability against whole-token competitors, so it can prune the right continuation. A validity mask, as in SynCode, simply renormalizes over whatever is left. A decoder that operates on character-level probabilities should close most of the gap.

The contrast with prior work is precise. UTF-8 Plumbing guarantees validity with a byte-level finite-state checker but has no notion of which valid character is plausible. Canonical BPE reclaims probability wasted on nonstandard segmentations but explicitly does not guarantee UTF-8 validity. The DoLa and DIRECTER plausibility floors operate on tokens and are blind to whether a token is a byte fragment. Our decoder combines validity, character-level probability and a plausibility floor in one decision rule.

Mechanism

We track a small byte-level automaton $s_t$, the UTF-8 state after the text emitted so far, which records whether we are mid-character and how many continuation bytes are owed. At a character boundary, let $P(c \mid x)$ be the probability that the next complete character is $c$ given context $x$. It is the sum over all token paths $\pi$ whose bytes spell exactly $c$ (plus any trailing bytes that belong to the following character, which are carried forward):

$$P(c \mid x) = \sum_{\pi \,:\, \mathrm{bytes}(\pi) \text{ begins with } c} \; \prod_{j} p(\pi_j \mid x, \pi_{<j}).$$

UTF-8 characters are at most four bytes long, so the paths are short. The automaton prunes any fragment that cannot extend to a valid character. We approximate the sum with a width-$K$ expansion over fragments, and we report how large $K$ must be for the approximation to stop changing results.

The plausibility floor is DoLa's rule lifted from tokens to characters:

$$\mathcal{C}_{\text{plaus}} = \{c : P(c \mid x) \ge \alpha \max_{c'} P(c' \mid x)\}.$$

Here $\alpha \in (0,1)$ is the relative floor. Any steering or contrast method (DoLa's layer contrast, a DIRECTER-style activation nudge) is then applied only inside $\mathcal{C}_{\text{plaus}}$ and scored at the character level. The character is emitted to the output stream only once it is complete, which makes incremental detokenization exact by construction.

For ASCII text, a character is a single byte and almost always a single token. In that case the method reduces to ordinary token decoding and costs almost nothing extra.

Research Program

The work proceeds in three stages.

The first stage measures the byte-level understanding–generation gap. We use ByteCanary's Common, Uncommon, Rare and Unseen tiers in both of its modes: Level 0, which completes a byte prefix with no context, and Level 1, which completes a character inside a sentence. For each item we compute scoring accuracy against distractors that have the same byte length and share the same leading byte. Sharing the leading byte isolates the completion decision. We also compute generation accuracy using ByteCanary's Term Match (semantic correctness of the generated character) and its strict validity check. The gap is defined as $\Delta = \text{scoring accuracy} - \text{Term Match}$.

The second stage attributes the gap. We log where free decoding goes wrong: wrong leading fragment, correct lead with a wrong completion, or an invalid sequence. We also measure how often a token-level $\alpha$ floor prunes the gold continuation.

The third stage builds and evaluates the character-level decoder under two conditions. The first is plain sampling. The second is steered decoding: DoLa on ByteCanary Level 1 and on non-Latin contexts, and a DIRECTER-style nudge. Steering is where we expect the floor to matter most. Subtracting an "amateur" or early-layer distribution rewards whatever the amateur disfavors, and a model with little training on raw bytes strongly disfavors exactly these byte fragments.

Models are chosen from the open-weight sets the file already evaluates. We use Llama 3.2 and Qwen 3.5 from ByteCanary's cross-model study, and Llama-3.1-8B-Instruct and Mistral-Nemo from Improbable Bigrams. This brings the question to the 7B+ scale that ByteCanary lists as open.

The multimodal version of the gap is a lens here, not a target. We do not claim anything about image generation. We do record whether the diagnostic transfers: whether the gap Moon et al. report as a two-fold validity lag behaves like the recognition–production asymmetry that GAPEVAL documents in unified image models.

Baselines

The naive reference point is unconstrained sampling followed by replacing invalid bytes with U+FFFD, the Unicode replacement character. It shows the raw gap. It is known to corrupt meaning and to break downstream tools.

The strongest competitor on validity is byte-level constrained decoding in the SynCode style from UTF-8 Plumbing. This decoder masks every token that would produce ill-formed UTF-8 and renormalizes over the rest. On the TweetEval emoji subset, it raised accuracy from 0% to 62% and cut the crash rate from 100% to 0%. It already achieves full validity, so our method must beat it on correctness. The target is Term Match on ByteCanary and emoji accuracy on TweetEval, with validity held at 100%. Beating the reported 62% emoji accuracy under the same prompts and model would count as a win.

The second competitor is canonical BPE masking, using its local bigram approximation, both alone and combined with the validity mask. It may improve correctness by concentrating probability on standard segmentations. For it, the file reports only lower log-loss on PTB and WikiText with no raw figures, so there is no reported result on Lacuna for canonical masking on ByteCanary.

For ByteCanary itself, the reference numbers are the roughly 60% Term Match plateau, 86.97% partial validity on unseen characters for the 355M model, and a gap of up to 65 points between partial and strict validity across open-weight models, all reported by Moon et al.. Those figures come from their models. We will re-run every baseline on our checkpoints rather than compare across papers.

For steered decoding, the baselines are DoLa with its token-level floor (reported gains of 12 to 17 absolute points on TruthfulQA for LLaMA-65B and LLaMA-7B) and DIRECTER's rejection floor. Both are run on the same contexts with $\alpha$ and $\beta$ tuned on the same held-out split and with the same tuning budget as ours.

The key ablation removes the plausibility floor but keeps exact character marginalization. The companion ablation keeps the floor but applies it to tokens combined with the validity mask. Together they separate the two ingredients. All methods use identical prompts, models, sampling temperature and a matched grid of hyperparameter settings, and we report wall-clock overhead alongside accuracy.

Why not just…?

Why not just mask invalid tokens with a byte automaton? It fixes validity completely and is the main threat on that axis. It does nothing about which valid character wins. Renormalizing after masking hands the pruned probability to whatever completions survive, and those survivors can be wrong characters. Stage two's error attribution measures directly how many masked-decoder errors are "valid but wrong." If that share is small and Term Match matches ours, the character-level machinery is unnecessary, and we will report that result.

Why not just sum over character completions exactly and skip the plausibility floor? This is a real threat for plain sampling. There, correct character probabilities may be all that is needed, and the floor may add nothing. We expect the floor to earn its place only under steering and contrast, where DoLa and Yuan et al. show that subtracting a weaker distribution inflates junk. The floor-free ablation, run in both the plain and steered regimes, settles this. We will scope the claim to whichever regime the evidence supports.

Why not just re-segment inputs or use canonical tokenization? Alternative pre-segmentation reduced hallucinations on improbable bigrams by 98% for Mistral-Nemo in Jang et al.. That fix acts on the input side, however. It does not govern what the model emits. Canonical masking also leaves invalid output possible, as its authors state. We include both as baselines and combinations. If canonical masking combined with the validity mask closes $\Delta$, our decoder is redundant.

Why not just scale the model? UTF-8 Plumbing proves that any vocabulary containing byte fragments permits invalid output regardless of model size. Moon et al. find that larger vocabularies can do worse on rare characters. Our cross-size comparison within the Qwen and Llama families reports $\Delta$ as a function of scale.

Decisive Checks

The first check is whether $\Delta$ is large. If teacher-forced scoring accuracy on the Rare and Unseen tiers exceeds Term Match by at least 15 points, the premise holds. If it is near zero, the failure is one of knowledge, not decoding, and the method is not worth building.

The second check is whether character-level decoding recovers most of $\Delta$ on 4-byte characters. These characters, such as rare CJK ideographs and emojis, are where Moon et al. find models collapsing into memorized templates.

The third check is whether, under DoLa steering, the token-level floor produces measurably more invalid or wrong characters than the character-level floor at matched TruthfulQA-style gains on English. This check tests that the fix costs nothing where characters are single bytes.

The fourth check is whether streamed output equals batch output exactly, and whether the added latency stays within the 16% overhead DIRECTER reports for its own rejection loop.