awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
harvardnlp avatar

harvardnlp/annotated-transformer

0
View on GitHub↗
7,325 stars·1,549 forks·Jupyter Notebook·MIT·30 viewsnlp.seas.harvard.edu/annotated-transformer↗

Annotated Transformer

The Annotated Transformer is an educational resource that provides annotated code implementations of the Transformer architecture for sequence-to-sequence tasks, built with PyTorch. It serves as a learning tool for understanding attention mechanisms, multi-head parallel attention, and scaled dot-product attention through executable examples that walk through each component of the model.

The project covers the full Transformer pipeline, including stacked encoder-decoder layers with residual connections and layer normalization, sinusoidal positional encoding for order-aware representation, and masked self-attention decoding for auto-regressive generation. It also demonstrates label smoothing regularization to reduce overconfidence during training, and provides a framework for neural machine translation that encodes input sequences and decodes output sequences using attention mechanisms.

The documentation includes annotated code that explains how multi-head self-attention works, how positional encoding injects sequence order information, and how the model processes sequences through stacked self-attention and feed-forward layers. The resource is designed to help learners implement and train Transformer-based sequence models for translation tasks, with explanations of each architectural component from the original paper.

Features

  • Encoder-Decoder Architectures - Processes input through identical encoder layers and generates output via decoder layers with cross-attention.
  • Sequence Encoders - Processes an input sequence through stacked self-attention and feed-forward layers to produce continuous representations.
  • Causal Masking - Implements causal masking to prevent future token leakage during auto-regressive sequence generation.
  • Multi-Head Attention Mechanisms - Splits queries, keys, and values across multiple parallel heads to learn distinct representation subspaces.
  • Sinusoidal Encodings - Injects fixed sinusoidal signals into token embeddings to encode absolute and relative position information.
  • Residual Connection Implementations - Adds skip connections around each sub-layer followed by layer normalization to stabilize deep training.
  • Sequence Decoders - Generates an output sequence token by token using masked self-attention and encoder-decoder attention.
  • Sequence Learning Models - Builds models that transform input sequences into output sequences using attention mechanisms.
  • Transformer Architecture Implementation - Implements the full Transformer architecture from the original paper for sequence-to-sequence tasks.
  • Positional Encodings - Injects sinusoidal signals into token embeddings to provide the model with information about token order.
  • Paper Implementations - Provides an annotated code implementation of the Transformer architecture with explanations of each component.
  • Scaled Attention Computations - Computes attention by scaling query-key dot products before softmax to prevent gradient vanishing in high-dimensional spaces.
  • Educational Tutorials - Provides annotated code examples that teach how multi-head self-attention and scaled dot-product attention work.
  • Neural Machine Translation - Trains sequence models with label smoothing and positional encoding for translation tasks.
  • Neural Machine Translation Frameworks - Provides a framework for encoding input sequences and decoding output sequences using transformer layers.
  • Label Smoothing Techniques - Demonstrates label smoothing regularization to reduce overconfidence during transformer training.
  • PyTorch Deep Learning Examples - Ships a deep learning model built with PyTorch for processing sequential data using attention mechanisms.

Star history

Star history chart for harvardnlp/annotated-transformerStar history chart for harvardnlp/annotated-transformer

How this analysis was created: This summary and feature list were written by an AI model that read the project's README and public documentation pages. Each feature links to the documentation it came from; stars, license and language come straight from the GitHub API. The model does not read the source code, and the analysis is refreshed when the project is re-analysed. Learn more on our About page.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Frequently asked questions

What does harvardnlp/annotated-transformer do?

The Annotated Transformer is an educational resource that provides annotated code implementations of the Transformer architecture for sequence-to-sequence tasks, built with PyTorch. It serves as a learning tool for understanding attention mechanisms, multi-head parallel attention, and scaled dot-product attention through executable examples that walk through each component of the model.

What are the main features of harvardnlp/annotated-transformer?

