Skip to content

Support OpenAI OSS Models with Tiktoken tokenizer #7494

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

Merged
merged 2 commits into from
Aug 11, 2025

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented Aug 9, 2025

Fixes #7491

@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 23:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for OpenAI OSS (Open Source Software) models using the Tiktoken tokenizer by introducing a new encoding type o200k_harmony and supporting the gpt-oss model family.

  • Introduces a new O200kHarmony encoding with specialized special tokens for OSS models
  • Adds comprehensive test coverage for the new tokenizer functionality
  • Expands model name mappings to include various OpenAI model variations and fine-tuned models

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Microsoft.ML.Tokenizers/Model/TiktokenTokenizer.cs Adds O200kHarmony encoding support, new special tokens, and expanded model mappings for gpt-oss and fine-tuned models
test/Microsoft.ML.Tokenizers.Tests/TiktokenTests.cs Adds comprehensive test coverage for the new OSS tokenizer including encoding tests and special token validation

@tarekgh
Copy link
Member Author

tarekgh commented Aug 9, 2025

CC @stephentoub @ericstj

@stephentoub
Copy link
Member

Thanks

@stephentoub
Copy link
Member

We should also add gpt-5:
openai/tiktoken@5818d56#diff-0d973848bd229418209db2c46c86167000845592ca6b98fad215c21c317bc494R12

@tarekgh tarekgh merged commit fb39755 into dotnet:main Aug 11, 2025
25 checks passed
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.

Incorporate new harmony tiktoken vocabulary
2 participants