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

tracking tokenization and cost for different LLMs #31

Open
dovinmu opened this issue Jun 10, 2023 · 1 comment
Open

tracking tokenization and cost for different LLMs #31

dovinmu opened this issue Jun 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@dovinmu
Copy link
Collaborator

dovinmu commented Jun 10, 2023

Estimating the cost of each LLM call is a handy tool, but if we start supporting non-OpenAI models we might want the ability to do that in a more general way. Specifically, GooseAI (adding in #30) doesn't return a count of tokens used, so we would need to know how to count the tokens given the prompt and completion (thus we'd need to know the tokenizer that the model used). The math is also different from the math for OpenAI, so if we wanted to improve / expand this feature it might make sense to have LLM provider-specific functions that can calculate the cost. We could also find a heuristic and make sure it's within error tolerance (usually just dividing the character count by a constant).

For now we'll probably just only have cost estimation for OpenAI.

@cthulahoops
Copy link
Collaborator

Goose AI Tokenizer documented here: https://goose.ai/tokenizer

We also lose the ability to compute costs easily if we use the streaming API for openai. I compute token costs in chatcli like this:

https://github.com/cthulahoops/chatcli/blob/main/chatcli_gpt/conversation.py#L48

@anjakefala anjakefala added the enhancement New feature or request label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants