Research map / Large language models / Instruction and fine-tuning
LLM Maybe LongLM: SelfExtend LLM Context Window Without Tuning
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Proposes SelfExtend, an inference-only method that extends LLM context windows by mapping distant relative positions via floor-division grouped attention while keeping standard neighbor attention, requiring no fine-tuning.
Problem
LLMs with RoPE fail on inputs longer than their pretraining context window because unseen (out-of-distribution) relative positions appear at inference; existing extension methods require fine-tuning on long data.
Approach
Build two-level attention at inference: grouped attention that floor-divides positions for distant tokens (mapping unseen relative positions into the pretrained range) and standard neighbor attention for tokens within a local window; merge both before softmax. Only the attention computation changes, so no weights are updated.
Key results
- SelfExtend-Llama-2-7b-chat keeps PG-19 perplexity around 9 up to 16384 tokens while vanilla Llama-2-7b-chat exceeds 10^3 beyond 4096 tokens.
- SelfExtend achieves 100% passkey retrieval accuracy across all tested depths and context lengths for Mistral-7B-instruct-0.1 without fine-tuning.
- On LongBench, SE-Phi-2 (8k) improves NarrativeQA from 4.46 to 12.04 and Qasper from 7.01 to 12.10 over vanilla Phi-2 (2k); SelfExtend roughly maintains Open LLM Leaderboard short-context scores.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Apply SelfExtend to extend Llama-2-7B-chat context | Llama-2-7B-chat · PG19, 16384 | perplexity: > 10^3 -> 9.274 | Helped |
| Apply SelfExtend to extend Mistral-7B-Instruct-v0.1 context | Mistral-7B-Instruct-v0.1 · PG19, 16384 | perplexity: > 10^3 -> 9.128 | Helped |
| Extend Llama-2-7B-chat context with SelfExtend to 25k | Llama-2-7B-chat · LongBench HotpotQA | score: 25.4 -> 35.47 | Helped |
| Apply SelfExtend at 16k context | Llama2-13B-chat · L-Eval average | score: 39.01 -> 42.10 | Helped |
| Apply SelfExtend at 16k context | Mistral-7B-Instruct-v0.1 · L-Eval average | score: 43.94 -> 45.27 | Helped |
| Apply SelfExtend at 8k context | Phi-2 · L-Eval average | score: 42.64 -> 44.69 | Helped |
| Apply SelfExtend to SOLAR-10.7B | SOLAR-10.7B-Instruct-v1.0 · L-Eval average | score: 55.34 -> 58.30 | Helped |
| Extend Phi-2 to 4k with SelfExtend (group size 4, neighbor window 512) (ablation) | Phi-2 · LongBench NarrativeQA | score: 4.46 -> 6.49 (+45.52\%) | Helped |
| Extend Phi-2 to 6k with SelfExtend (group size 8, neighbor window 512) (ablation) | Phi-2 · LongBench NarrativeQA | score: 4.46 -> 8.98 (+101.35\%) | Helped |
| Extend Phi-2 to 8k with SelfExtend (group size 12, neighbor window 512) (ablation) | Phi-2 · LongBench NarrativeQA | score: 4.46 -> 12.04 (+169.96\%) | Helped |
| Increase Phi-2 SelfExtend context from 6k to 8k (ablation) | Phi-2 · LongBench Qasper | score: 12.84 -> 12.10 | Hurt |
| Increase Phi-2 SelfExtend context from 6k to 8k (ablation) | Phi-2 · LongBench TREC | score: 62.5 -> 60.0 | Hurt |
Surprising findings
- Low perplexity on long sequences does not imply long-context ability: Mistral with sliding window attention keeps low PPL but cannot retrieve passkeys outside its window.
- A purely inference-time attention modification can match or beat several fine-tuned long-context models on LongBench and L-Eval.
Limitations
- Performance degrades with large group sizes, so contexts cannot be extended indefinitely.
- Naive implementation adds computation across all query-key pairs and still processes the full sequence.
- Hyperparameters (group size, neighbor window) need tuning and the heuristic rule may not transfer across models, e.g., Llama-3 needs a much smaller neighbor window.
Experimental setup
Datasets: PG-19 LongBench L-Eval Hugging Face Open LLM Leaderboard tasks (ARC-c, HellaSwag, MMLU, TruthfulQA, GSM8K)
Benchmarks: PG-19 Passkey retrieval LongBench L-Eval Hugging Face Open LLM Leaderboard Varying-length passkey retrieval
Metrics: perplexity accuracy F1 / task score
Baselines: Llama-2-7b-chat LongChat1.5-7B-32k Vicuna1.5-7B-16k CLEX-7B-16k CodeLlama-7B-16k MistralLite-16k Yarn-Llama-2-7b-64k LongLora-7b-16k Llama2-13b-NTK GPT-3.5-Turbo-16k
Builds on: RoPE position interpolation ReRoPE LongBench L-Eval
Closest papers by meaning
- A Little Goes a Long Way: Efficient Long Context Training and Inference with Partial Contexts (ICLR 2025 · similarity 0.91)
- ReAttention: Training-Free Infinite Context with Finite Attention Scope (ICLR 2025 · similarity 0.91)
- SparQ Attention: Bandwidth-Efficient LLM Inference (ICML 2024 · similarity 0.90)
- PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise Training (ICLR 2024 · similarity 0.90)
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory (NeurIPS 2024 · similarity 0.90)
- Why Does the Effective Context Length of LLMs Fall Short? (ICLR 2025 · similarity 0.90)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
