|
Download README.md from mrshibly/MiniGPT: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/spaces/mrshibly/MiniGPT/resolve/main/README.md
- Command line
-
hf download hf://spaces/mrshibly/MiniGPT/README.md
-
curl -L -o README.md https://huggingface.co/spaces/mrshibly/MiniGPT/resolve/main/README.md
2.78 kB
A newer version of the Gradio SDK is available: 6.32.0
metadata
title: MiniGPT-from-Scratch
emoji: π
colorFrom: indigo
colorTo: purple
sdk: gradio
sdk_version: 5.16.2
app_file: app.py
pinned: false
MiniGPT-from-Scratch π
A from-scratch implementation of a decoder-only Transformer (GPT) language model, built in 30 days. This project is designed as a deep-dive into LLM engineering, following the architecture of GPT-2.
π Features
- Custom BPE Tokenizer: Fully trained on the dataset using Hugging Face
tokenizers. - GPT Architecture: Multi-head causal self-attention, GELU MLPs, LayerNorm (Pre-Norm), and residual connections.
- Optimized Training: Supports PyTorch AMP (Mixed Precision), Cosine Decay with Warmup, and weight tying.
- Interactive Demo: Built-in Gradio web app for real-time text generation.
- Evaluation: Integrated perplexity calculation for model benchmarking.
π οΈ Tech Stack
- Language: Python 3.10+
- Deep Learning: PyTorch
- Tokenization: Hugging Face Tokenizers
- Interface: Gradio
- Data: FineWeb-Edu (Sample)
π Project Structure
MiniGPT/
βββ data/ # Raw and processed datasets
βββ notebooks/ # Colab/Kaggle training templates
βββ src/
β βββ datasets/ # Data loading and preprocessing logic
β βββ model/ # Transformer architecture (GPT, Attention, Blocks)
β βββ tokenizer/ # BPE training and wrapper
β βββ train/ # Training loop with AMP and validation
β βββ app.py # Gradio Web Demo
βββ checkpoints/ # Saved model weights (.pt)
βββ requirements.txt # Project dependencies
π How to Use
1. Setup
git clone https://github.com/mrshibly/MiniGPT-from-Scratch.git
cd MiniGPT-from-Scratch
pip install -r requirements.txt
2. Preprocess Data
python src/datasets/download_fineweb.py
python src/datasets/clean_text.py
python src/tokenizer/train_tokenizer.py
python src/datasets/prepare_data.py
3. Train
To train locally (CPU/GPU):
python src/train/train.py
Note: For full 50M training, use the Colab Template.
4. Interactive Demo
Once you have a checkpoint in checkpoints/ckpt.pt:
python src/app.py
π Model Configurations
| Config | Params | Layers | Heads | d_model |
|---|---|---|---|---|
| Tiny | ~7M | 4 | 4 | 256 |
| Standard | ~50M | 6 | 8 | 512 |
π Latest Training Benchmarks
- Dataset: 500MB FineWeb-Edu
- Parameters: 27.54 Million
- Validation Loss: 4.8415
- Perplexity: 126.65
- Status: Successfully generating coherent English-like sentences.
π License
MIT