Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Nano-GPT: Transformer-Based Language Model

An interactive Transformer language model trained on the Tiny Shakespeare dataset. πŸ“œ

Inspired by Andrej Karpathy, this project helped me understand the core concepts behind Transformers, like self-attention and sequence generation. I’m now working on scaling this up to create a GPT-2 clone! πŸš€


πŸ“˜ What I Built

  • Self-Attention Mechanism: Helps the model focus on relevant tokens in the sequence.
  • Multi-Head Attention: Captures diverse relationships between tokens for richer understanding.
  • Positional Embeddings: Gives the model a sense of token order, crucial for sequences.
  • Layer Normalization: Stabilizes and accelerates training for better convergence.
  • Feedforward Neural Network: Processes attention outputs to extract complex features.
  • Token and Positional Embeddings: Converts characters into meaningful vector representations.
  • Greedy & Multinomial Sampling: Enables flexible and creative text generation.

πŸ› οΈ Model Details

  • 🧠 Parameters: ~3 Million
  • πŸ“š Dataset: Tiny Shakespeare (~1MB of Shakespeare’s works)
  • ⚑ Training Split: 90% training, 10% validation
  • πŸ“Š Loss Estimation: Robust evaluation on both train and validation sets

After training, the model can generate Shakespeare-like text β€” it’s incredible to see how it captures the style and rhythm of classic literature! ✨


πŸš€ Try It Out!


πŸ’‘ What’s Next?

I’m working on scaling this up into a GPT-2 clone, and I’m exploring optimizations like rotary embeddings and flash attention. If you have ideas or suggestions, I’d love to hear them! Let’s keep learning and building together. πŸš€


🀝 Acknowledgments

A huge shoutout to Andrej Karpathy for making complex concepts like self-attention, multi-head attention, and layer normalization so understandable β€” your teachings inspired this project! πŸ™Œ

#Demo_pic image

About

Nano-GPT: Tiny Shakespeare Language Model A Transformer-based model with ~3M parameters, trained on the Tiny Shakespeare dataset to generate Shakespeare-like text. Inspired by Andrej Karpathy, built from scratch! πŸš€

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages