Papers › Giraffe: Adventures in Expanding Context Lengths in LLMs

Giraffe: Adventures in Expanding Context Lengths in LLMs

21 Aug 2023arXiv:2308.10882archive 2025-07-28

Arka Pal, Deep Karkhanis, Manley Roberts, Samuel Dooley, Arvind Sundararajan, Siddartha Naidu

Modern large language models (LLMs) that rely on attention mechanisms are typically trained with fixed context lengths which enforce upper limits on the length of input sequences that they can handle at evaluation time. To use these models on sequences longer than the train-time context length, one might employ techniques from the growing family of context length extrapolation methods -- most of which focus on modifying the system of positional encodings used in the attention mechanism to indicate where tokens or activations are located in the input sequence. We conduct a wide survey of existing methods of context length extrapolation on a base LLaMA or LLaMA 2 model, and introduce some of our own design as well -- in particular, a new truncation strategy for modifying the basis for the position encoding. We test these methods using three new evaluation tasks (FreeFormQA, AlteredNumericQA, and LongChat-Lines) as well as perplexity, which we find to be less fine-grained as a measure of long context performance of LLMs. We release the three tasks publicly as datasets on HuggingFace. We discover that linear scaling is the best method for extending context length, and show that further gains can be achieved by using longer scales at evaluation time. We also discover promising extrapolation capabilities in the truncated basis. To support further research in this area, we release three new 13B parameter long-context models which we call Giraffe: 4k and 16k context models trained from base LLaMA-13B, and a 32k context model trained from base LLaMA2-13B. We also release the code to replicate our results.

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="2308.10882")

Code

Syntology Ran 10 of 13 code samples harvested from 1 repository linked to this paper; 3 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 2 ran · fixture could not drive it; 7 ran with no contract checked.

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

abacusai/long-context officialmentioned in papermentioned on GitHubpytorchApache-2.0 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

13 samples harvested; 10 ran; 0 honoured the contract we drafted; 3 have 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 · our draft was wrong
2ran · fixture could not drive it
7ran
3unverified

Licence: 0 of the 13 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 abacusai/long-context. “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.

repeat_kv abacusai/long-context/python/models/modeling_giraffe.py official repository ran · fixture could not drive it fingerprinted Apache-2.0 (permissive) · 30d7eec482ebf6b1 · report
apply_rotary_pos_emb abacusai/long-context/python/models/modeling_giraffe.py official repository ran · fixture could not drive it Apache-2.0 (permissive) · 37fc3129c3d06e0c · report
chunk abacusai/long-context/python/train/finetune_context.py official repository ran Apache-2.0 (permissive) · 0e92b47ad30b6534 · report
duplicate_interleave abacusai/long-context/python/models/xpos.py official repository ran fingerprinted Apache-2.0 (permissive) · 03e99c761c545617 · report
fixed_pos_embedding abacusai/long-context/python/models/xpos.py official repository ran fingerprinted Apache-2.0 (permissive) · ff55f4ed6ff9941f · report
join_pages abacusai/long-context/python/train/finetune_context.py official repository ran Apache-2.0 (permissive) · a0583ce41b433723 · report
load_testcases abacusai/long-context/python/eval/longeval/utils.py official repository ran Apache-2.0 (permissive) · 769944cde562a1ab · report
rotate_every_two abacusai/long-context/python/models/xpos.py official repository ran fingerprinted Apache-2.0 (permissive) · 368e8872aa996b9e · report
rotate_half abacusai/long-context/python/models/modeling_giraffe.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · b99eea6376d1e212 · report
truncate_frequency abacusai/long-context/python/models/interpolate.py official repository ran Apache-2.0 (permissive) · 70016ef148e9a350 · report
batch_apply_rotary_pos_emb abacusai/long-context/python/models/interpolate.py official repository unverified Apache-2.0 (permissive) · cebd84ad2b9da0a0 · report
get_output_dir abacusai/long-context/python/eval/longeval/utils.py official repository unverified Apache-2.0 (permissive) · f1195d8a23d10b75 · report
tokenize_and_chunk abacusai/long-context/python/train/finetune_context.py official repository unverified Apache-2.0 (permissive) · 69b3ed047105ab30 · report

Tasks

16k4k

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

BASEFocus

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