SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.04131 · 2023

Towards Interpretable Sequence Continuation: Analyzing Shared Circuits in Large Language Models

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 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; 3 failures of our instrument; 0 no recorded run), 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/2311.04131.json · badge: /api/ran/2311.04131.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
apartresearch/seqcont_circuits canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
FunctionStatusWhere it lives
generate_prompts_list Ran
ran; our contract draft was wrong, not the code
apartresearch/seqcont_circuits/src/generate_data/generate_data.py
code served (permissive licence) · get_code("37c7e7201e0561bd")
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 random

random.seed(0)

ARGS = {
    'x': 0,
    'y': 5,
    'words': ['apple', 'banana', 'cherry', 'dragon', 'elephant', 'forest', 'guitar', 'house', 'island', 'jungle'],
    'verb': 'discovered'
}
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
get_ind Ran
ran, honoured the contract we drafted
apartresearch/seqcont_circuits/src/attn_pats/viz_attn_pat.py
code served (permissive licence) · get_code("dd5e09c02352289f")
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 tuple, ndim 1, dtype family int; 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 torch

torch.manual_seed(0)

# The function get_ind takes:
# 1. token_list: a list that supports .index() method
# 2. token1: a token to find in the list
# 3. token2: another token to find in the list
# 4. printInd: a boolean flag for printing

token_list = ["hello", "world", "python", "code"]
token1 = "hello"
token2 = "python"
printInd = True

ARGS = {
    "token_list": token_list,
    "token1": token1,
    "token2": token2,
    "printInd": printInd,
}
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 tuple, ndim 1, dtype family int — a tuple 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
get_top_preds_moredata Ran
ran; our contract draft was wrong, not the code
apartresearch/seqcont_circuits/src/generate_data/generate_data.py
code served (permissive licence) · get_code("dcb8a86427dafedb")
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 tuple. 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
import torch.nn as nn
from typing import Optional

torch.manual_seed(0)

class MockModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4):
        super().__init__()
        self.vocab_size = vocab_size
        self.hidden_dim = hidden_dim
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.linear = nn.Linear(hidden_dim, vocab_size)
    
    def forward(self, tokens):
        # tokens shape: (batch, seq_len)
        x = self.embedding(tokens)
        logits = self.linear(x)
        return logits
    
    def to_tokens(self, text, prepend_bos=True):
        # Convert text to token IDs
        # Simple mock: hash characters to token IDs
        token_ids = [hash(c) % self.vocab_size for c in text]
        tokens = torch.tensor([token_ids], dtype=torch.long)
        if prepend_bos:
            bos_token = torch.tensor([[0]], dtype=torch.long)
            tokens = torch.cat([bos_token, tokens], dim=1)
        return tokens
    
    def to_str_tokens(self, text, prepend_bos=True):
        # Convert text to string tokens (character level)
        str_tokens = list(text)
        if prepend_bos:
            str_tokens = ['<BOS>'] + str_tokens
        return str_tokens
    
    def to_string(self, token_id):
        # Convert token ID back to string representation
        token_id_val = token_id.item() if hasattr(token_id, 'item') else token_id
        return chr(65 + (token_id_val % 26))

model = MockModel(vocab_size=100, hidden_dim=4)

prompt = "What is"
answer = "the answer"
incor = "B"

ARGS = {
    "prompt": prompt,
    "answer": answer,
    "model": model,
    "incor": incor,
    "prepend_space_to_answer": True,
    "print_details": True,
    "prepend_bos": True,
    "top_k": 10
}
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 tuple — a tuple output has no array shape of its own; none is 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
replace_nw_seqtype Ran
ran; our contract draft was wrong, not the code
apartresearch/seqcont_circuits/src/generate_data/generate_data.py
code served (permissive licence) · get_code("9658312cf330f245")
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 copy

# Analyze the function:
# - data_list: a list of dictionaries, each dict has keys and values
# - repl_type: a string that is either 'numerals' or 'months'
# The function:
#   - Creates a replacement dictionary based on repl_type
#   - Deep copies the data_list
#   - Iterates through items (dicts) in the list
#   - Replaces values that match keys in repl_dict
#   - Handles special keys 'corr' and 'incorr' by replacing and adding space
#   - If 'text' key exists, replaces month names in the text with their mapped values

# Build minimal valid arguments

data_list = [
    {
        'name': 'one',
        'value': 'two',
        'text': 'The meeting is in one month and two days',
        'corr': 'three'
    },
    {
        'name': 'four',
        'value': 'five',
        'text': 'We have six items and seven more',
        'incorr': 'eight'
    }
]

repl_type = 'numerals'

ARGS = {
    'data_list': data_list,
    'repl_type': repl_type
}
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

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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.

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

While transformer models exhibit strong capabilities on linguistic tasks, their complex architectures make them difficult to interpret. Recent work has aimed to reverse engineer transformer models into human-readable representations called circuits that implement algorithmic functions. We extend this research by analyzing and comparing circuits for similar sequence continuation tasks, which include increasing sequences of Arabic numerals, number words, and months. By applying circuit interpretability analysis, we identify a key sub-circuit in both GPT-2 Small and Llama-2-7B responsible for detecting sequence members and for predicting the next member in a sequence. Our analysis reveals that semantically related sequences rely on shared circuit subgraphs with analogous roles. Additionally, we show that this sub-circuit has effects on various math-related prompts, such as on intervaled circuits, Spanish number word and months continuation, and natural language word problems. Overall, documenting shared computational structures enables better model behavior predictions, identification of errors, and safer editing procedures. This mechanistic understanding of transformers is a critical step towards building more robust, aligned, and interpretable language models.

For agents

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

get_harvested_code_for_paper("2311.04131")
get_code_for_paper("2311.04131")
have("2311.04131")

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

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

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

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

Connect an agent — have() is free.