Causality-Induced Positional Encoding for Transformer-Based Representation Learning of Non-Sequential Features

Kaichen Xu, Yihang Du, Mianpeng Liu, Zimu Yu, Xiaobo Sun

Abstract

Transformers have achieved state-of-the-art performance in sequential tasks, yet their inherent permutation invariance necessitates positional encodings (PE) that typically assume a linear order. This assumption fails for non-sequential data, such as gene expression or economic indicators, where features are related through complex causal structures rather than sequence. We present CAPE (Causality-Aware Position Encoder), a framework that replaces linear positions with learned causal relationships. By embedding these structures into hyperbolic space and converting them into rotary encodings, CAPE enables Transformers to leverage the underlying logic of non-sequential datasets. Our evaluation across multi-omics domains demonstrates significant improvements, including an 11.1% average reduction in Mean Squared Error for gene perturbation prediction.

Introduction: The Sequential Blind Spot

The success of Transformers in natural language processing stems from their ability to model dependencies between tokens. However, without positional encoding, a Transformer treats input as an unordered set. Standard PE methods, such as sinusoidal functions or Rotary Positional Embedding (RoPE), are designed for data with a natural, linear progression (e.g., the 1st word precedes the 2nd).

In many scientific domains, data is non-sequential. For instance, in a single-cell RNA sequence, there is no inherent "first" or "second" gene. Yet, these features are not independent; they are governed by intricate causal relationships, such as regulatory networks where one gene influences the expression of another. Existing models often resort to arbitrary "pseudo-orders," which fail to capture this biological logic.

Comparison of sequential and non-sequential data processing pipelines.

The CAPE Framework

To address this, CAPE introduces a three-step process to inject "causal positions" into the Transformer architecture, redefining "nearness" from sequence proximity to causal influence.

The three-step CAPE framework: Causal Structure Learning, Hyperbolic Mapping, and Rotary Transformation.

1. Causal Structure Learning

The framework begins by inferring the hidden causal structure of the features using a generalized nonlinear Structural Equation Model (SEM). This step identifies a Weighted Directed Acyclic Graph (DAG) where edges represent the strength and direction of causal influence between features.

2. Hyperbolic Embedding

Causal graphs are inherently hierarchical. CAPE maps the discovered DAG into hyperbolic space (specifically the hyperboloid model), which is mathematically suited for representing tree-like hierarchies with minimal distortion. This geometric representation captures two critical properties:

  • Causal Strength: Proximity in the embedding space reflects the intensity of the link between features.
  • Causal Specificity: The distance from the origin distinguishes "general" root causes from "specific" leaf effects.

3. Rotary Transformation

Finally, the hyperbolic coordinates are mapped to a Poincaré ball and converted into a Rotary Positional Encoding (RoPE) format. This allows the self-attention mechanism to naturally attenuate attention between features that are causally distant, a phenomenon termed Generality-Induced Attenuation.

Experimental Results

CAPE was evaluated across diverse "non-sequential" datasets, including transcriptomics (scRNA-seq), proteomics, and DNA methylomics.

  • Gene Perturbation Prediction (GPP): Integrating CAPE into foundational models like scBERT and scGPT resulted in an 11.1% average reduction in Mean Squared Error (MSE).
  • Cell Type Annotation: The model showed marked improvements in accuracy and F1-scores. Notably, in the mouse organogenesis (mOP) dataset, scBERT's accuracy increased from approximately 74% to 85% when enhanced with CAPE.
  • Ablation Studies: Results confirmed that both the causal discovery phase and the hyperbolic geometric representation are vital; removing either component led to significant performance degradation.

Discussion and Future Directions

CAPE demonstrates that treating causality as geometry provides a powerful inductive bias for Transformers. By placing "master regulator" features near the origin and specific effects near the boundary, the model mimics human-like reasoning about cause and effect.

However, challenges remain. CAPE currently assumes a static causal graph, whereas real-world relationships may vary across different states (e.g., healthy vs. diseased cells). Furthermore, the model's performance is tied to the quality of the initial causal inference. Future research will focus on uncertainty-aware causal discovery and sample-dependent structures to better handle noisy, dynamic environments.

Conclusion

By bridging the gap between causal discovery and geometric deep learning, CAPE provides a robust path forward for applying Transformer architectures to the complex, non-sequential data structures prevalent in biology and beyond.

Summary updated

BibTeX
@inproceedings{xu2025causality,
  author = {Kaichen Xu and Yihang Du and Mianpeng Liu and Zimu Yu and Xiaobo Sun},
  title = {{Causality-Induced Positional Encoding for Transformer-Based Representation Learning of Non-Sequential Features}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=hsD30Qljz0},
}
Figure