openai / openai/tiktoken

Interest in porting any of the implementation from TokenDagger? (With Possible PR)

Open
#441 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
19.3k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

I saw, tokendagger, a drop-in replacement for tiktokken that appears to have some different performance characteristics.

Would there be any interest in porting over those changes to tiktokken? I see two big differences -- one is how it handles special tokens and the other are regex-related modifications -- IE using PCRE2 JIT, but hyperscan might be even faster.

Happy to give it a shot and run a few benchmarks!


Here's a rough implementation of how tokendagger handles special tokens, which would be more performant when there's a large special token library, but the user is only working with a small subset of those tokens. Not so useful for GPT's tokenization, which is the focus of tiktokken, but it could speed up when it's being used for other implementations.

IE: we iterate through the tokens with a simple find and cache the locations of those tokens instead of building out a special regex.

https://github.com/Jeffrharr/tiktoken/pull/1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing TokenDagger and the rough implementation linked in Jeffrharr/tiktoken#1, then compare its special-token handling and regex-related changes with tiktoken. Run benchmarks for the proposed approaches, including PCRE2 JIT or Hyperscan if relevant. Done would be a scoped port with benchmark results and a clear decision about which changes to include.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.