This is a simple project that demostrates how to use tiktoken library in action for encoding and decoding text using OpenAI's tokenizer (e.g, gpt-3.5, gpt-4o, etc.)
This repo uses uv as package manager.
- Uses model-specific tokenizer
- Encode any string into OpenAI's tokens
- Decode tokens back in readable text format
- Git
- Python
- UV Package manager
- Clone the repository
git clone https://github.com/aayushgupta-dev/tokenizer.git
cd tokenizer- Install dependencies
uv add --script .\tokenizer.py "tiktoken"- Run the code using UV
uv run .\tokenizer.pyText: Hello, how are you today??
Encoded text: [13225, 11, 1495, 553, 481, 4044, 6961]
Decoded text: Hello, how are you today??