This repository is the best-known PyTorch implementation of the Transformer from “Attention Is All You Need,” the 2017 paper that reshaped modern AI. Written to mirror the paper faithfully, it has close to 10,000 stars on GitHub and has served as the reference codebase for countless students and engineers learning how self-attention actually works.
The project implements the complete encoder–decoder Transformer in readable PyTorch: multi-head self-attention, positional encoding, label smoothing, learning-rate scheduling with warmup, and beam-search decoding. It reproduces the paper’s headline experiment — English-to-German translation on WMT 2014 — with training and evaluation scripts, BPE tokenization, and configuration that tracks the original setup. Development was most recently active in 2024, and the code remains a stable, self-contained teaching artifact rather than a fast-moving library. Few repositories make the jump from paper equations to working tensors this directly, which is exactly why it keeps being assigned in courses and cited in blog posts that teach attention from scratch.
Free. The project is open source under the MIT license — clone it, run it, and teach from it at no cost.
Students, instructors, and engineers who want to understand the Transformer from working code rather than diagrams — and anyone building a foundation before tackling modern LLM frameworks. It is equally handy as a clean, dependency-light baseline when experimenting with attention variants or testing ideas for sequence modeling research.