Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the string_view subscript overflow for Phi4 Tokenizer #899

Merged
merged 2 commits into from
Feb 28, 2025
Merged

Conversation

wenbingl
Copy link
Member

No description provided.

@wenbingl wenbingl requested a review from a team as a code owner February 28, 2025 06:12
auto res = m_text.substr(0, j);
m_text = m_text.substr(j);
return res;
}
i = j;
Copy link
Member Author

Choose a reason for hiding this comment

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

@sayanshaw24, any reason that why we need use both i and j here?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's because j is a temp variable; before we copy i to it here: https://github.com/microsoft/onnxruntime-extensions/blob/main/operators/tokenizer/bpe_utils.hpp#L373 and so in this line we reset i before the last regex check (for (?i:'s|'t|'re|'ve|'m|'ll|'d)?)

@wenbingl wenbingl merged commit ee945bb into main Feb 28, 2025
46 checks passed
@wenbingl wenbingl deleted the phi4s branch February 28, 2025 17:17
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