Commit 1fba2f5
Percentage-mode decoder: anchor on
The previous decoder picked the "best answer position" by scanning for
the position with the most numeric mass, and skipped range-label
positions via a `max_single_value_prob > 0.95 * total_mass` heuristic.
That worked but was implicit: correctness depended on the numeric
argmax at the answer position being ≤ 0.95 (empirical on gpt-5.4-nano),
not on a property of the response format.
Rewrite as a deterministic walk over the reconstructed chosen-token
stream (argmax per position; temperature=0 guarantees chosen==argmax):
1. Accumulate text token-by-token.
2. Fire an anchor once the running text matches
`re.compile(r"probability[^:]*:", re.IGNORECASE)` — this catches
both `Probability (0-100):` (label preserved) and paraphrases
like `Estimated probability:` (label dropped) that the model
emits roughly evenly on gpt-5.4-nano.
3. Return the mass-weighted expected value at the first post-anchor
position with ≥0.1 numeric mass.
Pre-anchor digit positions (the `0` and `100` from `(0-100)`) are prompt
echo — they precede the colon, so `[^:]*` correctly stops before them
and they never get considered as answers. No probability threshold
needed.
Live n=100 ACSIncome / gpt-5.4-nano: AUC 0.803 (previous heuristic
approach: 0.805 — a 0.002 rounding-noise difference; the anchor loses
one edge case where the model malformed its response as
`**Estimated probability ( 62%**` with no colon). Full test suite
still passes (296 tests). Percentage-mode unit tests rewritten to
mirror real response shapes (echoed label; paraphrased anchor;
preamble-only rejection).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>probability<...>: instead of prob mass1 parent dc333b3 commit 1fba2f5
2 files changed
Lines changed: 154 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
297 | 311 | | |
298 | 312 | | |
299 | 313 | | |
300 | 314 | | |
| 315 | + | |
301 | 316 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
310 | 340 | | |
311 | 341 | | |
312 | 342 | | |
| |||
325 | 355 | | |
326 | 356 | | |
327 | 357 | | |
328 | | - | |
329 | | - | |
330 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
331 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
332 | 380 | | |
333 | 381 | | |
334 | 382 | | |
| |||
337 | 385 | | |
338 | 386 | | |
339 | 387 | | |
340 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
341 | 391 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | 392 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 393 | + | |
| 394 | + | |
364 | 395 | | |
365 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
366 | 402 | | |
367 | 403 | | |
368 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
| 425 | + | |
425 | 426 | | |
426 | 427 | | |
427 | 428 | | |
428 | | - | |
| 429 | + | |
429 | 430 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
436 | 445 | | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
444 | 488 | | |
445 | 489 | | |
446 | 490 | | |
447 | 491 | | |
448 | 492 | | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
453 | 496 | | |
454 | | - | |
455 | | - | |
456 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
457 | 500 | | |
458 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
459 | 522 | | |
460 | 523 | | |
461 | 524 | | |
| |||
0 commit comments