☆ Save 7.1 Transformer Architecture and Core Components — Sequence-to-Sequence Models and Encoder–Decoder Structure

06/15/2026

This article explains how the Transformer is structured and why it has become a core neural architecture in natural language processing. Unlike sequential models that process tokens one by one, the Transformer processes the entire input simultaneously and computes relationships between tokens. Here we focus on the core components: Sequence-to-Sequence Model, Encoder–Decoder Architecture, Transformer Encoder, Transformer Decoder, Word Embedding, and Context Length.

Table of Contents

Sequence-to-Sequence Model and Transformer

A Transformer is a Sequence-to-Sequence Model that converts an input sequence into an output sequence. For example, it can take a sentence in one language and generate a sentence in another language. Both input and output consist of token sequences, and their lengths may differ.

This architecture is widely used in machine translation, text generation, and summarization. A key point is that the Transformer does not simply map words directly, but reconstructs meaning based on relationships across the entire sentence. The core mechanism enabling this is Self-Attention.

RNN vs Seq2Seq vs Transformer

RNN processes sequences step by step. It naturally captures order information by computing each state based on the previous one, but it is difficult to parallelize and may lose information in long sequences.

Traditional Seq2Seq models encode the input into a single representation and then generate the output from it. However, as input length increases, it becomes difficult to store all necessary information in a single vector.

The Transformer solves this problem by processing all tokens at once and directly computing relationships between them. For example, in “I love you”, the token “love” can simultaneously attend to both “I” and “you”. This enables parallelization in Transformers and provides stable performance even for long contexts.

Encoder–Decoder Architecture and Context Vector

The Encoder–Decoder Architecture separates understanding the input from generating the output. The Encoder converts the input sequence into context-aware representations, while the Decoder generates the output sequence based on them.

The Encoder output is not a single vector but a set of vectors, one per token, each enriched with contextual information. Collectively, this can be viewed as a Context Vector representation of the input.

The Decoder uses this Context Vector to determine which parts of the input are most relevant when generating each token. This process leads to Encoder–Decoder Attention, also known as Cross Attention.

Transformer Encoder and Encoder Layer

The Transformer Encoder is a stack of identical encoder layers. Each Encoder Layer (Transformer Block) consists of two main components:

Self-Attention is the core of the Transformer. It allows the model to consider relationships between all words when interpreting a specific token. For example, it plays a key role in resolving what pronouns refer to.

The FFN non-linearly transforms the representations produced by Self-Attention, strengthening the learned features. The same network is applied independently to each position, forming a form of Parameter Sharing.

Word Embedding, Token, Vocabulary

Transformers do not process raw text directly. Instead, text is first split into tokens. A Token can be a word or a subword unit. The total set of tokens is called the Vocabulary.

Each token is converted into a vector using Word Embedding. This produces a Dense Vector Representation that encodes semantic meaning numerically.

These representations capture semantic relationships between words, connecting to concepts such as Vector Space Semantics and Semantic Similarity. Common embedding methods include Word2Vec, GloVe, FastText, and ELMo.

In Transformers, these embeddings are used as input to the Encoder, and their dimensionality is called the Embedding Dimension.

Transformer Decoder and Cross Attention

The Transformer Decoder is responsible for generating the output sequence. It consists of three main components:

Masked Self-Attention uses Causal Masking to block future information, enabling Autoregressive Generation. The model generates each token based only on previously generated tokens.

Encoder–Decoder Attention determines which parts of the input sequence should be attended to during generation. This allows the model to learn alignment between input and output sequences.

Context Length and Parallel Processing

Context Length refers to the maximum number of tokens a model can process at once. A longer context length allows the model to consider more information simultaneously, which is important for Long-Context Modeling.

Transformers can process tokens in parallel, making them highly efficient for training compared to RNNs. This provides significant advantages in speed and scalability.

However, allowing every token to attend to every other token increases computational cost. This trade-off is fundamental to understanding Transformer efficiency and scalability.

※ This article was independently compiled and adapted from lectures by Professor Sungroh Yoon at Seoul National University.

Recommended prerequisite reading (2/2)

Recommended next reading (5/20)

+5

Posts on the same topic (8/12)

+4

Related concepts (0/0)

No related concept posts yet.

📍 Where this concept fits in the AI learning map

See where this concept sits within the full AI Universe.

📍 Current position in AI Universe

Reset Show completed · Login required Loading…

🌌 AI Universe

⭐ Concept

Select a star.

View the full AI Universe

« 7. Transformer — From Se…|7.2 Attention and Langua… »

🔖 Tags: encoder-decoder architecture · Sequence-to-Sequence Model · transformer architecture · Transformer Decoder · transformer encoder · Word Embedding