git404hub

what is transformer-decoder-from-scratch fr?

neelbhattacharya80-creator/transformer-decoder-from-scratch — explained in plain English

Analysis updated 2026-05-18

0PythonAudience · researcherComplexity · 4/5Setup · hard

tl;dr

A personal, hand built decoder only Transformer language model written in PyTorch, documented as a learning project with training notes and sample output.

vibe map

mindmap
  root((Transformer From Scratch))
    What it does
      Builds decoder Transformer
      Trains from scratch
      Generates text
    Tech stack
      Python
      PyTorch
      tiktoken
    Use cases
      Study attention internals
      Train small language model
      Learn optimizer internals
    Audience
      ML learners
      Researchers

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

Study a hand written implementation of self attention, RoPE, and AdamW for learning purposes.

VIBE 2

Train a small decoder only language model on a text dataset like WikiText-103.

VIBE 3

Generate autoregressive text samples from a from-scratch Transformer model.

VIBE 4

Reference the gradient accumulation and learning rate warmup techniques used here.

what's the stack?

PythonPyTorchtiktoken

how it stacks up fr

neelbhattacharya80-creator/transformer-decoder-from-scratch0xallam/my-recipe0xhassaan/nn-from-scratch
Stars00
LanguagePythonPythonPython
Last pushed2022-11-22
MaintenanceDormant
Setup difficultyhardmoderatemoderate
Complexity4/52/54/5
Audienceresearchergeneraldeveloper

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

how do i run it?

Difficulty · hard time til it works · 1day+

Requires a GPU for practical training and understanding of Transformer internals to follow along.

in plain english

This project is a personal learning exercise where the author built a decoder only Transformer, the type of architecture behind modern language models, almost entirely by hand instead of using pre built libraries. PyTorch is used only for basic building blocks like automatic differentiation, tensor math, and running computations on the GPU. Everything else, including the attention mechanism, positional encoding, normalization layers, the optimizer, the loss function, and the training loop, was written from scratch. The resulting model has about 30 million trainable parameters and can both be trained and used to generate text one word at a time. The README is written as a personal account of what the author learned along the way, rather than as a polished product description. They describe debugging issues like their custom optimizer accidentally staying on the CPU while the model ran on the GPU, and several bugs in the positional encoding caused by reshaping tensors incorrectly. They also describe efficiency improvements they made, such as combining three separate calculations into one, and building then abandoning a custom tokenizer in favor of an existing one called tiktoken because their own version was too slow. Training the model required adjusting the learning rate schedule and using a technique called gradient accumulation to work around limited GPU memory on the author's own graphics card. The model was trained on a public dataset called WikiText-103, and its training loss dropped steadily over time before leveling off. Sample output included in the README shows the model producing text that is grammatically correct and readable, but which tends to drift away from the original topic over longer passages and does not stay factually accurate. The author attributes this mainly to the size of the training data and the amount of compute used rather than to the architecture itself, and plans to continue training on a larger dataset using rented GPUs to improve results.

prompts (copy fr)

prompt 1
Explain how the custom AdamW optimizer is implemented in this project.
prompt 2
Walk me through the RoPE positional encoding bugs described in the README.
prompt 3
Help me understand why the model's output drifts off topic in longer generations.
prompt 4
Show me how gradient accumulation is used here to work around limited GPU memory.

Frequently asked questions

what is transformer-decoder-from-scratch fr?

A personal, hand built decoder only Transformer language model written in PyTorch, documented as a learning project with training notes and sample output.

What language is transformer-decoder-from-scratch written in?

Mainly Python. The stack also includes Python, PyTorch, tiktoken.

How hard is transformer-decoder-from-scratch to set up?

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

Who is transformer-decoder-from-scratch for?

Mainly researcher.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.