The main features of harvardnlp/annotated-transformer are: Encoder-Decoder Architectures, Sequence Encoders, Causal Masking, Multi-Head Attention Mechanisms, Sinusoidal Encodings, Residual Connection Implementations, Sequence Decoders, Sequence Learning Models.

What are some open-source alternatives to harvardnlp/annotated-transformer?

Open-source alternatives to harvardnlp/annotated-transformer include: datawhalechina/thorough-pytorch — This project is an educational resource and comprehensive guide for implementing and deploying deep learning models… kyubyong/transformer — This project is a TensorFlow implementation of a transformer model, providing a text-to-text deep learning framework… datawhalechina/tiny-universe — Tiny Universe is an educational monorepo that delivers multiple independent implementations of core AI subsystems as… hyunwoongko/transformer — This project is a PyTorch implementation of an attention-based neural network designed for sequence-to-sequence deep… pageman/sutskever-30-implementations — This project is a collection of deep learning research implementations and a reproduction kit designed to translate… jadore801120/attention-is-all-you-need-pytorch — This project is a Transformer machine translation model and attention-based neural network implemented using the…

Open-source alternatives to Annotated Transformer

Similar open-source projects, ranked by how many features they share with Annotated Transformer.
  • datawhalechina/thorough-pytorchdatawhalechina avatar

    datawhalechina/thorough-pytorch

    3,684View on GitHub↗

    This project is an educational resource and comprehensive guide for implementing and deploying deep learning models using the PyTorch framework. It provides a structured learning curriculum consisting of tutorials and notebooks that cover neural network architectures, data pipelines, and model optimization across multiple AI domains. The curriculum includes practical implementation guides for building convolutional networks, transformers, and recurrent models. It specifically focuses on workflows for computer vision, including image classification, object detection, and segmentation, as well

    Jupyter Notebookdeep-learningmachine-learningpython
    View on GitHub↗3,684
  • kyubyong/transformerKyubyong avatar

    Kyubyong/transformer

    4,470View on GitHub↗

    This project is a TensorFlow implementation of a transformer model, providing a text-to-text deep learning framework designed to recognize and generate sequence patterns. It functions as an attention-based sequence model and a neural machine translation framework for converting text from one language to another. The system implements the transformer network architecture, utilizing multi-head attention and positional encoding to process sequential data. It provides the necessary tools for transformer model training and machine translation inference, allowing for the execution of trained models

    Pythonattention-is-all-you-needattention-mechanismimplementation
    View on GitHub↗4,470
  • datawhalechina/tiny-universedatawhalechina avatar

    datawhalechina/tiny-universe

    4,505View on GitHub↗

    Tiny Universe is an educational monorepo that delivers multiple independent implementations of core AI subsystems as self-contained Jupyter notebooks. It provides from-scratch constructions of foundational architectures including a complete Transformer model built from the original paper specification, a denoising diffusion probabilistic model for image generation, and a ReAct-style autonomous agent framework that equips an LLM with tools for planning and multi-step task execution. The project distinguishes itself by covering the full lifecycle of modern AI systems through hands-on implementa

    Jupyter Notebookagentdiffusionevaluation-metrics
    View on GitHub↗4,505
  • hyunwoongko/transformerhyunwoongko avatar

    hyunwoongko/transformer

    4,601View on GitHub↗

    This project is a PyTorch implementation of an attention-based neural network designed for sequence-to-sequence deep learning tasks. It serves as a library for constructing deep learning sequence models that utilize encoder and decoder structures to process natural language and sequential data. The implementation centers on a multi-head attention mechanism to capture diverse relationships between tokens without using recurrence. It includes sinusoidal positional encoding to maintain sequence order and point-wise feed-forward networks to transform token positions independently. The architectu

    Pythonattentiondatasetpytorch
    View on GitHub↗4,601
  • See all 30 alternatives to Annotated Transformer→