SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2502.13870 · 2025

SPEX: Scaling Feature Interaction Explanations for LLMs

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 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; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 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/2502.13870.json · badge: /api/ran/2502.13870.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
basics-lab/spectral-explain canonical (classifier label)
classifier basis not recorded on the link
7 ran · 3 no recorded run
FunctionStatusWhere it lives
eval_function Ran
ran on a synthesized input
basics-lab/spectral-explain/experiments/removal.py
code served (permissive licence) · get_code("6c55879dd8a805c3")
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 float, ndim 0, dtype family float, shape () 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
import numpy as np
from math import prod

# Analyze the function:
# - x: indexed with integers (x[i]), so needs to be indexable (list, array, tensor)
# - list_of_interactions: iterable of (y, v) tuples where:
#   - y: iterable of indices used to index into x
#   - v: numeric value to multiply with the product

# Create x as a list of integers (0 and 1 work well with (-1)**x[i])
x = [0, 1, 0, 1, 1]

# Create list_of_interactions as list of (indices, value) tuples
# Each tuple contains:
#   - y: tuple/list of indices into x
#   - v: numeric coefficient
list_of_interactions = [
    ([0, 1], 2.5),        # indices 0,1 with coefficient 2.5
    ([1, 2, 3], -1.0),    # indices 1,2,3 with coefficient -1.0
    ([0, 4], 0.5),        # indices 0,4 with coefficient 0.5
    ([2], 3.0),           # index 2 with coefficient 3.0
]

ARGS = {
    'x': x,
    'list_of_interactions': list_of_interactions,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
fourier_to_mobius Ran
ran on a synthesized input
basics-lab/spectral-explain/src/spectralexplain/utils.py
code served (permissive licence) · get_code("7d19628adb34ce36")
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
from itertools import chain, combinations

# Create a simple fourier_dict with some test data
# The function expects a dictionary where:
# - keys are tuples of 0s and 1s (location tuples)
# - values are numeric coefficients (can be complex, but real part is used)

fourier_dict = {
    (1, 0, 0): 2.5 + 0.5j,
    (0, 1, 0): 3.0 + 1.0j,
    (1, 1, 0): 1.5 + 0.2j,
    (0, 0, 1): 2.0 - 0.1j,
    (1, 0, 1): 1.0 + 0.3j,
}

ARGS = {
    "fourier_dict": fourier_dict
}
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
get_num_samples Ran
ran on a synthesized input
basics-lab/spectral-explain/src/spectralexplain/support_recovery.py
code served (permissive licence) · get_code("4f594e42f5b0b233")
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 int, ndim 0, dtype family int, shape () 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)

class Signal:
    def __init__(self):
        self.all_samples = [
            [1.0, 2.0, 3.0, 4.0],
            [5.0, 6.0, 7.0, 8.0]
        ]

signal = Signal()
b = 3

ARGS = {
    "signal": signal,
    "b": b
}
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 int, ndim 0, dtype family int, shape () — shape () 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
make_dependancy_tree Ran
ran on a synthesized input
basics-lab/spectral-explain/experiments/removal.py
code served (permissive licence) · get_code("9107e21a5ad6e23e")
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

torch.manual_seed(0)

# Analyze the function:
# - list_of_interactions: iterated as (y, val) pairs
#   - y is iterated over (for i in y), so it's an iterable of indices
#   - val is multiplied by (-1) ** len(y), so it's a number
# - n: used as range(n) to create tree list of size n

# Create valid arguments
list_of_interactions = [
    ([0, 1], 2.5),
    ([1, 2], -1.3),
    ([0], 0.7),
    ([1, 2, 3], 4.2),
]

n = 4

ARGS = {
    "list_of_interactions": list_of_interactions,
    "n": n,
}
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
powerset Ran
ran on a synthesized input
basics-lab/spectral-explain/src/spectralexplain/utils.py
code served (permissive licence) · get_code("b1f0be90b2b91abd")
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 2, 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 numpy as np

# The function takes a loc_tuple (which should be a tuple or array-like of 0s and 1s)
# and an optional max_order parameter. Let's construct valid arguments.

