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,024K, InfLLM still effectively captures long-distance dependencies. Our code can be found in https://github.com/thunlp/InfLLM.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 12 code samples harvested from 1 repository linked to this paper: 11 ran (of which 0 constructed an object rather than computing a result; 5 with no instrument failure: 1 honoured, 0 violated, 4 with no contract checked; 6 where Syntology's instrument failed) · 1 unverified. Where Syntology's instrument failed: 5 where our contract draft was wrong; 1 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 12 samples from 1 repository, 11 ran (5 with no instrument failure; 6 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written on 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 3 of the 11 samples that ran have no recorded date.

thunlp/infllm officialmentioned in papermentioned on GitHubpytorchMITSyntology: 12 samples, 11 ran (6 instrument-failed) · 1 unverified 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 (of which 0 constructed an object rather than computing a result; 5 with no instrument failure: 1 honoured, 0 violated, 4 with no contract checked; 6 where Syntology's instrument failed) · 1 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · honoured contract
5ran · our draft was wrong
1ran; the contract check could not run
4ran
1unverified

Licence: 4 of the 12 samples are pointer only, meaning Syntology does not serve that copy's text. For 4 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. 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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.

thunlp/infllm official repository 12 samples, 11 ran (6 instrument-failed) · 1 unverified
build_chat in 29 papers benchmark/pred.py ran MIT (permissive) here; the stored copy is pointer only · 899f8b2f018b4018 · report fixture: signature tokenizer:MockTokenizer/0/?, prompt:str/0/str, model_name:str/0/str · returned str · level recorded 2026-09-24
count_score in 27 papers benchmark/metrics.py ran · honoured contract fingerprinted MIT (permissive) here; the stored copy is pointer only · b349b79d9cc2934b · report fixture: signature prediction:str/0/str, ground_truth:int/0/int · returned float · level recorded, date not recorded
f1_score in 121 papers benchmark/infinitebench_eval.py ran · our draft was wrong fingerprinted MIT (permissive) · 2eb701a1cd15182a · report fixture: signature prediction:list/1/int, ground_truth:list/1/int · returned tuple · level recorded 2026-09-24
inf_llm_forward inf_llm/attention/inf_llm.py ran MIT (permissive) · a3139f9838c7d186 · report fixture: signature n_local:int/0/int, n_init:int/0/int, topk:int/0/int, block_size:int/0/int, max_cached_block:int/0/int, exc_block_size:int/0/int, fattn:bool/0/bool, repr_topk:int/0/int, cache_strategy:str/0/str, score_decay:NoneType/0/?, chunk_topk_calc:NoneType/0/?, async_global_stream:bool/0/bool, pin_memory:bool/0/bool, faiss:bool/0/bool, perhead:bool/0/bool, forward_kwargs:dict/0/? · returned function · level recorded 2026-09-24
load_infinite_bench benchmark/pred.py ran MIT (permissive) · 121ee531e379175c · report fixture: signature path:str/0/str, data_name:str/0/str · returned list · level recorded 2026-09-24
normalize_answer in 304 papers benchmark/metrics.py ran · our draft was wrong fingerprinted MIT (permissive) here; the stored copy is pointer only · e7e75981cb464788 · report fixture: signature s:str/0/str · returned str · level recorded, date not recorded
normalize_answer in 304 papers benchmark/infinitebench_eval.py ran · our draft was wrong fingerprinted MIT (permissive) · 4b44a4d3fd80a48d · report fixture: signature s:str/0/str · returned str · level recorded 2026-09-24
normalize_zh_answer in 32 papers benchmark/metrics.py ran · our draft was wrong fingerprinted MIT (permissive) here; the stored copy is pointer only · 8c5c581f9264c810 · report fixture: signature s:str/0/str · returned str · level recorded, date not recorded
normalize_zh_answer in 32 papers benchmark/infinitebench_eval.py ran · our draft was wrong fingerprinted MIT (permissive) · f62b4d2a31aa1081 · report fixture: signature s:str/0/str · returned str · level recorded 2026-09-24
origin_forward inf_llm/attention/origin.py ran; the contract check could not run (DEP_MISSING) MIT (permissive) · 7e700bfa53cce7cf · report fixture: signature fattn:bool/0/bool, args:tuple/1/empty, kwargs:dict/0/? · returned function · level recorded 2026-09-24
stream_llm_forward inf_llm/attention/stream_llm.py ran MIT (permissive) · c03a0458a393d5c5 · report fixture: returned function · level recorded 2026-09-24
infinite_lm_forward inf_llm/attention/infinite_lm.py 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