FAILURE MAP
← Case archive

FA-98406 / Token sampling filters / Open access

Token sampling: Bad-word sequence filter checks only the final token · case 01

Bad-word sequence filter checks only the final token.

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

ROOT CAUSE

Only candidate identity is compared with the final element, without matching the preceding prefix.

THE FAILURE

Only candidate identity is compared with the final element, without matching the preceding prefix.

Unsuccessful approach: Checking only the immediately previous prefix token misses banned sequences with longer prefixes.

Case contract

Remove a candidate when prefix plus that candidate ends with any complete banned token sequence.

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(prefix, candidates, banned_sequences):
    return sorted(t for t in candidates if not any(seq and t==seq[-1] for seq in banned_sequences))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multi token ban',solve(['a','b'],['c','x'],[['a','b','c']]),['x'])
check('unrelated same end',solve(['q'],['c'],[['a','b','c']]),['c'])
check('single token ban',solve([],['x','y'],[['x']]),['y'])
check('empty candidate',solve(['a'],[],[['a','b']]),[])
check('empty ban rule',solve([],['x'],[[]]),['x'])
check('prefix longer',solve(['u','a','b'],['c'],[['a','b','c']]),[])
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
multi token ban['x']['x']Passed
unrelated same end[]['c']Failed
single token ban['y']['y']Passed
empty candidate[][]Passed
empty ban rule['x']['x']Passed
prefix longer[][]Passed

SHA-256 / f02d44aef5546621d266b2c9e2c2499002f1e4384c8e1cc6ab98eb35be05ddc3

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(prefix, candidates, banned_sequences):
    return sorted(t for t in candidates if not any(seq and prefix[-1:]+[t]==seq for seq in banned_sequences))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multi token ban',solve(['a','b'],['c','x'],[['a','b','c']]),['x'])
check('unrelated same end',solve(['q'],['c'],[['a','b','c']]),['c'])
check('single token ban',solve([],['x','y'],[['x']]),['y'])
check('empty candidate',solve(['a'],[],[['a','b']]),[])
check('empty ban rule',solve([],['x'],[[]]),['x'])
check('prefix longer',solve(['u','a','b'],['c'],[['a','b','c']]),[])
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
multi token ban['c', 'x']['x']Failed
unrelated same end['c']['c']Passed
single token ban['y']['y']Passed
empty candidate[][]Passed
empty ban rule['x']['x']Passed
prefix longer['c'][]Failed

SHA-256 / b622aa523f15d7e666066ac31582bb514c609f3cfe34ce606c90ce7c26069fd6

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

Case digest / faa4b24f62c90f3efbdcfc6d92b0a54a67dd157a1291bce0e70e531509be78fa