Brief Description:
ToKEn viSuAl is a Python-powered app that analyzes your text with two visual features:
- Adds a splash of color to help you understand it better π.
- It shows a list of the top-k most probable tokens. It uses OpenAI's powerful language models to figure out how likely each word (or part of a word) is to appear.
Features:
- Token Probability Visualization: See which words matter most! Color intensity shows how likely each token is.
- Most Likely Token Score: See scores for the top-k most probable tokens π.
- Customizable System Prompt: Guide the analysis with your own prompts π‘.
- OpenAI Integration: Tap into the power of GPT-3.5-turbo and GPT-4 π.
- Adjustable Parameters: Tweak temperature, maximum tokens, and seed for fine-tuned results.
- Memory Capability: Optionally keep the context of your chat history for even deeper analysis π§ .
Installation
-
Clone the GitHub Repository:
git clone https://github.com/<your-username>/token-probs.git
-
Install Dependencies:
cd token-probs pip install -r requirements.txt
Getting Started
-
Set Your OpenAI API Key: Choose one of these ways:
- Environment Variable:
export OPENAI_API_KEY=sk-.... - Directly in the App: Enter your API key in the right spot π.
- Environment Variable:
-
Run the Application:
python tokens_prob.py
-
Start chatting in your web browser! π¬
How to Use
- Type in your text. π
- (Optional) Add a custom system prompt to focus the analysis. π€
- Play around with the parameters! (temperature, max tokens, seed)
- See your text light up with color-coded tokens! π€©
Project Structure
token-probs/tokens_prob.py: The heart of the application.requirements.txt: All the Python libraries we need.
Credits
This is an adapted version of the viztoken project from HoloViz https://holoviz-dev.github.io/blog-dev/posts/openai_logprobs_colored/! π
