A modern, feature-rich GPT implementation with advanced training capabilities, hyperparameter optimization, and an intuitive GUI interface.
- Multi-Head Attention with configurable heads and embedding dimensions
- Grouped Query Attention for improved efficiency
- Mixture of Experts (MoE) for scalable model capacity
- Configurable transformer blocks with LayerNorm and dropout
- Character-level tokenization with custom vocabulary
- Optuna-powered optimization with pruning for efficient search
- Automatic VRAM management to prevent out-of-memory errors
- Persistent study storage with SQLite database
- Best parameters auto-save to JSON for reproducibility
- Three-tab interface: Text Generation, Training, and Hyperparameter Optimization
- Real-time training visualization with loss plotting
- Live hyperparameter display showing current model configuration
- Progress tracking with progress bars and status updates
- Model save/load functionality through file dialogs
- Mixed precision training with automatic scaling (CUDA)
- Gradient accumulation and weight decay
- Real-time loss monitoring with customizable plot intervals
- Stop/resume functionality with threading support
- Memory-efficient batching with configurable batch sizes
- Python 3.8 or higher
- CUDA-compatible GPU (recommended) or CPU
- Git
-
Clone the repository:
git clone https://github.com/DatGuyShorty/DGS-GPT.git cd DGS-GPT -
Create a virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Prepare your dataset:
- Place your text data in
vocab.txt - The model will automatically create character-level vocabulary
- Sample datasets can be any plain text file
- Place your text data in
python gui.pyThis launches the full-featured GUI with three main tabs:
- Text Generation: Generate text from prompts
- Training: Train the model with real-time visualization
- Hyperparameter Optimization: Auto-tune model parameters
python ShitGPT.py- Open the GUI and navigate to the "Text Generation" tab
- Enter your prompt in the text area
- Click "Generate Text" to produce AI-generated content
- Generated text appears in the output area below
- Go to the "Training" tab
- Set training parameters:
- Iterations: Number of training steps
- Plot Step: How often to update the loss plot
- View current hyperparameters in the display widget
- Click "Start Training" to begin
- Monitor progress with the real-time loss plot and progress bar
- Use "Stop Training" to halt training early if needed
- Navigate to the "Hyperparameter Optimization" tab
- Configure optimization settings:
- Number of Trials: How many parameter combinations to test
- Steps per Trial: Training steps per configuration
- Click "Start Optimization" to begin automated tuning
- Monitor progress in the log output
- Best parameters are automatically saved and applied
- Save Model: File β Save Model (or Ctrl+S)
- Load Model: File β Load Model (or Ctrl+O)
- Models are saved as
.pthfiles with complete state dictionaries
@dataclass
class Config:
# Model Architecture
block_size: int = 256 # Sequence length
n_layer: int = 16 # Number of transformer layers
n_head: int = 16 # Number of attention heads
n_embd: int = 1024 # Embedding dimension
dropout: float = 0.01 # Dropout rate
# Advanced Features
use_moe: bool = False # Enable Mixture of Experts
moe_num_experts: int = 4 # Number of MoE experts
moe_k: int = 1 # Top-k experts to use
attention_type: str = "multihead" # "multihead" or "grouped_query"
n_query_groups: int = 1 # Query groups for GQA
# Training Parameters
learning_rate: float = 5e-4 # Learning rate
weight_decay: float = 1e-5 # L2 regularization
batch_size: int = 24 # Batch size
max_iters: int = 1000 # Maximum training iterations- Learning Rate: 1e-5 to 1e-2 (log scale)
- Weight Decay: 1e-6 to 1e-2 (log scale)
- Embedding Dimension: [256, 512, 1024]
- Number of Layers: Adaptive based on embedding size
- Attention Heads: [4, 8, 16]
- Dropout: 0.05 to 0.3
DGS-GPT/
βββ ShitGPT.py # Core model implementation
βββ gui.py # Graphical user interface
βββ dataset.py # Data loading utilities
βββ live_training_plot.py # Real-time plotting utilities
βββ requirements.txt # Python dependencies
βββ setup.sh # Setup script
βββ vocab.txt # Training text data
βββ best_hyperparams.json # Optimized parameters
βββ optuna_study.db # Optimization history
βββ gpt_model.pth # Trained model weights
βββ README.md # This file
Enable MoE for scalable model capacity:
config.use_moe = True
config.moe_num_experts = 8
config.moe_k = 2Use GQA for improved efficiency:
config.attention_type = "grouped_query"
config.n_query_groups = 4 # Must divide n_head evenly- Replace
vocab.txtwith your text data - The model automatically builds character-level vocabulary
- Larger datasets generally produce better results
CUDA Out of Memory:
- Reduce
batch_sizein config - Lower
n_embdorn_layervalues - Close other GPU-intensive applications
Training Not Starting:
- Ensure
vocab.txtexists and contains text - Check that PyTorch detects your GPU (if available)
- Verify all dependencies are installed
GUI Not Opening:
- Install tkinter:
pip install tk - On Linux:
sudo apt-get install python3-tk - Check display settings for headless systems
- Use CUDA-enabled GPU for significant speedup
- Adjust batch size based on available VRAM
- Use mixed precision training (automatic on CUDA)
- Enable MoE for larger model capacity with similar memory usage
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and test thoroughly
- Commit with descriptive messages:
git commit -m "Add feature" - Push to your fork:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with PyTorch for deep learning
- Optuna for hyperparameter optimization
- Matplotlib for visualization
- Inspired by the GPT architecture and modern transformer implementations
If you encounter issues or have questions:
- Check the Troubleshooting section
- Search existing Issues
- Create a new issue with detailed information
- Include system specs, error messages, and reproduction steps
Happy Training! π