fix(inference): TemplateProcessing IDs are authoritative for SP BOS/EOS (codex follow-up)#117
Merged
Merged
Conversation
Addresses codex round-1 finding: when a SentencePiece tokenizer has both `<s>`/`</s>` in vocab AND a TemplateProcessing post_processor that uses different special tokens (e.g. `[CLS]`/`[SEP]`), the prior fallback order (`bos_id.or(pp.bos_id)`) silently injected the vocab guesses instead of the template-supplied IDs. Inverts to `pp.bos_id.or(bos_id)` so the template IDs win when present, with vocab-name fallback only when the template omits explicit IDs. Adds two focused unit tests in `common.rs`: - BERT-style template ([CLS]/[SEP], IDs 101/102) → verifies template IDs win - XLM-RoBERTa-style template (<s>/</s>, IDs 0/2) → verifies the E5 path still resolves correctly E5 audit case still passes (9/9 multilingual_e5_small). Workspace clippy clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Closes the codex round-1 Major finding on PR #106. The original fix preferred hard-coded `
`/`` vocab guesses over the template-supplied IDs. This change inverts the precedence so the TemplateProcessing IDs are authoritative when present.Why this is a separate PR
PR #106 merged into PR #105's (now-orphaned) base branch instead of main during the show stack collapse. The umbrella PR #104 brought the original PR #106 content to main but not this round-1 fix. This small PR closes the gap.
Diff
1 file (sentencepiece.rs) + 1 test file (common.rs):
Verification
🤖 Generated with Claude Code