App to visualize the entropy of the next token prediction from GPT-2 (124M) as you type. Also shows the probability distribution of the top predicted tokens.
Built with Python, Flask, Hugging Face Transformers, and Plotly.js.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git cd YOUR_REPOSITORY_NAME -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate(On Windows use:
venv\Scripts\activate) -
Install dependencies:
pip install -r requirements.txt
- Ensure your virtual environment is active.
- Run the Flask development server:
python app.py
- Wait for the model to load (check terminal output). This may take a few minutes the first time as the LLM model is downloaded.
- Open your web browser and navigate to
http://127.0.0.1:5001.
- Real-time (debounced) entropy calculation for next token predictions.
- Bar chart visualization of the top N predicted tokens and their probabilities.
- Uses Hugging Face
transformersfor LLM access (defaults togpt2). - Leverages Apple Silicon (MPS) for acceleration if available.
