Semantic-aware AFT for Stock Prediction
- Semantic-aware AFT is a regime-adaptive Transformer model that groups 95 financial features into 11 semantic categories to forecast stock returns.
- It integrates a Market Regime Encoder, Adaptive Gate Network, and Adaptive Financial Context module to dynamically bias self-attention using semantic similarity.
- The architecture employs a composite objective and corrected backtesting protocols, with ablation studies showing that removing semantic components degrades key performance metrics like directional accuracy and Sharpe ratio.
Semantic-aware AFT (SAFT) is a Transformer-based architecture for stock return prediction under non-stationary financial markets. In the formulation described in "Adaptive Financial Transformer with Regime-Gated Attention for Stock Return Prediction," SAFT extends a standard Transformer encoder with a Market Regime Encoder, an Adaptive Gate Network, and an Adaptive Financial Context module, allowing self-attention to be dynamically biased by semantic relationships between financial indicators rather than treating all input features uniformly. The model groups 95 engineered financial features into 11 semantic categories, uses corrected sequence alignment and non-overlapping backtesting, and optimizes a financially-aware composite objective that combines prediction error, directional accuracy, and non-overlapping Sharpe ratio (Sarkar, 28 Jun 2026).
1. Architectural formulation
SAFT is defined as an extension of the standard Transformer encoder with three domain-specific modules: a Market Regime Encoder that compresses group-wise feature statistics into a latent regime vector, an Adaptive Gate Network that turns the regime vector into per-group gate weights, and an Adaptive Financial Context that uses those weights to bias the self-attention scores via group-wise semantic similarity (Sarkar, 28 Jun 2026).
The input is a batch of lookback windows
with technical features over trading days. The sequence is projected to
prepended with a learnable CLS token, and added to sinusoidal positional encoding. The Market Regime Encoder operates on each semantic feature group and computes
followed by concatenation and fusion:
The Adaptive Gate Network transforms the regime vector into normalized group weights,
and the resulting weights modulate the Adaptive Financial Context. Two Transformer encoder layers then process the sequence, after which the CLS representation is normalized, passed through an MLP, and linearly projected to the return forecast
This design is explicitly regime-adaptive: latent market-state information is not appended as an auxiliary feature, but used to modulate the relative importance of semantic feature groups inside the attention computation itself. A plausible implication is that SAFT treats regime inference and feature interaction as coupled operations rather than separate preprocessing and prediction stages.
2. Semantic grouping and regime-gated attention
A central component of SAFT is the partition of the 95 engineered features into semantic categories (Sarkar, 28 Jun 2026).
| Semantic category | Feature count |
|---|---|
| Price | 7 |
| Returns | 5 |
| Volatility | 8 |
| Trend | 9 |
| Momentum | 3 |
| Volume | 8 |
| Candlestick | 11 |
| Statistics | 9 |
| Lags | 15 |
| Breakout | 15 |
| Calendar | 5 |
For each group 0, SAFT projects the grouped sequence to head dimension 1,
2
normalizes it,
3
and forms a cosine-similarity matrix
4
The financial bias is then aggregated as
5
The self-attention mechanism is correspondingly modified to
6
Elementwise, the attention coefficient is
7
The paper characterizes this mechanism as forcing the self-attention to focus on time-steps that exhibit similar behavior within each financial concept, dynamically scaled by the inferred market regime. In that sense, the term “semantic-aware” refers not to natural-language supervision but to semantically organized financial indicators whose pairwise similarities are injected directly into the attention logits.
3. Objective design and evaluation corrections
SAFT uses a financially-aware composite objective,
8
with
9
0
and
1
The hyperparameters 2 are tuned via Optuna (Sarkar, 28 Jun 2026).
The objective is paired with two methodological corrections. First, SAFT identifies a sequence-alignment problem in prior work: using 3 to predict
4
introduces a 1-day lookahead lag. SAFT instead aligns
5
with no lag. Second, to avoid Sharpe inflation by 6, SAFT computes trading returns only on non-overlapping 5-day blocks,
7
and then annualizes Sharpe as
8
These corrections are not peripheral implementation choices. They address reported trading performance directly, and the paper presents them as necessary safeguards against sequence misalignment and backtest inflation. A plausible implication is that SAFT should be read not only as an architectural proposal but also as a methodological intervention in how financial forecasting models are evaluated.
4. Experimental protocol
The reported experiments use AAPL daily data from 2018–2024, totaling 1,762 days, with chronological 70/15/15% train/validation/test splits (Sarkar, 28 Jun 2026). Results are reported across five random seeds, 9, as mean 0 confidence interval. Hyperparameter search uses the Optuna TPE sampler with 50 trials and MedianPruner after 5 epochs. The search space includes
- 1,
- 2,
- dropout 3,
- 4,
- 5,
- 6,
- heads 7,
- layers 8,
- and a Top-40 feature toggle.
The study includes ablation experiments removing the Gate Network, the Regime Encoder, or the Financial Context, as well as a comparison with all 95 features versus Top-40 features. It also reports multi-stock validation on AAPL, MSFT, GOOG, AMZN, META, and NVDA using identical hyperparameters and a single-seed run for the leaderboard. Statistical tests consist of paired 9-tests and Cohen’s 0 comparing Baseline AFT and Optimized AFT.
The paper’s abstract further states that experiments compare the proposed architecture against classical machine learning models, recurrent neural networks, and Transformer baselines, and that the evaluation includes chronological evaluation, ablation studies, explainability analysis, and multi-stock validation. The emphasis on chronological splitting, repeated seeds, and corrected backtesting protocols situates SAFT within a more conservative evaluation regime than is sometimes seen in financial forecasting.
5. Empirical findings, ablations, and explainability
On the five-seed AAPL benchmark, Baseline AFT reports
- 1,
- 2,
- 3,
- 4,
- 5,
- and 6.
Optimized AFT with Top-40 features reports
- 7,
- 8,
- 9,
- 0,
- 1,
- and 2. The paired 3-test finds no statistically significant differences, with examples including 4 and 5 (Sarkar, 28 Jun 2026).
The reported efficiency gains are more clear-cut. Parameters are reduced from 6 (7), feature count is reduced from 8 (9), and per-block complexity is given as
0
with 1 and 2. The abstract correspondingly describes the model as reducing model complexity by 3 and improving parameter efficiency through feature selection.
The multi-stock leaderboard reports the following single-seed results: AAPL achieves 4, 5, 6, 7; MSFT, 8, 9, 0, 1; GOOG, 2, 3, 4, 5; AMZN, 6, 7, 8, 9; META, 0, 1, 2, 3; and NVDA, 4, 5, 6, 7. Aggregate performance across the six stocks is 8, 9, 0, and 1.
The ablation results attribute a particularly strong role to the Adaptive Financial Context: removing it causes Sharpe to collapse from 2, while directional accuracy falls by more than 5 percentage points. Removing the Gate Network or the Regime Encoder also degrades directional accuracy and Sharpe. Explainability analysis using Integrated Gradients identifies volatility features, specifically Rolling Variance and ATR, together with Momentum-20, as having the highest attributions. The gate dynamics indicate that low-volatility regimes emphasize Price and Trend groups, whereas high-volatility regimes emphasize Volatility and Breakout groups. CLS-token attention shows a strong recency bias, with the highest weights on the last 5–10 days when forecasting.
Taken together, the quantitative picture is mixed in a way that is methodologically informative. The abstract describes competitive predictive performance, but the five-seed comparison between Baseline AFT and Optimized AFT does not show statistically significant differences on the cited metrics. By contrast, the ablations suggest that the semantic and regime-gated components are materially important to trading-oriented behavior once the architecture is fixed.
6. Nomenclature and relation to other 2026 uses of “SAFT”
The acronym SAFT is overloaded in the 2026 arXiv literature. In "Semantic-Topological Graph Reasoning for Language-Guided Pulmonary Screening," SAFT denotes Selective Asymmetric Fine-Tuning, a parameter-efficient fine-tuning strategy that updates less than 1% of parameters while freezing GroundingDINO, MedSAM, DINOv2, and most of LLaMA-3-V (Xue et al., 7 Apr 2026). In "Semantic-aware Adversarial Fine-tuning for CLIP," SAFT denotes Semantic-aware Adversarial Fine-Tuning, a robustness-oriented procedure that fine-tunes CLIP’s image encoder using semantic-aware adversarial examples generated from ensembles of refined textual descriptions (Zhang et al., 12 Feb 2026).
Semantic-aware AFT is distinct from both usages. It is not a PEFT recipe for multimodal medical segmentation, nor an adversarial training method for zero-shot vision-LLMs. Instead, it is a financial time-series Transformer architecture whose semantic awareness arises from grouping engineered indicators into Price, Returns, Volatility, Trend, Momentum, Volume, Candlestick, Statistics, Lags, Breakout, and Calendar categories, and whose adaptivity arises from regime-gated attention over those groups. This distinction is practically important, because the same acronym refers to different methodological objects: a training strategy in pulmonary screening, a fine-tuning algorithm for CLIP robustness, and a regime-adaptive forecasting architecture in finance (Sarkar, 28 Jun 2026).