
trekhleb/homemade-gpt-js
📦 Open Source Projecttrekhleb
A minimal, educational implementation of GPT using TensorFlow.js in under 300 lines of code.
homemade-gpt-js is a pedagogical implementation of a GPT-style transformer architecture built from scratch using TensorFlow.js. By stripping away the complexity of production-grade frameworks, it allows developers to inspect the core mechanics of modern LLMs. The repository focuses on clarity and educational value, demonstrating how to construct transformer blocks, implement multi-head self-attention, and manage positional embeddings using the TF.js library. Because it runs entirely in TypeScript/JavaScript, it is an excellent tool for web developers looking to bridge the gap between frontend engineering and machine learning. The project emphasizes readability, making it an ideal starting point for those who have read the 'Attention Is All You Need' paper and want to see the mathematical concepts translated into executable code without the overhead of massive dependencies.
💡Highlights
- ├─Under 300 lines of model code
- ├─Built with TensorFlow.js
- └─Educational transformer design
🎯For
- ├─AI Educators
- ├─Web Developers
- └─Machine Learning Students