Odd-Harmonic Spherical Positional Encoding
Implementation & benchmark of arXiv:2608.21587 — Tight upper bound on $d_{GH}(S^1,S^{2k+1})$: GPT's short proof
Source paper: Tight upper bound on $d_{GH}(S^1,S^{2k+1})$: GPT's short proof arXiv:2608.21587 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace or augment a scalar periodic positional coordinate with a normalized bank of odd Fourier harmonics, keeping every position on the same-radius sphere. The resulting representation has an explicit translation-invariant similarity kernel, allowing the frequency count and spectral weighting to control how sharply attention distinguishes nearby versus distant phases.
Formulas
Mathematical statement
The paper defines the symmetric moment curve for an integer k greater than or equal to 0 as g(t) = (1 divided by square root of k plus 1) times (cos(t), sin(t), cos(3t), sin(3t), ..., cos((2k+1)t), sin((2k+1)t)), where t is an angle modulo 2 pi and g(t) lies in the unit sphere in R^(2k+2). Constant norm follows from ||g(t)||_2^2 = (1/(k+1)) times the sum from j=0 to k of [cos^2((2j+1)t) + sin^2((2j+1)t)] = 1. For two angles t and s, the induced inner-product kernel is K_k(t,s) = g(t)^T g(s) = (1/(k+1)) times the sum from j=0 to k of cos((2j+1)(t-s)) = sin(2(k+1)(t-s)) divided by [2(k+1) sin(t-s)] when sin(t-s) is nonzero, with continuous limiting value 1 at t=s. The Euclidean distance is ||g(t)-g(s)||_2^2 = 2 - 2K_k(t,s). The neural-network adaptation uses nonnegative spectral weights a_j and Z = sum from j=0 to k of a_j^2: p_k(t) = (1/sqrt(Z))(a_0 cos(t), a_0 sin(t), ..., a_k cos((2k+1)t), a_k sin((2k+1)t)). It remains unit norm and has kernel K_a(t,s) = (1/Z) times the sum from j=0 to k of a_j^2 cos((2j+1)(t-s)).
Implementation notes
(1) Integrate this at the positional-embedding stage of a small decoder-only transformer. For each token position n, map it to a phase t_n = 2*pi*n/P when the task has known period P. For ordinary sequence positions, use t_n = 2*pi*n/P_max with a large P_max, or concatenate this encoding with the existing positional encoding. Construct k+1 harmonic pairs at odd frequencies 1, 3, ..., 2k+1, then project the resulting vector from dimension 2(k+1) to the model dimension d_model using a learned matrix W_p and add it to token embeddings before the first attention block. Start with fixed a_j = 1. An optional learned version uses unconstrained parameters b_j, sets a_j = softplus(b_j), and recomputes Z = sum_j a_j^2 on every forward pass. (2) Pseudocode: for each position n, set t = 2*pi*n/P; initialize z as an empty vector; for j from 0 through k, set omega = 2*j+1 and append a[j]*cos(omega*t) and a[j]*sin(omega*t); divide z by sqrt(sum_j a[j]^2); set h[n] = token_embedding[n] + W_p times z. (3) Compute the embedding and normalization exactly from the displayed formulas. Log the empirical positional kernel and verify that its value before projection equals K_a(t_n,t_m). Estimate no theorem constants; all quantities are directly computable. (4) First experiment: train a 2-layer, 4-head transformer on modular addition, copy-with-period-P, and synthetic periodic sequence-prediction tasks. Compare learned absolute positions, standard sinusoidal positions with frequencies 1, 2, 4, ..., and this odd-harmonic spherical encoding for k in {1, 3, 7, 15}. Keep projected positional dimension and parameter count comparable. Evaluate validation accuracy at training lengths and substantially longer extrapolation lengths, attention entropy versus phase difference, positional-vector norm variation, gradient-norm variance, and wall-clock overhead. The falsifiable hypothesis is improved periodic extrapolation and more stable positional norms, especially when the test period is represented by the encoding.
Verification
This idea has not been verified yet.
Verification happens in two stages: Stage 1 — a mechanism check on a toy system confirms the claimed mathematical phenomenon reproduces; Stage 2 — a benchmark implements the idea on a real (small) neural network task and compares it against a tuned baseline over 8 paired seeds with a permutation test.
Artifacts
Artifacts unavailable.