SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.10882 · 2023

Giraffe: Adventures in Expanding Context Lengths in LLMs

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 9 failures of our instrument; 3 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/2308.10882.json · badge: /api/ran/2308.10882.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
abacusai/long-context canonical (classifier label)
classifier basis: plan_row
10 ran · 3 no recorded run
FunctionStatusWhere it lives
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
abacusai/long-context/python/models/modeling_giraffe.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)
abacusai/long-context/python/models/modeling_giraffe.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Beomi/BitNet-Transformers, is pointer only (licence: NONE) · get_code("37fc3129c3d06e0c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Beomi/BitNet-Transformers, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

chunk Ran
ran; our contract draft was wrong, not the code
abacusai/long-context/python/train/finetune_context.py
code served (permissive licence) · get_code("0e92b47ad30b6534")
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 numpy as np

# Construct a valid batch dict with input_ids and attention_mask
# The function expects lists of sequences

batch = {
    'input_ids': [
        np.array([101, 2054, 2003, 0], dtype=np.int32),
        np.array([101, 1045, 2572, 0, 0], dtype=np.int32),
    ],
    'attention_mask': [
        np.array([1, 1, 1, 0], dtype=np.int32),
        np.array([1, 1, 1, 0, 0], dtype=np.int32),
    ]
}

ARGS = {
    'batch': batch,
    'chunk_size': 4,
    'step_size': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
duplicate_interleave Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
abacusai/long-context/python/models/xpos.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Cranial-XIX/longhorn, is pointer only (licence: NONE) · get_code("03e99c761c545617")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Cranial-XIX/longhorn, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

fixed_pos_embedding Ran
ran, honoured the contract we drafted
abacusai/long-context/python/models/xpos.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from text-machine-lab/mini_gpt, is pointer only (licence: NONE) · get_code("ff55f4ed6ff9941f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from text-machine-lab/mini_gpt, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

join_pages Ran
ran; our contract draft was wrong, not the code
abacusai/long-context/python/train/finetune_context.py
code served (permissive licence) · get_code("a0583ce41b433723")
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

def join_pages(record):
    if '_chunked_text' in record:
        return {'document': '\n\n'.join(record['_chunked_text'])}
    elif 'text' in record:
        return {'document': record['text']}
    else:
        raise NotImplementedError(str(record.keys()))

# Test case 1: record with '_chunked_text'
record_with_chunks = {
    '_chunked_text': ['chunk one', 'chunk two', 'chunk three']
}

ARGS = {
    'record': record_with_chunks
}
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
load_testcases Ran
ran; our contract draft was wrong, not the code
abacusai/long-context/python/eval/longeval/utils.py
code served (permissive licence) · get_code("769944cde562a1ab")
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 list, ndim 1, 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 json
import tempfile
import os

# Create a temporary JSON file with test cases
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test_cases.jsonl")

# Write some test case data to the file
test_cases_data = [
    {"id": 1, "input": "test1", "output": "result1"},
    {"id": 2, "input": "test2", "output": "result2"},
    {"id": 3, "input": "test3", "output": "result3"},
]

with open(test_file, 'w') as f:
    for test_case in test_cases_data:
        f.write(json.dumps(test_case) + '\n')

ARGS = {
    "test_file": test_file
}
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 list, ndim 1, dtype family float — a list 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
rotate_every_two Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
abacusai/long-context/python/models/xpos.py
code served (permissive licence) · get_code("368e8872aa996b9e")
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 Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) 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_every_two takes a tensor x and performs rotations
# on the last dimension. It expects a 4D tensor with shape (batch, dim1, dim2, last_dim)
# where last_dim should be even (since it splits by ::2 and 1::2)

x = torch.randn(2, 3, 4, 6)  # batch=2, dim1=3, dim2=4, last_dim=6 (even)

ARGS = {
    "x": x
}
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 Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) — shape (2, 3, 4, 6) 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
rotate_half Ran
ran; our contract draft was wrong, not the code
abacusai/long-context/python/models/modeling_giraffe.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
truncate_frequency Ran
ran; our contract draft was wrong, not the code
abacusai/long-context/python/models/interpolate.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from text-machine-lab/mini_gpt, is pointer only (licence: NONE) · get_code("70016ef148e9a350")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from text-machine-lab/mini_gpt, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

batch_apply_rotary_pos_emb Not yet run
unverified (harvested, no recorded run)
abacusai/long-context/python/models/interpolate.py
code served (permissive licence) · get_code("cebd84ad2b9da0a0")
How it ran

no invocation recorded.

get_output_dir Not yet run
unverified (harvested, no recorded run)
abacusai/long-context/python/eval/longeval/utils.py
code served (permissive licence) · get_code("f1195d8a23d10b75")
How it ran

no invocation recorded.

tokenize_and_chunk Not yet run
unverified (harvested, no recorded run)
abacusai/long-context/python/train/finetune_context.py
code served (permissive licence) · get_code("69b3ed047105ab30")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 7 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 2 the same month, 7 later) and 6 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
16 dated earlier, 7 the same month, 334 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
6 dated earlier, 1 the same month, 234 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
duplicate_interleave 7 other papers
3 dated earlier, 4 later
2206.13517 (2022-06)
ProGen2: Exploring the Boundaries of Protein Language Models
2307.04349 (2023-07)
RLTF: Reinforcement Learning from Unit Test Feedback
2307.08621 (2023-07)
Retentive Network: A Successor to Transformer for Large Language Models
and 4 more not named here
apply_rotary_pos_emb 5 other papers
5 later
2310.11453 (2023-10)
BitNet: Scaling 1-bit Transformers for Large Language Models
2312.15166 (2023-12)
SOLAR 10.7B: Scaling Large Language Models with Simple yet Effective Depth Up-Scaling
2402.16061 (2024-02)
How Large Language Models Encode Context Knowledge? A Layer-Wise Probing Study
and 2 more not named here
rotate_every_two 5 other papers
2 dated earlier, 3 later
2206.13517 (2022-06)
ProGen2: Exploring the Boundaries of Protein Language Models
2307.04349 (2023-07)
RLTF: Reinforcement Learning from Unit Test Feedback
2403.00818 (2024-03)
DenseMamba: State Space Models with Dense Hidden Connection for Efficient Large Language Models
and 2 more not named here
fixed_pos_embedding 1 other paper
1 later
2404.02204 (2024-04)
Emergent Abilities in Reduced-Scale Generative Language Models
truncate_frequency 1 other paper
1 later
2404.02204 (2024-04)
Emergent Abilities in Reduced-Scale Generative Language Models

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

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.

For agents

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

get_harvested_code_for_paper("2308.10882")
get_code_for_paper("2308.10882")
have("2308.10882")

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

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

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

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

Connect an agent — have() is free.