Skip to content

analyticalrohit/llms-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn Substack X Youtube Topmate

LLMs from Scratch

Overview

This repository is a hands on guide to building a ChatGPT like LLM in PyTorch. It breaks the architecture into simple parts and explains each one step by step.

LLM Architecture

Let us have a birds eye view of the Generative Pretrained Transformer (GPT) like LLM architecture.

Example: Every moment is a beginning

LLMs work by predicting one word or token at a time. LLMs generate text iteratively. Each predicted word token is appended to the previous input to form the context for the next prediction.

Contents

Code Notebook

Dive into the hands-on examples for each LLM component using interactive Jupyter notebooks.

Topic Code
Tokenization 01_tokenization.ipynb
Token Embeddings 02_token_embeddings.ipynb
Positional Embeddings 03_positional_embeddings.ipynb
Self Attention Mechanism TODO
Multi-Head Self Attention TODO
FeedForward Neural Networks TODO
Residual Connections TODO
Layer Normalization TODO
Transformer Block TODO
Cross Entropy Loss TODO
Training and Generation TODO

Install Dependencies

pip install -r requirements.txt

If you're installing torch with CUDA support, make sure to use the correct installation command from PyTorch's official website, as some versions require a specific installation method.

Blog Post

Read the full breakdown and insights in the accompanying blogs.

Newsletter

📌 Join 10,000+ ML enthusiasts and professionals from 150+ countries.
✅ Learn AI for FREE with visuals, easy-to-follow insights.
✅ Get cutting-edge topics like GenAI, RAGs, and LLMs in your inbox every week.

Subscribe to AwesomeNeuron Newsletter

AwesomeNeuron Newsletter

Contributing

We welcome contributions! If you have improvements, new notebooks, or fixes to suggest:

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/YourTopic.
  3. Add or update notebooks in the notebooks/ folder.
  4. Commit your changes: git commit -m 'Add or update YourTopic notebook'.
  5. Push your branch: git push origin feature/YourTopic.
  6. Open a pull request for review.

License

This project is licensed under MIT License


⭐️ If you find this repository helpful, please consider giving it a star!

Star History Chart

Keywords: AI, Machine Learning, Deep Learning, PyTorch, Generative AI, LLMs, Transformers