openai / tiktoken

tiktoken is a fast BPE tokeniser for use with OpenAI's models.
MIT License
11.17k stars 751 forks source link

encoding_for_model("gpt-4") #220

Closed fanpeeps closed 7 months ago

fanpeeps commented 7 months ago

Readme suggestions selecting appropraite tokenizer with this request for gpt-4:

enc = tiktoken.encoding_for_model("gpt-4")

Yet, when doing so, this error is produced:

ValueError: Unknown encoding gpt-4. Plugins found: ['tiktoken_ext.openai_public']

hauntsaninja commented 7 months ago

That sounds like you ran tiktoken.get_encoding("gpt-4") instead of tiktoken.encoding_for_model("gpt-4")