SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.09198 · 2023

Never Lost in the Middle: Mastering Long-Context Question Answering with Position-Agnostic Decompositional Training

arXiv · PDF · Open in the Atlas

Code that ran

15 of 17 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, 1 violated it and 0 have no contract verdict; 13 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2311.09198.json · badge: /api/ran/2311.09198.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
hejunqing/never-lost-in-the-middle canonical (classifier label)
classifier basis: census
14 ran · 1 no recorded run
qihoo360/360zhinao community (classifier label)
classifier basis not recorded on the link
1 ran · 1 no recorded run
FunctionStatusWhere it lives
add_eod Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/new_utils.py
code served (permissive licence) · get_code("afdae69731929a72")
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.

import re

def add_eod(input_text, dataset='dureader'):
    if dataset != 'dureader' and dataset != 'passage_retrieval_zh' and (dataset != 'vcsum'):
        modified_text = input_text
    else:
        pattern = re.compile('(\\[\\d+\\] (.*?)[^\\[]*)')
        out = pattern.findall(input_text)
        out = [''.join(t) for t in out if isinstance(t, tuple)]
        modified_text = f'<eod>\n'.join(out)
    if dataset == 'multifieldqa_zh':
        modified_text = '[1] ' + modified_text
    modified_text += '<eod>\n'
    print(modified_text)
    return modified_text


ARGS = {
    'input_text': '[1] This is a test passage with some content here[2] Another passage section',
    'dataset': 'dureader'
}
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
build_chat Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hejunqing/never-lost-in-the-middle/Lost_Retrieval/src/pred_single.py
code served (permissive licence) · get_code("251720ea85d2ca71")
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.

import torch

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.vocab_size = 1000
    
    def encode(self, text):
        return [1, 2, 3]
    
    def decode(self, tokens):
        return "decoded text"

tokenizer = MockTokenizer()
tokenized_prompt = [1, 2, 3, 4, 5]
prompt = "Hello, how are you?"

ARGS = {
    "tokenizer": tokenizer,
    "tokenized_prompt": tokenized_prompt,
    "prompt": prompt
}
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 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
build_chat Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hejunqing/never-lost-in-the-middle/LongBench/src/baichuan_pred_shuffle.py
code served (permissive licence) · get_code("7024e12377186e51")
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.

import torch

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.vocab_size = 100
    
    def encode(self, text):
        return [1, 2, 3]
    
    def decode(self, tokens):
        return "decoded text"

tokenizer = MockTokenizer()
tokenized_prompt = [1, 2, 3, 4, 5]
prompt = "Hello world"

ARGS = {
    "tokenizer": tokenizer,
    "tokenized_prompt": tokenized_prompt,
    "prompt": prompt
}
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 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
build_chat Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/pred_chatglm.py
code served (permissive licence) · get_code("7439724189daf2cb")
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.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Stand-in tokenizer classes for different model types
class ChatGLM3Tokenizer:
    def build_chat_input(self, prompt):
        # Returns an object with input_ids attribute
        class InputIds:
            def __init__(self):
                self.input_ids = [[1, 2, 3, 4]]  # Special tokens + prompt tokens
        return InputIds()
    
    def decode(self, token_ids, skip_special_tokens=False):
        return "decoded prompt text"

class ChatGLMTokenizer:
    def build_prompt(self, prompt):
        return f"[INST]{prompt}[/INST]"

class GenericTokenizer:
    pass

# Test with different model names
def create_tokenizer_for_model(model_name):
    if 'chatglm3' in model_name:
        return ChatGLM3Tokenizer()
    elif 'chatglm' in model_name:
        return ChatGLMTokenizer()
    else:
        return GenericTokenizer()

# Create test cases for each model type
test_cases = [
    ('chatglm3-6b', ChatGLM3Tokenizer()),
    ('chatglm-6b', ChatGLMTokenizer()),
    ('Qwen-7B', GenericTokenizer()),
    ('llama2-7b', GenericTokenizer()),
    ('xgen-7b', GenericTokenizer()),
    ('internlm-7b', GenericTokenizer()),
]

