Skip to content

fix: recognize model stop tokens when checking generation truncation - #85

Open
Afloat16 wants to merge 1 commit into
billion-token-one-task:masterfrom
Afloat16:fix/generation-eos-config-20261202-r2
Open

Afloat16 wants to merge 1 commit into
billion-token-one-task:masterfrom
Afloat16:fix/generation-eos-config-20261202-r2

Conversation

@Afloat16

@Afloat16 Afloat16 commented Dec 2, 2026

Copy link
Copy Markdown

Problem

The local runner uses the tokenizer's single EOS token to decide whether a continuation completed. Transformers generation uses the model's GenerationConfig, which can specify a different stop token or several stop tokens. A valid completion ending on one of those tokens exactly at max_new_tokens is therefore marked truncated, potentially turning a completed measurement into a generation_truncated failure.

Changes

Use the model's configured EOS token or token list when inspecting the continuation, with the existing tokenizer token as the fallback. Keep actual token-budget exhaustion marked as truncated and retain shared pad/EOS handling.

Primary API definition: https://github.com/huggingface/transformers/blob/main/src/transformers/generation/configuration_utils.py (eos_token_id accepts an integer or a list).

Validation

  • 2 failed, 4 passed on base.
  • Controlled tensor-shaped generation outputs exercise a different scalar EOS, multiple EOS tokens, tokenizer fallback, actual exhaustion, short completions, and shared padding/EOS. No model download is needed.
  • python -m pytest -q tests/test_generation_eos_config.py tests/test_runner_contract_and_failure_policy.py tests/test_degenerate_measurement.py: 50 passed, 30 subtests passed.

@cla-assistant

cla-assistant Bot commented Dec 2, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

1 participant