Add a tokenizing visualizer utility #1561
shhlife
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
Very cool! Griptape's Tokenizers don't have a Going to move this to show-and-tell so others can see what you've built. |
Beta Was this translation helpful? Give feedback.
0 replies
-
ah, so it would only work for certain tokenizers, like openAi? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's very helpful to get an understanding of how text is tokenized. A visualizer would be super useful.
We have a method on the
OpenAiTokenizer
that can count tokens, but nothing that visualizes how they look to the user.Here's a script that can do that:
To use it, you can do something like:
The result looks something like:
![image](https://private-user-images.githubusercontent.com/5397345/402400677-3b0a13c7-f128-410b-83b7-2dd534a9747b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDIyNDUsIm5iZiI6MTczOTM0MTk0NSwicGF0aCI6Ii81Mzk3MzQ1LzQwMjQwMDY3Ny0zYjBhMTNjNy1mMTI4LTQxMGItODNiNy0yZGQ1MzRhOTc0N2IucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDYzMjI1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDc2NzczODAzMjhlZTdiOGFmZDA3NTExZDUwOWVkOGExODAxM2M1MWYwZjYwZmYxMjZhOWM0NzlhZmVmNDE4ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.y82plaANfPUmCo0MIhxwtpCH08mMTtdAynJtKOCqRJs)
Beta Was this translation helpful? Give feedback.
All reactions