# Use the first test case for ARGS
model_name = 'chatglm3-6b'
tokenizer = ChatGLM3Tokenizer()
prompt = "Hello, how are you?"

ARGS = {
    'tokenizer': tokenizer,
    'prompt': prompt,
    'model_name': model_name,
}
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 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
build_chat2 Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/Lost_Retrieval/src/pred_single.py
code served (permissive licence) · get_code("619fcfb88a0948e5")
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.

import torch
from unittest.mock import Mock

torch.manual_seed(0)

class MockTokenizer:
    def build_prompt(self, prompt):
        return f"Built prompt: {prompt}"

tokenizer = MockTokenizer()
tokenized_prompt = [1, 2, 3, 4]
prompt = "Hello, how are you?"

ARGS = {
    "tokenizer": tokenizer,
    "tokenized_prompt": tokenized_prompt,
    "prompt": prompt
}
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 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
build_chat_baichuan Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hejunqing/never-lost-in-the-middle/LongBench/src/pred_shuffle_reader.py
code served (permissive licence) · get_code("9cea8a9dc64a79cc")
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.

import torch

torch.manual_seed(0)

# The function uses:
# - tokenizer: passed but not actually used in the function body
# - tokenized_prompt: passed but not actually used in the function body
# - prompt: a string that gets wrapped with reserved tokens

class DummyTokenizer:
    """Minimal tokenizer stand-in"""
    def __init__(self):
        pass

tokenizer = DummyTokenizer()
tokenized_prompt = torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]])
prompt = "Hello world"

ARGS = {
    "tokenizer": tokenizer,
    "tokenized_prompt": tokenized_prompt,
    "prompt": prompt
}
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 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
count_score Ran
ran, honoured the contract we drafted
hejunqing/never-lost-in-the-middle/LongBench/src/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from borealisai/radar-decoding, is pointer only (licence: LGPL-3.0) · get_code("b349b79d9cc2934b")
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 borealisai/radar-decoding, and LGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

get_pred Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/baichuan_pred_shuffle.py
code served (permissive licence) · get_code("9ac0485160d687f7")
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 list, ndim 1, 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
import torch.nn as nn
from unittest.mock import MagicMock

torch.manual_seed(0)

