Skip to content

fix(eval): keep F1 finite for constructor tokens - #898

Merged
dosco merged 2 commits into
ax-llm:mainfrom
Elon-Jiang:fix/f1-constructor-token
Nov 16, 2026
Merged

dosco merged 2 commits into
ax-llm:mainfrom
Elon-Jiang:fix/f1-constructor-token

Conversation

@Elon-Jiang

@Elon-Jiang Elon-Jiang commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor
  • What kind of change does this PR introduce?

    Bug fix for the public AxEvalUtil.f1Score metric.

  • What is the current behavior?

    AxEvalUtil.f1Score('constructor', 'constructor') returns NaN, as do partial and disjoint comparisons involving that word. The token-count dictionary inherits Object.prototype.constructor, which is mistaken for an existing count. This can contaminate evaluation averages. The merged novel-F1 fix fix(eval): compute novel F1 token overlap #856 explicitly leaves the ordinary F1 helper unchanged; this covers that remaining public path.

  • What is the new behavior (if this is a feature change)?

    Start the private token-count dictionary without a prototype. Identical constructor tokens score 1, disjoint tokens 0, and multiset overlap stays bounded by occurrence counts. Normalization, empty-input semantics, exact match and novel F1 are unchanged.

  • AxIR portable behavior check:

    The portable behavior changes in src/ax/dsp/eval.ts, with regressions in src/ax/dsp/eval.test.ts. New open backlog entry axir-2026-11-15-keep-ordinary-f1-token-counts-independent-of-inherited-object-pr is bound to fix(eval): keep F1 finite for constructor tokens #898 and lists those exact two files. Only the required ir/axir-backlog.json and rendered docs/AXIR_BACKLOG.md exception accompany the handwritten TypeScript. Existing entries/exemptions are unchanged. npm run axir:backlog:check -- --base origin/main --head HEAD and npm run axir:backlog:validate pass. No generated language or AxIR source change is included.

  • Other information:

    Against main 007ab8366e5bfa98d871feb1af188cc029295c58, the public-export regression produced 5 failures and 23 passing controls/existing tests. All 28 pass after the one-line fix.

    • Related eval/util/metrics tests: 62 passed.
    • Full Ax unit suite, npm run test:unit --workspace=@ax-llm/ax -- --maxWorkers=2: 4,157 passed, 4 skipped. Run with local HTTP/controlled subprocess permission; the initial restricted-environment attempt was not an acceptance result.
    • npm run test:type-check --workspace=@ax-llm/ax and npm run build --workspace=@ax-llm/ax: passed.
    • Changed-file Biome and cspell checks, actual pre-commit hook, and git diff --check: passed.

    Reproduction calls the exported metric in Node directly; no model, provider, or external service is involved. AI assistance (Codex) was used for investigation, implementation, review and testing. No human code review is claimed.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

External contribution policy

✅ This PR now complies with the external contribution policy.

@Elon-Jiang
Elon-Jiang marked this pull request as ready for review November 15, 2026 14:42
@dosco
dosco merged commit 60e0e6a into ax-llm:main Nov 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants