SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.04805 · 2026

Attention's Gravitational Field: A Power-Law Interpretation of Positional Correlation

Edward Zhang

arXiv · PDF · Open in the Atlas

Code that ran

9 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 failures of our instrument; 3 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.04805.json · badge: /api/ran/2603.04805.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
windyrobin/AGF canonical (classifier label)
classifier basis: census
0 ran · 1 no recorded run
OpenNMT/OpenNMT-py community
Papers with Code archive
9 ran · 2 no recorded run
FunctionStatusWhere it lives
AlibiPositionalBias Ran
ran on a synthesized input · constructed an object; no result was computed
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("525c2d39941bbce9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, AlibiPositionalBias: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small valid input tensor for forward pass
# Shape: (batch=2, heads=4, seq_len_i=3, seq_len_j=5)
qk_dots = torch.randn(2, 4, 3, 5)

ARGS = {
    'heads': 4,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AlibiPositionalBias — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AlibiPositionalBias output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_relative_position_bucket Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("729ef446f280b974")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from math import log

torch.manual_seed(0)

# Create a small tensor for relative_position
# The function expects int32 tensor with arbitrary shape
relative_position = torch.tensor([[-5, -2, 0, 3], [5, 10, 50, 150]], dtype=torch.int32)

ARGS = {
    "relative_position": relative_position,
    "bidirectional": True,
    "num_buckets": 32,
    "max_distance": 128,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_bias Ran
ran, honoured the contract we drafted
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("d3473dc6f8a2cee8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (4, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from math import log, sqrt

torch.manual_seed(0)

ARGS = {
    "query_length": 4,
    "key_length": 6,
    "is_decoder": False,
    "max_relative_positions": 128,
    "relative_positions_buckets": 32,
    "device": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (4, 6) — shape (4, 6) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gen_relative_positions Ran
ran, honoured the contract we drafted
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("137d5fd06cd817a4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (5, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "length": 5,
    "max_relative_positions": 3,
    "cache": False,
    "device": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (5, 5) — shape (5, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
pad_at_dim Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("e62e48a00ed06f63")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 7) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor for testing
# Shape: (2, 4) - batch size 2, feature dim 4
t = torch.randn(2, 4)

# Define padding as (left, right) tuple for the dimension
pad = (1, 2)

# Dimension to pad (-1 means last dimension)
dim = -1

# Padding value
value = 0.0

ARGS = {
    "t": t,
    "pad": pad,
    "dim": dim,
    "value": value,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 7) — shape (2, 7) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
relative_matmul Ran
ran; our contract draft was wrong, not the code
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("a14fa691ae6f254a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct arguments for relative_matmul
# x shape: [batch_size x heads x q_len x k_len]
batch_size = 2
heads = 3
q_len = 4
k_len = 5

x = torch.randn(batch_size, heads, q_len, k_len)

# z should be compatible for matmul with reshaped x_t_r
# x_t_r shape: [q_len, heads * batch_size, k_len]
# After matmul with z, we need output compatible with view(q_len, batch_size, heads, -1)
# So z should be [k_len, output_dim] where output_dim can be any value
z = torch.randn(k_len, 6)

transpose = False

ARGS = {
    "x": x,
    "z": z,
    "transpose": transpose,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) — shape (2, 3, 4, 6) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rotaryembeddings Ran
ran; our contract draft was wrong, not the code
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("0d802270606c7e37")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "dim": 8,
    "maxseqlen": 16,
    "base": 10000,
    "device": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
shape Ran
ran; our contract draft was wrong, not the code
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("156ac72eda8c9323")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 3, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small tensor with shape [batchsize x length x modeldim]
# Using distinct sizes: batch=2, length=3, modeldim=8
x = torch.randn(2, 3, 8)

# dim_per_head should divide modeldim evenly
# modeldim=8, so dim_per_head=2 means we'll have 4 heads
dim_per_head = 2

ARGS = {
    "x": x,
    "dim_per_head": dim_per_head,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 4, 3, 2) — shape (2, 4, 3, 2) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unshape Ran
ran; our contract draft was wrong, not the code
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("3c73b517864547c4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 15) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a tensor with shape [batchsize x heads x length x dimperhead]
# Using distinct sizes: batchsize=2, heads=3, length=4, dimperhead=5
x = torch.randn(2, 3, 4, 5)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 15) — shape (2, 4, 15) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MultiHeadedAttention Not yet run
unverified (harvested, no recorded run)
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("62f1ce6285ab599b")
How it ran

no invocation recorded.

apply_rotary_emb Not yet run
unverified (harvested, no recorded run)
OpenNMT/OpenNMT-py/onmt/modules/multi_headed_attn.py
code served (permissive licence) · get_code("19d46f07e889fbb9")
How it ran

no invocation recorded.

attention Not yet run
unverified (harvested, no recorded run)
windyrobin/AGF/attention.py
pointer only (licence: NONE) · get_code("1f873422e04f7352")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, windyrobin/AGF when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
pad_at_dim
brick of this paper's assembly: helper
3 other papers
2 dated earlier, 1 later
2010.06192 (2020-10)
Revisiting BFloat16 Training
2210.06155 (2022-10)
ERNIE-Layout: Layout Knowledge Enhanced Pre-training for Visually-rich Document Understanding
2605.10537 (2026-05)
Mela: Test-Time Memory Consolidation based on Transformation Hypothesis

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

This paper explores the underlying principles of positional relationships and encodings within Large Language Models (LLMs) and introduces the concept of Attention-Gravitational Field (AGF). By decoupling positional encodings from semantic embeddings, we optimize the model architecture and achieve superior accuracy compared to prevailing encoding methods. Furthermore, we provide an in-depth analysis of AGF, demonstrating its intrinsic consistency with learning and stability curves, as well as its empirical alignment with Newton's Law of Universal Gravitation. By offering a rigorous theoretical exploration of these phenomena, this work represents a significant step toward interpreting the Attention mechanism and unlocks new possibilities for future research in model optimization and interpretability.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.04805")
get_code_for_paper("2603.04805")
have("2603.04805")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.04805.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.04805.svg)](https://syntology.ai/paper/2603.04805)

Connect an agent — have() is free.