Back to dictionary

Transformers

Transformers

Quick answer

Transformers are a deep learning architecture introduced in 2017 that processes sequential data using a self-attention mechanism, allowing the model to weigh the relevance of every element in an input sequence simultaneously. Transformers form the foundation of modern large language models, automatic speech recognition systems, and text-to-speech engines.

Table of contents
No headings found in #article-body

Summarize with AI

Put these concepts to work

Turn the fundamentals into a working voice AI product with Smallest.

Table of contents
No headings found in #article-body

Summarize with AI

Put these concepts to work

Turn the fundamentals into a working voice AI product with Smallest.

What Are Transformers in AI?

The transformer is a neural network architecture that replaced earlier sequence-to-sequence models (such as recurrent neural networks) by relying entirely on an attention mechanism to draw global dependencies between input and output. Introduced in the 2017 paper "Attention Is All You Need," transformers have become the dominant architecture in natural language processing, speech recognition, and generative AI.

How Transformers Work

Self-Attention Mechanism

The core innovation is self-attention, which lets the model evaluate the relationship between every pair of tokens in a sequence in parallel. For each token, the model computes three vectors: a query, a key, and a value. Attention scores are derived by comparing queries against keys, then used to produce a weighted sum of values. This allows the model to capture long-range dependencies without processing tokens one at a time.

Encoder-Decoder Structure

The original transformer uses an encoder-decoder layout:

  • Encoder: Reads the full input sequence and produces contextual representations for each token.

  • Decoder: Generates output tokens one at a time, attending both to previously generated tokens and to the encoder output.

Many modern systems use only one half. Encoder-only models (like BERT) excel at classification and understanding tasks, while decoder-only models (like GPT) excel at text generation.

Positional Encoding

Because transformers process all tokens in parallel rather than sequentially, they require positional encodings to inject information about token order into the model.

Transformers in Speech Technology

In voice AI, transformers power both automatic speech recognition (ASR) and text-to-speech (TTS) systems. ASR models use transformer encoders to convert audio features into text, while TTS systems use transformer decoders to generate natural-sounding speech from text input. The architecture's ability to model long-range context makes it especially effective for producing coherent, natural prosody in synthesized speech.

Why Transformers Matter

  • Parallelism: Unlike RNNs, transformers process entire sequences at once, enabling faster training on modern GPUs.

  • Scalability: Performance improves predictably as model size and training data increase.

  • Versatility: The same core architecture applies to text, audio, images, and multimodal tasks.

Frequently asked questions

Frequently asked questions

The transformer is a deep learning architecture that uses self-attention to process all elements of an input sequence in parallel. It replaced recurrent neural networks as the dominant model for language, speech, and generative AI tasks due to its superior ability to capture long-range dependencies and its efficient parallelization during training.