Attention Is All You Need PyTorch

Attention Is All You Need PyTorch

★ 4 🔖 2500 saves 💰 Free GitHub

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.

Overview

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.

Key Features

  • Faithful, readable implementation of the original Transformer architecture
  • Multi-head attention, positional encoding, and masked decoding
  • Training pipeline reproducing the WMT 2014 translation setup
  • Beam search and label smoothing included out of the box
  • Heavily commented, paper-aligned code structure for learning
  • One of the most starred educational deep-learning repositories on GitHub
  • MIT licensed for unrestricted study, teaching, and reuse
  • Companion notes and visualizations explaining attention step by step

💳 Pricing

Free. The project is open source under the MIT license — clone it, run it, and teach from it at no cost.

Who Is It For

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.

🚀 Visit Attention Is All You Need PyTorch Official Site

🚩 Report an issue