Skip to content

Handle byte_fallback configuration in BPETokenizer#44

Open
Gunnarguy wants to merge 1 commit into
mainfrom
fix/byte-fallback-bpetokenizer-2959915231792515435
Open

Handle byte_fallback configuration in BPETokenizer#44
Gunnarguy wants to merge 1 commit into
mainfrom
fix/byte-fallback-bpetokenizer-2959915231792515435

Conversation

@Gunnarguy

Copy link
Copy Markdown
Owner

Added a byteFallback property to the BPETokenizer class that correctly extracts its value from tokenizerData.model.byteFallback. Updated the fallback behavior for unknown tokens inside tokenize(text:) to correctly output the unknown token when byteFallback is false, instead of incorrectly forcing a byte-level hexadecimal encoding.


PR created automatically by Jules for task 2959915231792515435 started by @Gunnarguy

Co-authored-by: Gunnarguy <110250624+Gunnarguy@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings June 24, 2026 23:22

@sourcery-ai sourcery-ai Bot 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.

Sorry @Gunnarguy, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

Pull request overview

Adds support for the Hugging Face byte_fallback (exposed as byteFallback) setting in the Swift BPETokenizer, and adjusts unknown-token handling to respect that configuration during tokenization.

Changes:

  • Added byteFallback to BPETokenizer and initialized it from tokenizerData.model.byteFallback.
  • Updated tokenize(text:) to emit the configured unknown token when byteFallback is disabled, instead of always byte/hex-fallback encoding unknown tokens.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +238 to +242
if !byteFallback, let unknownToken = unknownToken {
tokens.append(unknownToken)
} else {
tokens.append(contentsOf: hexaEncode(text: token))
}
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