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

Kaichen Xu, Yihang Du, Mianpeng Liu, Zimu Yu, Xiaobo Sun
9/20/2025
cs.LGq-bio.QM

Official code: Catchxu/CAPE (2 stars, MIT, last commit 2026-04-21).

Abstract

Positional encoding is essential for supplementing transformer with positional information of tokens. Existing positional encoding methods demand predefined token/feature order, rendering them unsuitable for real-world data with non-sequential yet causally-related features. To address this limitation, we propose CAPE, a novel method that identifies underlying causal structure over non-sequential features as a weighted directed acyclic graph (DAG) using generalized structural equation modeling. The DAG is then embedded in hyperbolic space where its geometric structure is well-preserved using a hyperboloid model-based approach that effectively captures two important causal graph properties (causal strength & causal specificity). This step yields causality-aware positional encodings for the features, which are converted into their rotary form for integrating with transformer's self-attention mechanism. Theoretical analysis reveals that CAPE-generated rotary positional encodings possess three valuable properties for enhanced self-attention, including causal distance-induced attenuation, causal generality-induced attenuation, and robustness to positional disturbances. We evaluate CAPE over both synthetic and real-word datasets, empirically demonstrating its theoretical properties and effectiveness in enhancing transformer for data with non-sequential features. Our code is available at https://github.com/Catchxu/CAPE.

View on arXivView PDF

Code Implementations(1)

Catchxu/CAPEOfficial100%
MIT

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

20Shell, PythonMay 23, 20256 months agoMIT

Similar Papers

Cite this paper

@article{xu2025causalityinduced,
  title  = {Causality-Induced Positional Encoding for Transformer-Based Representation Learning of Non-Sequential Features},
  author = {Kaichen Xu and Yihang Du and Mianpeng Liu and Zimu Yu and Xiaobo Sun},
  year   = {2025},
  eprint = {2509.16629},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2509.16629v2},
  journal = {NEURIPS 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2509.16629.svg)](https://codeofpaper.com/paper/2509.16629)

Discussion