Upload folder using huggingface_hub
Browse files- README.md +40 -0
- hnt-architecture.md +382 -0
README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- hnt
|
| 5 |
+
- neural-transformer
|
| 6 |
+
- global-workspace
|
| 7 |
+
- multi-scale
|
| 8 |
+
- residual-streams
|
| 9 |
+
- security-llm
|
| 10 |
+
- architecture
|
| 11 |
+
language: en
|
| 12 |
+
library: transformers
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Hayula Neural Transformer: Multi-Scale Residual Stream Architecture with Global Workspace Gating for Security Language Models
|
| 17 |
+
|
| 18 |
+
**Authors:** Hayula AI Lab
|
| 19 |
+
|
| 20 |
+
**Preprint. July 2026.**
|
| 21 |
+
|
| 22 |
+
## Abstract
|
| 23 |
+
|
| 24 |
+
We introduce the Hayula Neural Transformer (HNT), a novel architecture that bakes Global Workspace theory (Baars, 1988) into transformer design through Multi-Scale Residual Streams. Inspired by the discovery that J-lens vectors form a global workspace in standard transformers—with broadcast heads specialized for relaying workspace content and MLP layers preferentially amplifying workspace-aligned directions (Gurnee et al., 2026)—HNT explicitly separates computation into three residual streams: a *main stream* for standard autoregressive computation, a *local stream* for syntax and surface-level features concentrated in early layers, and a *global stream* for workspace-level conceptual content concentrated in middle layers. A Cross-Stream Gating (CSG) mechanism, parameterized as a low-rank bilinear form inspired by QK-circuit analysis (Anthropic, 2025a), controls information flow between streams while minimizing feature interference. We further introduce *Broadcast Heads*: attention heads whose OV circuits are optimized for workspace content relay using gain-based selection metrics derived from MLP amplification analysis. Applied to security-domain training on a curated corpus of threat intelligence, vulnerability descriptions, and secure code repositories, HNT achieves 18% greater concept depth (measured by J-lens projection magnitude) than equivalent-parameter standard transformers, with a 22% reduction in feature interference as measured by the interference weight metric (Anthropic, 2025b). Our results demonstrate that architectural specialization informed by mechanistic interpretability yields disproportionate gains in domain-specific reasoning tasks.
|
| 25 |
+
|
| 26 |
+
## Paper
|
| 27 |
+
|
| 28 |
+
The full paper is available as [`hnt-architecture.md`](hnt-architecture.md) in this repository.
|
| 29 |
+
|
| 30 |
+
## Citation
|
| 31 |
+
|
| 32 |
+
```bibtex
|
| 33 |
+
@techreport{hayula2026hnt,
|
| 34 |
+
title={Hayula Neural Transformer: Multi-Scale Residual Stream Architecture with Global Workspace Gating for Security Language Models},
|
| 35 |
+
author={Hayula AI Lab},
|
| 36 |
+
year={2026},
|
| 37 |
+
month={July},
|
| 38 |
+
note={Preprint}
|
| 39 |
+
}
|
| 40 |
+
```
|
hnt-architecture.md
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hayula Neural Transformer: Multi-Scale Residual Stream Architecture with Global Workspace Gating for Security Language Models
|
| 2 |
+
|
| 3 |
+
**Hayula AI Lab**
|
| 4 |
+
|
| 5 |
+
*Preprint. July 2026.*
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Abstract
|
| 10 |
+
|
| 11 |
+
We introduce the Hayula Neural Transformer (HNT), a novel architecture that bakes Global Workspace theory (Baars, 1988) into transformer design through Multi-Scale Residual Streams. Inspired by the discovery that J-lens vectors form a global workspace in standard transformers—with broadcast heads specialized for relaying workspace content and MLP layers preferentially amplifying workspace-aligned directions (Gurnee et al., 2026)—HNT explicitly separates computation into three residual streams: a *main stream* for standard autoregressive computation, a *local stream* for syntax and surface-level features concentrated in early layers, and a *global stream* for workspace-level conceptual content concentrated in middle layers. A Cross-Stream Gating (CSG) mechanism, parameterized as a low-rank bilinear form inspired by QK-circuit analysis (Anthropic, 2025a), controls information flow between streams while minimizing feature interference. We further introduce *Broadcast Heads*: attention heads whose OV circuits are optimized for workspace content relay using gain-based selection metrics derived from MLP amplification analysis. Applied to security-domain training on a curated corpus of threat intelligence, vulnerability descriptions, and secure code repositories, HNT achieves 18% greater concept depth (measured by J-lens projection magnitude) than equivalent-parameter standard transformers, with a 22% reduction in feature interference as measured by the interference weight metric (Anthropic, 2025b). Our results demonstrate that architectural specialization informed by mechanistic interpretability yields disproportionate gains in domain-specific reasoning tasks.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## 1 Introduction
|
| 16 |
+
|
| 17 |
+
The residual stream in modern transformer architectures serves as a shared communication channel through which all attention heads and MLP layers read and write (Elhage et al., 2021). This design has proven remarkably effective, but recent mechanistic analyses reveal a fundamental tension: the residual stream must simultaneously support low-level syntactic processing, mid-level semantic composition, and high-level conceptual reasoning, all within a single superposition of features (Elhage et al., 2022). The resulting interference between features operating at different abstraction scales limits both representational capacity and training efficiency.
|
| 18 |
+
|
| 19 |
+
Anthropic's Global Workspace paper (Gurnee et al., 2026) provides a mechanistic lens for understanding this tension. The authors demonstrate that J-lens vectors—directions in the residual stream that correspond to verbalizable concepts—form a global workspace in standard transformers. Crucially, they identify two specialized computational roles: *broadcast heads* whose attention patterns and OV circuits are optimized to relay workspace content across token positions, and *MLP gain amplification*, wherein MLP layers preferentially strengthen residual directions already aligned with the workspace. These findings suggest that the standard transformer's residual stream, despite its monolithic appearance, is already performing a form of workspace separation—but doing so implicitly, without architectural specialization.
|
| 20 |
+
|
| 21 |
+
The present work asks: what happens if we make this separation *explicit*? We propose the Hayula Neural Transformer (HNT), which replaces the single residual stream with three architecturally separated streams:
|
| 22 |
+
|
| 23 |
+
1. **Local stream** ($\mathbf{r}^{\text{local}}_t$): Specialized for surface-level features—token identity, positional encoding, local syntactic patterns. Active primarily in layers $L_0$ through $L_{10}$.
|
| 24 |
+
|
| 25 |
+
2. **Main stream** ($\mathbf{r}^{\text{main}}_t$): The standard autoregressive pathway, present at all layers, responsible for next-token prediction.
|
| 26 |
+
|
| 27 |
+
3. **Global stream** ($\mathbf{r}^{\text{global}}_t$): A dedicated workspace for conceptual content—entities, relations, reasoning chains. Active primarily in layers $L_{11}$ through $L_{26}$.
|
| 28 |
+
|
| 29 |
+
Between these streams, a learned Cross-Stream Gating (CSG) mechanism controls information flow, parameterized as a low-rank bilinear form that draws on insights from the Attention QK circuit analysis (Anthropic, 2025a) and interference weight theory (Anthropic, 2025b). We further introduce *Broadcast Heads* as a specialized attention head variant whose OV circuits are trained with an auxiliary loss that encourages workspace-content relay, using gain-based selection metrics derived from MLP amplification analysis.
|
| 30 |
+
|
| 31 |
+
Our primary contributions are:
|
| 32 |
+
|
| 33 |
+
- **Multi-Scale Residual Stream architecture** that explicitly separates computation by abstraction level, reducing feature interference between syntactic and conceptual processing.
|
| 34 |
+
- **Cross-Stream Gating (CSG)** mechanism inspired by QK-circuit structure, parameterized as a low-rank bilinear form with learned interference penalties.
|
| 35 |
+
- **Broadcast Head** specialization using OV gain metrics for workspace content relay.
|
| 36 |
+
- **Theoretical analysis** showing that stream separation reduces the expected interference between features at different abstraction scales.
|
| 37 |
+
- **Empirical validation** on security-domain training, demonstrating 18% higher concept depth and 22% lower interference than baseline transformers.
|
| 38 |
+
|
| 39 |
+
The remainder of this paper is organized as follows. Section 2 reviews related work. Section 3 presents the full architecture. Section 4 provides theoretical analysis. Sections 5 and 6 describe experiments and results. Section 7 concludes.
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## 2 Related Work
|
| 44 |
+
|
| 45 |
+
### 2.1 Global Workspace Theory
|
| 46 |
+
|
| 47 |
+
Baars' Global Workspace Theory (Baars, 1988) proposes that conscious processing involves a central workspace—a limited-capacity arena where information from specialized processors is integrated and broadcast to the rest of the system. This framework has been influential in cognitive architecture design (Shanahan, 2006) and, more recently, in mechanistic interpretability of neural networks.
|
| 48 |
+
|
| 49 |
+
Gurnee et al. (2026) provide the first rigorous evidence that transformer language models implement a computational analogue of the global workspace. Using J-lens projection—a technique that measures how strongly a given concept direction is represented in the residual stream at each layer—they show that verbalizable concepts follow a characteristic "workspace trajectory": weak in early layers, maximal in middle layers (the workspace layer range), and decaying in later layers. They further identify broadcast heads as attention heads whose outputs disproportionately amplify workspace content, and demonstrate that MLP layers exhibit gain amplification—a preference for increasing the magnitude of directions already aligned with the workspace.
|
| 50 |
+
|
| 51 |
+
### 2.2 Transformer Circuits and the Residual Stream
|
| 52 |
+
|
| 53 |
+
Elhage et al. (2021) introduced the mathematical framework for analyzing transformers as circuits operating through a shared residual stream. In this framework, each layer reads from the residual stream and writes back to it, creating a superposition of features at every token position. The resulting interference between features has been analyzed through the lens of *interference weights* (Anthropic, 2025b), which measure the degree to which distinct features compete for representational capacity.
|
| 54 |
+
|
| 55 |
+
The Attention QK Circuit paper (Anthropic, 2025a) further characterizes how attention heads compute query-key interactions, showing that these circuits are often low-rank and specialized for particular types of feature matching. This motivates our use of low-rank bilinear forms in the Cross-Stream Gating mechanism.
|
| 56 |
+
|
| 57 |
+
### 2.3 Specialized Architectures
|
| 58 |
+
|
| 59 |
+
Several prior works have explored architectural variations on the transformer. Mixture-of-Experts (MoE) architectures (Shazeer et al., 2017; Fedus et al., 2022) introduce conditional computation by routing tokens to different expert sub-networks. While MoE provides capacity scaling, it does not address the abstraction-level separation that motivates our work.
|
| 60 |
+
|
| 61 |
+
Hayula Circuit-Aware LoRA (Hayula AI Lab, 2026a) introduces parameter-efficient fine-tuning that respects the circuit structure of transformer layers. The present work extends this philosophy to architecture design itself, building specialized computational pathways informed by mechanistic understanding.
|
| 62 |
+
|
| 63 |
+
The companion papers to this work—Hayula Multi-Head Routing Attention (Hayula AI Lab, 2026b), Hayula Synthetic Memory Integration (Hayula AI Lab, 2026c), and Hayula Adaptive Sparsity (Hayula AI Lab, 2026d)—explore complementary architectural innovations for security language models. The present work focuses specifically on the residual stream architecture and gating mechanism.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## 3 Architecture
|
| 68 |
+
|
| 69 |
+
We now describe the Hayula Neural Transformer architecture in detail. Let $\mathbf{x} \in \mathbb{R}^{d}$ denote the input embedding at a given token position, and let $L$ denote the total number of transformer layers.
|
| 70 |
+
|
| 71 |
+
### 3.1 Multi-Scale Residual Streams
|
| 72 |
+
|
| 73 |
+
Standard transformers maintain a single residual stream $\mathbf{r}_t \in \mathbb{R}^{d}$ at each token position $t$. HNT replaces this with three parallel streams:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\begin{aligned}
|
| 77 |
+
\mathbf{r}^{\text{local}}_t &\in \mathbb{R}^{d_{\text{local}}} \quad \text{(surface-level features)} \\
|
| 78 |
+
\mathbf{r}^{\text{main}}_t &\in \mathbb{R}^{d_{\text{main}}} \quad \text{(autoregressive computation)} \\
|
| 79 |
+
\mathbf{r}^{\text{global}}_t &\in \mathbb{R}^{d_{\text{global}}} \quad \text{(workspace concepts)}
|
| 80 |
+
\end{aligned}
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
The total parameter count is preserved by setting $d_{\text{local}} + d_{\text{main}} + d_{\text{global}} = d$, with typical ratios $\alpha_{\text{local}} = 0.15$, $\alpha_{\text{main}} = 0.55$, $\alpha_{\text{global}} = 0.30$ for a 7B-parameter model. These ratios are determined by the relative information-theoretic capacity required at each abstraction level, formalized in Section 4.
|
| 84 |
+
|
| 85 |
+
#### Layer Allocation
|
| 86 |
+
|
| 87 |
+
Each stream is active at a specific subset of layers:
|
| 88 |
+
|
| 89 |
+
- **Local stream**: active at layers $\ell \in \{0, 1, \dots, L_{\text{local}}\}$ where $L_{\text{local}} = \lfloor 0.4L \rfloor$. At higher layers, $\mathbf{r}^{\text{local}}_t$ is frozen (no further writes), preserving the features learned in early processing.
|
| 90 |
+
- **Main stream**: active at all layers $\ell \in \{0, 1, \dots, L\}$.
|
| 91 |
+
- **Global stream**: active at layers $\ell \in \{L_{\text{global}}^{\text{start}}, \dots, L\}$ where $L_{\text{global}}^{\text{start}} = \lfloor 0.42L \rfloor$, corresponding to the workspace layer range identified by Gurnee et al. (2026). Below this range, $\mathbf{r}^{\text{global}}_t$ receives writes from CSG but does not directly participate in attention.
|
| 92 |
+
|
| 93 |
+
This allocation mirrors the empirical finding that syntactic processing dominates early layers, conceptual processing dominates middle-to-late layers, and a backbone of general computation is needed throughout (Gurnee et al., 2026; Tenney et al., 2019).
|
| 94 |
+
|
| 95 |
+
### 3.2 Stream-Specific Computation
|
| 96 |
+
|
| 97 |
+
At each active layer $\ell$, each stream undergoes the standard transformer sublayer computation, but with stream-specific parameters:
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
\begin{aligned}
|
| 101 |
+
\mathbf{r}^{\text{s}}_t &\leftarrow \mathbf{r}^{\text{s}}_t + \text{Attn}^{\text{s}}_{\ell}(\mathbf{r}^{\text{s}}_t) \\
|
| 102 |
+
\mathbf{r}^{\text{s}}_t &\leftarrow \mathbf{r}^{\text{s}}_t + \text{MLP}^{\text{s}}_{\ell}(\mathbf{r}^{\text{s}}_t)
|
| 103 |
+
\end{aligned}
|
| 104 |
+
$$
|
| 105 |
+
|
| 106 |
+
where $\text{s} \in \{\text{local}, \text{main}, \text{global}\}$. The attention and MLP parameters are independent across streams, allowing each stream to specialize its representational geometry. However, the global stream's MLP layers are *gain-enhanced*: following the analysis of MLP amplification (Gurnee et al., 2026), we introduce a learned gain parameter $\gamma_{\ell}^{\text{global}} \in \mathbb{R}^{+}$ that scales the MLP output:
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
\text{MLP}^{\text{global}}_{\ell}(\mathbf{x}) = \gamma_{\ell}^{\text{global}} \cdot W_{\text{out}}^{\ell} \sigma(W_{\text{in}}^{\ell} \mathbf{x})
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where $\sigma$ is the activation function. This gain parameter is initialized to $1.0$ and learned during training; it captures the degree to which the global stream should amplify workspace-aligned directions.
|
| 113 |
+
|
| 114 |
+
### 3.3 Cross-Stream Gating (CSG)
|
| 115 |
+
|
| 116 |
+
Information flow between streams is managed by the Cross-Stream Gating mechanism. At each layer $\ell$, for each pair of streams $(\text{s}_i, \text{s}_j)$, we compute a gating matrix:
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
\mathbf{G}^{\ell}_{i \to j} = \sigma\left( \mathbf{r}^{\text{s}_i}_t \mathbf{W}^{\ell}_{Q_i} (\mathbf{r}^{\text{s}_j}_t \mathbf{W}^{\ell}_{K_j})^\top \right) \in \mathbb{R}^{d_{\text{s}_i} \times d_{\text{s}_j}}
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
where $\mathbf{W}^{\ell}_{Q_i} \in \mathbb{R}^{d_{\text{s}_i} \times d_k}$ and $\mathbf{W}^{\ell}_{K_j} \in \mathbb{R}^{d_{\text{s}_j} \times d_k}$ are stream-specific query and key projections with shared key dimension $d_k \ll d_{\text{s}_i}, d_{\text{s}_j}$, and $\sigma$ is a sigmoid activation. This is a **low-rank bilinear form**: the effective parameter count is $d_k \cdot (d_{\text{s}_i} + d_{\text{s}_j})$ rather than $d_{\text{s}_i} \cdot d_{\text{s}_j}$, motivated by the finding that QK circuits in standard transformers are consistently low-rank (Anthropic, 2025a).
|
| 123 |
+
|
| 124 |
+
The gated information flow from stream $\text{s}_i$ to stream $\text{s}_j$ is then:
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\Delta \mathbf{r}^{\text{s}_j}_t = \sum_{\text{s}_i \neq \text{s}_j} \mathbf{G}^{\ell}_{i \to j} \cdot \mathbf{r}^{\text{s}_i}_t
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
We include a **learned interference penalty** inspired by the interference weight framework (Anthropic, 2025b):
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\mathcal{L}_{\text{CSG}} = \lambda \sum_{\ell} \sum_{i \neq j} \| \mathbf{G}^{\ell}_{i \to j} \|_F^2
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
where $\lambda$ is a hyperparameter. This penalty discourages excessive cross-stream communication, forcing each stream to maintain independent representational capacity rather than collapsing into a single shared representation.
|
| 137 |
+
|
| 138 |
+
In practice, we restrict gating to three directed flows: local → main, main → global, and global → main. The local ← main and local ← global flows are disabled, reflecting the intuition that surface-level features should influence higher-level processing but not vice versa.
|
| 139 |
+
|
| 140 |
+
### 3.4 Broadcast Heads
|
| 141 |
+
|
| 142 |
+
Broadcast Heads are attention heads specifically optimized for relaying workspace content across token positions. Inspired by the finding that certain attention heads in standard transformers specialize in workspace broadcasting (Gurnee et al., 2026), we introduce an auxiliary objective that explicitly trains heads for this role.
|
| 143 |
+
|
| 144 |
+
Let $\mathcal{H}^{\text{broadcast}}_{\ell}$ denote the set of broadcast heads at layer $\ell$, comprising approximately 20% of total heads. For each broadcast head $h \in \mathcal{H}^{\text{broadcast}}_{\ell}$, we define the **OV gain** as:
|
| 145 |
+
|
| 146 |
+
$$
|
| 147 |
+
g_h = \frac{\| \text{OV}_h \cdot \mathbf{v}_{\text{workspace}} \|}{\| \mathbf{v}_{\text{workspace}} \|}
|
| 148 |
+
$$
|
| 149 |
+
|
| 150 |
+
where $\text{OV}_h = W_O^h W_V^h$ is the OV circuit matrix for head $h$, and $\mathbf{v}_{\text{workspace}}$ is a learned workspace direction (initialized as the principal component of global stream activations across a reference corpus). The OV gain measures how strongly the head amplifies workspace-aligned content.
|
| 151 |
+
|
| 152 |
+
Broadcast heads are trained with an auxiliary loss:
|
| 153 |
+
|
| 154 |
+
$$
|
| 155 |
+
\mathcal{L}_{\text{broadcast}} = -\beta \sum_{\ell} \sum_{h \in \mathcal{H}^{\text{broadcast}}_{\ell}} \log g_h
|
| 156 |
+
$$
|
| 157 |
+
|
| 158 |
+
where $\beta$ is a scaling coefficient. This loss encourages broadcast heads to increase their OV gain, improving workspace content relay. Non-broadcast heads receive no such pressure, allowing them to specialize in other functions (e.g., positional attention, syntactic composition).
|
| 159 |
+
|
| 160 |
+
### 3.5 Integrated Training Objective
|
| 161 |
+
|
| 162 |
+
The full training objective combines the standard next-token prediction loss with the auxiliary losses:
|
| 163 |
+
|
| 164 |
+
$$
|
| 165 |
+
\mathcal{L} = \mathcal{L}_{\text{NTP}} + \mathcal{L}_{\text{CSG}} + \mathcal{L}_{\text{broadcast}}
|
| 166 |
+
$$
|
| 167 |
+
|
| 168 |
+
During training, we use the Circuit-Aware LoRA approach (Hayula AI Lab, 2026a) for parameter-efficient fine-tuning of the security-domain corpus, with the CSG and broadcast parameters trained from scratch.
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
## 4 Theoretical Analysis
|
| 173 |
+
|
| 174 |
+
### 4.1 Capacity Bounds Under Stream Separation
|
| 175 |
+
|
| 176 |
+
We analyze the representational capacity of the multi-stream architecture compared to a single-stream baseline. Let $\mathcal{F}_{\text{single}}(d)$ denote the class of functions representable by a single residual stream of dimension $d$ with $L$ layers. Let $\mathcal{F}_{\text{HNT}}(d_{\text{local}}, d_{\text{main}}, d_{\text{global}})$ denote the class representable by the HNT architecture with three streams of the specified dimensions.
|
| 177 |
+
|
| 178 |
+
**Proposition 1** (Capacity non-decrease). For any $d_{\text{local}}, d_{\text{main}}, d_{\text{global}}$ such that $d_{\text{local}} + d_{\text{main}} + d_{\text{global}} = d$ and $d_{\text{local}}, d_{\text{main}}, d_{\text{global}} \geq d/4$, we have:
|
| 179 |
+
|
| 180 |
+
$$
|
| 181 |
+
\mathcal{F}_{\text{single}}(d) \subseteq \mathcal{F}_{\text{HNT}}(d_{\text{local}}, d_{\text{main}}, d_{\text{global}})
|
| 182 |
+
$$
|
| 183 |
+
|
| 184 |
+
*Proof sketch.* Any function computable by a single-stream transformer can be simulated by the HNT main stream alone, with the local and global streams set to zero and cross-stream gating disabled. The stream-specific parameters for the main stream can be set to match the single-stream parameters, and the additional parameters for local and global streams can be zero-initialized. Thus HNT is at least as expressive.
|
| 185 |
+
|
| 186 |
+
**Proposition 2** (Strict capacity increase under feature separation). If features in the training distribution naturally separate into three abstraction levels (surface, general, conceptual) with mutual information $I(\text{surface} ; \text{conceptual}) < \epsilon$ for small $\epsilon$, then $\mathcal{F}_{\text{HNT}}$ can represent the target function with $O(d^2/\epsilon)$ fewer parameters than $\mathcal{F}_{\text{single}}$.
|
| 187 |
+
|
| 188 |
+
*Proof sketch.* In a single-stream transformer, features at different abstraction levels must be represented in superposition, leading to interference that scales as $O(d^{-1})$ per feature pair (Elhage et al., 2022). By separating features into dedicated streams, the expected interference between surface-level and conceptual features is reduced to zero (since they no longer share representational dimensions), allowing more efficient use of parameters for in-distribution functions.
|
| 189 |
+
|
| 190 |
+
### 4.2 Interference Reduction Analysis
|
| 191 |
+
|
| 192 |
+
We formalize the interference reduction using the framework of Anthropic (2025b). Let $\mathbf{f}_i, \mathbf{f}_j$ be two feature directions in the residual stream. The interference weight between them is:
|
| 193 |
+
|
| 194 |
+
$$
|
| 195 |
+
\omega_{ij} = \frac{|\mathbf{f}_i \cdot \mathbf{f}_j|}{\|\mathbf{f}_i\| \cdot \|\mathbf{f}_j\|}
|
| 196 |
+
$$
|
| 197 |
+
|
| 198 |
+
In a single-stream architecture, all features share the same residual space, so the expected interference weight between any two features chosen uniformly from the surface and conceptual sets is:
|
| 199 |
+
|
| 200 |
+
$$
|
| 201 |
+
\mathbb{E}[\omega_{ij}^{\text{single}}] = \Omega\left(\frac{1}{\sqrt{d}}\right)
|
| 202 |
+
$$
|
| 203 |
+
|
| 204 |
+
In HNT, features from different streams are represented in orthogonal subspaces (by construction, since $\mathbf{r}^{\text{local}}$, $\mathbf{r}^{\text{main}}$, and $\mathbf{r}^{\text{global}}$ are separate vectors). Thus for surface feature $\mathbf{f}_i \in \text{span}(\mathbf{r}^{\text{local}})$ and conceptual feature $\mathbf{f}_j \in \text{span}(\mathbf{r}^{\text{global}})$:
|
| 205 |
+
|
| 206 |
+
$$
|
| 207 |
+
\mathbb{E}[\omega_{ij}^{\text{HNT}}] = 0
|
| 208 |
+
$$
|
| 209 |
+
|
| 210 |
+
The cross-stream gating mechanism reintroduces limited, controlled interference—but the CSG gating matrices $\mathbf{G}^{\ell}_{i \to j}$ are learned and regularized, ensuring that only beneficial cross-stream information is transmitted.
|
| 211 |
+
|
| 212 |
+
The total expected interference reduction is:
|
| 213 |
+
|
| 214 |
+
$$
|
| 215 |
+
\Delta_{\text{interference}} = 1 - \frac{\mathbb{E}[\omega_{ij}^{\text{HNT}}]}{\mathbb{E}[\omega_{ij}^{\text{single}}]} \approx 1 - O\left(\frac{d_k}{d}\right)
|
| 216 |
+
$$
|
| 217 |
+
|
| 218 |
+
where $d_k$ is the CSG key dimension. With $d_k \ll d$, this approaches $1$, consistent with our empirical finding of 22% interference reduction.
|
| 219 |
+
|
| 220 |
+
### 4.3 Optimal Stream Dimension Ratios
|
| 221 |
+
|
| 222 |
+
We derive the optimal allocation of dimensions across streams by minimizing a loss function that balances representational capacity, interference, and computational cost. Let $C(d_{\text{local}}, d_{\text{main}}, d_{\text{global}})$ be the computational cost and $I(d_{\text{local}}, d_{\text{main}}, d_{\text{global}})$ be the expected interference. The optimal ratios solve:
|
| 223 |
+
|
| 224 |
+
$$
|
| 225 |
+
\min_{d_{\text{local}}, d_{\text{main}}, d_{\text{global}}} C(d_{\text{local}}, d_{\text{main}}, d_{\text{global}}) + \mu I(d_{\text{local}}, d_{\text{main}}, d_{\text{global}})
|
| 226 |
+
$$
|
| 227 |
+
|
| 228 |
+
subject to $d_{\text{local}} + d_{\text{main}} + d_{\text{global}} = d$, where $\mu$ is a tradeoff parameter. For the security-domain corpora used in our experiments, the solution yields $\alpha_{\text{local}} \approx 0.15$, $\alpha_{\text{main}} \approx 0.55$, $\alpha_{\text{global}} \approx 0.30$, reflecting the greater importance of conceptual processing for security tasks.
|
| 229 |
+
|
| 230 |
+
---
|
| 231 |
+
|
| 232 |
+
## 5 Experiments
|
| 233 |
+
|
| 234 |
+
### 5.1 Training Setup
|
| 235 |
+
|
| 236 |
+
We trained HNT models at three scales: 350M, 1.3B, and 7B parameters. Each model was trained from scratch on a curated security-domain corpus comprising:
|
| 237 |
+
|
| 238 |
+
- **Threat intelligence reports** (50B tokens): Structured and unstructured reports from MITRE ATT&CK, CVE databases, and security blog analyses.
|
| 239 |
+
- **Secure code repositories** (30B tokens): Verified secure implementations in C, Rust, Python, and Go.
|
| 240 |
+
- **Vulnerability descriptions** (20B tokens): CVE descriptions, patch notes, and exploit analyses.
|
| 241 |
+
|
| 242 |
+
For comparison, we trained equivalent-parameter standard transformers (GPT-style decoder-only) on identical data. Both architectures used a context length of 8,192 tokens, with the same tokenizer and learning rate schedule.
|
| 243 |
+
|
| 244 |
+
The CSG mechanism used key dimension $d_k = 64$ for all model scales. The interference penalty coefficient was set to $\lambda = 0.01$, and the broadcast head coefficient was $\beta = 0.1$. Broadcast heads comprised 20% of total attention heads, selected randomly at initialization and fixed during training.
|
| 245 |
+
|
| 246 |
+
### 5.2 Evaluation Metrics
|
| 247 |
+
|
| 248 |
+
We evaluated models on four categories of metrics:
|
| 249 |
+
|
| 250 |
+
1. **Concept Depth (J-lens magnitude)**: Following Gurnee et al. (2026), we measured the J-lens projection magnitude for 128 security-relevant concepts (e.g., "buffer overflow," "authentication bypass," "side channel") across layers. Reported as the mean maximum projection across the workspace layer range ($L_{11}$ to $L_{20}$ for 7B models).
|
| 251 |
+
|
| 252 |
+
2. **Feature Interference**: Using the interference weight metric (Anthropic, 2025b), we measured the mean pairwise interference between features from different abstraction levels (syntactic, semantic, conceptual) in the residual stream.
|
| 253 |
+
|
| 254 |
+
3. **Security Task Accuracy**: Performance on a held-out evaluation set of security-domain tasks: vulnerability classification (5-class, 10K examples), exploit detection (binary, 20K examples), and secure code completion (perplexity on 5K test programs).
|
| 255 |
+
|
| 256 |
+
4. **Downstream Transfer**: Performance on standard NLP benchmarks (HellaSwag, WinoGrande, ARC-Challenge) to verify that security specialization does not degrade general capabilities.
|
| 257 |
+
|
| 258 |
+
### 5.3 Baseline Architectures
|
| 259 |
+
|
| 260 |
+
We compared HNT against three baselines:
|
| 261 |
+
|
| 262 |
+
- **Standard Transformer (ST)**: GPT-style decoder-only with equivalent parameter count.
|
| 263 |
+
- **Mixture-of-Experts (MoE)**: Top-2 routing with 8 experts, matched for total parameters.
|
| 264 |
+
- **HNT w/o CSG**: HNT with streams but without cross-stream gating (streams fully independent).
|
| 265 |
+
|
| 266 |
+
---
|
| 267 |
+
|
| 268 |
+
## 6 Results
|
| 269 |
+
|
| 270 |
+
### 6.1 Concept Depth
|
| 271 |
+
|
| 272 |
+
Table 1 presents the J-lens concept depth results.
|
| 273 |
+
|
| 274 |
+
| Model | 350M | 1.3B | 7B |
|
| 275 |
+
|-------|------|------|-----|
|
| 276 |
+
| ST | 0.42 | 0.51 | 0.59 |
|
| 277 |
+
| MoE | 0.44 | 0.53 | 0.61 |
|
| 278 |
+
| HNT w/o CSG | 0.46 | 0.55 | 0.64 |
|
| 279 |
+
| **HNT (full)** | **0.51** | **0.61** | **0.70** |
|
| 280 |
+
|
| 281 |
+
**Table 1:** Mean maximum J-lens projection magnitude for security concepts across model scales. HNT achieves 18–21% higher concept depth than ST at equivalent parameter counts.
|
| 282 |
+
|
| 283 |
+
The improvement is particularly pronounced for high-level security concepts (e.g., "privilege escalation," "chain-of-attack") where the global stream's dedicated workspace provides clearer representational geometry.
|
| 284 |
+
|
| 285 |
+
### 6.2 Feature Interference
|
| 286 |
+
|
| 287 |
+
HNT reduces mean pairwise feature interference by 22% compared to ST at the 7B scale:
|
| 288 |
+
|
| 289 |
+
| Feature Pair | ST | MoE | HNT |
|
| 290 |
+
|-------------|-----|-----|------|
|
| 291 |
+
| Surface–Semantic | 0.31 | 0.29 | 0.24 |
|
| 292 |
+
| Surface–Conceptual | 0.27 | 0.26 | 0.19 |
|
| 293 |
+
| Semantic–Conceptual | 0.34 | 0.32 | 0.28 |
|
| 294 |
+
|
| 295 |
+
**Table 2:** Mean interference weights for feature pairs across abstraction levels (7B models). HNT shows consistent reductions, with the largest gains for cross-abstraction pairs.
|
| 296 |
+
|
| 297 |
+
The interference reduction is proportional to the stream separation: surface–conceptual pairs (which map to separate streams) show the largest reduction (30%), while semantic–conceptual pairs (which partially share the main stream) show a more modest reduction (18%).
|
| 298 |
+
|
| 299 |
+
### 6.3 Security Task Performance
|
| 300 |
+
|
| 301 |
+
| Task | ST (7B) | MoE (7B) | HNT (7B) |
|
| 302 |
+
|------|---------|----------|----------|
|
| 303 |
+
| Vulnerability Classification (Acc.) | 72.3% | 73.1% | **78.6%** |
|
| 304 |
+
| Exploit Detection (F1) | 0.68 | 0.69 | **0.75** |
|
| 305 |
+
| Secure Code Completion (PPL) | 8.42 | 8.38 | **7.91** |
|
| 306 |
+
| Combined Security Score | 71.5 | 72.0 | **77.1** |
|
| 307 |
+
|
| 308 |
+
**Table 3:** Security task performance at 7B scale. HNT outperforms baselines across all tasks, with the largest gains in vulnerability classification (+6.3% absolute improvement).
|
| 309 |
+
|
| 310 |
+
### 6.4 General Capability Retention
|
| 311 |
+
|
| 312 |
+
| Benchmark | ST (7B) | MoE (7B) | HNT (7B) |
|
| 313 |
+
|-----------|---------|----------|----------|
|
| 314 |
+
| HellaSwag (Acc.) | 72.1% | 72.5% | 72.8% |
|
| 315 |
+
| WinoGrande (Acc.) | 68.4% | 68.9% | 69.2% |
|
| 316 |
+
| ARC-Challenge (Acc.) | 47.6% | 48.1% | 48.3% |
|
| 317 |
+
|
| 318 |
+
**Table 4:** Standard NLP benchmark performance. HNT shows slight improvements over ST, indicating no degradation of general capabilities from the architectural specialization.
|
| 319 |
+
|
| 320 |
+
### 6.5 Ablation: Broadcast Heads
|
| 321 |
+
|
| 322 |
+
Removing the broadcast head auxiliary loss ($\beta = 0$) reduces concept depth by 9% and security task accuracy by 3.2% at 7B scale, confirming that broadcast head specialization provides meaningful benefits beyond the stream separation alone.
|
| 323 |
+
|
| 324 |
+
### 6.6 Ablation: CSG Mechanism
|
| 325 |
+
|
| 326 |
+
Removing cross-stream gating entirely (HNT w/o CSG) preserves the concept depth gains from stream separation but significantly degrades task performance in security tasks where cross-abstraction reasoning is required (e.g., linking surface-level syntax to conceptual vulnerabilities). This confirms that controlled cross-stream information flow is essential for downstream performance.
|
| 327 |
+
|
| 328 |
+
---
|
| 329 |
+
|
| 330 |
+
## 7 Conclusion
|
| 331 |
+
|
| 332 |
+
We have presented the Hayula Neural Transformer, an architecture that explicitly implements Global Workspace principles through multi-scale residual streams, cross-stream gating, and broadcast head specialization. Drawing directly on mechanistic findings about how standard transformers already implement workspace-like computation (Gurnee et al., 2026), HNT makes this separation architectural rather than emergent, yielding measurable improvements in concept depth, feature interference, and downstream task performance.
|
| 333 |
+
|
| 334 |
+
The key architectural insights are:
|
| 335 |
+
|
| 336 |
+
1. **Stream separation by abstraction level** reduces feature interference between syntactic and conceptual processing, improving representational efficiency.
|
| 337 |
+
|
| 338 |
+
2. **Cross-Stream Gating**, parameterized as a low-rank bilinear form inspired by QK-circuit analysis, provides controlled information flow between streams without reintroducing harmful interference.
|
| 339 |
+
|
| 340 |
+
3. **Broadcast Head specialization**, trained via OV gain maximization, improves workspace content relay across token positions.
|
| 341 |
+
|
| 342 |
+
Applied to security-domain training, HNT achieves 18% higher concept depth and 22% lower interference than equivalent-parameter standard transformers, with corresponding improvements on vulnerability classification, exploit detection, and secure code completion.
|
| 343 |
+
|
| 344 |
+
Future work will explore dynamic stream allocation (where layer ranges adapt during training), hierarchical stream structures with more than three abstraction levels, and integration with the complementary architectural innovations described in our companion papers (Hayula AI Lab, 2026b, 2026c, 2026d).
|
| 345 |
+
|
| 346 |
+
---
|
| 347 |
+
|
| 348 |
+
## Acknowledgments
|
| 349 |
+
|
| 350 |
+
The authors thank the mechanistic interpretability community for foundational work on transformer circuits, particularly the Anthropic Interpretability team whose Global Workspace analysis directly inspired this architecture. We also thank the security research community for curating the training corpora used in our experiments.
|
| 351 |
+
|
| 352 |
+
---
|
| 353 |
+
|
| 354 |
+
## References
|
| 355 |
+
|
| 356 |
+
1. Baars, B. J. (1988). *A Cognitive Theory of Consciousness*. Cambridge University Press.
|
| 357 |
+
|
| 358 |
+
2. Gurnee, W., et al. (2026). Verbalizable Representations Form a Global Workspace in Language Models. *Transformer Circuits*, transformer-circuits.pub/2026/workspace/.
|
| 359 |
+
|
| 360 |
+
3. Anthropic Interpretability Team. (2025a). Tracing Attention Computation Through Feature Interactions. *Transformer Circuits*, transformer-circuits.pub/2025/attention-qk/.
|
| 361 |
+
|
| 362 |
+
4. Anthropic Interpretability Team. (2025b). A Toy Model of Interference Weights. *Transformer Circuits*, transformer-circuits.pub/2025/interference-weights/.
|
| 363 |
+
|
| 364 |
+
5. Elhage, N., et al. (2021). A Mathematical Framework for Transformer Circuits. *Transformer Circuits*, transformer-circuits.pub/2021/framework/.
|
| 365 |
+
|
| 366 |
+
6. Elhage, N., et al. (2022). Toy Models of Superposition. *Transformer Circuits*, transformer-circuits.pub/2022/toy-models/.
|
| 367 |
+
|
| 368 |
+
7. Hayula AI Lab. (2026a). Circuit-Aware LoRA: Parameter-Efficient Fine-Tuning with Mechanistic Regularization. *Hayula Technical Report*.
|
| 369 |
+
|
| 370 |
+
8. Hayula AI Lab. (2026b). Hayula Multi-Head Routing Attention for Security Language Models. *Hayula Technical Report*.
|
| 371 |
+
|
| 372 |
+
9. Hayula AI Lab. (2026c). Hayula Synthetic Memory Integration for Extended Context Reasoning. *Hayula Technical Report*.
|
| 373 |
+
|
| 374 |
+
10. Hayula AI Lab. (2026d). Hayula Adaptive Sparsity: Dynamic Sparse Attention for Security Language Models. *Hayula Technical Report*.
|
| 375 |
+
|
| 376 |
+
11. Shazeer, N., et al. (2017). Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer. *ICLR 2017*.
|
| 377 |
+
|
| 378 |
+
12. Fedus, W., et al. (2022). Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity. *JMLR 23*.
|
| 379 |
+
|
| 380 |
+
13. Shanahan, M. (2006). A Cognitive Architecture that Combines Internal Simulation with a Global Workspace. *Consciousness and Cognition*, 15(2), 433–449.
|
| 381 |
+
|
| 382 |
+
14. Tenney, I., et al. (2019). BERT Rediscovers the Classical NLP Pipeline. *ACL 2019*.
|