---
title: Kan Extension Transformers (KETs)
url: https://www.emergentmind.com/topics/kan-extension-transformers-kets
type: topic
---

# Kan Extension Transformers (KETs)

Kan Extension Transformers (KETs) are a categorical formulation of Transformer layers in which contextualization is expressed as a weighted structured extension operator. In this framework, a layer aggregates values carried by source objects defined over a neighborhood system and extends them to target token positions; standard self-attention appears as the singleton-neighborhood case, Geometric Transformer style incidence mixing appears as a sparse edge-restricted case, and KET constitutes the higher-order simplicial case [2605.27259]. The same formal lens is used to relate aggregation to diffusion-style completion and to characterize predict-detach self-conditioning as a causally valid mechanism for exposing noncausal structure without transporting teacher-forced future hidden states [2605.27259].

## 1. Categorical definition and formal apparatus

The core categorical setup introduces functors
\[
F : \mathcal{C} \to \mathcal{E}, \qquad K : \mathcal{C} \to \mathcal{D},
\]
with the left Kan extension of \(F\) along \(K\), denoted \(\operatorname{Lan}_K F\), defined as a universal extension
\[
\operatorname{Lan}_K F : \mathcal{D} \to \mathcal{E}
\]
equipped with a natural transformation
\[
\eta : F \Rightarrow (\operatorname{Lan}_K F)\circ K
\]
such that for any
\[
G : \mathcal{D} \to \mathcal{E}, \qquad \gamma : F \Rightarrow G\circ K,
\]
there exists a unique natural transformation
\[
\alpha : \operatorname{Lan}_K F \Rightarrow G
\]
with
\[
\gamma = (\alpha K)\circ \eta.
\]
Dually, the right Kan extension \(\operatorname{Ran}_K F\) is characterized by maps
\[
\epsilon : (\operatorname{Ran}_K F)\circ K \Rightarrow F.
\]
The paper further states the pointwise colimit and limit formulas
\[
(\operatorname{Lan}_K F)(d) \;\cong\; \operatorname*{colim}_{(K \downarrow d)} F,
\qquad
(\operatorname{Ran}_K F)(d) \;\cong\; \operatorname*{lim}_{(d \downarrow K)} F,
\]
and the enriched coend and end expressions
\[
(\operatorname{Lan}_K F)(d) \;\cong\; \int^{c \in \mathcal{C}} \mathcal{D}(Kc,d)\,\otimes\,F(c),
\qquad
(\operatorname{Ran}_K F)(d) \;\cong\; \int_{c \in \mathcal{C}} [\mathcal{D}(d,Kc),\,F(c)].
\]
The interpretive summary given in the paper is concise: left Kan corresponds to aggregation from local evidence, whereas right Kan corresponds to completion under constraints [2605.27259].

Within the Transformer setting, the target token positions are written as
\[
\mathcal{T} = \{0,\dots,S-1\},
\]
and source-side features are assigned by
\[
X : \mathcal{N} \to \mathbf{Vect}.
\]
This yields the common weighted aggregation form
\[
h'_t
\;\approx\;
\int^{\sigma \in \mathcal{N}} W(t,\sigma)\otimes X(\sigma)
\;\approx\;
\sum_{\sigma \in \mathcal{N}} w(t,\sigma)\,V(\sigma).
\]
The terminology is explicit. “Carriers” are the values transported from source objects, including token states, edge embeddings, and higher-order simplex values. “Neighborhoods” are the objects over which aggregation occurs, including tokens, learned topological neighbors, and simplices. “Weights” \(W(t,\sigma)\) encode compatibility or incidence between source object \(\sigma\) and target token \(t\), including attention kernels, geometric proximity, and simplicial incidence [2605.27259].

This formulation is not merely a restatement of attention in categorical notation. It is intended as a common language in which several Transformer-like mechanisms become instances of the same extension schema. A plausible implication is that architectural variation can be analyzed along two largely separable axes: the source neighborhood family and the information regime carried through that family.

## 2. Attention, geometric incidence mixing, and simplicial generalization

Standard self-attention is recovered by restricting the source neighborhood system to tokens:
\[
\mathcal{N}_{\mathrm{attn}} = \{0,\dots,S-1\}.
\]
Each source object is a token \(s\), and the update at target token \(t\) is
\[
h'_t = \sum_s w(t,s)\,V_s.
\]
Categorically, this is presented as a weighted left-Kan-style extension in which source and target objects are token positions; the familiar query-key-value mechanism supplies the weights and carriers, with queries \(Q_t\) parameterizing weights \(w(t,s)\) against keys \(K_s\), and values \(V_s\) carrying the features associated with source objects [2605.27259].

