SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2507.11953 · ACL · 2025

IAM: Efficient Inference through Attention Mapping between Different-scale LLMs

Yi Zhao, Zuchao Li, Hai Zhao

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 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 1 has no contract verdict; 5 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/2507.11953.json · badge: /api/ran/2507.11953.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
QwenLM/Qwen canonical (classifier label)
classifier basis: census
7 ran · 3 no recorded run
FunctionStatusWhere it lives
add_extra_stop_words Ran
ran on a synthesized input
QwenLM/Qwen/openai_api.py
code served (permissive licence) · get_code("385a35a03fe04cde")
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

torch.manual_seed(0)

# The function takes stop_words as a parameter
# It checks if stop_words is truthy, then processes it
# It iterates over stop_words with "for x in stop_words"
# It calls x.lstrip('\n') on each element, so elements must be strings
# It checks if s (a string) is in _stop_words list
# It appends strings to _stop_words list

# Test case 1: list of strings with some containing leading newlines
stop_words_input = [
    "the",
    "\nand",
    "a",
    "\n\nor",
    "is"
]

ARGS = {
    "stop_words": stop_words_input
}
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 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
count_substr Ran
ran, honoured the contract we drafted
QwenLM/Qwen/eval/evaluate_chat_ceval.py
code served (permissive licence) · get_code("b00d2721b4146e60")
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 int, ndim 0, dtype family int, shape () 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 re

def count_substr(gen, pattern):
    return len(re.findall(pattern, gen))

# Setup code
gen = "hello world hello there hello"
pattern = r"hello"

ARGS = {
    "gen": gen,
    "pattern": pattern
}
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 int, ndim 0, dtype family int, shape () — shape () 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
format_example Ran
ran; our contract draft was wrong, not the code
QwenLM/Qwen/eval/evaluate_ceval.py
code served (permissive licence) · get_code("15a59658a1a9f53d")
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

choices = ['A', 'B', 'C', 'D']

def format_example(line, include_answer=True):
    example = '问题:' + line['question']
    for choice in choices:
        example += f"\n{choice}. {line[f'{choice}']}"
    if include_answer:
        example += '\n答案:' + line['answer'] + '\n\n'
    else:
        example += '\n答案:'
    return example

# Construct valid arguments
line = {
    'question': '这是一道测试题目',
    'A': '选项A',
    'B': '选项B',
    'C': '选项C',
    'D': '选项D',
    'answer': 'A'
}

ARGS = {
    'line': line,
    'include_answer': True
}
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
generate_few_shot_prompt Ran
ran; our contract draft was wrong, not the code
QwenLM/Qwen/eval/evaluate_ceval.py
code served (permissive licence) · get_code("750fa374392ec0e0")
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 pandas as pd

# Define the choices globally as used in format_example
choices = ['A', 'B', 'C', 'D']

def format_example(line, include_answer=True):
    example = '问题:' + line['question']
    for choice in choices:
        example += f"\n{choice}. {line[f'{choice}']}"
    if include_answer:
        example += '\n答案:' + line['answer'] + '\n\n'
    else:
        example += '\n答案:'
    return example

def generate_few_shot_prompt(k, subject, dev_df):
    prompt = ''
    if k == -1:
        k = dev_df.shape[0]
    for i in range(k):
        prompt += format_example(dev_df.iloc[i, :], include_answer=True)
    return prompt

# Create sample data for dev_df
# The dataframe needs columns: 'question', 'A', 'B', 'C', 'D', 'answer'
dev_data = [
    {
        'question': '2 + 2 等于多少?',
        'A': '3',
        'B': '4',
        'C': '5',
        'D': '6',
        'answer': 'B'
    },
    {
        'question': '首都是什么?',
        'A': '上海',
        'B': '北京',
        'C': '深圳',
        'D': '广州',
        'answer': 'B'
    },
    {
        'question': '世界最高的山是?',
        'A': '乞力马扎罗山',
        'B': '勃朗峰',
        'C': '珠穆朗玛峰',
        'D': '麦金利山',
        'answer': 'C'
    }
]

dev_df = pd.DataFrame(dev_data)

