SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2307.06945 · ICLR · 2024

In-context Autoencoder for Context Compression in a Large Language Model

Tao Ge, Furu Wei, Si-Qing Chen, Jing Hu, Xun Wang, Lei Wang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 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 0 have no contract verdict; 6 failures of our instrument; 0 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2307.06945.json · badge: /api/ran/2307.06945.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
getao/icae canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
getao/icae/code/icae_v1/base/modeling_llama_icae.py
code served (permissive licence) · get_code("30d7eec482ebf6b1")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (2, 6, 5, 4) as a later run recorded it. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T23:09:20Z). 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 torch

torch.manual_seed(0)

# Create a tensor with shape (batch, num_key_value_heads, seqlen, head_dim)
# Using distinct sizes: batch=2, num_key_value_heads=3, seqlen=5, head_dim=4
hidden_states = torch.randn(2, 3, 5, 4)

# n_rep is the repetition factor
n_rep = 2

ARGS = {
    "hidden_states": hidden_states,
    "n_rep": n_rep,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float, shape (2, 6, 5, 4) — shape (2, 6, 5, 4) 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
apply_rotary_pos_emb Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
getao/icae/code/icae_v1/base/modeling_llama_icae.py
code served (permissive licence) · get_code("f725bc2d76076485")
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 tuple, ndim 5, 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)

# Create small tensors for q and k
# Shape: (batch_size=2, seq_len=3, hidden_dim=4)
q = torch.randn(2, 3, 4)
k = torch.randn(2, 3, 4)

# Create cos and sin tensors
# The function squeezes dimensions 1 and 0, then indexes by position_ids
# So we need shape that allows this: (1, 1, seq_len, hidden_dim)
cos = torch.randn(1, 1, 5, 4)
sin = torch.randn(1, 1, 5, 4)

# Create position_ids
# Shape: (batch_size=2, seq_len=3)
position_ids = torch.tensor([[0, 1, 2], [1, 2, 3]])

