Papers
Topics
Authors
Recent
Search
2000 character limit reached

Hrrformer Architecture

Updated 22 May 2026
  • Hrrformer Architecture is a Transformer variant that redefines self-attention using HRR's circular convolution and correlation, enhancing computational efficiency.
  • It achieves sub-quadratic time (O(TH log H)) and linear space complexity, enabling practical processing of much longer sequences than traditional models.
  • Empirical evaluations show rapid convergence (~20 epochs) and superior performance on tasks such as malware classification and long-range benchmarks.

The Hrrformer is a Transformer-family architecture in which the conventional self-attention mechanism is re-cast in terms of Holographic Reduced Representations (HRR), a neuro-symbolic method utilizing circular convolution and correlation. By replacing pairwise dot-product attention with HRR-based superposition and unbinding operations, the Hrrformer achieves sub-quadratic time and space complexity—O(THlogH)\mathcal{O}(T H \log H) time and O(TH)\mathcal{O}(T H) space—enabling practical attention at sequence lengths well beyond the feasible limits of standard Transformers. Despite approximate attention from HRR, the Hrrformer retains high accuracy on benchmarks and demonstrates rapid convergence and efficiency for domains requiring very long context windows, most notably malware sequence classification (Alam et al., 2023).

1. Query, Key, and Value Computation in Hrrformer

Token embeddings xtRHx_t\in\mathbb{R}^H are projected positionwise into queries qtq_t, keys ktk_t, and values vtv_t via learned matrices WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}:

Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,

where XRT×HX\in\mathbb{R}^{T\times H} represents the stacked input sequence. Multi-head attention divides HH into O(TH)\mathcal{O}(T H)0 heads of O(TH)\mathcal{O}(T H)1 dimensions per head, applying these projections per head identically. These projections preserve the canonical query–key–value paradigm of the original Transformer.

2. Holographic Reduced Representation Attention

Hrrformer attention replaces dot products and softmax weighting with two operators originating from Plate’s HRR: circular convolution (binding) and circular correlation (unbinding), both efficiently implemented via FFT.

  • Binding (Circular Convolution): Given O(TH)\mathcal{O}(T H)2,

O(TH)\mathcal{O}(T H)3

where O(TH)\mathcal{O}(T H)4 is the complex FFT, O(TH)\mathcal{O}(T H)5 its inverse, and O(TH)\mathcal{O}(T H)6 denotes elementwise multiplication.

  • Unbinding (Circular Correlation): For O(TH)\mathcal{O}(T H)7,

O(TH)\mathcal{O}(T H)8

with O(TH)\mathcal{O}(T H)9 denoting elementwise division.

For suitably random xtRHx_t\in\mathbb{R}^H0 and xtRHx_t\in\mathbb{R}^H1 (IID zero-mean Gaussians with variance xtRHx_t\in\mathbb{R}^H2), HRR ensures near-orthogonality in high dimensions:

xtRHx_t\in\mathbb{R}^H3

3. HRR-based Self-Attention Workflow

The Hrrformer’s attention implements the Transformer’s high-level querying logic via superposition and HRR unbinding:

  1. Key–Value Superposition: Encode all key–value pairs in a single vector,

xtRHx_t\in\mathbb{R}^H4

  1. Query Unbinding: For each position xtRHx_t\in\mathbb{R}^H5, extract an approximate value via,

xtRHx_t\in\mathbb{R}^H6

where xtRHx_t\in\mathbb{R}^H7 is the correlation inverse of xtRHx_t\in\mathbb{R}^H8.

  1. Softmax Denoising: Compute xtRHx_t\in\mathbb{R}^H9 for all qtq_t0 as attention logits, stack into vector qtq_t1, and obtain normalized weights qtq_t2. Although qtq_t3 contains uniform noise, the softmax operation is invariant to addition of a constant offset, effectively “denoising” the signal.
  2. Weighted Value Output: The output at position qtq_t4 is given by

qtq_t5

Each convolution/correlation is qtq_t6 via FFT; total attention is qtq_t7 in time and qtq_t8 in space, since only qtq_t9 and the ktk_t0 arrays are retained.

