SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.04797 · 2024

Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2403.04797.json · badge: /api/ran/2403.04797.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
vita-group/ms-poe canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
FunctionStatusWhere it lives
best_subspan_em Ran
ran, honoured the contract we drafted
vita-group/ms-poe/utils/lost_in_the_middle/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from voidism/lookback-lens, is pointer only (licence: NONE) · get_code("10af7cdbc53df7e5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from voidism/lookback-lens, and GitHub detected no licence in that repository 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. A run is recorded.

format_instruct_prompt Ran
ran; our contract draft was wrong, not the code
vita-group/ms-poe/inference.py
code served (permissive licence) · get_code("1e504ba0ec5a8a8b")
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 str. 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.

ARGS = {
    'instruction': 'Write a Python function that returns the sum of two numbers.'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
vita-group/ms-poe/utils/lost_in_the_middle/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from zmzhang2000/trustworthy-alignment, is pointer only (licence: NONE) · get_code("9706a9a0b961096b")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from zmzhang2000/trustworthy-alignment, and GitHub detected no licence in that repository 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. A run is recorded.

sample_rotary_emb Ran
ran; our contract draft was wrong, not the code
vita-group/ms-poe/utils/modify_arch/llama.py
code served (permissive licence) · get_code("783f23ce2b755375")
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, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# cos and sin are accessed with indexing [::num_key_value_groups, ...]
# They need to be tensors with at least 1 dimension
# Using shape (12, 4) so that sampling with different num_key_value_groups works well
cos = torch.randn(12, 4)
sin = torch.randn(12, 4)

# num_key_value_groups is used as a step in slicing
# Using 3 so that [::3, ...] produces a valid subset
num_key_value_groups = 3

ARGS = {
    "cos": cos,
    "sin": sin,
    "num_key_value_groups": num_key_value_groups
}
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, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
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
get_qa_prompt Not yet run
unverified (harvested, no recorded run)
vita-group/ms-poe/utils/lost_in_the_middle/prompting.py
code served (permissive licence) · get_code("286b6ac3dc4a717d")
How it ran

no invocation recorded.

get_qa_prompt_index Not yet run
unverified (harvested, no recorded run)
vita-group/ms-poe/utils/lost_in_the_middle/prompting.py
code served (permissive licence) · get_code("01cd2c144c0ba704")
How it ran

no invocation recorded.

get_qa_prompt_only_true_index Not yet run
unverified (harvested, no recorded run)
vita-group/ms-poe/utils/lost_in_the_middle/prompting.py
code served (permissive licence) · get_code("6aba27dd9e3ea2fb")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 2 the same month, 3 later) and 4 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
normalize_answer 11 other papers
1 dated earlier, 1 the same month, 9 later
2308.07922 (2023-08)
RAVEN: In-Context Learning with Retrieval-Augmented Encoder-Decoder Language Models
2403.15268 (2024-03)
Awakening Augmented Generation: Learning to Awaken Internal Knowledge of Large Language Models for Question Answering
2406.02536 (2024-06)
Mitigate Position Bias in Large Language Models via Scaling a Single Dimension
and 8 more not named here
best_subspan_em 5 other papers
1 the same month, 4 later
2403.15268 (2024-03)
Awakening Augmented Generation: Learning to Awaken Internal Knowledge of Large Language Models for Question Answering
2406.02536 (2024-06)
Mitigate Position Bias in Large Language Models via Scaling a Single Dimension
2407.07071 (2024-07)
Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Maps
and 2 more not named here
get_qa_prompt 1 other paper
1 later
2406.02536 (2024-06)
Mitigate Position Bias in Large Language Models via Scaling a Single Dimension

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-22.

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 aims to overcome the "lost-in-the-middle" challenge of large language models (LLMs). While recent advancements have successfully enabled LLMs to perform stable language modeling with up to 4 million tokens, the persistent difficulty faced by most LLMs in identifying relevant information situated in the middle of the context has not been adequately tackled. To address this problem, this paper introduces Multi-scale Positional Encoding (Ms-PoE) which is a simple yet effective plug-and-play approach to enhance the capacity of LLMs to handle the relevant information located in the middle of the context, without fine-tuning or introducing any additional overhead. Ms-PoE leverages the position indice rescaling to relieve the long-term decay effect introduced by RoPE, while meticulously assigning distinct scaling ratios to different attention heads to preserve essential knowledge learned during the pre-training step, forming a multi-scale context fusion from short to long distance. Extensive experiments with a wide range of LLMs demonstrate the efficacy of our approach. Notably, Ms-PoE achieves an average accuracy gain of up to 3.8 on the Zero-SCROLLS benchmark over the original LLMs. Code are available at https://github.com/VITA-Group/Ms-PoE.

For agents

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

get_harvested_code_for_paper("2403.04797")
get_code_for_paper("2403.04797")
have("2403.04797")

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

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

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

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

Connect an agent — have() is free.