Restoring rare-word tails clipped by alignment and min_p
Chat-tuned models collapse the >5-nat probability tail by 50x–107x in their final layers, and
min_p/top_p then truncate whatever survives. GRAIL separates mid-word spelling
from word-start selection, constrains repetition within a Fisher–Rao KL ball, and adds 0.18 ms/tok
(99.3% of native min_p throughput) on unmodified open weights.
Unedited Side-by-Side Transcripts
The ten unedited transcripts below (side-by-side, stock Qwen3.6-35B,
Gemma-4-12B-it, and Meta-Llama-3.1-8B) share one prompt; only the sampler
differs (min_p vs. GRAIL).
Logit-Space Pipeline
Five stateful transforms executed between the final linear projection and the multinomial draw. Zero weight edits.
Subword vs. Word-Boundary Split
When continuation is true, min_p=0.02 and T=0.72 keep spelling and word
fragments intact across the boundary. When continuation is false, min_p is skipped and only
a 9.5-nat far-tail floor is applied, letting rare words stay selectable.
Fisher–Rao KL Anti-Echo
Step 2 tracks running counts for recent tokens, 5-character stems, sentence-opener classes, and fast/slow
128-dim lm_head embeddings. It combines these penalties via Gram-Schmidt orthogonal to
prompt embeddings, then rescales so KL divergence stays under kl_budget (0.24).
Rolling Surprisal Thermostat
Step 3 maintains a rolling mean surprisal over the last 64 tokens. The word-start temperature is
increased when this mean falls below 2.15 nats and decreased when it exceeds
2.68 nats.
Structural Habit Damping
Word-start masks damp contrastive antithesis triggers, colons/semicolons within a 28-token cooldown, stock discourse openers, non-prompt nominalizations outside quotes, and premature EOS or byline headers. Quote parity disables lexical penalties inside quoted speech.
Contrastive & Tiny-Draft SC
Subtract logits from the chat/textbook negative stream gated by JSD and an asymmetric plausibility gate
(boost_min_p=0.015) so positive boosts only apply to tokens the target model already
supports. Pairing a 35B target with a 0.6B zero-sync sparse drafter runs at 39 to 52 tok/s on Apple
Silicon.
Fine-Tuned Models: Artaud + GRAIL
Stock RLHF checkpoints concentrate probability mass on a narrow set of stylistic patterns, driving many expressions to near-zero probability before sampling begins. GRAIL on Artaud (fine-tuned from Inkling-2-Mini) operates across a distribution that preserves rare syntax and vocabulary, eliminating self-echo and clearing all four detectors (Desklib <1%, TMR <2%, ModernBERT <3%, Mesmer up to 96.5% human).
Empirical Benchmarks
Unmodified Qwen3.6-35B-A3B, Gemma-4-12B-it, and
Meta-Llama-3.1-8B-Instruct across four independent detectors, blind cross-family judges,
3-seed runs, throughput measurements, and an 80-question verifiable QA harness.
| Sampler (Qwen3.6-35B-A3B) | Speed | Mesmer Human (Peak) | Desklib AI% | TMR AI% | ModBERT AI% | Stem Echo | Anti (12) | Judge A/C/N | Blind A/B |
|---|---|---|---|---|---|---|---|---|---|
| min_p (T=0.8, min_p=0.05) | 48.2 tok/s | 0.0% (0.0%) | 100.0% | 97.7% | 86.7% | 0.325 | 5 | 7.6 / 8.9 / 5.5 | baseline |
| Fast-SMC (B=4 → 1 at 100t) | 36.3 tok/s | 0.6% (2.1%) | 52.8% | 71.0% | 49.0% | 0.192 | 2 | 8.1 / 8.4 / 5.8 | 7W – 5L |
| Cross-Frame GRAIL-SC (B=2) | 35.2 tok/s | 47.0% (99.4%) | 53.9% | 59.0% | 32.7% | 0.197 | 0 | 7.1 / 7.2 / 6.3 | 8W – 3L – 1T |
| Dual-Failure + Surge + Fork | 31.0 tok/s | 35.7% (99.9%) | 42.5% | 59.5% | 29.4% | 0.212 | 1 | 8.6 / 8.3 / 8.2 | 9W – 3L |
| Tiny-Draft + Plausibility (3-seed, n=36) | 51.6 ± 1.0 | 45.0 ± 2.9% (99.9%) | 55.0 ± 9.8% | 49.2 ± 6.0% | 33.4 ± 3.6% | 0.232 | 0 (1/36) | 7.3 / 7.1 / 7.2 | 7W – 5L |
| Tiny-Draft + Plausibility + S1 Fork (3×28) | 39.2 tok/s | 28.7% (99.7%) | 39.2% | 58.3% | 39.4% | 0.185 | 0 | 9.2 / 9.2 / 7.1 | 10W – 2L |
| Sparse Draft-Contrast (4B, n=12) | 23.7 tok/s | 45.7% (98.3%) | 47.3% | 54.5% | 20.2% | 0.193 | 0 | 6.9 / 6.9 / 6.6 | 6W – 5L – 1T |
| Model & Sampler (Native Chat Turn) | Speed | Words | Desklib AI% | TMR AI% | ModBERT AI% | Stem Echo | Judge A/C/N | Blind A/B |
|---|---|---|---|---|---|---|---|---|
| Gemma-4-12B-it (min_p, n=8) | 44.0 tok/s | 264 | 99.8% | 96.5% | 96.4% | 0.250 | 8.6 / 8.6 / 8.0 | baseline |
| Gemma-4-12B-it (In-Turn GRAIL-SC, B=2) | 35.0 tok/s | 308 | 60.9% | 49.7% | 37.1% | 0.144 | 8.8 / 8.2 / 9.0 | 7W – 1L |
| Gemma-4-12B-it (In-Turn GRAIL-SC + Fork) | 29.4 tok/s | 308 | 68.1% | 53.8% | 33.7% | 0.167 | 8.9 / 9.0 / 8.9 | 7W – 1L |
| Llama-3.1-8B-Instruct (min_p, n=12) | 78.0 tok/s | 298 | 100.0% | 96.1% | 98.7% | 0.296 | 9.2 / 9.2 / 7.4 | baseline |
| Llama-3.1-8B-Instruct (In-Turn GRAIL-SC, B=2) | 53.5 tok/s | 303 | 60.5% | 57.4% | 22.5% | 0.133 | 7.7 / 6.6 / 6.5 | 8W – 4L |
| Sampler (Stock Qwen3.6-35B-A3B, 4 Prompts) | Speed | Mesmer Human (Peak) | Desklib AI% | TMR AI% | ModBERT AI% | Tail >5 nats | Stem Echo | Anti (4) | Judge A/C/N |
|---|---|---|---|---|---|---|---|---|---|
| min_p (Nguyen et al. 2024) | 41.3 tok/s | 0.0% (0.0%) | 99.5% | 71.3% | 74.7% | 0.0% | 0.284 | 3 | 9.0 / 10.0 / 8.5 |
| top_p (Holtzman et al. 2020) | 42.6 tok/s | 0.0% (0.0%) | 99.7% | 95.2% | 75.2% | 1.2% | 0.348 | 2 | 9.5 / 9.5 / 9.2 |
| DRY (Repetition Penalty) | 41.1 tok/s | 0.0% (0.0%) | 94.3% | 71.6% | 50.4% | 0.0% | 0.309 | 3 | 7.5 / 9.2 / 7.8 |
| Typical (Meister et al. 2023) | 40.8 tok/s | 3.5% (14.0%) | 62.8% | 58.6% | 74.7% | 4.1% | 0.283 | 0 | 9.0 / 9.8 / 8.5 |
| XTC (Standalone) | 41.1 tok/s | 17.0% (67.9%) | 80.8% | 74.7% | 74.3% | 6.7% | 0.239 | 0 | 7.8 / 8.8 / 7.8 |
| Eta (Hewitt et al. 2022) | 40.6 tok/s | 18.9% (70.8%) | 73.6% | 65.5% | 3.3% | 12.7% | 0.242 | 0 | 8.0 / 9.0 / 8.8 |
| GRAIL-SC (Batched B=2, Anchor) | 33.9 tok/s | 14.9% (55.1%) | 17.6% | 28.0% | 1.8% | 15.2% | 0.288 | 0 | 7.5 / 8.5 / 7.8 |
| GRAIL-SMC (Sentence-Aligned B=4) | 20.5 tok/s | 29.3% (89.6%) | 62.4% | 76.4% | 74.1% | 14.6% | 0.238 | 0 | 8.0 / 8.0 / 7.8 |
| GRAIL-SC-SMC (Sentence-Aligned K=3, B=6) | 18.6 tok/s | 24.8% (98.8%) | 25.7% | 41.5% | 2.7% | 11.8% | 0.201 | 0 | 8.0 / 8.5 / 8.0 |
| Mode (Apple Silicon MLX, JL-128 63.6–67.1 MB) | Qwen3.6-35B (MoE) | Gemma-4-12B (Dense) | Artaud (Inkling-2) | Notes |
|---|---|---|---|---|
| min_p (T=0.8, min_p=0.05) | 40.5 tok/s (100%) | 42.4 tok/s (100%) | 51.3 tok/s | Bare mlx-lm baseline |
| Standard GRAIL (single-stream) | 40.2 tok/s (99.3%) | 36.0 tok/s (84.9%) | 54.0 tok/s | 0.18 ms/tok overhead on Qwen3.6; 3.19 ms/tok on PyTorch MPS (V=151k) |
| Standard GRAIL + B=4 opening fork | 33.5 tok/s (82.7%) | 31.8 tok/s (75.0%) | — | Native B=1 KV cache; merges only at forks |
| GRAIL-SC (batched B=2) | 33.9 tok/s (83.7%) | 32.0 tok/s (75.5%) | — | Positive + contrastive stream in one pass; 3.70 ms/tok on PyTorch MPS |
| Tiny-Draft Sparse Contrast (35B + 0.6B) | 51.6 ± 1.0 tok/s | — | — | Zero-sync syntax-gated skipping; 39.2 tok/s with S1 fork (10W–2L A/B) |
| Fast-SMC (B=4 → B=1 at 100 tok) | 36.3 tok/s | — | — | +77% faster than full-length B=4 SMC |
| GRAIL-SMC (full-length B=4) | 20.5 tok/s (50.6%) | 24.1 tok/s (56.8%) | — | 4 parallel trajectories |
| GRAIL-SC-SMC (full-length K=3, B=6) | 18.6 tok/s (45.9%) | 17.1 tok/s (40.3%) | — | 3 dual-contrastive trajectories (6 streams) |
| Model (40 Math + 40 Factual QA, Exact-Match Parser) | Sampler | Total Correct | Accuracy | Factual Slice |
|---|---|---|---|---|
| Qwen3.6-35B-A3B | min_p (T=0.8, min_p=0.05) | 29 / 40 | 72.5% | 19 / 20 |
| Qwen3.6-35B-A3B | GRAIL (goldilocks) | 30 / 40 | 75.0% | 19 / 20 |
| Meta-Llama-3.1-8B-Instruct | min_p (T=0.8, min_p=0.05) | 34 / 40 | 85.0% | 19 / 20 |
| Meta-Llama-3.1-8B-Instruct | GRAIL (goldilocks) | 33 / 40 | 82.5% | 19 / 20 |
| Combined (80 Verifiable Questions) | GRAIL vs. min_p | 63 / 80 vs. 63 / 80 | 78.8% (Exact Parity) | 38 / 40 (95.0%) |
Runtime Integrations
It depends only on numpy. PyTorch or MLX are lazy-loaded inside the sampler and remain
unimported unless actually used. grail-sampler drops into HuggingFace Transformers, MLX, vLLM,
llama.cpp (native C++17), oMLX, and SGLang without truncation at the downstream boundary.
GrailLogitsProcessor, batched generate_sc(), and cross-tokenizer generate_draft_sc() on CPU, CUDA, and MPS (3.19 ms/tok on MPS).llama_sampler_init_grail() header verified against upstream llama.h, plus Python bindings.LogitsProcessor adapters with lazy imports and multi-turn reset hooks.CustomLogitProcessor pipelines, plus speculative verify_draft_batch().grail-demo)min_p vs. GRAIL runs on any local or HuggingFace checkpoint across MLX and PyTorch.