OpenAITokenizers
org.llm4s.llmconnect.provider.OpenAITokenizers
@Stable
object OpenAITokenizers
Which tokenizer vocabulary an OpenAI model uses, so its tokens can be counted exactly without a call to the API.
val counter = OpenAITokenizers.counterFor("gpt-4o") // o200k_base
The name may carry the openai/ or azure/ prefix. An Azure deployment is matched on the OpenAI model name its text contains, spelled as OpenAI spells it: azure/my-gpt-4o-deployment is o200k_base, while a deployment whose name does not contain a model name is not recognised.
Models of other vendors have no public tokenizer here. Count them with ConversationTokenCounter.cl100k(), an approximation that can be 20-30% off, or with your own StringTokenizer through ConversationTokenCounter.of.
Attributes
- Source
- OpenAITokenizers.scala
- Graph
-
- Supertypes
- Self type
-
OpenAITokenizers.type
Members list
In this article