4. Layer Design and Integration

A single Hrrformer encoder layer adopts a pre-layer normalization (pre-norm) Transformer form:

  • Layer structure:
    • LayerNormktk_t1
    • Projections: ktk_t2
    • HRR attention (produces ktk_t3)
    • Residual: ktk_t4
    • LayerNormktk_t5
    • 2-layer MLP (GELU or ReLU nonlinearity, linear back to ktk_t6); output ktk_t7
    • Residual: ktk_t8

For the Long Range Arena (LRA) Image task, three layers are used; for other LRA tasks, up to six layers; for EMBER malware classification, a single layer suffices. Multi-head attention splits ktk_t9, and outputs are concatenated and linearly projected to vtv_t0.

5. Implementation and Hyperparameters

Key details include:

  • FFT batching: Binding/unbinding operations are computed via

vtv_t1

batchwise across all tokens and heads.

  • Numerical stability: A small vtv_t2 (e.g., vtv_t3) is added when dividing in vtv_t4 to prevent division by zero in the frequency domain.
  • Softmax: No special processing outside conventional masking for padding.
  • Hyperparameter ranges:
    • LRA: vtv_t5 or vtv_t6, vtv_t7–vtv_t8 heads, MLP-dim vtv_t9–WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}0, dropout 0.1, Adam optimizer, initial lr WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}1 decayed to WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}2 over 20 epochs.
    • EMBER: WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}3, WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}4, MLP-dim WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}5, single layer, 10 training epochs.

6. Efficiency, Approximation, and Scaling Analysis

Comparisons with standard transformer attention include:

Property Standard Attention Hrrformer/HRR Attention
Time complexity WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}6 WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}7
Space complexity WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}8 WQ,WK,WVRH×HW^Q,W^K,W^V\in\mathbb{R}^{H\times H}9
Exactness Exact Approximate, denoised
Typical convergence Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,0200 epochs Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,120 epochs

HRR attention is approximate and introduces uniform noise to Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,2, but given softmax “denoising,” the empirical impact is limited. For Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,3, computational savings are substantial. On LRA benchmarks, the Hrrformer achieves convergence in Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,420 epochs, in contrast to Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,5200 for most sparse or linear-efficient alternatives.

7. Empirical Evaluation

Findings from (Alam et al., 2023):

  • Long Range Arena (LRA, Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,6 up to 16K):
    • Single-layer Hrrformer achieves Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,7 average accuracy; multilayer, Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,8.
    • Performance nearly matches Luna-256 (Q=XWQ,K=XWK,V=XWV,Q = X W^Q,\quad K = X W^K,\quad V = X W^V,9) and exceeds the original Transformer (XRT×HX\in\mathbb{R}^{T\times H}0).
    • Per-epoch speed is XRT×HX\in\mathbb{R}^{T\times H}1 samples/sec (vs XRT×HX\in\mathbb{R}^{T\times H}2 for Luna-256), XRT×HX\in\mathbb{R}^{T\times H}310x faster, with XRT×HX\in\mathbb{R}^{T\times H}479% less GPU memory usage.
    • Total training time is up to XRT×HX\in\mathbb{R}^{T\times H}5 faster due to both per-epoch speed and decreased epochs to convergence.
  • EMBER Malware Classification (XRT×HX\in\mathbb{R}^{T\times H}6 up to 131K):
    • Hrrformer scales to XRT×HX\in\mathbb{R}^{T\times H}7; other full-attention models run out of memory by XRT×HX\in\mathbb{R}^{T\times H}8K–XRT×HX\in\mathbb{R}^{T\times H}9K.
    • At HH0, achieves HH1 accuracy, surpassing all baselines.
    • Runtime per epoch equals or surpasses the best (F-Net), partly attributed to HH2.

In summary, the Hrrformer formulation—by recasting Transformer self-attention with HRR operators—matches the core query–key–value logic but with near-linear scaling in sequence length and substantial empirical speedup, maintaining near–state-of-the-art accuracy and data efficiency on both synthetic and real-world long-sequence tasks (Alam et al., 2023).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Hrrformer Architecture.