A lightweight, fully customizable GPT (Decoder-only Transformer) model built from scratch in PyTorch. This project covers the entire end-to-end LLM lifecycle: training a custom BPE tokenizer, training the model, serving inference via a FastAPI backend, and running an interactive Gradio web UI.
- Custom GPT Architecture: Decoder-only Transformer with scaled dot-product Multi-Head Self-Attention, LayerNorm, GELU activations, and positional embeddings.
- Custom Tokenizer: Hugging Face
tokenizersByte-Pair Encoding (BPE) trained specifically on the target dataset. - REST API: Production-ready FastAPI server (
app.py) for serving text generation endpoints. - Interactive Web UI: Gradio interface (
frontend.py) featuring customizable generation parameters (temperature, max tokens).
myGPT/
├── src/
│ ├── model.py # PyTorch MiniGPT architecture definition
│ ├── train.py # Tokenizer training & model training loop
│ └── generate.py # Standalone CLI generation script
├── tokenizer/ # Saved custom tokenizer files (tokenizer.json)
├── app.py # FastAPI backend API
├── frontend.py # Gradio web user interface
├── requirements.txt # Python dependencies
└── README.md