The geometric case, called TopoCoend, preserves tokens as source objects but changes the neighborhood structure from positional adjacency to learned geometric adjacency in a latent space
\[
z_t = \pi(v_t).
\]
The resulting \(\mathcal{N}_{\mathrm{topo}}\) is described as a learned geometric graph with fuzzy \(k\)-NN weights \(W_{\mathrm{topo}}(t,s)\) induced by topological proximity rather than sequence position alone. Its update is
\[
h'_t = h_t + \sum_s w_{\mathrm{topo}}(t,s)\,V_s.
\]
This remains a coend-style weighted extension, but with learned neighborhoods rather than a fixed sequential token-to-token pattern [2605.27259].

KET changes the source objects themselves by lifting from tokens, viewed as \(0\)-simplices, to edges, viewed as \(1\)-simplices, and optionally to higher-order simplices such as faces or motifs. The generic simplicial update is
\[
h'_t
=
h_t + \sum_{\sigma \in \mathcal{N}_{\mathrm{simp}}}
w_{\mathrm{simp}}(t,\sigma)\,V(\sigma).
\]
Two concrete realizations are specified. The first is quadratic KET:
\[
h'_t
=
h_t +
\sum_{\sigma \in \mathcal{N}_{\mathrm{simp}}}
w(t,\sigma)\,V(\sigma), \qquad
w(t,\sigma)=\operatorname{softmax}(Q_t^\top K_\sigma),
\]
which is described as an attention kernel over simplices rather than over tokens and is typically \(O(S^2)\) in sequence length. The second is incidence-restricted KET:
\[
h'_t
\;\approx\;
h_t + \sum_{\sigma \ni t} \phi\bigl(V(\sigma)\bigr),
\]
with the edge-only causal example
\[
e_t = \psi([v_{t-1},v_t]), \qquad
h'_t = h_t + \phi(e_t).
\]
This reduces complexity to \(O(S)\) and is used to clarify the connection to Geometric Transformer, which is identified as an incidence-restricted special case of KET [2605.27259].

A significant restriction is also stated explicitly. Although the framework is simplicial and topological in its indexing, the KET equations do not introduce explicit boundary or coboundary operators \((\partial,\delta)\), Hodge Laplacians, or weighted cochain complexes. The simplicial structure enters through neighborhood indexing and incidence-restricted transport rather than through explicit Laplacian or chain-complex formulas [2605.27259]. This point addresses a likely misconception: KET is not presented as a Hodge-theoretic or message-passing Laplacian model, even though it invokes simplices and incidence.

## 3. Aggregation, completion, and the diffusion-style bridge

The paper connects left Kan aggregation to right Kan completion by introducing structured block prediction and denoising. Direct block prediction is formulated as
\[
f : C_t \longrightarrow \Sigma^B,
\]
with
\[
\Sigma^B = \Sigma \times \Sigma \times \cdots \times \Sigma.
\]
Denoising completion is formulated as
\[
f : (C_t,\tilde{x}_{t+1:t+B}) \longrightarrow x_{t+1:t+B},
\]
together with the corruption schedule
\[
p(s) = 0.05 + 0.45 \cdot \frac{s-1}{7}, \qquad s \in \{1,\dots,8\},
\]
which spans corruption rates from \(0.05\) to \(0.50\) [2605.27259].

The conceptual claim is that left Kan constructions, expressed through coends, describe aggregation from local evidence, whereas right Kan constructions, expressed through ends or limits, describe completion subject to multiple local constraints. Denoising block prediction uses partial future objects as constraints and asks the model to fill in missing structure; the paper describes this using a “horn filling” analogy from simplicial homotopy [2605.27259].

The formulation is deliberately limited. The text states that it does not present explicit diffusion updates such as
\[
x_{t+1} = x_t + \tau L x_t.
\]
Instead, denoising is positioned as a right-Kan-style completion regime rather than as a discretization of a Laplacian flow or a particular stochastic differential process [2605.27259]. This distinction matters because it prevents over-identifying the framework with standard diffusion implementations. The bridge is structural and conceptual: completion under constraints resembles denoising, but the paper does not reduce KET to a specific diffusion algorithm.

The structured-completion perspective broadens the scope of the framework beyond autoregressive language modeling. The paper states that it generalizes to blockwise infilling and broader tasks where partial target structure is available [2605.27259]. This suggests a research program in which the same extension operator is reused across causal prediction, block prediction, and denoising completion, with the primary change occurring in the information supplied to the operator.

## 4. Predict-detach self-conditioning and causal validity

