FA-98426 / Token sampling filters / Open access
Token sampling: Top-k probability mass is measured before candidate restriction · case 01
Top-k probability mass is measured before candidate restriction.
ROOT CAUSE
The nucleus cumulative mass is calculated over the full vocabulary before the top-k restriction.
THE FAILURE
The nucleus cumulative mass is calculated over the full vocabulary before the top-k restriction.
Unsuccessful approach: Using unnormalized exponentials as cumulative mass makes the threshold cease to represent a probability fraction.
Case contract
Select top k by descending score and lexical ties, normalize softmax over this restricted set, and retain its shortest prefix reaching p; p<=0 or k<=0 returns 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(scores, k, p):
import math
ranked=sorted(scores,key=lambda t:(-scores[t],t)); m=max(scores.values(),default=0)
ex={t:math.exp(v-m) for t,v in scores.items()}; z=sum(ex.values()); out=[]; total=0
for t in ranked:
total+=ex[t]/z; out.append(t)
if total>=p:break
return out[:max(0,k)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restricted mass',solve({'a':2.0,'b':1.0,'c':0.0},2,.68),['a'])
check('full retained mass',solve({'a':2.0,'b':1.0,'c':0.0},2,.8),['a','b'])
check('one candidate top k',solve({'a':N,'b':0.0},1,.5),['a'])
check('zero k',solve({'a':N},0,.5),[])
check('empty',solve({},2,.5),[])
check('zero target',solve({'a':N,'b':0.0},2,0),[])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| restricted mass | ['a', 'b'] | ['a'] | Failed |
| full retained mass | ['a', 'b'] | ['a', 'b'] | Passed |
| one candidate top k | ['a'] | ['a'] | Passed |
| zero k | [] | [] | Passed |
| empty | [] | [] | Passed |
| zero target | ['a'] | [] | Failed |
SHA-256 / ea343be9f1fb68d3a051275845d6fa9eabdb157b845e03dc108c5fc953d7e696
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(scores, k, p):
import math
ranked=sorted(scores,key=lambda t:(-scores[t],t))[:max(0,k)]; ex=[math.exp(scores[t]) for t in ranked]; out=[]; total=0
for t,v in zip(ranked,ex):
total+=v; out.append(t)
if total>=p:break
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restricted mass',solve({'a':2.0,'b':1.0,'c':0.0},2,.68),['a'])
check('full retained mass',solve({'a':2.0,'b':1.0,'c':0.0},2,.8),['a','b'])
check('one candidate top k',solve({'a':N,'b':0.0},1,.5),['a'])
check('zero k',solve({'a':N},0,.5),[])
check('empty',solve({},2,.5),[])
check('zero target',solve({'a':N,'b':0.0},2,0),[])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| restricted mass | ['a'] | ['a'] | Passed |
| full retained mass | ['a'] | ['a', 'b'] | Failed |
| one candidate top k | ['a'] | ['a'] | Passed |
| zero k | [] | [] | Passed |
| empty | [] | [] | Passed |
| zero target | ['a'] | [] | Failed |
SHA-256 / 35d644e5786b605522468077b405210052e2ecd36410350ef5ecd99cfc844624
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.803371+00:00.
Case digest / 96cdd7562cf2a434147aee668f1ae5a0ecb2eecb5fd29be899a04364241a85ee