naklecha/llama3-from-scratch

This repository walks through an implementation of Llama 3 one matrix multiplication at a time.

github.com/naklecha/llama3-from-scratch
naklecha/llama3-from-scratch homepage screenshot

About naklecha/llama3-from-scratch

This repository is an educational walkthrough that implements Llama 3 from scratch in a notebook file, one tensor and matrix multiplication at a time. It loads tensors directly from the model file Meta published for Llama 3, so the weights must be downloaded from Meta's official site before the code can run.

The walkthrough covers tokenizing a sample prompt with tiktoken, reading the model configuration, and converting tokens into embeddings while tracking tensor shapes. The author states that the tokenizer is not a BPE implementation and that one embedding step uses a built-in neural network module. The repository is open source.

Key features

  • Walks through a Llama 3 implementation one tensor and matrix multiplication at a time
  • Loads tensors directly from Meta's Llama 3 model weights file
  • Reads model configuration to derive layers, attention heads and vocabulary size
  • Tokenizes a sample prompt using tiktoken and Llama 3 special tokens
  • Shows token embeddings with tensor shapes, such as 17 tokens by 4096 dimensions
  • Includes a notebook file and a requirements file for setup
Best for: Students and developers who want to study how Llama 3 works internally by reading step-by-step code.
Good for
  • Explains each step with notes on tensor shapes
  • Shows the model configuration values and what they imply about the architecture
  • Open source, with a license file included
Watch out for
  • Requires separately downloading Meta's model weights before the code can run
  • Does not implement a BPE tokenizer; uses tiktoken instead
  • Uses a built-in neural network module for the embedding step

naklecha/llama3-from-scratch at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Yes · Source code
Language
English
Last checked
Oct 6, 2026 · Online when checked
Listed
Oct 5, 2026

naklecha/llama3-from-scratch alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in Learn to Code

Well-known listings from the same topic.

All 387

naklecha/llama3-from-scratch FAQ

Do I need to download anything before running the code?
Yes. The author states that you need to download the Llama 3 weights from Meta's official link before running the file.
Does the repository implement a BPE tokenizer?
No. The author says it does not implement a BPE tokenizer and uses tiktoken instead. The README links to Andrej Karpathy's minbpe project for a BPE implementation.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing