Skip to content
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

Show the number of tokens #78

Open
SommerEngineering opened this issue Aug 19, 2024 · 0 comments
Open

Show the number of tokens #78

SommerEngineering opened this issue Aug 19, 2024 · 0 comments

Comments

@SommerEngineering
Copy link
Member

We could try to show the number of tokens in the assistants and the chat. However, there are several challenges:

  • Different models use different tokenizers. As I write this, OpenAI has documented three different tokenizers on its website. LLaMA uses another one, etc.

  • The number of tokens depends on the language. For English, there are good estimates that could be used instead of a tokenizer. Quoting OpenAI: "A helpful rule of thumb is that one token generally corresponds to ~4 characters of text for common English text. This translates to roughly ¾ of a word (so 100 tokens ~= 75 words)." Not every text is written in English, though.

  • From a performance perspective, it is desirable not to use the actual tokenizer but a good approximation.

  • For C#, there is the library SharpToken and alternatively TikTokenSharp. However, TikTokenSharp loads data from the internet, which I don't want for AI Studio. The developers of SharpToken indicate that Microsoft has now developed the library Microsoft.ML.Tokenizers. The Microsoft library is supposed to be very performant.

We will continue to monitor the situation. We may need to implement a token estimator and show the result as an estimate in the UI.

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

No branches or pull requests

1 participant