ARGS = {
    "q": q,
    "k": k,
    "cos": cos,
    "sin": sin,
    "position_ids": position_ids,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 5, 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
instruct_ft_tokenize_function Ran
ran; our contract draft was wrong, not the code
getao/icae/code/icae_v2/training_utils.py
code served (permissive licence) · get_code("5d4c3fbe9286bb9a")
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 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 torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def __call__(self, text, max_length=None, truncation=False, padding=False, 
                 return_attention_mask=False, add_special_tokens=False):
        # Return mock tokenized output
        if isinstance(text, list):
            return {
                'input_ids': [[101, 2054, 2003, 1045] for _ in text]
            }
        else:
            return {
                'input_ids': [[101, 2054, 2003, 1045]]
            }

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.tokenizer = MockTokenizer()
        self.ft_token_id = 50256
        self.eos_id = 2
        self.mem_size = 8
        
        # Create mock training_args
        self.training_args = type('obj', (object,), {'model_max_length': 5120})()
    
    def compute_num_segments(self, length):
        # Simple mock implementation
        return max(1, (length + self.mem_size - 1) // self.mem_size)

# Create mock examples dict with batch of 2
examples = {
    'input': [
        "What is machine learning?",
        "Explain deep learning"
    ],
    'prompt': [
        "You are helpful",
        "Answer the question"
    ],
    'answer': [
        "Machine learning is a subset of AI",
        "Deep learning uses neural networks"
    ]
}

# Create model
model = MockModel()

# Create memory mock (list of token IDs)
mem = [1000, 1001, 1002]

ARGS = {
    'examples': examples,
    'model': model,
    'mem': mem
}
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 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
pretrain_tokenize_function Ran
ran; our contract draft was wrong, not the code
getao/icae/code/icae_v2/training_utils.py
code served (permissive licence) · get_code("620be8b457171d50")
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 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 random

# Set seed for reproducibility
torch.manual_seed(0)
random.seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __call__(self, texts, truncation=False, padding=False, return_attention_mask=False):
        # Return a dict with input_ids for each text
        if isinstance(texts, str):
            texts = [texts]
        
        # Create simple token sequences
        input_ids = []
        for i, text in enumerate(texts):
            # Create varying length sequences (20-30 tokens)
            seq_len = 20 + (i % 3) * 5
            tokens = list(range(i * 100, i * 100 + seq_len))
            input_ids.append(tokens)
        
        return {
            'input_ids': input_ids
        }

# Create minimal training args
class MinimalTrainingArgs:
    def __init__(self):
        self.model_max_length = 16
        self.min_tokens_for_lm = 5
        self.add_special_token_for_lm = True
        self.leave_tokens_for_lm = 2

# Create minimal model
class MinimalModel:
    def __init__(self):
        self.tokenizer = MinimalTokenizer()
        self.training_args = MinimalTrainingArgs()
        self.mem_size = 3
        self.ae_token_id = 999
        self.eos_id = 1000
        self.lm_token_id = 1001
    
    def compute_num_segments(self, length):
        # Simple computation: number of segments based on length
        return max(1, length // 4)

# Create examples dict
examples = {
    'text': [
        'This is the first example text for tokenization.',
        'This is the second example text for tokenization and testing.'
    ]
}

# Create memory array
mem = [2000, 2001, 2002]

# Construct the ARGS dictionary
ARGS = {
    'examples': examples,
    'model': MinimalModel(),
    'mem': mem,
    'lm_ratio': 0.3
}
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 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
rotate_half Ran
ran; our contract draft was wrong, not the code
getao/icae/code/icae_v1/base/modeling_llama_icae.py
code served (permissive licence) · get_code("b99eea6376d1e212")
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 Tensor, ndim 2, dtype family float, shape (2, 4) 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 torch

torch.manual_seed(0)

# The function rotate_half takes a single parameter 'x' which is a tensor
# It accesses x.shape[-1] to get the last dimension
# It uses indexing with [..., :] slicing notation
# It calls torch.cat() to concatenate tensors

# Create a small tensor with shape (2, 4) - batch size 2, hidden dim 4
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
text_extraction Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
getao/icae/code/icae_v2/training_utils.py
code served (permissive licence) · get_code("1e1210d72545f26a")
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. 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 random

random.seed(42)

# Analyzing the function:
# - input_ids: needs to support len(), indexing with [start:end], and random.randint operations
# - length: an integer for comparison and slicing
# - lm_ratio: a float between 0.0 and 1.0

# input_ids should be a list or similar sequence
input_ids = [10, 20, 30, 40, 50, 60, 70, 80]  # List of token IDs

# length should be an integer smaller than or equal to len(input_ids)
length = 5

# lm_ratio is a probability between 0.0 and 1.0
lm_ratio = 0.3

ARGS = {
    'input_ids': input_ids,
    'length': length,
    'lm_ratio': lm_ratio
}
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 tuple — a tuple output has no array shape of its own; none is 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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 3 the same month, 3 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
rotate_half 360 other papers
10 dated earlier, 5 the same month, 342 later, 3 undated · 30 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
repeat_kv 243 other papers
3 dated earlier, 2 the same month, 236 later, 2 undated · 22 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2305.17888 (2023-05)
LLM-QAT: Data-Free Quantization Aware Training for Large Language Models
and 240 more not named here
apply_rotary_pos_emb 83 other papers
1 dated earlier, 3 the same month, 79 later · 6 only as an assembly brick
2306.15595 (2023-06)
Extending Context Window of Large Language Models via Positional Interpolation
2307.05695 (2023-07)
ReLoRA: High-Rank Training Through Low-Rank Updates
2307.08072 (2023-07)
Do Emergent Abilities Exist in Quantized Large Language Models: An Empirical Study
and 80 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

We propose the In-context Autoencoder (ICAE), leveraging the power of a large language model (LLM) to compress a long context into short compact memory slots that can be directly conditioned on by the LLM for various purposes. ICAE is first pretrained using both autoencoding and language modeling objectives on massive text data, enabling it to generate memory slots that accurately and comprehensively represent the original context. Then, it is fine-tuned on instruction data for producing desirable responses to various prompts. Experiments demonstrate that our lightweight ICAE, introducing about 1% additional parameters, effectively achieves 4× context compression based on Llama, offering advantages in both improved latency and GPU memory cost during inference, and showing an interesting insight in memorization as well as potential for scalability. These promising results imply a novel perspective on the connection between working memory in cognitive science and representation learning in LLMs, revealing ICAE's significant implications in addressing the long context problem and suggesting further research in LLM context management. Our data, code and models are available at https://github.com/getao/icae. As ar&ficial intelligence becomes an increasingly powerful force, some of the world's biggest companies are worrying about how the technology will be used ethically, and how the public will perceive its spread. To combat these problems (among others), five tech companies -Google, Amazon, MicrosoD, Facebook, and IBM -set up a research group called the Partnership on AI. … AI taking white collar jobs, eroding trust in public media, becoming embedded in public ins&tu&ons like the courts and hospitals: these are the sorts of problems facing the industry in the future.

For agents

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

get_harvested_code_for_paper("2307.06945")
get_code_for_paper("2307.06945")
have("2307.06945")

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

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

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

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

Connect an agent — have() is free.