Skip to content

fix(tokenizer): honor add_bos in HF tokenization - #2389

Open
dajiaohuang wants to merge 3 commits into
abetlen:mainfrom
dajiaohuang:fix/hf-tokenizer-add-bos
Open

dajiaohuang wants to merge 3 commits into
abetlen:mainfrom
dajiaohuang:fix/hf-tokenizer-add-bos

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 21, 2026 •

Copy link
Copy Markdown

Summary

  • LlamaHFTokenizer.tokenize accepted add_bos but ignored it, so chat-format callers could add duplicate BOS tokens or omit a requested BOS.
  • Honor the flag while preserving an explicit BOS in input text and other tokenizer-added special tokens.

Validation

  • Focused synthetic pytest: 4 passed using Python 3.13 and a task-local package stub to load the tokenizer without a native llama.cpp library or model.
  • Ruff check and format check passed. The full test suite/native build was not run; no model weights were downloaded and no inference or external AI service was used.

Changelog

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.

1 participant