An AI-powered web application that generates something close to authentic-sounding dialogue from The Simpsons using a fine-tuned GPT-2 language model.
This project demonstrates the complete machine learning workflow from data preparation to deployment, showcasing how to fine-tune a language model on a custom dataset using consumer-grade hardware. The model generates character-specific dialogue that captures the personality and speaking style of iconic Simpsons characters.
Model: Hugging Face Space
- Character Selection: Choose from various Simpsons characters
- Location Context: Set the scene with different Springfield locations
- Prompt Words: Guide the dialogue generation with starter words
- Advanced Parameters: Fine-tune generation with adjustable settings
- Temperature (creativity level)
- Top-k and Top-p sampling
- Maximum output length
- Number of outputs
- Repetition penalty
- Model: GPT-2 (124M parameters)
- Framework: PyTorch + Hugging Face Transformers
- Training Hardware: AMD Radeon RX 6950 XT GPU (16GB VRAM)
- CPU: Intel i5-13400F
- RAM: 32GB DDR4
- OS: Linux Mint(22.3 Zena)
- Framework: React 18 with TypeScript
- Styling: Tailwind CSS
- Icons: Lucide React
- API Client: Gradio Client
- Model Hosting: Hugging Face Spaces (Gradio)
- Frontend: Cloudflare
- Architecture: Serverless API calls to Hugging Face
- Dataset Preparation: Collected and structured thousands of Simpsons dialogue samples from Kaggle
- Data Format: Custom conditioning format:
[CHAR:Name][LOC:Location][PROMPT:Word] - Fine-tuning: Trained GPT-2 on local hardware with character/location awareness
- Evaluation: Tested for personality consistency and contextual relevance
- User selects character, location, and prompt word
- Frontend formats input with special tokens
- Request sent to Hugging Face Gradio API
- Model generates dialogue using configured sampling parameters
- Response displayed with formatted output
- Context Conditioning: Model learns to associate characters with their speech patterns
- Location Awareness: Setting influences dialogue topics and references
- Controlled Generation: Multiple parameters allow fine-grained output control
This project was designed as a comprehensive learning exercise in:
- Configuring AMD ROCm for deep learning on RDNA2 architecture
- Managing GPU memory constraints during training
- Optimizing training pipelines for consumer hardware
- Fine-tuning pretrained language models
- Custom tokenization and data preprocessing
- Implementing conditional text generation
- Hyperparameter tuning and experimentation
- Building responsive React applications
- Integrating ML models via REST APIs
- Managing asynchronous operations and loading states
- Deploying serverless ML applications
- Understanding the resource gap between hobby projects and production AI
- Learning to work within hardware limitations
- Balancing model quality with practical constraints
node >= 18.0.0
npm >= 9.0.0# Clone the repository
git clone https://github.com/jonorl/simpsons-GPT.git
cd simpsons-GPT
# Install dependencies
npm install
# Run development server
npm run devThe application connects to the Hugging Face Spaces API automatically. No API keys required for basic usage.
| Parameter | Default | Range | Purpose |
|---|---|---|---|
| Temperature | 0.8 | 0.1-2.0 | Controls randomness |
| Top-k | 50 | 1-100 | Limits vocabulary selection |
| Top-p | 0.9 | 0.1-1.0 | Nucleus sampling threshold |
| Max Length | 100 | 20-200 | Maximum tokens generated |
| Repetition Penalty | 1.2 | 1.0-2.0 | Reduces repeated phrases |
- Trained on consumer hardware, not production-scale infrastructure
- Output may be abstract or nonsensical compared to industry models
- Limited by ~124M parameters vs billions in modern LLMs
- Free-tier Hugging Face Spaces has cold start delays
- First request may take 30-60 seconds
- Subsequent requests are faster (server warm)
- Model trained on TV dialogue, not real-world conversations
- May occasionally generate unexpected combinations
- Best used for demonstration and learning purposes
This project is for educational and portfolio purposes. The Simpsons characters and content are property of 20th Century Fox/Disney.
Jonathan Orlowski
- Portfolio: Jonathan Orlowski
- Prashant Banerjee (prashant111) for the Kaggle Simpsons dataset
- Hugging Face for model hosting and Transformers library
- PyTorch team for the deep learning framework
- Gradio for the deployment interface
- AMD for ROCm GPU support
- The Simpsons for decades of memorable dialogue