FAILURE MAP
← Case archive

FA-98351 / Token sampling filters / Open access

Token sampling: Nucleus threshold is applied to unnormalized weights · case 01

Nucleus threshold is applied to unnormalized weights.

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

ROOT CAUSE

The comparison is against raw cumulative weight rather than normalized probability.

THE FAILURE

The comparison is against raw cumulative weight rather than normalized probability.

Unsuccessful approach: Normalizing weights but retaining a strict threshold mishandles an exact cumulative boundary.

Case contract

Normalize nonnegative weights by their total, then retain the shortest descending-weight prefix reaching p; empty or zero-total inputs 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(weights, p):
    ranked=sorted(weights,key=lambda t:(-weights[t],t)); out=[]; mass=0
    for t in ranked:
        mass+=weights[t]; out.append(t)
        if mass>=p: break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scaled weights',solve({'a':6*N,'b':3*N,'c':N},.8),['a','b'])
check('exact first mass',solve({'a':N,'b':N},.5),['a'])
check('zero target',solve({'a':N},0),[])
check('empty',solve({},.5),[])
check('zero total',solve({'a':0,'b':0},.5),[])
check('threshold above one',solve({'a':N,'b':N},1.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
scaled weights['a']['a', 'b']Failed
exact first mass['a']['a']Passed
zero target['a'][]Failed
empty[][]Passed
zero total['a', 'b'][]Failed
threshold above one['a', 'b']['a', 'b']Passed

SHA-256 / d5c312ad0a2a734bb6755997c15ce7dba37d4d8bb57f9491595f96b225653397

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(weights, p):
    total=sum(weights.values()); ranked=sorted(weights,key=lambda t:(-weights[t],t)); out=[]; mass=0
    for t in ranked:
        mass+=weights[t]/total if total else 0; out.append(t)
        if mass>p: break
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scaled weights',solve({'a':6*N,'b':3*N,'c':N},.8),['a','b'])
check('exact first mass',solve({'a':N,'b':N},.5),['a'])
check('zero target',solve({'a':N},0),[])
check('empty',solve({},.5),[])
check('zero total',solve({'a':0,'b':0},.5),[])
check('threshold above one',solve({'a':N,'b':N},1.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
scaled weights['a', 'b']['a', 'b']Passed
exact first mass['a', 'b']['a']Failed
zero target['a'][]Failed
empty[][]Passed
zero total['a', 'b'][]Failed
threshold above one['a', 'b']['a', 'b']Passed

SHA-256 / ca3ae74f7b4741d55d72c1930a6040deedf6991c78d6be08989723054952240d

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:11.933257+00:00.

Case digest / abf3a76c028ac954017f3f473ede52013673600a8ce99802077b5dd3899f116a