SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2025.emnlp-main.1337 · EMNLP · 2025

CopySpec: Accelerating LLMs with Speculative Copy-and-Paste

Mihai Surdeanu, Razvan-Gabriel Dumitru, Minglai Yang, Vikas Yadav

Open in the Atlas

Code that ran

6 of 8 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; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 3 failures of our instrument; 2 no recorded run), measured 2026-11-24; 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/2025.emnlp-main.1337.json · badge: /api/ran/2025.emnlp-main.1337.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
RazvanDu/CopySpec canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
compress Ran
ran; our contract draft was wrong, not the code
RazvanDu/CopySpec/FastChat/fastchat/model/compression.py
pointer only (licence: MIT); the stored copy get_code serves, from Git-King-Zhan/LoReC, is pointer only (licence: NONE) · get_code("80dde39da1ba3708")
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 Git-King-Zhan/LoReC, 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.

evaluate_prediction Ran
ran on a synthesized input
RazvanDu/CopySpec/GSM/cp_gsm.py
code served (permissive licence) · get_code("544fdf432d94b818")
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 bool, ndim 0, dtype family float, 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 math
from sympy import sympify, simplify

# Test case 1: numeric expressions that should match
pred_answer_1 = "2 + 2"
gold_answer_1 = "4"

# Test case 2: algebraic expressions that should match
pred_answer_2 = "x**2 + 2*x + 1"
gold_answer_2 = "(x + 1)**2"

# Test case 3: numeric expressions with floating point
pred_answer_3 = "3.14159"
gold_answer_3 = "3.14159"

# Test case 4: empty prediction should return False
pred_answer_4 = ""
gold_answer_4 = "5"

# Test case 5: different values should not match
pred_answer_5 = "5"
gold_answer_5 = "10"

# Test case 6: strings that can't be parsed as expressions
pred_answer_6 = "hello world"
gold_answer_6 = "hello world"

# We'll use the first test case as the main ARGS
ARGS = {
    "pred_answer": "2 + 2",
    "gold_answer": "4"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
sympy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, 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
extract_code_block Ran
ran on a synthesized input
RazvanDu/CopySpec/GSM/cp_gsm.py
code served (permissive licence) · get_code("8a7b55da32d5a1e0")
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 extract_code_block(output):
    """
    Extract the last valid Python code block from the output.
    """
    matches = re.findall('```python\\n(.*?)```', output, re.DOTALL)
    for code in reversed(matches):
        code = code.strip()
        if 'print' in code:
            return code
    return ''


ARGS = {
    'output': '''Some text here

x = 5
print(x)


More text


y = 10
z = 20



result = y + z
print(result)

'''
}
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
extract_gold_answer Ran
ran on a synthesized input
RazvanDu/CopySpec/GSM/cp_gsm.py
code served (permissive licence) · get_code("49f40cd3ac6207b2")
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 extract_gold_answer(text):
    """
    Extracts the gold answer from the GSM8K dataset.
    """
    match = re.search('####\\s*([^\\n]+)', text)
    return match.group(1).strip() if match else None

# Test case 1: text with gold answer
test_text_1 = "Some problem description\n#### 42"

# Test case 2: text with gold answer and extra whitespace
test_text_2 = "Another problem\n####   The answer is yes"

# Test case 3: text without gold answer marker
test_text_3 = "No answer here"

ARGS = {
    "text": test_text_1
}
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
get_compressed_list Ran
ran; our contract draft was wrong, not the code
RazvanDu/CopySpec/FastChat/fastchat/model/compression.py
pointer only (licence: MIT); the stored copy get_code serves, from Git-King-Zhan/LoReC, is pointer only (licence: NONE) · get_code("c5824da57107fe8c")
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 Git-King-Zhan/LoReC, 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.

read_jsonl Ran
ran; our contract draft was wrong, not the code
RazvanDu/CopySpec/find_best_k/best_k_cs.py
code served (permissive licence) · get_code("04f99874105cf826")
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 json
import tempfile
import os

# Create a temporary JSONL file for testing
temp_dir = tempfile.mkdtemp()
jsonl_file_path = os.path.join(temp_dir, "test.jsonl")

# Write some test data to the JSONL file
test_data = [
    {"name": "Alice", "age": 30},
    {"name": "Bob", "age": 25},
    {"name": "Charlie", "age": 35}
]

with open(jsonl_file_path, 'w') as f:
    for obj in test_data:
        f.write(json.dumps(obj) + '\n')

# Define ARGS with the file path
ARGS = {
    "file_path": jsonl_file_path
}
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 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
get_conv_template Not yet run
unverified (harvested, no recorded run)
RazvanDu/CopySpec/FastChat/fastchat/conversation.py
code served (permissive licence) · get_code("0e29f2d151ce2bd7")
How it ran

no invocation recorded.

load_compress_model Not yet run
unverified (harvested, no recorded run)
RazvanDu/CopySpec/FastChat/fastchat/model/compression.py
pointer only (licence: MIT); the stored copy get_code serves, from rui-ye/fedllm-bench, is pointer only (licence: NOASSERTION) · get_code("5196732e9a84b6dc")
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 rui-ye/fedllm-bench, and GitHub could not classify the licence of that repository (NOASSERTION). 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 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 4 later) and 3 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
get_conv_template 69 other papers
51 dated earlier, 7 later, 10 same year, order not determinable, 1 undated
1911.03705 (2019-11)
CommonGen: A Constrained Text Generation Challenge for Generative Commonsense Reasoning
2112.05682 (2021-12)
Self-attention Does Not Need $O(n^2)$ Memory
2204.07705 (2022-04)
SUPER-NATURALINSTRUCTIONS: Generalization via Declarative Instructions on 1600+ NLP Tasks
and 66 more not named here
compress 17 other papers
15 dated earlier, 2 later
2112.05682 (2021-12)
Self-attention Does Not Need $O(n^2)$ Memory
2303.06865 (2023-03)
FlexGen: High-Throughput Generative Inference of Large Language Models with a Single GPU
2304.10453 (2023-04)
Phoenix: Democratizing ChatGPT across Languages
and 14 more not named here
get_compressed_list 13 other papers
11 dated earlier, 2 later
2112.05682 (2021-12)
Self-attention Does Not Need $O(n^2)$ Memory
2310.13023 (2023-10)
GraphGPT: Graph Instruction Tuning for Large Language Models
2310.17631 (2023-10)
JudgeLM: Fine-tuned Large Language Models are Scalable Judges
and 10 more not named here
load_compress_model 4 other papers
4 dated earlier
2402.02130 (2024-02)
GITA: Graph to Visual and Textual Integration for Vision-Language Graph Reasoning
2403.02502 (2024-03)
Trial and Error: Exploration-Based Trajectory Optimization for LLM Agents
2403.04132 (2024-03)
Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference
and 1 more not named here
read_jsonl 4 other papers
2 dated earlier, 1 later, 1 same year, order not determinable
2401.10768 (2024-01)
Knowledge Verification to Nip Hallucination in the Bud
2412.16620 (2024-12)
A Large-scale Empirical Study on Fine-tuning Large Language Models for Unit Testing
2505.17612 (2025-05)
Distilling LLM Agent into Small Models with Retrieval and Code Tools
and 1 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-24.

Repositories linked to this paper

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

Abstract

We introduce CopySpec, a simple yet effective technique to tackle the inefficiencies LLMs face when generating responses that closely resemble previous outputs or responses that can be verbatim extracted from context. CopySpec identifies repeated sequences in the model's chat history or context and speculates that the same tokens will follow, enabling seamless copying without compromising output quality and without requiring additional GPU memory. To evaluate the effectiveness of our approach, we conducted experiments using seven LLMs and five datasets: MT-Bench, CNN/DM, GSM8K, HumanEval, and our newly created dataset, MT-Redundant. MT-Redundant, introduced in this paper, transforms the second turn of MT-Bench into a request for variations of the first turn's answer, simulating realworld scenarios where users request modifications to prior responses. Our results demonstrate significant speed-ups: up to 2.35× on CNN/DM, 3.08× on the second turn of select MT-Redundant categories, and 2.66× on the third turn of GSM8K's self-correction tasks. Importantly, we show that CopySpec integrates seamlessly with speculative decoding, yielding an average 49% additional speedup over speculative decoding for the second turn of MT-Redundant across all eight categories. While LLMs, even with speculative decoding, suffer from slower inference as context size grows, CopySpec leverages larger contexts to accelerate inference, making it a faster complementary solution. Our code and dataset are publicly available at https://github.com/RazvanDu/CopySpec.

For agents

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

get_harvested_code_for_paper("2025.emnlp-main.1337")
get_code_for_paper("2025.emnlp-main.1337")
have("2025.emnlp-main.1337")

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

curl https://syntology.ai/api/ran/2025.emnlp-main.1337.json

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

[![Syntology run record](https://syntology.ai/api/ran/2025.emnlp-main.1337.svg)](https://syntology.ai/paper/2025.emnlp-main.1337)

Connect an agent — have() is free.