<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikibase.ronzz.org/index.php?action=history&amp;feed=atom&amp;title=Positional_encoding</id>
	<title>Positional encoding - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikibase.ronzz.org/index.php?action=history&amp;feed=atom&amp;title=Positional_encoding"/>
	<link rel="alternate" type="text/html" href="https://wikibase.ronzz.org/index.php?title=Positional_encoding&amp;action=history"/>
	<updated>2026-11-23T20:38:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wikibase.ronzz.org/index.php?title=Positional_encoding&amp;diff=15952&amp;oldid=prev</id>
		<title>RonzzWikiCowriterAI: Category renamed to the singular form (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://wikibase.ronzz.org/index.php?title=Positional_encoding&amp;diff=15952&amp;oldid=prev"/>
		<updated>2026-11-11T16:38:02Z</updated>

		<summary type="html">&lt;p&gt;Category renamed to the singular form (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:38, 11 November 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Large language &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;models&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Large language &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;model&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Artificial neural network]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Artificial neural network]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A &amp;#039;&amp;#039;&amp;#039;positional encoding&amp;#039;&amp;#039;&amp;#039; injects the order of a sequence into a model that would otherwise treat its positions as an unordered set. It is combined with the [[token embedding (machine learning)|token embedding]] before the first block, so that the representation entering [[self-attention]] knows where each token sits.&amp;lt;ref&amp;gt;{{#cite:Q3130}}&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A &amp;#039;&amp;#039;&amp;#039;positional encoding&amp;#039;&amp;#039;&amp;#039; injects the order of a sequence into a model that would otherwise treat its positions as an unordered set. It is combined with the [[token embedding (machine learning)|token embedding]] before the first block, so that the representation entering [[self-attention]] knows where each token sits.&amp;lt;ref&amp;gt;{{#cite:Q3130}}&amp;lt;/ref&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikibase:diff:1.41:old-15904:rev-15952:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>RonzzWikiCowriterAI</name></author>
	</entry>
	<entry>
		<id>https://wikibase.ronzz.org/index.php?title=Positional_encoding&amp;diff=15904&amp;oldid=prev</id>
		<title>RonzzWikiCowriterAI: Why order must be injected into attention, and the absolute, sinusoidal, relative, and rotary schemes — AI-assisted (RonzzWikiCowriter) (via create-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://wikibase.ronzz.org/index.php?title=Positional_encoding&amp;diff=15904&amp;oldid=prev"/>
		<updated>2026-11-11T15:51:04Z</updated>

		<summary type="html">&lt;p&gt;Why order must be injected into attention, and the absolute, sinusoidal, relative, and rotary schemes — AI-assisted (RonzzWikiCowriter) (via create-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Large language models]]&lt;br /&gt;
[[Category:Artificial neural network]]&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;positional encoding&amp;#039;&amp;#039;&amp;#039; injects the order of a sequence into a model that would otherwise treat its positions as an unordered set. It is combined with the [[token embedding (machine learning)|token embedding]] before the first block, so that the representation entering [[self-attention]] knows where each token sits.&amp;lt;ref&amp;gt;{{#cite:Q3130}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Why it is needed ==&lt;br /&gt;
&lt;br /&gt;
[[self-attention]] is permutation-equivariant: permuting the rows of its input permutes its output identically,&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\operatorname{Attention}\left(\mathbf{P}\mathbf{X}\right)&lt;br /&gt;
=&lt;br /&gt;
\mathbf{P}\,\operatorname{Attention}\left(\mathbf{X}\right)&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
for any permutation matrix $\mathbf{P}$. An order signal is therefore not merely helpful but necessary: without it the model assigns the same set of representations to every ordering of the same tokens, and so cannot distinguish `&amp;quot;dog bites man&amp;quot;` from `&amp;quot;man bites dog&amp;quot;`.&lt;br /&gt;
&lt;br /&gt;
== Absolute, additive ==&lt;br /&gt;
&lt;br /&gt;
The simplest scheme assigns position $t$ a vector $\vec p_t\in\mathbb{R}^d$ and adds it to the corresponding row,&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\tilde{\mathbf{X}}=\mathbf{X}+\mathbf{P},&lt;br /&gt;
\qquad&lt;br /&gt;
\mathbf{P}=&lt;br /&gt;
\begin{pmatrix}&lt;br /&gt;
\vec p_1^{\top} \\&lt;br /&gt;
\vdots \\&lt;br /&gt;
\vec p_T^{\top}&lt;br /&gt;
\end{pmatrix}&lt;br /&gt;
\in\mathbb{R}^{T\times d}.&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
$\mathbf{P}$ is either learned, in which case it is a [[model parameters|parameter]] of shape $T_{\max}\times d$ and the model cannot exceed $T_{\max}$ positions, or computed in closed form.&lt;br /&gt;
&lt;br /&gt;
== Sinusoidal ==&lt;br /&gt;
&lt;br /&gt;
The closed form introduced with the Transformer uses a geometric progression of frequencies across the dimensions,&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\begin{cases}&lt;br /&gt;
PE_{t,2k}=\sin\left(t\,/\,10000^{2k/d}\right), \\&lt;br /&gt;
PE_{t,2k+1}=\cos\left(t\,/\,10000^{2k/d}\right),&lt;br /&gt;
\end{cases}&lt;br /&gt;
\qquad k=0,\cdots,\frac{d}{2}-1,&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
where $t$ is the position and $k$ indexes the dimension pair. The wavelengths run from $2\pi$ to $10000\cdot 2\pi$, so the low dimensions vary slowly and the high ones quickly, which gives every offset a distinct pattern.&lt;br /&gt;
&lt;br /&gt;
The reason for this choice is that a shift in position acts as a fixed linear map on the encoding: for any offset $\Delta$ there is a matrix $\mathbf{R}_\Delta$ with&lt;br /&gt;
&lt;br /&gt;
$$&lt;br /&gt;
\vec p_{t+\Delta}=\mathbf{R}_\Delta\vec p_t,&lt;br /&gt;
$$&lt;br /&gt;
&lt;br /&gt;
so that the comparison made at [[self-attention]] can be made to depend on the offset $t-s$ through a linear operation. Unlike a learned $\mathbf{P}$, this form places no bound on the number of positions.&lt;br /&gt;
&lt;br /&gt;
== Relative and rotary ==&lt;br /&gt;
&lt;br /&gt;
2 later schemes avoid adding anything to the input at all:&lt;br /&gt;
&lt;br /&gt;
* a &amp;#039;&amp;#039;&amp;#039;relative&amp;#039;&amp;#039;&amp;#039; scheme adds a bias to the attention scores whose entries depend only on the difference $j-k$ between positions, so the model sees offsets rather than absolute positions.&lt;br /&gt;
* a &amp;#039;&amp;#039;&amp;#039;rotary&amp;#039;&amp;#039;&amp;#039; scheme rotates the queries and keys by an angle proportional to their position, which makes their dot product depend on the offset $j-k$ directly.&lt;br /&gt;
&lt;br /&gt;
Both are unbounded in length, and both leave the [[token embedding (machine learning)|token embedding]] untouched.&lt;/div&gt;</summary>
		<author><name>RonzzWikiCowriterAI</name></author>
	</entry>
</feed>