Papers › KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation

KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation

20 May 2022arXiv:2205.09921archive 2025-07-28

Ta-Chung Chi, Ting-Han Fan, Peter J. Ramadge, Alexander I. Rudnicky

Relative positional embeddings (RPE) have received considerable attention since RPEs effectively model the relative distance among tokens and enable length extrapolation. We propose KERPLE, a framework that generalizes relative position embedding for extrapolation by kernelizing positional differences. We achieve this goal using conditionally positive definite (CPD) kernels, a class of functions known for generalizing distance metrics. To maintain the inner product interpretation of self-attention, we show that a CPD kernel can be transformed into a PD kernel by adding a constant offset. This offset is implicitly absorbed in the Softmax normalization during self-attention. The diversity of CPD kernels allows us to derive various RPEs that enable length extrapolation in a principled way. Experiments demonstrate that the logarithmic variant achieves excellent extrapolation performance on three large language modeling datasets. Our implementation and pretrained checkpoints are released at~\url{https://github.com/chijames/KERPLE.git}.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2205.09921")

Code

Syntology Ran 2 of 8 code samples harvested from 1 repository linked to this paper; 6 have no recorded run. Of those that ran: 2 ran with no contract checked.

By repository: official repository: 8 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

chijames/kerple officialmentioned in papermentioned on GitHubpytorchApache-2.0 report
eleutherai/gpt-neox officialmentioned in papermentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

8 samples harvested; 2 ran; 0 honoured the contract we drafted; 6 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran
6unverified

Licence: 8 of the 8 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from chijames/KERPLE. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

bias_gelu chijames/KERPLE/megatron/model/activations.py official repository ran Apache-2.0 recorded; this copy not marked cleared · pointer only · eb7511606bf2a37e · report
bias_gelu_back chijames/KERPLE/megatron/model/activations.py official repository ran Apache-2.0 recorded; this copy not marked cleared · pointer only · 5dc15a21043ef7e3 · report
get_activation chijames/KERPLE/megatron/model/activations.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 6ddf47f8b4c13803 · report
get_docs chijames/KERPLE/configs/gen_docs.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 750d7ac5c014981c · report
get_flops chijames/KERPLE/megatron/logging.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 6baae5f9664f3498 · report
human_readable_flops chijames/KERPLE/megatron/logging.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 3b4fd8987610cea1 · report
pairwise chijames/KERPLE/configs/gen_docs.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 50c9c165cf801f59 · report
to_md chijames/KERPLE/configs/gen_docs.py official repository unverified Apache-2.0 recorded; this copy not marked cleared · pointer only · 64dd872a8ac47294 · report

Tasks

DiversityLanguage ModelingLanguage Modelling

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Softmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections