{"abstract":"Typical sampling ranks by raw surprisal distance.","category":"Token sampling filters","checks":6,"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.","contract_signature":"probabilities, mass","evaluation_group":"w3-tsf-typicality-entropy","failed_approach":"Using a strict mass threshold fails when the included probabilities land exactly on the requested mass.","family":"w3-token-sampling-filters-typicality-entropy","id":"FA-98366","implementations":{"attempt":{"sha256":"3b402f7403aa19fc1cce5f18aae6d029699e5b2c06780f4ab02b74231193c166","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(probabilities, mass):\n    import math\n    H=-sum(p*math.log(p) for p in probabilities.values() if p>0)\n    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\n    if not ranked:return []\n    for t in ranked:\n        out.append(t); s+=probabilities[t]\n        if s>mass: break\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('entropy-centered selection',solve({'a':.5,'b':.3,'c':.2},.6),['b','a'])\ncheck('uniform',solve({'a':.5,'b':.5},.5),['a'])\ncheck('empty',solve({},.5),[])\ncheck('zero mass retains leading candidate',solve({'a':1.0},0),['a'])\ncheck('zero probability ignored',solve({'a':1.0,'z':0},.5),['a'])\ncheck('full mass',solve({'a':.7,'b':.3},1),['a','b'])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"f58b039520c5070a58595ecaa4141785d754897a2f7a6a465f5bd9212d4b933c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(probabilities, mass):\n    import math\n    ranked=sorted((t for t,p in probabilities.items() if p>0),key=lambda t:(abs(-math.log(probabilities[t])),t)); out=[]; s=0\n    if not ranked:return []\n    for t in ranked:\n        out.append(t); s+=probabilities[t]\n        if s>=mass: break\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('entropy-centered selection',solve({'a':.5,'b':.3,'c':.2},.6),['b','a'])\ncheck('uniform',solve({'a':.5,'b':.5},.5),['a'])\ncheck('empty',solve({},.5),[])\ncheck('zero mass retains leading candidate',solve({'a':1.0},0),['a'])\ncheck('zero probability ignored',solve({'a':1.0,'z':0},.5),['a'])\ncheck('full mass',solve({'a':.7,'b':.3},1),['a','b'])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w3-token-sampling-filters-typicality-entropy","generated_at":"2026-09-30T16:48:12.370814+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A finite, deterministic token-selection contract isolates one decoding operation from model inference and runtime behavior.","root_cause":"Typicality uses distance from surprisal zero instead of distribution entropy.","sha256":"fa2f63ee4b8eb3126ada8615e786a079e41c858b7e5ac27e0a32f4f11fe2bcba","title":"Token sampling: Typical sampling ranks by raw surprisal distance · case 01","variant":1,"variant_policy":"The same explicitly authored fixtures repeat across all five numbered records; runtime N is unused. These records share one mechanism and must remain together in evaluation splits.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":27.231,"exit_code":1,"observations":[{"actual":["b","a"],"check":"entropy-centered selection","expected":["b","a"],"passed":true},{"actual":["a","b"],"check":"uniform","expected":["a"],"passed":false},{"actual":[],"check":"empty","expected":[],"passed":true},{"actual":["a"],"check":"zero mass retains leading candidate","expected":["a"],"passed":true},{"actual":["a"],"check":"zero probability ignored","expected":["a"],"passed":true},{"actual":["a","b"],"check":"full mass","expected":["a","b"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"entropy-centered selection\", \"actual\": [\"b\", \"a\"], \"expected\": [\"b\", \"a\"], \"passed\": true}, {\"check\": \"uniform\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\"], \"passed\": false}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"zero mass retains leading candidate\", \"actual\": [\"a\"], \"expected\": [\"a\"], \"passed\": true}, {\"check\": \"zero probability ignored\", \"actual\": [\"a\"], \"expected\": [\"a\"], \"passed\": true}, {\"check\": \"full mass\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":29.079,"exit_code":1,"observations":[{"actual":["a","b"],"check":"entropy-centered selection","expected":["b","a"],"passed":false},{"actual":["a"],"check":"uniform","expected":["a"],"passed":true},{"actual":[],"check":"empty","expected":[],"passed":true},{"actual":["a"],"check":"zero mass retains leading candidate","expected":["a"],"passed":true},{"actual":["a"],"check":"zero probability ignored","expected":["a"],"passed":true},{"actual":["a","b"],"check":"full mass","expected":["a","b"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"entropy-centered selection\", \"actual\": [\"a\", \"b\"], \"expected\": [\"b\", \"a\"], \"passed\": false}, {\"check\": \"uniform\", \"actual\": [\"a\"], \"expected\": [\"a\"], \"passed\": true}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"zero mass retains leading candidate\", \"actual\": [\"a\"], \"expected\": [\"a\"], \"passed\": true}, {\"check\": \"zero probability ignored\", \"actual\": [\"a\"], \"expected\": [\"a\"], \"passed\": true}, {\"check\": \"full mass\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}