git404hub

what is llama3-from-scratch fr?

naklecha/llama3-from-scratch — explained in plain English

Analysis updated 2026-06-24

15,243Jupyter NotebookAudience · researcherComplexity · 4/5Setup · hard

tl;dr

A Jupyter Notebook that rebuilds Meta's Llama 3 language model from scratch in plain Python, walking through every matrix multiplication step so you can see exactly how it works inside.

vibe map

mindmap
  root((llama3-from-scratch))
    What it does
      Rebuilds Llama 3
      Step by step
      Plain Python
    Key Concepts
      Tokenizer BPE
      Attention heads
      RMS normalization
      Token embeddings
    Tech Stack
      Python PyTorch
      Jupyter Notebook
      tiktoken
    Requirements
      Meta weight file
      Gated access
      High RAM machine
    Audience
      ML researchers
      LLM learners

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Walk through every step of a transformer forward pass using real Llama 3 weights to understand how large language models actually work.

VIBE 2

Use as a hands-on companion to understand attention heads, RMS normalization, and token embeddings alongside running code.

VIBE 3

Adapt the notebook to inspect how specific inputs flow through Llama 3 layers for research or debugging transformer internals.

what's the stack?

PythonPyTorchJupyter Notebooktiktoken

how it stacks up fr

naklecha/llama3-from-scratchai4finance-foundation/finrlmml-book/mml-book.github.io
Stars15,24315,14315,479
LanguageJupyter NotebookJupyter NotebookJupyter Notebook
Setup difficultyhardmoderateeasy
Complexity4/54/53/5
Audienceresearcherresearcherresearcher

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · hard time til it works · 1day+

Requires downloading official Llama 3 weights from Meta (gated access) plus a machine with enough RAM or VRAM to load them.

in plain english

This repository is a long, hand-walked tutorial that re-implements Meta's Llama 3 language model from scratch, one matrix multiplication at a time. Llama 3 is a large language model: software that takes some text and predicts the next piece of text. Rather than wrap it inside a black-box library call, the author loads Meta's published Llama 3 weights file directly and reconstructs every step the model takes in plain Python, narrating what is happening as the shapes of the numbers change. The README walks through the pipeline a beginner needs to follow such a model. First it sets up a tokenizer (the piece that splits text into the numeric tokens the model actually processes), borrowing tiktoken to handle the byte-pair encoding rather than writing one. Then it reads the raw model file and inspects its config, which the file itself reports as 32 transformer layers, 32 attention heads, and a vocabulary of 128256 tokens. From there the notebook converts text to tokens, looks up token embeddings, applies RMS normalisation, and goes layer by layer through the transformer block, building queries, keys, values, and outputs for each attention head by hand. You would read this repository if you already use large language models and want to understand what is actually happening inside one, or if you find it easier to learn by reading numeric code than reading a research paper. It is presented as a Jupyter Notebook and depends on PyTorch and tiktoken, both named in the README. Running it requires downloading the official Llama 3 weights from Meta. The full README is longer than what was provided.

prompts (copy fr)

prompt 1
In the llama3-from-scratch notebook, what is happening when the code builds queries, keys, and values for each attention head? Walk me through the tensor shapes at each step.
prompt 2
How does RMS normalization work in this from-scratch Llama 3 implementation and why is it used instead of standard LayerNorm?
prompt 3
I want to visualize the attention weights for a specific input token in the llama3-from-scratch notebook. How do I extract and plot them?
prompt 4
Explain what byte-pair encoding does in the tokenizer step of this notebook and show me how to run it on a custom input string using tiktoken.
prompt 5
How does the notebook load the raw Llama 3 weight file and map tensor names to the transformer layers? Walk me through that setup section.

Frequently asked questions

what is llama3-from-scratch fr?

A Jupyter Notebook that rebuilds Meta's Llama 3 language model from scratch in plain Python, walking through every matrix multiplication step so you can see exactly how it works inside.

What language is llama3-from-scratch written in?

Mainly Jupyter Notebook. The stack also includes Python, PyTorch, Jupyter Notebook.

How hard is llama3-from-scratch to set up?

Setup difficulty is rated hard, with roughly 1day+ to a first successful run.

Who is llama3-from-scratch for?

Mainly researcher.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.