ARGS = {
    'k': 2,
    'subject': 'chinese_history',
    'dev_df': dev_df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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
QwenLM/Qwen/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
process_before_extraction Ran
ran; our contract draft was wrong, not the code
QwenLM/Qwen/eval/evaluate_chat_ceval.py
code served (permissive licence) · get_code("6c9a7bedfe4e295e")
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)

# Analyze the function to understand what it needs:
# - gen: a string that gets manipulated with .replace()
# - question: a string that gets .rstrip(), .split(), and indexing
# - choice_dict: a dict with string keys and string values that get .rstrip()

# Create test data
gen = "这是一个答案文本包含了一些选项A或B的内容。答案是非常重要的信息"
question = "什么是重要的_答案是什么。"
choice_dict = {
    'A': '非常重要的信息。',
    'B': '某个选项。',
    'C': '另一个选项'
}

ARGS = {
    'gen': gen,
    'question': question,
    'choice_dict': choice_dict
}
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
trim_stop_words Ran
ran; our contract draft was wrong, not the code
QwenLM/Qwen/openai_api.py
code served (permissive licence) · get_code("469cf12b400c2c5a")
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

# Construct arguments for trim_stop_words function
response = "The quick brown fox jumps over the lazy dog. STOP_HERE and more text after."
stop_words = ["STOP_HERE", "END", "FINISH"]

ARGS = {
    "response": response,
    "stop_words": stop_words
}
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
load_model_on_gpus Not yet run
unverified (harvested, no recorded run)
QwenLM/Qwen/utils.py
code served (permissive licence) · get_code("b10fc288b8419c43")
How it ran

no invocation recorded.

load_models_tokenizer Not yet run
unverified (harvested, no recorded run)
QwenLM/Qwen/eval/evaluate_ceval.py
code served (permissive licence) · get_code("c5b93ff86c687133")
How it ran

no invocation recorded.

load_models_tokenizer Not yet run
unverified (harvested, no recorded run)
QwenLM/Qwen/eval/evaluate_chat_ceval.py
code served (permissive licence) · get_code("da7a3a8751b47e90")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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
preprocess 8 other papers
8 dated earlier
2311.09198 (2023-11)
Never Lost in the Middle: Mastering Long-Context Question Answering with Position-Agnostic Decompositional Training
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
and 5 more not named here
trim_stop_words 3 other papers
3 dated earlier
2402.11905 (2024-02)
Learning to Edit: Aligning LLMs with Knowledge Editing
2403.07691 (2024-03)
ORPO: Monolithic Preference Optimization without Reference Model
2406.15334 (2024-06)
Multimodal Task Vectors Enable Many-Shot Multimodal In-Context Learning
add_extra_stop_words 2 other papers
2 dated earlier
2402.11905 (2024-02)
Learning to Edit: Aligning LLMs with Knowledge Editing
2406.15334 (2024-06)
Multimodal Task Vectors Enable Many-Shot Multimodal In-Context Learning
load_model_on_gpus 1 other paper
1 dated earlier
2402.11905 (2024-02)
Learning to Edit: Aligning LLMs with Knowledge Editing

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

LLMs encounter significant challenges in resource consumption nowadays, especially with long contexts. Despite extensive efforts dedicate to enhancing inference efficiency, these methods primarily exploit internal sparsity within the models, without leveraging external information for optimization. We identify the high similarity of attention matrices across different-scale LLMs, which offers a novel perspective for optimization. We first conduct a comprehensive analysis of how to measure similarity, how to select mapping Layers and whether mapping is consistency. Based on these insights, we introduce the IAM framework, which achieves dual benefits of accelerated attention computation and reduced KV cache usage by performing attention mapping between small and large LLMs. Our experimental results demonstrate that IAM can accelerate prefill by 15% and reduce KV cache usage by 22.1% without appreciably sacrificing performance. Experiments on different series of models show the generalizability of IAM. Importantly, it is also orthogonal to many existing KV cache optimization methods, making it a versatile addition to the current toolkit for enhancing LLM efficiency. Our code is available at https://github.com/QQQ-yi/IAM

For agents

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

get_harvested_code_for_paper("2507.11953")
get_code_for_paper("2507.11953")
have("2507.11953")

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

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

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

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

Connect an agent — have() is free.