# Build a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.eos_token_id = 2
        self.bos_token_id = 1
        self.pad_token_id = 0
    
    def __call__(self, text, truncation=False, max_length=None, return_tensors=None, add_special_tokens=True):
        # Return a mock object with input_ids attribute
        if return_tensors == 'pt':
            # Simple tokenization: create a tensor based on text length
            token_ids = torch.tensor([[1] + [i % 100 + 3 for i in range(len(text) // 5 + 1)] + [2]], dtype=torch.long)
            if max_length and token_ids.shape[1] > max_length:
                token_ids = token_ids[:, :max_length]
            result = MagicMock()
            result.input_ids = token_ids
            result.to = lambda device: result
            return result
        return None
    
    def decode(self, token_ids, skip_special_tokens=False):
        return "decoded text"

# Build a minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, max_new_tokens=None, do_sample=None, temperature=None, 
                 top_p=None, eos_token_id=None, bos_token_id=None, pad_token_id=None, 
                 early_stopping=None, repetition_penalty=None):
        # Return a tensor combining input_ids with some generated tokens
        batch_size = input_ids.shape[0]
        context_len = input_ids.shape[1]
        total_len = context_len + max_new_tokens
        # Generate output tokens
        output = torch.cat([input_ids, torch.randint(3, 100, (batch_size, max_new_tokens))], dim=1)
        return output

# Build test data
data = [
    {
        'input': 'What is the capital?',
        'answers': ['Paris'],
        'all_classes': ['France', 'Germany']
    },
    {
        'input': 'What is 2+2?',
        'answers': ['4'],
        'all_classes': ['Numbers', 'Math']
    }
]

# Build arguments
ARGS = {
    'model': MinimalModel(),
    'tokenizer': MinimalTokenizer(),
    'data': data,
    'max_length': 512,
    'max_gen': 50,
    'prompt_format': '{input}',
    'dataset': 'nq',
    'device': 'cpu'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from borealisai/radar-decoding, is pointer only (licence: LGPL-3.0) · get_code("e7e75981cb464788")
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 borealisai/radar-decoding, and LGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

normalize_zh_answer Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/metrics.py
pointer only (licence: MIT); the stored copy get_code serves, from borealisai/radar-decoding, is pointer only (licence: LGPL-3.0) · get_code("8c5c581f9264c810")
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 borealisai/radar-decoding, and LGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

parse_args Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/pred_chatglm.py
code served (permissive licence) · get_code("36753478d8bfe1e1")
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 Namespace. 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 argparse

def parse_args(args=None):
    parser = argparse.ArgumentParser()
    parser.add_argument('--model', type=str, default=None, choices=['Qwen-14b-chat', 'llama2-7b-chat-4k', 'longchat-v1.5-7b-32k', 'xgen-7b-8k', 'internlm-7b-8k', 'chatglm2-6b', 'chatglm2-6b-32k', 'vicuna-v1.5-7b-16k'])
    parser.add_argument('--e', action='store_true', help='Evaluate on LongBench-E')
    return parser.parse_args(args)

ARGS = {
    'args': ['--model', 'Qwen-14b-chat', '--e']
}
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 Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace 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
post_process Ran
ran, violated the contract we drafted
hejunqing/never-lost-in-the-middle/LongBench/src/pred_chatglm.py
code served (permissive licence) · get_code("4489113b536ca6eb")
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 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.

import torch
import numpy as np

torch.manual_seed(0)

# The function post_process takes two parameters:
# 1. response: a string that gets processed based on model_name
# 2. model_name: a string used to determine which processing branch to take

# Test case 1: xgen model
response_xgen = "Some response text\nAssistant: This is the assistant response"
model_name_xgen = "xgen-7b"

# Test case 2: internlm model
response_internlm = "Some response<eoa>This should be removed"
model_name_internlm = "internlm-chat"

# Test case 3: other model (no special processing)
response_other = "Just a regular response"
model_name_other = "gpt2"

# We'll use the xgen case as the primary test
ARGS = {
    "response": "Some response text\nAssistant: This is the assistant response",
    "model_name": "xgen-7b"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — 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
preprocess Ran
ran; our contract draft was wrong, not the code
qihoo360/360zhinao/Reranking/finetune.py
code served (permissive licence) · get_code("8b733c9fc590e4c1")
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 dict. 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 transformers
from transformers.trainer_pt_utils import LabelSmoother

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.im_start_id = 100
        self.im_end_id = 101
        self.pad_token_id = 0
        self._token_to_ids = {
            'system': [102],
            'user': [103],
            'assistant': [104],
            '\n': [105],
            'You are a helpful assistant.': [106, 107],
            'Hello': [108, 109],
            'Hi there': [110, 111, 112],
        }
    
    def __call__(self, text):
        if text in self._token_to_ids:
            return type('obj', (object,), {'input_ids': self._token_to_ids[text]})()
        return type('obj', (object,), {'input_ids': [113]})()

tokenizer = MockTokenizer()

sources = [
    [
        {'from': 'user', 'value': 'Hello'},
        {'from': 'assistant', 'value': 'Hi there'},
    ],
    [
        {'from': 'user', 'value': 'Hello'},
        {'from': 'assistant', 'value': 'Hi there'},
    ],
]

ARGS = {
    'sources': sources,
    'tokenizer': tokenizer,
    'max_len': 64,
    'system_message': 'You are a helpful assistant.',
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
replace_head Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/new_utils.py
code served (permissive licence) · get_code("372ffbf8201660a5")
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.

import re

# Test case 1: dureader dataset
context_dureader = "文章1\n这是第一篇文章 文章2 这是第二篇文章"
dataset_dureader = "dureader"

# Test case 2: passage_retrieval_zh dataset
context_passage = "段落1:这是第一段 段落2:这是第二段"
dataset_passage = "passage_retrieval_zh"

# Test case 3: vcsum dataset
context_vcsum = "讲者1:第一个讲话 讲者2:第二个讲话"
dataset_vcsum = "vcsum"

# We'll use the dureader case as the primary test
ARGS = {
    "context": context_dureader,
    "dataset": dataset_dureader
}
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
shorten Ran
ran; our contract draft was wrong, not the code
hejunqing/never-lost-in-the-middle/LongBench/src/new_utils.py
code served (permissive licence) · get_code("6653c42aad855a65")
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.

import torch

def shorten(context, sep='<eod>', num=10):
    text = context.lstrip(sep)
    paras = text.split(sep)
    context = sep.join(paras[:num])
    return context

ARGS = {
    'context': '<eod>paragraph 1<eod>paragraph 2<eod>paragraph 3<eod>paragraph 4<eod>paragraph 5',
    'sep': '<eod>',
    'num': 10
}
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 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
build_chat Not yet run
unverified (harvested, no recorded run)
hejunqing/never-lost-in-the-middle/LongBench/src/pred_shuffle_reader.py
code served (permissive licence) · get_code("0af745ab8b003692")
How it ran

no invocation recorded.

preprocess Not yet run
unverified (harvested, no recorded run)
qihoo360/360zhinao/Reranking/flag_models.py
code served (permissive licence) · get_code("a30e2612231ea545")
How it ran

no invocation recorded.

Also present in other papers' code

Of 17 samples lifted from this paper's linked repositories, 17 carry a function identity and 0 do not. Of the 17 distinct functions with an identity, 5 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 3 the same month, 5 later) and 12 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 133 other papers
51 dated earlier, 3 the same month, 77 later, 1 same year, order not determinable, 1 undated · 1 only as an assembly brick
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 130 more not named here
normalize_zh_answer 28 other papers
1 the same month, 26 later, 1 undated
2311.04934 (2023-11)
Prompt Cache: Modular Attention Reuse for Low-Latency Inference
2024.findings-emnlp.230 (2024 (year only))
CLongEval: A Chinese Benchmark for Evaluating Long-Context Large Language Models
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
and 25 more not named here
count_score 24 other papers
1 the same month, 22 later, 1 undated
2311.04934 (2023-11)
Prompt Cache: Modular Attention Reuse for Low-Latency Inference
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
2402.04617 (2024-02)
InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory
and 21 more not named here
post_process 14 other papers
14 later
2402.02750 (2024-02)
KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache
2404.14469 (2024-04)
SnapKV: LLM Knows What You are Looking for Before Generation
2405.04434 (2024-05)
DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model
and 11 more not named here
preprocess 8 other papers
8 later
2401.10935 (2024-01)
SeeClick: Harnessing GUI Grounding for Advanced Visual GUI Agents
2402.11905 (2024-02)
Learning to Edit: Aligning LLMs with Knowledge Editing
2406.11317 (2024-06)
GUICourse: From General Vision Language Models to Versatile GUI Agents
and 5 more not named here

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

While large language models (LLMs) are equipped with longer text input capabilities than before, they are struggling to seek correct information in long contexts. The "lost in the middle" problem challenges most LLMs, referring to the dramatic decline in accuracy when correct information is located in the middle. To overcome this crucial issue, this paper proposes to enhance the information searching and reflection ability of LLMs in long contexts via specially designed tasks called Attention Strengthening Multi-doc QA (ASM QA). Following these tasks, our model excels in focusing more precisely on the desired information. Experimental results show substantial improvement in Multi-doc QA and other benchmarks, superior to state-of-the-art models by 13.7% absolute gain in shuffled settings, by 21.5% in passage retrieval task. We release our model, Ziya-Reader to promote related research in the community.

For agents

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

get_harvested_code_for_paper("2311.09198")
get_code_for_paper("2311.09198")
have("2311.09198")

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

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

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

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

Connect an agent — have() is free.