Our primary objective is to conduct a brief survey of various classical and quantum neural net sequence models, which includes self-attention and recurrent neural networks, with a focus on recent quantum approaches proposed to work with near-term quantum devices, while exploring some basic enhancements for these quantum models. We re-implement a key representative set of these existing methods, adapting an image classification approach using quantum self-attention to create a quantum hybrid transformer that works for text and image classification, and applying quantum self-attention and quantum recurrent neural networks to natural language processing tasks. We also explore different encoding techniques and introduce positional encoding into quantum self-attention neural networks leading to improved accuracy and faster convergence in text and image classification experiments. This paper also performs a comparative analysis of classical self-attention models and their quantum counterparts, helping shed light on the differences in these models and their performance.
Quantum self-attention is a promising approach to replace traditional self-attention mechanisms in classical deep learning, which often require a massive number of GPUs for training. Although several early studies have proposed quantum self-attention architectures, these models often struggle with classification tasks in vision transformers. In this study, we address this limitation by enhancing quantum self-attention through integration with circuit classifier design and, crucially, by optimizing the number of strong entangling layers. Evaluation results show that incorporating an optimal number of entangling layers substantially improves classification performance, outperforming models that rely solely on directly measured quantum self-attention. We further analyze how varying the number of quantum classifier layers affects classification accuracy during training. Experiments on downscaled MNIST and MC datasets reveal that the nature of the input data has minimal impact on the final outcomes. Notably, testing accuracy reaches 56% when using 10–16 strong entangling layers, highlighting the critical role of entanglement in model performance. For SOTA comparison, we replicate existing quantum self-attention methods and demonstrate that our model consistently achieves 10-23% better performance results. Additionally, we compare different optimizers and find that Nesterov Momentum delivers the most effective convergence for our architecture.
We propose a variational quantum implementation of self-attention (QSA)-the core operation in transformers and large language models-which predicts future elements of a sequence by forming overlap-weighted combinations of past data. At variance with previous approaches, our QSA realizes the required nonlinearity through interference of state overlaps and a degree-
k polynomial kernel, and estimates a loss based on Rényi-
1/2 entropic functionals via two observables' expectation values, avoiding the decoding of amplitude-encoded predictions into classical probabilities. QSA also accommodates a constrained, trainable data-embedding tying state overlaps to data-level similarities. Its dominant end-to-end training complexity scales as
O(μ−1k2Td), versus
O(Tdk+1) of the fairest classical comparison, with
μ a training signal; we show numerically that this allows a complexity advantage in the regime where sequence length
T dominates the embedding size
d. In simulations, our QSA-based quantum transformer learns sequence prediction on classical data and on many-body transverse-field Ising trajectories-establishing trainable attention as a practical primitive for quantum dynamical modeling.