# Create a location tuple with some 1s and 0s
# This represents positions where we have non-zero locations
loc_tuple = (1, 0, 1, 1, 0)

# max_order limits the maximum order of combinations to generate
# If None, it defaults to the count of 1s in loc_tuple
max_order = 2

ARGS = {
    "loc_tuple": loc_tuple,
    "max_order": max_order
}
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 list, ndim 2, dtype family int — 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
scaler_classification Ran
ran on a synthesized input
basics-lab/spectral-explain/experiments/dataloader.py
code served (permissive licence) · get_code("1d7a8fb3797b5107")
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 numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler

torch.manual_seed(0)

# Create small numpy arrays for X_train and X_test
X_train = np.random.randn(2, 4).astype(np.float32)
X_test = np.random.randn(2, 4).astype(np.float32)

# Create pandas Series for y_train and y_test (they have .to_numpy() method)
y_train = pd.Series([0, 1])
y_test = pd.Series([1, 0])

ARGS = {
    "X_train": X_train,
    "X_test": X_test,
    "y_train": y_train,
    "y_test": y_test
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, sklearn, 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
scaler_regression Ran
ran on a synthesized input
basics-lab/spectral-explain/experiments/dataloader.py
code served (permissive licence) · get_code("335822cf082d847d")
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 numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler

torch.manual_seed(0)

# Create small sample data
# X_train: shape (2, 4) - 2 samples, 4 features
X_train = pd.DataFrame(np.random.randn(2, 4), columns=['f1', 'f2', 'f3', 'f4'])

# X_test: shape (2, 4) - 2 samples, 4 features
X_test = pd.DataFrame(np.random.randn(2, 4), columns=['f1', 'f2', 'f3', 'f4'])

# y_train: shape (2,) - 2 targets
y_train = pd.Series(np.random.randn(2))

# y_test: shape (2,) - 2 targets
y_test = pd.Series(np.random.randn(2))

ARGS = {
    'X_train': X_train,
    'X_test': X_test,
    'y_train': y_train,
    'y_test': y_test
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, sklearn, 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
estimate_r2 Not yet run
unverified (harvested, no recorded run)
basics-lab/spectral-explain/src/spectralexplain/utils.py
code served (permissive licence) · get_code("8306ee06d44ca5f2")
How it ran

no invocation recorded.

run_and_evaluate_method Not yet run
unverified (harvested, no recorded run)
basics-lab/spectral-explain/experiments/faithfulness.py
code served (permissive licence) · get_code("c70c75284b91e46f")
How it ran

no invocation recorded.

vec_to_index Not yet run
unverified (harvested, no recorded run)
basics-lab/spectral-explain/experiments/removal.py
code served (permissive licence) · get_code("f949f31b5f8130a7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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

Large language models (LLMs) have revolutionized machine learning due to their ability to capture complex interactions between input features. Popular post-hoc explanation methods like SHAP provide marginal feature attributions, while their extensions to interaction importances only scale to small input lengths ($\approx 20$). We propose Spectral Explainer (SPEX), a model-agnostic interaction attribution algorithm that efficiently scales to large input lengths ($\approx 1000)$. SPEX exploits underlying natural sparsity among interactions -- common in real-world data -- and applies a sparse Fourier transform using a channel decoding algorithm to efficiently identify important interactions. We perform experiments across three difficult long-context datasets that require LLMs to utilize interactions between inputs to complete the task. For large inputs, SPEX outperforms marginal attribution methods by up to 20% in terms of faithfully reconstructing LLM outputs. Further, SPEX successfully identifies key features and interactions that strongly influence model output. For one of our datasets, HotpotQA, SPEX provides interactions that align with human annotations. Finally, we use our model-agnostic approach to generate explanations to demonstrate abstract reasoning in closed-source LLMs (GPT-4o mini) and compositional reasoning in vision-language models.

For agents

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

get_harvested_code_for_paper("2502.13870")
get_code_for_paper("2502.13870")
have("2502.13870")

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

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

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

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

Connect an agent — have() is free.