A central mechanism is predict-detach self-conditioning, in which noncausal neighborhoods are made compatible with causal validity by changing what is transported through those neighborhoods. The detached predictive carrier is defined as
\[
\hat e_t
=
detach\!\left(softmax(\ell_t / T)\, E\right),
\]
and equivalently in the appendix as
\[
\hat e_t
=
\operatorname{detach}\!\Bigl(
\operatorname{softmax}(\ell_t/T)\,E
\Bigr), \qquad
\ell_t = W_o h_t.
\]
Here \(E\) is the embedding matrix and \(T\) is a temperature parameter [2605.27259].

The rationale for detach is given in two explicit points. First, there are “No gold-future values”: the carrier is computed from a prefix-valid predictive state rather than from a hidden state that already encodes the true future under teacher forcing. Second, there is “No leakage gradient”: detaching blocks the auxiliary branch from becoming a backdoor through which the model could cheaply encode targets into the carriers that will later be consumed by noncausal aggregation [2605.27259].

Under this regime, the same extension operator—whether attention, topological aggregation, or simplicial aggregation—can reuse noncausal neighborhoods without violating causal validity because the transported values are endogenous predictions frozen by detach rather than teacher-forced future states [2605.27259]. The point of emphasis is that validity depends on which values flow through the graph, not merely on whether the graph itself includes noncausal edges.

The paper includes a leakage diagnostic. Targets are shuffled within a batch; if noncausal neighborhoods transport teacher-forced hidden states, perplexity collapses toward \(1\). By contrast, predict-detach regimes remain high under shuffling, which is taken to indicate causal validity [2605.27259]. This diagnostic supports the paper’s stronger claim that the principal issue is information leakage through carriers, not noncausal connectivity as such.

A common misunderstanding is therefore directly addressed by the reported experiments: noncausal structure is not inherently invalid. According to the paper, it becomes valid when paired with detached predictive carriers and invalid when paired with teacher-forced future states [2605.27259].

## 5. Computational regimes, implementations, and complexity

The framework distinguishes several computational regimes by neighborhood family and aggregation rule. Attention over tokens is standard \(O(S^2)\) softmax attention. TopoCoend performs token-level aggregation over learned topological neighborhoods, with complexity depending on \(k\)-NN sparsity and weights derived from latent \(z_t\) proximity. Quadratic KET uses a global attention-like kernel over simplices and is typically \(O(S^2)\), with greater expressivity arising from higher-order source objects. Incidence-restricted KET performs local aggregation from incident simplices such as edges and faces and is \(O(S)\); it is described as an efficient sparse approximation. GT is explicitly categorized as an incidence-restricted special case of KET [2605.27259].

The paper remarks that quadratic KET benefits disproportionately from modern GPU acceleration, which narrows its runtime gap relative to incidence-based variants, while incidence-restricted KET and GT are lighter-weight linear-time mixers [2605.27259]. This is presented as a practical trade-off rather than a formal complexity-theoretic novelty.

Two implementation blocks are specified verbatim. The Quadratic Kan Extension Block takes token states \(h_{0:S-1}\), a simplex set \(\mathcal{I}\), a value base \(v\), and an optional causal mask; it constructs simplex values \(V(\sigma)\), simplex keys \(K_\sigma = W_K V(\sigma)\), computes token queries \(Q_t = W_Q h_t\), optionally restricts the simplex set to \(\mathcal{I}_t = \{\sigma \in \mathcal{I} : \max(\sigma)\le t\}\) under a causal mask, forms
\[
w(t,\sigma) \gets \operatorname{softmax}_{\sigma \in \mathcal{I}_t}(Q_t^\top K_\sigma),
\]
aggregates
\[
m_t \gets \sum_{\sigma \in \mathcal{I}_t} w(t,\sigma)\,V(\sigma),
\]
and updates
\[
h'_t \gets \mathrm{LN}\!\bigl(h_t + \mathrm{MLP}(m_t)\bigr).
\]
The Incidence-Restricted Kan Block (Edge-Only) computes
\[
e_t \gets \psi([v_{t-1},v_t])
\]
for \(t=1,\dots,S-1\), then initializes \(m_t=0\), adds \(\phi(e_t)\) when \(t\ge 1\), optionally adds \(\phi(e_{t+1})\) when the regime is noncausal and \(t+1\le S-1\), and updates
\[
h'_t \gets \mathrm{LN}(h_t + m_t).
\]
The paper also states that initialization follows standard Transformer practice, while stability relies on detach to block gradients through the auxiliary branch and on gradient clipping with norm \(1.0\) [2605.27259].

This operational detail reinforces the paper’s general distinction between structural design and information regime. The same block structure can behave either causally or noncausally depending on the carriers and gradient pathways.

