This project provides a comprehensive implementation of a GPT-based language model complemented by interactive visualization tools built with Streamlit. It enables users to generate text from custom prompts and offers insightful visualizations of the model's internal mechanisms, including attention matrices and embeddings.
- GPT-2 Architecture: Custom implementation of the GPT model in
model.py
- Key Components: GPT, CausalSelfAttention, and LayerNorm classes
- Interactive Dashboard: Built with Streamlit in
sample.py
- User-Friendly: Easy-to-use interface for text generation and visualization
- Attention Matrix: Explore self-attention mechanisms through Plotly
- Embedding Analysis: Dynamic token and positional embedding visualizations
- Activation Functions: Interactive GELU function plots
Make sure you have Poetry installed on your system.
-
Clone the Repository:
git clone https://github.com/hornikmatej/sfc_project cd sfc_project
-
Install Dependencies:
poetry install
-
Activate Environment:
poetry shell
-
Launch the App:
poetry run streamlit run sample.py
-
Using the Interface:
- 📝 Enter your prompt in the sidebar
- 🎲 Click "Generate" to create text
- 🔍 Explore various visualizations
model.py
: Main GPT-2 implementationhelpers.py
: Visualization utilitiessample.py
: Streamlit interfacepoetry.toml
&poetry.lock
: Dependency management
- GPT Model: Core language model implementation
- Visualization Tools: Attention matrices, embeddings, and activation functions
- Helper Functions: Utility functions for data processing and visualization