RAG & Retrieval
ALiBi (Attention with Linear Biases) is a way to give a transformer position information by penalizing attention scores in proportion to the distance between query and key, instead of adding positional embeddings to the token embeddings.
ALiBi (Attention with Linear Biases) is a way to give a transformer position information by penalizing attention scores in proportion to the distance between query and key, instead of adding positional embeddings to the token embeddings. Because the bias is a simple per-head linear penalty, a model trained on short sequences can extrapolate to longer ones at inference time. In the original paper, a 1.3B model trained on 1,024-token inputs matched the perplexity of a sinusoidal-embedding model trained on 2,048 tokens while training 11% faster and using 11% less memory.
Primary source: arxiv.org
Example
In practice, developers reach for ALiBi when they need the capability described above as part of an AI feature or workflow.
Hands-on guides, comparisons, and tutorials that cover RAG & Retrieval.
FAQ
ALiBi (Attention with Linear Biases) is a way to give a transformer position information by penalizing attention scores in proportion to the distance between query and key, instead of adding positional embeddings to the token embeddings.
ALiBi sits in the RAG & Retrieval part of the AI stack. Understanding it helps you make better decisions when building, debugging, and shipping AI features.
Developers Digest publishes tutorials and videos that cover RAG & Retrieval topics including ALiBi. Check the blog and YouTube channel for hands-on walkthroughs.
Related
Positional encoding is the signal a transformer uses to know where each token sits in a sequence, since self-attention on its own treats input as an unordered set.
A way of encoding token positions in transformers by rotating each query and key vector by an angle proportional to its position.
The feed-forward network is the per-token block in every transformer layer that follows attention: two linear projections with a nonlinearity between them, applied to each position independently.

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.