## 6. Empirical evaluation, interpretation, and limitations

The empirical study evaluates 12 different Transformer implementations across strict-causal and predict-detach regimes on Penn Treebank, WikiText-2, and WikiText-103 [2605.27259]. For the main causal language-model comparisons, the reported configuration uses AdamW, learning rate \(3\times 10^{-4}\), weight decay \(10^{-5}\), batch size \(32\), context length \(128\), \(L=2\) layers, hidden dimension \(256\), \(4\) attention heads, \(5000\) training iterations, reporting every \(100\) steps, evaluation every \(1000\) steps, self-conditioned temperature \(T=1.0\), and for TopoCoend \(topo\_k=16\), \(topo\_dim=16\). Structured completion runs use matched Transformer and incidence-KET backbones, AdamW, learning rate \(3\times 10^{-4}\), weight decay \(10^{-2}\), context length \(128\), hidden dimension \(64\), \(8\) and \(16\) layers, \(4\) attention heads, block size \(4\), \(2000\) training steps, evaluation every \(250\) steps, denoising steps \(8\), and gradients clipped to norm \(1.0\) [2605.27259].

The strict-causal test perplexities are reported as follows:

| Model | PTB | WT2 | WT103 |
|---|---:|---:|---:|
| Transformer | 124.47 | 163.92 | 232.52 |
| GT-Causal | 127.17 | 157.74 | 215.69 |
| KET-Quad-C | 133.37 | 156.42 | 210.30 |
| KET-Inc-C | 137.19 | 161.12 | 213.76 |

The interpretation given in the paper is that on PTB, the plain Transformer is strongest among strict-causal models, whereas on WT2 and WT103, quadratic KET is the strongest among the tabulated causal architectures [2605.27259].

The predict-detach ablation is more pronounced. Test perplexity changes from KET-Quad-C to KET-Quad-PD are PTB \(133.37 \to 31.43\), WT2 \(156.42 \to 38.23\), and WT103 \(210.30 \to 51.89\). For KET-Inc-C to KET-Inc-PD they are PTB \(137.19 \to 6.54\), WT2 \(161.12 \to 19.08\), and WT103 \(213.76 \to 47.17\). GT-PD attains PTB \(1.05\), WT2 \(1.59\), and WT103 \(12.84\) [2605.27259]. The paper’s interpretation is that the largest empirical gains come from the predict-detach regime itself, while neighborhood family determines how those gains are expressed. It further reports that gold noncausal leakage diagnostics, in which teacher-forced future states are passed through noncausal neighborhoods, produce collapse toward perplexity \(\approx 1\), confirming that validity depends on which values flow through the graph [2605.27259].

For structured language modeling with \(B=4\), context \(128\), and \(d=64\), direct block prediction is reported to be much harder than denoising completion. Representative values include PTB with TF-Block-4 \(L=8\) at \(155.95 / 332.38\) versus KET-Block-4 \(L=8\) at \(152.25 / 327.62\), while TF-Denoise-4 \(L=8\) gives \(4.21 / 4.56\) and KET-Denoise-4 \(L=8\) gives \(4.21 / 4.55\). On WT2 with \(L=16\), TF-Block-4 gives \(177.87 / 343.04\), KET-Block-4 \(174.55 / 341.37\), TF-Denoise-4 \(4.35 / 4.73\), and KET-Denoise-4 \(4.35 / 4.72\). On WT103 with \(L=16\), TF-Block-4 gives \(491.12 / 796.10\), KET-Block-4 \(472.29 / 782.34\), TF-Denoise-4 \(5.69 / 5.96\), and KET-Denoise-4 \(5.74 / 6.01\) [2605.27259]. The stated interpretation is that direct block prediction into \(\Sigma^B\) is much harder than denoising completion, again highlighting regime effects over pure architecture choice.

The paper’s practical guidance follows directly from these results. In strict-causal language modeling, neighborhood design matters: quadratic KET is strongest among the compared causal architectures on WT2 and WT103, and incidence-restricted KET remains competitive with lower cost. Across all datasets, however, the larger gains come from the predict-detach regime rather than from changing the neighborhood family alone [2605.27259].

The limitations are also explicit. The study is modest in scale, centered on perplexity, and uses single-seed runs. Future work is said to require scaling neighborhood design and information regime separately, exploring richer simplicial families, adaptive simplex selection, longer-context sparse approximations, and hybrid systems combining KET with TopoCoend [2605.27259]. This suggests that the current contribution is primarily a unifying formalism with targeted empirical support rather than a definitive large-scale benchmark study.

Source: https://www.emergentmind.com/topics/kan-extension-transformers-kets