openai / openai/tiktoken

RuntimeError(StackOverflow) with tiktoken.encoding_for_model('gpt-4').encode(txt, disallowed_special=())

Open
#400 2 comments 1 reaction 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

Hi,

we are using tiktoken 0.5.2 to calculate the token count. It is working most of the time, but we are seeing the error: RuntimeError(StackOverflow) with one of the runs.

Here is the part of the stack trace:
SystemLog: File "/azureml-envs/azureml_40acd812113c64de92b8cc12dc98c336/lib/python3.11/site-packages/tiktoken/core.py", line 120, in encode
SystemLog: return self._core_bpe.encode(text, allowed_special)

I also checked the text size and it's pretty big (around 2 GB) is there any limitation on the size?

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 at tiktoken/core.py line 120 and reproduce the reported RuntimeError(StackOverflow) using a similarly large input with tiktoken 0.5.2. Check whether the failure is tied to input size or encoding behavior, then establish and test the supported behavior for large text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.