Skip to content

fix: honor add_bos=False with Hugging Face tokenizers - #2453

Open
remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-8c93829d704d
Open

remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-8c93829d704d

Conversation

@remote-controlled-man

Copy link
Copy Markdown
Contributor

LlamaHFTokenizer ignored add_bos=False when its Hugging Face tokenizer inserted a BOS token. For a GGUF that adds its own BOS, create_completion("Hello") passed two leading BOS tokens to the model and emitted a warning.

Use the Hugging Face special-token mask to remove the automatically added leading BOS. This preserves an explicit BOS in the input text and other special tokens such as a trailing EOS. Related to #1561.

Validation on macOS with CPU inference and cached GGUF fixtures:

  • make lint passed; make test passed (35 tests)
  • Regression tests in tests/test_llama.py, including a short generation with stories15M and a test tokenizer that inserts BOS

I used Codex to assist with the patch and tests.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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