FAILURE MAP
← Case archive

FA-98366 / Token sampling filters / Open access

Token sampling: Typical sampling ranks by raw surprisal distance · case 01

Typical sampling ranks by raw surprisal distance.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Typicality uses distance from surprisal zero instead of distribution entropy.

THE FAILURE

Typicality uses distance from surprisal zero instead of distribution entropy.

Unsuccessful approach: Using a strict mass threshold fails when the included probabilities land exactly on the requested mass.

Case contract

Compute entropy H=-sum(p log p), rank by abs(-log(p)-H) then token ID, and return the shortest nonempty prefix whose probability mass reaches mass; empty candidates return empty.

Why this case matters

A finite, deterministic token-selection contract isolates one decoding operation from model inference and runtime behavior.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(probabilities, mass):
    import math
    ranked=sorted((t for t,p in probabilities.items() if p>0),key=lambda t:(abs(-math.log(probabilities[t])),t)); out=[]; s=0
    if not ranked:return []
    for t in ranked:
        out.append(t); s+=probabilities[t]
        if s>=mass: break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entropy-centered selection',solve({'a':.5,'b':.3,'c':.2},.6),['b','a'])
check('uniform',solve({'a':.5,'b':.5},.5),['a'])
check('empty',solve({},.5),[])
check('zero mass retains leading candidate',solve({'a':1.0},0),['a'])
check('zero probability ignored',solve({'a':1.0,'z':0},.5),['a'])
check('full mass',solve({'a':.7,'b':.3},1),['a','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
entropy-centered selection['a', 'b']['b', 'a']Failed
uniform['a']['a']Passed
empty[][]Passed
zero mass retains leading candidate['a']['a']Passed
zero probability ignored['a']['a']Passed
full mass['a', 'b']['a', 'b']Passed

SHA-256 / f58b039520c5070a58595ecaa4141785d754897a2f7a6a465f5bd9212d4b933c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(probabilities, mass):
    import math
    H=-sum(p*math.log(p) for p in probabilities.values() if p>0)
    ranked=sorted((t for t,p in probabilities.items() if p>0),key=lambda t:(abs(-math.log(probabilities[t])-H),t)); out=[]; s=0
    if not ranked:return []
    for t in ranked:
        out.append(t); s+=probabilities[t]
        if s>mass: break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entropy-centered selection',solve({'a':.5,'b':.3,'c':.2},.6),['b','a'])
check('uniform',solve({'a':.5,'b':.5},.5),['a'])
check('empty',solve({},.5),[])
check('zero mass retains leading candidate',solve({'a':1.0},0),['a'])
check('zero probability ignored',solve({'a':1.0,'z':0},.5),['a'])
check('full mass',solve({'a':.7,'b':.3},1),['a','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
entropy-centered selection['b', 'a']['b', 'a']Passed
uniform['a', 'b']['a']Failed
empty[][]Passed
zero mass retains leading candidate['a']['a']Passed
zero probability ignored['a']['a']Passed
full mass['a', 'b']['a', 'b']Passed

SHA-256 / 3b402f7403aa19fc1cce5f18aae6d029699e5b2c06780f4ab02b74231193c166

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

These are toy finite-vocabulary contracts with supplied scores, histories, and draws; they do not claim production model quality or compatibility. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-30T16:48:12.370814+00:00.

Case digest / fa2f63ee4b8eb3126ada8615e786a079e41c858b7e5ac27e0a32f4f11fe2bcba