Papers › InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory

InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory

7 Feb 2024arXiv:2402.04617archive 2025-07-28

Chaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao, Yankai Lin, Zhengyan Zhang, Zhiyuan Liu, Maosong Sun

Large language models (LLMs) have emerged as a cornerstone in real-world applications with lengthy streaming inputs (e.g., LLM-driven agents). However, existing LLMs, pre-trained on sequences with a restricted maximum length, cannot process longer sequences due to the out-of-domain and distraction issues. Common solutions often involve continual pre-training on longer sequences, which will introduce expensive computational overhead and uncontrollable change in model capabilities. In this paper, we unveil the intrinsic capacity of LLMs for understanding extremely long sequences without any fine-tuning. To this end, we introduce a training-free memory-based method, InfLLM. Specifically, InfLLM stores distant contexts into additional memory units and employs an efficient mechanism to lookup token-relevant units for attention computation. Thereby, InfLLM allows LLMs to efficiently process long sequences with a limited context window and well capture long-distance dependencies. Without any training, InfLLM enables LLMs that are pre-trained on sequences consisting of a few thousand tokens to achieve comparable performance with competitive baselines that continually train these LLMs on long sequences. Even when the sequence length is scaled to $1,024$K, InfLLM still effectively captures long-distance dependencies. Our code can be found in \url{https://github.com/thunlp/InfLLM}.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.04617")

Code

Syntology Ran 11 of 12 code samples harvested from 1 repository linked to this paper; 1 has no recorded run. Of those that ran: 1 ran · honoured contract; 2 ran · our draft was wrong; 8 ran with no contract checked.

By repository: official repository: 12 samples from 1 repository, 11 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

thunlp/infllm officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

12 samples harvested; 11 ran; 1 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
2ran · our draft was wrong
8ran
1unverified

Licence: 0 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from thunlp/infllm. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

build_chat thunlp/infllm/benchmark/pred.py official repository ran MIT (permissive) · 899f8b2f018b4018 · report
count_score thunlp/infllm/benchmark/metrics.py official repository ran · honoured contract fingerprinted MIT (permissive) · b349b79d9cc2934b · report
f1_score thunlp/infllm/benchmark/infinitebench_eval.py official repository ran fingerprinted MIT (permissive) · 2eb701a1cd15182a · report
inf_llm_forward thunlp/infllm/inf_llm/attention/inf_llm.py official repository ran MIT (permissive) · a3139f9838c7d186 · report
load_infinite_bench thunlp/infllm/benchmark/pred.py official repository ran MIT (permissive) · 121ee531e379175c · report
normalize_answer thunlp/infllm/benchmark/metrics.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · e7e75981cb464788 · report
normalize_answer thunlp/infllm/benchmark/infinitebench_eval.py official repository ran fingerprinted MIT (permissive) · 4b44a4d3fd80a48d · report
normalize_zh_answer thunlp/infllm/benchmark/metrics.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 8c5c581f9264c810 · report
normalize_zh_answer thunlp/infllm/benchmark/infinitebench_eval.py official repository ran fingerprinted MIT (permissive) · f62b4d2a31aa1081 · report
origin_forward thunlp/infllm/inf_llm/attention/origin.py official repository ran MIT (permissive) · 7e700bfa53cce7cf · report
stream_llm_forward thunlp/infllm/inf_llm/attention/stream_llm.py official repository ran MIT (permissive) · c03a0458a393d5c5 · report
infinite_lm_forward thunlp/infllm/inf_llm/attention/infinite_lm.py official repository unverified MIT (permissive) · 8d4ac5178e695392 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections