wikillm

Paper · 2026-07-30 · cs.AI

Hidden APIs in Language Models: Discovering Reusable Causal Interfaces from Forked Futures

Describes a hidden state by how a frozen language model answers operations sampled only after the state is cached ("forked futures"). Compares Shared, Local, Mixture and Distributed codes by prequential causal description length under a fidelity limit. Shared gives the shortest held-out code on Qwen2.5-1.5B (0.216 nats gain) and Llama-3-8B (0.294). Results are author-reported.

Mechanistic interpretabilityCausal abstractionActivation patchingLinear probinginterpretabilitycausal-analysishidden-statesminimum-description-lengthactivation-patching

arXivPDFMarkdown16 min read

AI-compiled by claude-haiku-5-5 on 2026-11-13, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Two prompts can get the same answer from a model while the model's inner state behind that answer differs. Looking only at the answer cannot tell whether two such states are interchangeable. The paper asks a sharper question: if the model is later asked different follow-up questions, do the two states respond differently?

To test this, each prompt is run up to a point, the inner state is saved, and only then is a follow-up question chosen and added. The state therefore cannot "know" the follow-up. A state is described by how the model's answer changes across that set of follow-ups.

The authors then ask whether a small internal code can capture all the follow-up behaviour through one shared channel, or whether each follow-up needs its own code, or some mix. The candidate designs are scored by how cheaply they can describe the follow-up behaviour in sequence, subject to a fidelity limit. The shared design is cheapest in the tested cases. Parts of the shared code are then swapped between prompts to see whether the model uses them, and the whole pipeline is run on small synthetic models whose wiring is known. The conclusion holds only within the tested tasks, candidate designs and follow-up sets.

TL;DR

  • Within three structured task families and two detailed backbones (Qwen2.5-1.5B, Llama-3-8B), a Shared code (one bottleneck that every follow-up reads) has the lowest held-out prequential causal description length. Gains are 0.216 and 0.294 nats. §5 tab. 2
  • The gain is in code length, not accuracy: mean future-signature distortion differs by at most 0.011 across the four designs. §5 tab. 2
  • Donor-code swaps at the matching producer role score highest for Shared on target correctness, locality and copy preservation. Routes that match the API account for roughly three-quarters of the target effect (0.749), against about one-seventh for matched null routes (0.150). Both are author-reported. tab. 3 tab. S4
  • On six-layer synthetic organisms with known wiring, 14 of 16 are classified correctly. The false-Shared rate is 1/12 (8.3%), above the paper's own 5% target, and the paper marks that criterion as partly met. tab. S5 tab. S11
  • The claim is explicitly conditional on the candidate architectures, the operation bank and the held-out futures. It is not an identifiability result for pretrained models. §7

Problem

Current-answer probes and linear decoders show that a feature is present, but not that two states are interchangeable for later computation §1 §2. The paper needs two things: an equivalence defined by future computation, and a way to decide which compact code the model reuses, while controlling for code length. Assumptions: the operation bank is fixed in advance, the candidate architectures are fixed, and the held-out futures are representative of the tested operations §3 §7.

Method

Future causal signature §3

Let x_{1:t} be a prefix and h = h_{ℓ,t}(x) its hidden state at layer ℓ and token position t, cached before any operation is revealed app. X. An operation k induces a response distribution σ_k(h) = p_θ(y | x_{1:t}, k) eq. 1. The signature is the set of these responses over a sampled operation subset eq. 2. The default summary is the full-vocabulary logit vector; sensitivity runs swap in a top-100 truncation, answer-token probabilities or sequence likelihoods §3 app. C.

Two states are future-equivalent when their signatures are close. The distortion between a state and its reconstruction is the expected Jensen–Shannon divergence over operations drawn from the bank eq. 3. The appendix writes this as a plain average over the sampled operations app. C, eq. S3.

Forking and grouping §3 app. B app. X

Each latent episode is rendered as a prefix, the hidden state is cached, and only then is an operation sampled and rendered as a continuation. Collision controls check that same-answer pairs differ in signature and that same-signature rewordings do not app. B. All branches from one latent episode stay in one split, one prequential block and one bootstrap unit app. X.

Candidate codes §3 eq. 4 tab. S14

Each candidate is an encoder and a reconstructor, c = E(h, k) and ĥ = R(c, k) eq. 4.

  • Shared: one operation-agnostic code. The operation enters only at reconstruction §3.
  • Local: a separate encoder–reconstructor pair per operation (six in the reported setting) §3 tab. S14.
  • Mixture: several components combined through an operation-conditioned gate (four components) §3.
  • Distributed: several components (sixteen), with no privileged bottleneck §3.

Rank, sparsity and optimiser settings are matched where the architecture allows. Unavoidable extra capacity is charged in the code length, not ignored §3 app. X.

Prequential causal MDL and selection §3 eq. 5 eq. 6 eq. 7

The episodes are split into B = 20 ordered blocks §5. The first block is sent uninformed. Every later block is coded by a model fitted only on earlier blocks, and the code length is the sum of the negative log-likelihoods of those blocks' signatures eq. 5 app. C, eq. S4. A complexity penalty λ_r·r + λ_g·g is added, with r the active rank, g the number of gates, and (λ_r, λ_g) = (0.02, 0.05) §5.

The selected candidate minimises this code length subject to a family-wise fidelity limit eq. 6. Sharedness Gain is the best non-Shared code length minus the Shared code length, counted only when the fidelity limit also holds eq. 7.

Pseudocode
# Forked-futures interface selection  [§3] [eq. 6] [app. X]
# Input:  cached states, operation bank, candidate architectures,
#         ordered blocks (grouped by latent episode), fidelity limits
# Output: the lowest-code candidate that meets every fidelity limit

def select_interface(blocks, op_bank, candidates, fidelity_limit):
    # Score each candidate by its prequential code length  [eq. 5]
    scores = {}
    for arch in candidates:
        mdl = prequential_mdl(arch, blocks, op_bank)
        # Keep it only if the worst family stays under its limit  [eq. 6]
        if worst_family_fsd(arch, blocks, op_bank) <= fidelity_limit:
            scores[arch] = mdl
    # Return the cheapest feasible candidate; the margin is kept too  [app. X]
    return argmin_with_margin(scores)
Pseudocode
# Prequential code length of one candidate  [eq. 5] [app. C, eq. S4]
# Block 0 is sent uninformed; each later block is coded by a model
# fitted only on the blocks before it. The block order is shared by all
# candidates within a seed.

def prequential_mdl(arch, blocks, op_bank):
    # Uninformed cost of block 0, L0(D_1); value not stated  [eq. 5]
    total = uninformed_cost(blocks[0])
    for b in range(1, len(blocks)):
        # Fit on earlier blocks only, never on all data  [app. X]
        model = fit(arch, blocks[:b])
        # Negative log-likelihood of block b's signatures, in nats  [eq. 5] [§5]
        total += -log_likelihood(model, blocks[b], op_bank)
    # Penalty placement and rank summation not stated  [§5]
    total += 0.02 * arch.rank + 0.05 * arch.num_gates
    return total
Pseudocode
# Shared candidate: one code for every follow-up  [§3] [eq. 4]
# Shapes assume Qwen2.5-1.5B (d = 1536) with rank 64  [tab. S13] [tab. S14]

def shared_roundtrip(hidden, operation):
    # The encoder sees only the cached state, never the operation  [§3]
    code = encoder(hidden)                    # (1536) -> (64)
    # The operation enters only at reconstruction  [§3] [eq. 4]
    recon = reconstructor(code, operation)    # (64, op) -> (1536)
    return recon
Pseudocode
# Future-signature distortion of a reconstruction  [eq. 3] [app. C, eq. S3]
# The paper does not state how the reconstruction is written into the
# frozen model to produce its response distribution  [§3] [app. X]

def fsd(hidden, recon, sampled_ops, model):
    total = 0.0
    for op in sampled_ops:
        # Response distributions for the true and reconstructed states  [eq. 1]
        p = model.response(hidden, op)
        q = model.response(recon, op)
        # Jensen-Shannon divergence between the two responses  [eq. 3]
        total += js_divergence(p, q)
    return total / len(sampled_ops)

Mechanistic validation §4 app. E app. X

Transplantation. Pairs share the producer role and are matched on family, difficulty, length, insertion site and norm §4 app. E. The donor code takes the base code's place, and the surrounding residual stream is held fixed. Four donor types are used: same-family, cross-family, matched-random (same intervention load, no causal identity) and Local-API donors §4. TC measures the rate at which the donor-side update is realised; Locality (LOC) is the share of designated off-target slots that stay unchanged §4. Copy preservation is CopyPres = 1 − DonorCopy eq. 8, and the reported composite is the equal-weight mean of the three eq. 9.

Mediation. For a total target effect Δ_total and the effect Δ_blocked after blocking an API-aligned path, the mediated fraction is (Δ_total − Δ_blocked) / Δ_total eq. 10. Each API route is set against a null route with matched distance, rank, norm, load and patchability §4. Dimension and edge selectivity use BH-FDR at q = 0.05 app. E.

Organisms. The synthetic organisms are compact transformers. Depth is six layers, the residual stream is 256 wide, and the token set has 512 entries. Each is optimised for 3,000 steps, and every architecture is repeated over five seeds §4 app. F. The discovery pipeline sees activations and future signatures, never the class label §4 app. F.

Pseudocode
# Role-aligned transplant and composite score  [§4] [app. E] [eq. 8] [eq. 9]
# Illustrative only: the paper's intervention hook is not published.

def transplant_score(base, donor, layer, position):
    # Replace only the producer-role code; base context stays  [app. E]
    patched = base.with_code_at(layer, position, donor.code)
    # Target Correctness: did the donor-side relation appear  [§4]
    tc = target_correct(patched, donor.target)
    # Locality: are the pre-specified non-target slots unchanged  [§4]
    loc = locality(patched, base.nontarget_slots)
    # Copy preservation, higher is better  [eq. 8]
    copy_pres = 1 - donor_copy_rate(patched, donor)
    # Equal-weight composite of the three higher-is-better parts  [eq. 9]
    return (tc + loc + copy_pres) / 3

Hyperparameters

Values are as stated in the paper unless marked "not stated". Hardware and per-run costs are in tab. S14.

NameValueWhereNotes
Detailed backbonesQwen2.5-1.5B (d = 1536, 28 layers, 12 heads, bf16); Llama-3-8B (d = 4096, 32 layers, 32 heads, bf16)tab. S13Checkpoint hashes are abbreviated in the paper tab. S13
Selected layerQwen: 19; Llama: not statedapp. G tab. S7Chosen on validation seeds and frozen before test
Token position"mid-state position"tab. S7Exact index not stated
Interface rank64tab. S13 tab. S14Text says parameter-matched variants adjust width §3; see Pitfalls
ComponentsShared 1; Local 6; Mixture 4 (gated); Distributed 16 (gated)tab. S14 §5
Gate countMixture 4; Distributed 16tab. S13
OptimiserAdamW, β1 = 0.9, β2 = 0.999tab. S13Epsilon and warm-up not stated
Learning rate3e-4, cosine decaytab. S13Decay horizon not stated
Batch size256 signaturestab. S13
Weight decay / dropout1e-4 / 0.1tab. S13
Early stoppingStop after 10 checks without gain on validation causal MDLtab. S13Patience unit (epochs or steps) and split inside each block not stated
Prequential blocks20 ordered folds§5 tab. S13Block sizes and ordering rule not stated
Complexity penaltyλ_r = 0.02 (per rank), λ_g = 0.05 (per gate)§5 tab. S13
Parameter codeGaussian prior, two-part codetab. S13Prior variance and quantisation not stated
Data codeHeld-out signature code length, in nats (cross-entropy)tab. S13Log base of the JS divergence not stated
Signature defaultFull-vocabulary logits§3 app. COperations per state (K_h size) not stated; temperature default not stated
Signature sensitivitytop-k in {50, 100, 200, 500, full}; temperature in {0.5, 1.0, 1.5, 2.0}tab. S3
Fidelity limits ε_fFamily-specific, pre-specifiedeq. 6Values not stated
Equivalence margin (TOST)δ = 0.02 FSDapp. H
Non-inferiority marginδ = 0.05 FSDapp. H
Bootstrap10,000 paired resamples at the task-family levelapp. H tab. S2Three families per model; see Pitfalls
Permutation tests10,000 permutations, labels swapped within model, family, seed and splitapp. H tab. S8
MultiplicityBH-FDR, q = 0.05app. H app. E
Episode counts (train / val / test)Relation 4,200 / 900 / 1,200; program 3,800 / 820 / 1,080; proof 2,600 / 560 / 740§5Attribute/event and mixed data are described in tab. S13 but not in the main comparison
Operations16 used for training and 4 withheld per family; unseen 2- and 3-step compositions§5 tab. 1
Generators6 template families × 4 entity/relation pools; 2 template families held out§5 tab. S13
Prompt layoutsSeparate layouts for training, validation and test promptstab. S13Layouts are given in the table; not reproduced here
Languages / re-encodingEnglish, Chinese, random-symbol relabelling, three tokeniserstab. S13Chinese transfer is a coordinate test, not a multilingual evaluation
Organisms6 layers, width 256, vocab 512, 3,000 steps, 5 seeds per architecture, 4 held-out per class§4 tab. S1 app. F
Compute4 × NVIDIA A100 80 GB; Qwen ≈ 1.8 h and Llama ≈ 6.5 h per configuration; ≈ 18 kWh per full runtab. S14Peak memory 34 GB (Qwen), 71 GB (Llama); cache 128 GB and 512 GB

Results

Author-reported. Setup: Qwen2.5-1.5B and Llama-3-8B, three natural task families, held-out prequential blocks, Shared versus three alternatives, with 95% intervals from a paired bootstrap at the task-family level §5 tab. 2 tab. S2.

ModelArchitectureMDL (nats) ↓Mean FSD ↓Worst-family FSD ↓Tail-95 FSD ↓ParametersSG [95% CI]
Qwen2.5-1.5BShared1.2920.3410.3580.37298K0.216 [0.161, 0.278]
Qwen2.5-1.5BLocal1.5080.3430.3610.37998K
Qwen2.5-1.5BMixture1.6720.3490.3670.385103K
Qwen2.5-1.5BDistributed1.9810.3520.3710.3922.5M
Llama-3-8BShared1.1870.3280.3440.361262K0.294 [0.208, 0.391]
Llama-3-8BLocal1.4810.3310.3490.368262K
Llama-3-8BMixture1.5940.3360.3580.374270K
Llama-3-8BDistributed1.8630.3390.3620.3818.4M

Source: tab. 2 and tab. S2. Lower is better for MDL and FSD.

Other reported results:

  • Pooled Sharedness Gain: 95% bootstrap interval [0.172, 0.341]; permutation p < 0.001; seed variation 0.204 ± 0.036 tab. S8.
  • Equivalence and non-inferiority: Shared's mean FSD is within the TOST margin of the best alternative (p < 0.001), and non-inferior at δ = 0.05 tab. S8.
  • Multiplicity: 18 of 24 planned comparisons survive BH-FDR; the six that do not are reported tab. S8.
  • Transplantation (Qwen layer 19 as reported in app. G): Shared TC 0.91, LOC 0.88, CopyPres 0.85, CompScore 0.87; Local 0.72 / 0.75 / 0.66 / 0.70; Mixture 0.65 / 0.69 / 0.61 / 0.64; Distributed 0.48 / 0.52 / 0.42 / 0.46 tab. 3 tab. S4.
  • Donor controls (CompScore): same-family / cross-family / matched-random: Shared 0.88 / 0.78 / 0.53; Local 0.71 / 0.58 / 0.39; Mixture 0.64 / 0.51 / 0.34; Distributed 0.47 / 0.35 / 0.24 tab. S4.
  • Mediation: API paths 0.749 ± 0.089 versus null paths 0.150 ± 0.017 for mediated fraction (difference 0.599, p < 0.001); necessity–restoration 0.683 versus 0.121; multi-consumer blocking 0.714 versus 0.138. Based on 25 API paths and 25 matched null paths tab. S4.
  • Selectivity: 7 of 64 dimensions survive BH-FDR; API effects are about 24 times larger than random directions (mean 1.981 versus 0.083) tab. S4.
  • Graph: sparsity 0.791 ± 0.023; cross-seed Jaccard 0.83; threshold-free AUPRC 0.847 ± 0.031; hub layers 11, 13, 14, 15, 18; sink layers 22 to 26 tab. S10.
  • Representation identity (Qwen layer 19): the recovered API and the J-space baseline are practically equivalent under TOST. SAE/transcoder, output-gradient, PCA and random subspaces are lower on at least one of fidelity, transplantation or locality tab. S9.
  • Leave-one-natural-family-out (three folds): mean FSD Shared 0.387 versus Local 0.429 (Δ = −0.042). Per fold, Δ is −0.041 (relation), −0.038 (program) and −0.047 (proof). The backbone is not named tab. S6.
  • Ground-truth organisms: 14 of 16 correct. Shared, Mixture and Distributed are recovered in all four cases each. Of the four Local organisms, two are recovered, one is labelled Shared and one Mixture. False-Shared rate 1/12 = 8.3%. Mean correct-versus-runner-up MDL margin 0.183 ± 0.047; path overlap with the known graph 0.87 ± 0.06 tab. S5 fig. 2.
  • Further backbones: a directional sweep on Qwen2.5-7B, Mistral-7B, Gemma-2-9B and Phi-3-3.8B reports positive Sharedness Gain. Per-backbone numbers appear only in a figure §5 fig. 3.

Paper vs code

No official code.

Searched, with no matching repository found:

  • The arXiv abstract page: no code, data, or project link. It lists only the PDF, HTML and TeX source.
  • The paper's TeX source: no URL, repository, or project page anywhere. The paper says the configuration "should" be released, which reads as future tense app. B app. M.
  • GitHub repository search for "forked futures", "hidden apis language models", "causal interface prequential", "sharedness" and "forkedfutures". No repository matched the paper.

No code is recorded, so the discrepancy check against an implementation is not possible. The paper-internal inconsistencies are listed under Pitfalls.

Pitfalls

  • How the reconstruction enters the frozen model. FSD needs σ_k(ĥ), the response distribution with the reconstructed state in place of the true one eq. 3. The paper never says which layer and position receive ĥ, whether later positions are recomputed, or how the cache is handled. Implementers must choose this; a different injection changes FSD and therefore the selection §3 app. X.
  • MDL units and penalty placement. The MDL values (1.19 to 1.98) are not stated to be per-signature averages or totals. The penalty λ_r · rank is 0.02 × 64 = 1.28 nats for one rank-64 code. That is larger than the Sharedness Gain (0.216 and 0.294) and about the size of the MDL values themselves. Whether rank is summed across Local's six interfaces or Distributed's sixteen components is not stated. Both choices change the ranking §5 tab. S13.
  • Likelihood of distribution-valued signatures. The paper says the data term is a cross-entropy in nats, but does not say how the predictive likelihood of a full-vocabulary distribution is evaluated. Vocabularies are 151,936 (Qwen) and 128,256 (Llama) tokens tab. S13. The log base of the JS divergence is also not stated.
  • Parameter counts do not match the stated architecture. Shared's 98K on Qwen equals 1536 × 64 exactly, and 262K on Llama equals 4096 × 64. That is one rank-64 matrix, not an encoder–reconstructor pair. Local also reports 98K despite six interfaces. The text says parameter-matched variants "adjust their internal widths" §3, while Table S14 says "every active code has rank 64" tab. S14. Which is used is not stated.
  • Operation counts are ambiguous. The main text describes 20 operations per family, split 16 and 4 §5. The appendix gives operation counts of about 420 (relation), 380 (program), 260 (proof) and 340 (attribute/event) fig. S1. These may be rendered instances or operation-bank sizes; the paper does not say which.
  • Family count. The main comparison uses three families. The appendix describes four generation families, and Table S13 lists attribute/event and mixed data with sample counts app. B tab. S13. Only the three-family analysis has reported results.
  • Backbone count. The abstract and the figure caption say "five backbones" [abstract] fig. 3. The text lists six: two detailed models plus four in the sweep §5 tab. S2.
  • Bootstrap with three units. The task-family bootstrap resamples three units per model. That yields at most ten distinct resamples, so the reported intervals are coarse. The paper does not say whether seeds or episodes are also resampled app. H §5.
  • Mediation sample size. The mediation result rests on 25 API paths and 25 null paths tab. S4. Intervention results are reported for Qwen layer 19; whether Llama interventions were run, and at which layer, is not stated §5 app. G.
  • Mean-FSD difference in the statistics table. Table S8 reports the Shared-minus-best-alternative mean FSD as −0.008. From Table 2, the difference against Local is −0.002 (Qwen) and −0.003 (Llama), so the printed figure cannot be reproduced from the paper's own numbers tab. S8 tab. 2.
  • Composite score rounding. The printed CompScore cannot be recomputed exactly from the printed components. For Distributed, (0.48 + 0.52 + 0.42) / 3 = 0.47, not the printed 0.46. The paper says the composite uses unrounded values tab. 3 eq. 9. Use unrounded measurements if you need the composite.
  • Degradation percentages. The text says Shared degrades about 12% and Local about 24% under natural-family holdout tab. S6. Using Qwen's in-distribution values from Table 2, the degradation is about 13.5% (Shared) and 25% (Local). The backbone for Table S6 is not named.
  • Organism falsification target missed. The paper's own target is a false-Shared rate below 5%. The observed rate is 8.3% (1 of 12), so the criterion is marked partial tab. S11. Any claim of identifiability should carry that caveat. The organisms are synthetic and possibly easier than pretraining-formed mechanisms §7 app. F.
  • Selection details not stated. Fidelity limits ε_f are not given numerically. The layer used for Llama is not given. The early-stopping patience unit and split are not stated. The size of the first block and the rule that forms the 20 blocks are not stated. The uninformed cost L0 is not stated §3 tab. S13 tab. S7.
  • Latent-episode grouping. Branches from one latent state share a cache. Putting any of them in a different split, block or bootstrap unit leaks the signature. Group by latent episode throughout app. X app. B.
  • Reproducibility gaps. Checkpoint hashes are abbreviated. Framework versions, CUDA settings, tokenizer revisions and the deterministic-run settings are not given. The paper calls them necessary for the final release tab. S13 tab. S14.

Lineage

  • Builds on: causal abstraction and the intervention-based circuit-finding line of work §2. None has a card in this wiki.
  • Compared against: the Local, Mixture and Distributed codes §3; the probing, steering, sparse-feature and component-analysis baselines that the related-work section surveys §2 app. I.
  • Superseded by: none known.

Source and license

Adapted from “Hidden APIs in Language Models: Discovering Reusable Causal Interfaces from Forked Futures” by SiYuan Ma, Yiqin Luo, Zhangji, Canran Xiao, Albert Gao, Wei Wang, Qiwei Wu, Xinran Li, Jinfeng Wei, Qixin Zhang (arXiv:2607.27617), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.