attention mechanism
Zero-Shot Instruction Following in RL via Structured LTL Representations
Jackermeier, Mathias, Giuri, Mattia, Cloete, Jacques, Abate, Alessandro
We study instruction following in multi-task reinforcement learning, where an agent must zero-shot execute novel tasks not seen during training. In this setting, linear temporal logic (LTL) has recently been adopted as a powerful framework for specifying structured, temporally extended tasks. While existing approaches successfully train generalist policies, they often struggle to effectively capture the rich logical and temporal structure inherent in LTL specifications. In this work, we address these concerns with a novel approach to learn structured task representations that facilitate training and generalisation. Our method conditions the policy on sequences of Boolean formulae constructed from a finite automaton of the task. We propose a hierarchical neural architecture to encode the logical structure of these formulae, and introduce an attention mechanism that enables the policy to reason about future subgoals. Experiments in a variety of complex environments demonstrate the strong generalisation capabilities and superior performance of our approach.
On the Runway Cascade of Transformers for Language Modeling
In decoder-only (causal) transformers, the computation graph created by causal masking routes information through both direct-path attention and indirect paths formed by intermediate tokens. We denote these indirect paths between token pairs as their runways. We argue that certain failure modes of causal transformers as observed by a growing body of recent works are likely exacerbated by a misalignment between these two information propagation modes. We formalize runway cascade as a phenomenon whereby this misalignment results in redundancies and irrelevant information cascading to token representations despite adequately learned attention patterns. As a solution, we propose runway-aware rewiring as a more explicit way of incorporating runway context directly into each token's direct-path attention. This mechanism re-wires the attention pattern for each token based on a summary of its runway landscape, enabling awareness of accumulating representational influences and allowing for more balanced information propagation. Our proposed methodology introduces no additional parameters and can seamlessly be integrated into standard attention mechanism. Empirically, our rewired transformer results in steady improvements in general language modeling as well as noticeably stronger information retrieval and extrapolation abilities compared to standard transformers.
When Attention Does Not Explain the Peak: Temporal Reference vs. Forecast Output in Attention-Based Time-Series Forecasting
Akamatsu, Yuji, Yamanaka, Takao
Attention maps are often interpreted as evidence of what a forecasting model uses when making predictions. In our load-forecasting model, a CLS representation of historical demand queries 24 future exogenous horizon tokens through cross-attention, inviting a temporal interpretation in which highly attended horizons may appear to explain forecast peak timing. We test this interpretation using a horizon-level attention descriptor, $ฮจ_{\mathrm{out}}$. Across 31 day-aligned windows of the Panama load dataset, the forecast achieves a median peak-time error of 0 h and a 51.6% exact-match rate, whereas the argmax of $ฮจ_{\mathrm{out}}$ has a median error of 5 h and 0% exact match. The forecast peak is closer to the observed peak in 27 of 31 windows. This dissociation is not merely an argmax artifact: within $\pm1$ h, attention reaches only $1.16\times$, $1.11\times$, and $1.14\times$ the uniform baseline around observed, predicted, and weekly-naive peaks, respectively, indicating weak and non-selective concentration. Yet the attention profile is structured, with cross-window consistency of 0.83. Replacing 12 future weather features with their training-set means makes the profile nearly uniform, showing sensitivity to future weather variation rather than fixed horizon position alone. The dissociation is also reproduced across three random-seed runs. These results show that structured, input-sensitive, and reproducible horizon-level cross-attention need not provide a valid peak-selective explanation of forecast behavior. The observed behavior is instead consistent with an internal horizon-reference role for integrating future exogenous information, although this functional role is not causally established.
Focus on What Matters: Fisher-Guided Adaptive Multimodal Fusion for Vulnerability Detection
Bian, Yun, Chen, Yi, Wang, HaiQuan, Li, ShiHao, Cui, Zhe
False negatives in software vulnerability detection can lead vulnerable functions to directly enter the build and release pipeline, thereby triggering severe security hazards; to improve the comprehensiveness and accuracy of detection, multimodal vulnerability detection techniques that integrate code sequences and graph structures have gradually become the current mainstream paradigm. Existing methods typically jointly model source code sequences and code property graph, but simple concatenation or general interaction mechanisms struggle to fully extract control-flow and data-dependency information in the graph modality that is relevant to vulnerability discrimination, resulting in limited performance gains under real data distributions. To address this issue, this paper proposes the TaCCS-DFA framework, which quantifies the sensitivity of feature directions to classification decisions using Fisher information, constrains cross-modal attention within tasksensitive structural subspaces, and dynamically regulates fusion strength on a per-sample basis through adaptive gating, thereby suppressing the propagation of redundancy and noise while preserving the advantages of semantic representations. Theoretical analysis indicates that, under the isotropic perturbation assumption, this mechanism can tighten the upper bound of the output error from O(ฮต) to O( k/d ฮต). Experiments on the four real-world benchmarks BigVul, PrimeVul, Devign, and ReVeal demonstrate that TaCCS-DFA, with only a 3.4% increase in inference latency, improves the F1 score by up to 6.3 percentage points and achieves a superior balance between precision and recall in highly imbalanced scenarios. The above results indicate that selectively extracting task-relevant control flow and data dependency information from CPG helps alleviate false-negative issues in practical vulnerability detection scenarios and holds application value for DevSecOps pipelines.
Musical Attention Transformer: Music Generation Using a Music-Specific Attention Model
Takasuka, Shinnosuke, Mukai, Hideo
This study aims to enhance the quality of music generation using Transformers by incorporating meta-information. While Transformer-based approaches are effective at capturing long-term dependencies in musical compositions, the music they generate often suffers from issues such as excessive repetition or duplication of notes, leading to unnatural melodies. To address these limitations, we propose Musical Attention, a mechanism that incorporates meta-information such as bar numbers, key, signatures, and tempos into the attention process. Musical Attention explicitly leverages both the structural properties of music and its associated metadata, enabling the Transformer's attention mechanism to operate more effectively and thereby improving the quality of the generated output. In our framework, each musical note is represented as a combination of five events-pitch, bar number, onset, duration, and velocity in addition to the three metadata elements. The attention mechanism is then modified to reflect the correlations among these eight features, allowing the model to better capture the inherent characteristics of musical composition. Experimental results demonstrate that the model incorporating Musical Attention outperforms prior methods, such as Full Attention and Strided Attention, in terms of musical coherence, variation, and overall quality. Notably, it significantly reduces repetition and enhances the model's ability to generate diverse, harmonically consistent melodies. Musical Attention thus represents a meaningful advancement in AI-driven music generation, facilitating the creation of more natural and expressive compositions.
Graph Attention Networks for Detecting Epilepsy from EEG Signals Using Accessible Hardware in Low-Resource Settings
Mazurek, Szymon, Moore, Stephen, Crimi, Alessandro
Goal: Epilepsy remains under-diagnosed in low-income countries due to scarce neurologists and costly diagnostic tools. We propose a graph-based deep learning framework to detect epilepsy from low-cost Electroencephalography (EEG) hardware, tested on recordings from Nigeria and Guinea-Bissau. Our focus is on fair, accessible automatic assessment and explainability to shed light on epilepsy biomarkers. Methods: We model EEG signals as spatio-temporal graphs, classify them, and identify interchannel relationships and temporal dynamics using graph attention networks (GAT). To emphasize connectivity biomarkers, we adapt the inherently node-focused GAT to analyze edges. We also designed signal preprocessing for low-fidelity recordings and a lightweight GAT architecture trained on Google Colab and deployed on RaspberryPi devices. Results: The approach achieves promising classification performance, outperforming a standard classifier based on random forest and graph convolutional networks in terms of accuracy and robustness over multiple sessions, but also highlighting specific connections in the fronto-temporal region. Conclusions: The results highlight the potential of GATs to provide insightful and scalable diagnostic support for epilepsy in underserved regions, paving the way for affordable and accessible neurodiagnostic tools.
Multi-Step Forecasting of Grape Berry Temperature based on LSTM Model with Feed-Forward Attention
Gorthi, Srikanth, Divyanth, L. G., Bhalekar, Dattatray, Keller, Markus, Khot, Lav
Accurate forecasting of grape berry temperature (Tb) is essential for enabling timely heat stress management in vineyards. The models were trained using environmental data collected during the summer of 2023 and 2024 from a research vineyard (cv. Chardonnay) located at Prosser, WA, USA, and validated on data from the summer of 2025. The proposed FAM-LSTM model was benchmarked against conventional approaches, including Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), Recurrent Neural Network (RNN), and Random Forest (RF), across prediction horizons ranging from 15 minutes to 72 hours at a 15-minute temporal resolution (288 time steps). Additionally, two input scenarios were evaluated: (1) nearest open-field weather station observations and (2) in-vineyard microclimate measurements (i.e., air temperature and relative humidity). The model performance was assessed using mean absolute error (MAE), root mean squared error (RMSE), and mean absolute percentage error (MAPE). Results indicate that the FAM-LSTM model consistently outperformed all benchmark models across all prediction horizons and input scenarios. Furthermore, incorporating in-vineyard microclimate data significantly improved forecasting accuracy, particularly at longer horizons (72 h). Using open-field weather data, the FAM-LSTM achieved MAE, RMSE and MAPE in the respective ranges of 0.58 to 1.70 C, 0.65 to 2.07 C, and 2.65 to 8.09%. In-vineyard observations further improved the model performance with respective MAE, RMSE, and MAPE in the ranges of 0.51 to 1.55 C, 0.71 to 1.87 C, and 2.48 to 7.68%. Error analysis revealed that prediction uncertainty was highest during peak daytime periods (11:00 to 18:00) and increased progressively with the forecast horizon. Overall, FAM-LSTM framework offered a robust and high-resolution Tb forecasting and could support precision heat stress management in vineyards.
Plain Transformers Can be Powerful Graph Learners
Ma, Liheng, Pal, Soumyasundar, Zhang, Yingxue, Torr, Philip H. S., Coates, Mark
Transformers have attained outstanding performance across various modalities, owing to their simple but powerful scaled-dot-product (SDP) attention mechanisms. Researchers have attempted to migrate Transformers to graph learning, but most advanced Graph Transformers (GTs) have strayed far from plain Transformers, exhibiting major architectural differences either by integrating message-passing mechanisms or incorporating sophisticated attention mechanisms. These divergences hinder the easy adoption of training advances for Transformers developed in other domains. Contrary to previous GTs, this work demonstrates that the plain Transformer architecture can be a powerful graph learner. To achieve this, we propose to incorporate three simple, minimal, and easy-to-implement modifications to the plain Transformer architecture to construct our Powerful Plain Graph Transformers (PPGT): (1) simplified L2 attention for measuring the magnitude closeness among tokens; (2) adaptive root-mean-square normalization to preserve token magnitude information; and (3) a simple MLP-based stem for graph positional encoding. Consistent with its theoretical expressivity, PPGT demonstrates noteworthy realized expressivity on the empirical graph expressivity benchmark, comparing favorably to more complicated alternatives such as subgraph GNNs and higher-order GNNs. Its empirical performance across various graph datasets also justifies the effectiveness of PPGT. This finding underscores the versatility of plain Transformer architectures and highlights their strong potential as a unified backbone for multimodal learning across language, vision, and graph domains.
STS: Efficient Sparse Attention with Speculative Token Sparsity
Yu, Jiangnan, Xu, Ceyu, Wu, Yongji, Xie, Yuan
The quadratic complexity of attention imposes severe memory and computational bottlenecks on Large Language Model (LLM) inference. This challenge is particularly acute for emerging agentic applications that require processing multi-million token sequences. We propose STS, a sparse attention mechanism that requires no model retraining. STS leverages the key insight that tokens identified as important by a smaller draft model are highly predictive of important tokens for a larger target model. By integrating into speculative decoding frameworks, STS repurposes the draft model's attention scores to dynamically construct a token-and-head-wise sparsity mask. This mask effectively prunes the expensive attention computation in the target LLM. Our evaluation shows that STS achieves a 2.67x speedup operating at approximately 90% sparsity on representative benchmark NarrativeQA, maintaining negligible accuracy degradation compared to dense attention. STS establishes a new state-of-the-art on the sparsity-accuracy trade-off, outperforming prior techniques by enabling higher sparsity levels for a given accuracy budget.
PhysAttNet: Enhancing Predictive Performance in Industrial and Astrophysical Time Series via Physics-Informed Attention
Saadallah, Amal, Tjus, Julia, Wiederkeher, Petra, Rhode, Wolfgang
Accurate and robust time series forecasting is essential in many applications involving physical processes, such as manufacturing monitoring and astrophysical event detection. In these settings, predictive models must remain reliable under noise, variability, and measurement uncertainty while capturing temporally localized structures corresponding to physically meaningful events. Convolutional neural networks (CNNs) are widely used for such tasks due to their computational efficiency and strong representational capacity. However, their learned temporal representations often exhibit unstable or physically inconsistent attention patterns, reducing robustness, generalization, and interpretability. This paper introduces PhysAttNet, a physics-informed attention framework for time series forecasting. PhysAttNet augments a lightweight CNN forecaster with an attention head guided by domain-informed regularization reflecting the structural properties of physical signals. Specifically, three complementary constraints are imposed during training: an alignment regularization that encourages attention to follow smooth, peak-centered temporal structures derived from the input signal, a smoothness regularization that enforces continuous temporal evolution, and a sparsity regularization that promotes selective focus on informative intervals. These differentiable regularization terms introduce physics-guided inductive bias without requiring annotated explanations or manual supervision. Experiments on two distinct applications, namely predicting cutting forces during milling and forecasting flares in blazar time series, demonstrate that PhysAttNet improves forecasting accuracy, generalization, and prediction performance on structurally important events.