Rupa421's picture
Upload README.md with huggingface_hub
32d0f47 verified
|
Raw
History Blame Contribute Delete
2.13 kB
# πŸš€ MiniGPT from Scratch
![Python](https://img.shields.io/badge/Python-3.10-blue)
![PyTorch](https://img.shields.io/badge/PyTorch-2.x-red)
![License](https://img.shields.io/badge/License-MIT-green)
A decoder-only GPT implementation built completely from scratch using PyTorch.
This project was created as part of my journey to understand how modern Large Language Models work internally instead of simply using existing libraries.
---
# Features
- βœ… Character-level Tokenizer
- βœ… Token Embeddings
- βœ… Positional Embeddings
- βœ… Multi-Head Self Attention
- βœ… FlashAttention (`scaled_dot_product_attention`)
- βœ… Feed Forward Network (MLP)
- βœ… Residual Connections
- βœ… Layer Normalization
- βœ… Decoder-only GPT Architecture
- βœ… Autoregressive Text Generation
- βœ… Top-K Sampling
- βœ… Top-P (Nucleus) Sampling
- βœ… Temperature Sampling
---
# Architecture
```
Input Tokens
β”‚
β–Ό
Token Embedding
β”‚
β–Ό
Position Embedding
β”‚
β–Ό
Transformer Block Γ— 4
β”‚
β–Ό
LayerNorm
β”‚
β–Ό
Linear Head
β”‚
β–Ό
Vocabulary Logits
β”‚
β–Ό
Next Token
```
---
# Project Structure
```
MiniGPT-from-Scratch/
β”œβ”€β”€ model.py
β”œβ”€β”€ train.py
β”œβ”€β”€ generate.py
β”œβ”€β”€ utils.py
β”œβ”€β”€ config.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ notebook/
β”œβ”€β”€ checkpoints/
β”œβ”€β”€ outputs/
β”œβ”€β”€ images/
└── data/
```
---
# Dataset
Tiny Shakespeare
https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt
---
# Training
```bash
python train.py
```
---
# Generate Text
```bash
python generate.py
```
---
# Sample Output
```
FANH:
A Prusjortus:
Weath the too,
eyes glorls cobsuess fewn.
```
---
# Future Work
- KV Cache
- Mixed Precision
- LoRA Fine-tuning
- Beam Search
- HuggingFace Integration
- Distributed Training
- Triton Kernels
---
# Author
Built with ❀️ while learning PyTorch Internals and Transformer Architecture.