CPAC: Causal Prototype Attention Classifier
- CPAC is a prototype-based attention framework that uses query-key-only mechanisms for interpretable classification in EEG and fraud detection.
- It features distinct variants with fixed or learnable prototypes that guide decisions via attention routing or distance weighting.
- Empirical results reveal trade-offs between interpretability and performance, making CPAC a deployment-friendly, calibration-free model.
Searching arXiv for the cited CPAC-related papers and closely related context. Found the main ERP-XTTN paper and the fraud-detection CPAC paper; also checking baseline/context papers for naming consistency. The Causal Prototype Attention Classifier (CPAC) denotes a prototype-based attention paradigm that appears in two distinct arXiv formulations. In ERP-XTTN, CPAC is the classifier component of an interpretable, calibration-free architecture for cross-subject event-related potential classification, implemented through query-key-only cross-attention with no value projection so that classification depends entirely on attention routing and attention faithfulness is structural rather than post-hoc (Wyman et al., 1 Jun 2026). In fraud detection, CPAC is an interpretable latent classifier coupled to a VAE-GAN encoder, using prototype-based attention mechanisms to promote class-aware clustering and improved latent space structure under extreme class imbalance (Giusti et al., 19 Jul 2025). The shared theme is prototype-guided decision making; the operational form, learning objective, and meaning of “causal” differ materially across the two settings.
1. Terminological scope and architectural variants
The term CPAC does not refer to a single invariant neural module. In the ERP setting, it is instantiated as a cross-attention architecture that routes input EEG patches to fixed difference-wave prototypes via query-key-only cross-attention with no value projection. In the fraud setting, it is instantiated as a prototype bank together with an attention module that produces a feature-wise attention mask and a classifier defined by weighted distances to class prototypes (Wyman et al., 1 Jun 2026).
| Aspect | ERP-XTTN CPAC | Fraud-detection CPAC |
|---|---|---|
| Input representation | EEG epoch patches | Latent vector |
| Prototype type | Fixed difference-wave prototypes | Two learnable vectors in |
| Decision mechanism | Flattened attention routing matrix | Softmax over negative weighted distances |
This suggests a family resemblance rather than a single canonical architecture. In both formulations, prototypes act as anchors for class-relevant structure, but the ERP variant makes attention itself the sole evidentiary pathway, whereas the fraud variant uses attention to gate per-dimension distances to prototypes. A plausible implication is that “CPAC” is best understood as a design pattern centered on prototype-conditioned routing or distance weighting, rather than as one fixed network topology.
2. Query-key-only CPAC in ERP-XTTN
In ERP-XTTN, an input EEG epoch is defined as , with channels and time-samples. The epoch is chopped into non-overlapping patches of width samples; the configuration reported is at 256 Hz . Each patch is flattened and linearly projected into a 0-dimensional patch embedding space, with 1, yielding
2
For 3 fixed prototypes, prototype embeddings are formed as
4
After a shared LayerNorm, ERP-XTTN computes multi-head query and key projections, with 5 heads and 6:
7
The scaled dot-product attention weights are then
8
where the softmax is taken row-wise over prototypes, and the final routing matrix is the head average
9
The interpretation given is that 0 is the fraction of attention that patch 1 routes to prototype 2 (Wyman et al., 1 Jun 2026).
The defining restriction is the removal of the value pathway: No separate “value” projection is used: 3 itself is the sole input to the classifier head. After averaging heads, the model flattens 4 to a vector 5 and applies one linear layer,
6
Training uses binary cross-entropy-with-logits loss on 7, and inference thresholds 8 for a class label. The implementation details specify Self-attention: one layer, pre-norm, 9 heads, dropout=0.3 on weights, residual connection; Cross-attention: separate LayerNorm for queries/keys, 0 projections, no values; and Classifier: flatten 1 vector of length 2. Because the classifier has no alternative access path to the input, the paper characterizes attention faithfulness as structural rather than post-hoc.
3. Prototype construction and deployment-compatible preprocessing
ERP-XTTN derives prototypes automatically from the grand-average difference wave within each leave-one-subject-out (LOSO) training fold. For a single detection channel 3, the fold produces two class means, 4 for positive trials and 5 for negative trials, and defines the difference wave as
6
This signal is smoothed by a Gaussian (7 samples), after which the algorithm detects up to 8 extrema of both polarities after 9 ms, requiring prominence 0 and within-polarity separation 1 ms. For each selected peak at time 2, the method identifies the previous and next zero crossings, clamps the window width to 3 about 4, and stores the full-montage 5 over 6 channels restricted to the resulting window as a prototype tensor 7 (Wyman et al., 1 Jun 2026).
Prototype embedding uses exactly the same patch-splitting + linear projection as on 8, followed by mean pooling over the prototype’s own patches to yield the final 9. The implementation note states that each prototype 0 is stored as a 1 tensor (raw 2-wave segments); embedding is computed on the fly with the same projection as for input patches.
The preprocessing pipeline is explicitly causal. Every dataset is processed by a 4th-order Butterworth bandpass at 1–10 Hz, implemented as a causal IIR filter such as lfilter(b,a,x), with difference equation
3
and no backward pass, so 4 depends only on past and present samples. The data are then downsampled to 256 Hz (where needed) and epoched from 0–800 ms post-trigger. The paper frames these choices as deployment-compatible conditions and evaluates them under zero calibration and LOSO generalization. A common misconception would be to read “causal” here as causal discovery; in this formulation, the primary concrete use of the term is causal signal processing and temporally valid deployment.
4. Latent prototype-distance CPAC for fraud detection
In the fraud-detection formulation, CPAC is defined around four components: an Encoder 5, a prototype bank 6, an Attention module 7, and a Distance Aggregator + Classifier head. The encoder produces a 8-dimensional latent vector 9 (or 0); the prototype bank consists of two learnable vectors in 1 that serve as class “anchors” (non-fraud vs. fraud); and the attention module is a small MLP that ingests 2 and outputs a per-dimension gating vector 3 (Giusti et al., 19 Jul 2025).
The mathematical specification is explicit. The attention mechanism is
4
and, for each class 5, the weighted distance is
6
where 7 is a learned scalar controlling sensitivity. These distances are converted to soft assignments by
8
The final fraud probability is
9
or equivalently, with logits 0,
1
The paper states that causal reasoning is invoked by viewing each attention weight 2 as an estimate of the “causal effect” of latent feature 3 on the final decision, while prototypes provide counterfactual anchors. In this setting, therefore, “causal” is not the same notion as in ERP-XTTN’s causal IIR preprocessing. Rather, the term is used to organize interpretation around feature-level influence and counterfactual prototype comparison. This suggests that the causal semantics of CPAC are domain-specific and should not be treated as a single formal causal framework.
5. Training objectives, latent shaping, and empirical behavior
The ERP-XTTN training regimen specifies AdamW with lr=4, weight_decay=5, batch size 128, class-weighted BCE-with-logits; pos_weight=(#negative)/(#positive), linear warmup for 5 epochs 6 cosine annealing for 100 epochs 7 constant at 8, gradient clipping 9, dropout 0.3 after patch embedding and on attention weights, training-only augmentation through temporal jitter in 0 samples and additive Gaussian noise 1, and early stopping with a 15% holdout stratified by subject2class, monitored by LOSO-validation AUROC, with patience=15 epochs and max_epochs=250. The final model is retrained from scratch on train+val for the chosen epoch count (Wyman et al., 1 Jun 2026).
The fraud formulation introduces a broader objective because CPAC is attached to a VAE-GAN encoder. The stated losses are
3
4
5
6
For CPAC itself, the paper uses Binary Cross-Entropy or Focal Loss:
7
together with an attention-scale penalty
8
and a prototype-anchoring penalty
9
The combined CPAC head loss is
0
When attached to the VAE-GAN encoder, training alternates between minimizing 1 and minimizing 2, or, in a single-objective view,
3
The latent-space interpretation is stated directly: The BCE/Focal loss through CPAC backpropagates into the encoder, explicitly pulling latent vectors 4 toward their class prototype 5; the anchoring term 6 further encourages each prototype 7 to track the empirical centroid of class-8 latents; and as a result, 9’s form two tight, well-separated clusters, each around 00 or 01. Cluster separation is described as quantifiable by the Silhouette Score or Davies–Bouldin Index, while the paper visualizes overlap using PCA and 3D plots.
6. Performance, interpretability, limitations, and common misconceptions
In ERP-XTTN, CPAC is benchmarked against EEGNet and xDAWN+Riemannian-geometry (xDAWN+RG) under a targeted 3-channel montage and a full available montage. The reported mean LOSO AUROC across 9 datasets is:
| Setting | xDAWN+RG | EEGNet | ERP-XTTN |
|---|---|---|---|
| 3-channel | .715 | .731 | .716 |
| full montage | .777 | .794 | .766 |
The corresponding interpretability cost is reported as 02 at 3 channels and 03 at full montage. The paper states that the mean gap arises from two largely distinct sources: a temporal-flexibility cost relative to EEGNet and a spatial-exploitation cost relative to xDAWN+RG, the latter driven by signal-to-noise ratio at full montage, while also noting that on some tasks (e.g. ERN, P300, HRI-ErrP at 3ch) ERP-XTTN actually slightly outperformed xDAWN+RG (Wyman et al., 1 Jun 2026).
ERP-XTTN’s interpretability is quantified using two trial-level routing metrics: Attention entropy
04
averaged over trials, and Routing discriminability 05, defined as the mean cosine distance between class-mean attention vectors. The paper reports that the average interpretability cost 06 against EEGNet correlates (Spearman 07) with 08, 09, and an SNR proxy (grand-average 10-wave amplitude / trial-wise SD), suggesting that the fixed-prototype constraint costs most when the temporal signal is strong and narrowly peaked. Against xDAWN+RG, 11 correlates most with SNR in the full-montage case, indicating that spatial filtering outperforms static prototypes when there is rich spatial information. The grand-average waveform analysis further reports that the TP–FP correlation (mean Pearson 12) exceeds the TP–TN correlation on most datasets, which the paper interprets as evidence that misclassifications occur on trials whose morphology genuinely resembles the target prototype set.
In the fraud setting, the reported standalone CPAC metrics on raw data are Precision=87.20%, Recall=73.65%, F1=79.85%, AUC=95.80%. When used in VAE-GAN+CPAC as an oversampler, the paper states that the best setting (75 pre-SMOTE + VAE-GAN+CPAC) yields: Precision≈96.4%, Recall≈90.2%, F1≈93.1%, AUC≈96.9%, and the abstract summarizes this as an F1-score of 93.14\% percent and recall of 90.18\%, along with improved latent cluster separation. The ablation study reports that removing the CPAC head causes latent clusters collapse, heavy overlap, poor downstream accuracy; removing attention (13) degrades separation to a near-linear manifold; removing prototypes causes clusters to overlap badly; omitting scale/anchor penalties leaves clusters separated but with fuzzier boundaries; and swapping BCE14Focal Loss gives sharper latent separation visually but slight drop in raw F1 on hold-out (Giusti et al., 19 Jul 2025).
Several misconceptions can be addressed directly from these results. First, CPAC is not synonymous with lossless interpretability: the ERP evidence reports a measurable interpretability cost. Second, the causal label is not uniform across domains: ERP-XTTN grounds it in causal IIR preprocessing and deployment compatibility, whereas the fraud paper grounds it in feature-level “causal effects” and counterfactual anchors. Third, prototype guidance does not eliminate the need for domain structure: the ERP paper identifies limits associated with temporal flexibility and spatial exploitation, while the fraud paper explicitly lists one prototype per class, hyperparameter sensitivity, and possible extensions to multiple prototypes, contrastive or manifold regularization, denoising autoencoders, and application to network intrusion or medical outliers. Taken together, these studies position CPAC as an interpretable prototype-attention framework whose practical behavior depends strongly on how prototypes are defined, how attention is constrained, and which notion of causality is being invoked.