Skip to content
Projects

2025 · Python · PyTorch · LLM

GPT-2 Transformer — From Scratch

A 355M-parameter Transformer built from the ground up to understand how language models work.

Problem

Understand the internals of large language models instead of treating them as black boxes.

Solution

Implemented a 355M-parameter Transformer from scratch, following “Attention is All You Need” without pre-built LLM libraries.

Architecture

  • Decoder-only Transformer
  • Multi-head self-attention
  • Positional encoding
  • Layer normalization

Implementation details

  • Built attention, positional encoding and normalization directly in PyTorch.
  • Assembled the full 355M-parameter model from the underlying components.