AI GLOSSARY · AI CONCEPTS

Positional encoding

Markdown version · Wikidata Q141896396

Definition

Positional encoding is information about each token's position in a sequence that a Transformer receives alongside the token itself, because self-attention does not by itself preserve the order of the sequence.

Also called: positional encodings, positional embedding, rotary positional embedding, RoPE, rope embedding, position embedding.

In plain language

A language model reads words, and word order matters: 'the dog bit the man' differs from 'the man bit the dog'. The attention step inside a Transformer does not by itself keep track of order, so the model is given an extra signal for each word's place in the text. Think of numbering the pages of a loose pile of paper. The model can then learn that the first word and the fifth word relate differently from two neighbours. The limit is that the scheme in use is fixed when the model is built and trained, so behaviour on text much longer than the training text depends on that design and is not guaranteed.

Technical definition

The original Transformer paper added positional encodings to the input embeddings, using sine and cosine functions of different frequencies; the authors also tried learned positional embeddings and reported nearly identical results, and chose the sinusoidal form because it may allow extrapolation to longer sequences. Later work such as RoFormer proposes rotary position embedding (RoPE), which according to its abstract encodes absolute position with a rotation matrix and incorporates explicit relative position dependency in the self-attention formulation. Absolute, relative and rotary schemes are different designs for the same job.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Guide · Illustrative, not executed

    What Is an LLM? The Facts Agent Users Need

    What you see
    The current guide contrasts the original Transformer decoder's autoregressive generation with BERT's masked pretraining, and distinguishes runtime context from learned parameters.
    Why it exercises the concept
    Position information is part of how a model handles the ordered tokens inside that window. The guide covers the user-facing side of the window; it does not explain position schemes. Illustrative reading path.
  2. Skill by Skill Almanac · Illustrative, not executed

    context-window-packer 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill chooses which files fit one prompt's token budget and records what was kept, shrunk or dropped, and why.
    Why it exercises the concept
    The catalogue has no skill about position encodings themselves, so this is a contrast case about what you control: what goes into the ordered sequence the model reads.
  3. Skill by Skill Almanac · Illustrative, not executed

    local-model-sizing 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill works out whether an open-weight language model will run on a given GPU, Mac or PC, with a script that computes weight, KV-cache and overhead memory per quantization.
    Why it exercises the concept
    Sizing a local model deals with memory, not position schemes. It is a contrast case: the position encoding is part of the model you choose, not a setting this skill adjusts.

How it shows up when you use agents

You do not set positional encoding when you run Claude Code, Codex or Cursor. It shows up indirectly: the model receives your system prompt, files and tool results as one ordered sequence of tokens, and the position of each piece is part of what it works with.

What breaks when this is misunderstood is the idea that a bigger context window is just more room. The window limit is a property of the service. How well a model uses material far from the question is a separate matter that the sources here do not measure. The Transformer paper says its authors chose the sinusoidal scheme because it may allow extrapolation to longer sequences; that is a design hope, not a guarantee for any model you use.

A useful next step is to test a long-context task on your own files before relying on it, and to keep prompts tidy so that the instructions and material that matter most are easy to find. For the mechanism around this term see Transformer and Attention mechanism.

Common confusions

  • Positional encoding versus token embedding. An embedding represents what a token is. Position information represents where it is. In the original design the two are added together.
  • Sinusoidal versus learned. The original paper tried both and reported nearly identical results, so neither is the definition of the term.
  • Absolute versus relative position. Absolute schemes mark a token's place in the sequence. Relative schemes describe how far apart two tokens are. RoFormer's abstract says rotary embedding does the first with a rotation matrix and also builds in the second.
  • Position scheme versus context length. A position scheme is one design choice inside a model. The supported context length is stated by the vendor for a model or service.

Terms that mention Positional encoding

1 terms mention this one

More in AI concepts

Next steps

  1. What Is an LLM? The Facts Agent Users Need The long-form guide.
  2. context-window-packer A skill that exercises it.
  3. Transformer Related term.
  4. Token Related term.
  5. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.

Review record

Last verified

Drafted by Claude (original draft); OpenAI Codex (bounded factual repairs); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .

Change log (5)
  • : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
  • : First version.
  • : Verifier pass: removed unsourced sentence.
  • : Bounded source repairs: Updated only stale LLM guide caption to current Transformer/BERT objectives and context/learned-parameter distinction. Pending independent re-review.
  • : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.