Abstract
This work proposes QNet, a novel sequence encoder model that entirely inferences on the quantum computer using a minimum number of qubits. Let $n$ and $d$ represent the length of the sequence and the embedding size, respectively. The dot-product attention mechanism requires a time complexity of $O(n^2 \cdot d)$, while QNet has merely $O(n+d)$ quantum circuit depth. In addition, we introduce ResQNet, a quantum-classical hybrid model composed of several QNet blocks linked by residual connections, as an isomorph Transformer Encoder. We evaluated our work on various natural language processing tasks, including text classification, rating score prediction, and named entity recognition. Our models exhibit compelling performance over classical state-of-the-art models with a thousand times fewer parameters. In summary, this work investigates the advantage of machine learning on near-term quantum computers in sequential data by experimenting with natural language processing tasks.
1. Introduction
The dominant architecture in modern Natural Language Processing (NLP) is the Transformer, which relies heavily on the Multi-head Self-Attention mechanism. While powerful, self-attention has a major bottleneck: its time complexity is $O(n^2 \cdot d)$, where $n$ is the sequence length. This quadratic scaling makes processing long sequences computationally expensive and slow. As we enter the Noisy Intermediate-Scale Quantum (NISQ) era, researchers are looking for ways to leverage quantum properties—like superposition and entanglement—to perform machine learning more efficiently. This paper introduces QNet, a sequence encoder designed to be "quantum-native," running its core logic on a quantum computer to bypass the scaling limitations of classical Transformers.
2. Methodology
2.1 The QNet Encoder
The QNet encoder block is designed to process sequential data using quantum circuits. It replaces the computationally expensive self-attention mechanism with a Quantum Fourier Transform (QFT)-based approach.
The architecture consists of four primary stages:
- Word Embedding Encoding: QNet encodes word values as rotations on the Pauli-X axis and their positions as rotations on the Pauli-Z axis. This allows the model to store both semantic and structural information within the state of a single qubit per embedding dimension.
- Mixture Learning: This is the quantum alternative to self-attention. It uses the Quantum Fourier Transform (QFT) to "blend" information across different tokens in the sequence. By applying learnable rotation gates between a QFT and an inverse QFT, the model learns token relationships with a circuit depth of only $O(n)$.
- Positional Feedforward: To introduce non-linearity, the authors use a structure inspired by Grover’s Algorithm. It uses a Grover operator to flip amplitudes and change the basis, allowing Variational Quantum Circuits (VQC) to act as a pseudo-activation function.
2.2 ResQNet: A Hybrid Architecture
To mimic the deep architecture of a Transformer, the authors introduce ResQNet, which wraps the QNet encoder in a hybrid classical-quantum loop. This structure utilizes residual connections and linear transformations to stack multiple encoder blocks effectively.
3. Experimental Evaluation
The models were evaluated on four diverse NLP tasks: humor detection (ColBERT), programming question categorization (StackOverflow), clothing fit rating prediction (RentTheRunway), and named-entity recognition (MSRA).
3.1 Key Results
Experimental results demonstrate that QNet achieves state-of-the-art performance with significantly fewer parameters:
- Humor Detection (ColBERT): ResQNet achieved 91.17% accuracy, outperforming BERT-Tiny (87.23%) despite having roughly 50,000x fewer parameters.
- Question Classification: On the StackOverflow dataset, ResQNet reached 41.41% accuracy, while BERT-Tiny struggled at 5.38% in the same low-resource configuration.
- Named-Entity Recognition: ResQNet showed compelling results on the MSRA task (0.7261 F1-score for non-O tags), proving its capability in handling token-level labeling.
4. Discussion and Conclusion
QNet achieves a circuit depth of $O(n+d)$, a significant theoretical improvement over the $O(n^2 \cdot d)$ complexity of classical self-attention. The most striking finding is the extreme parameter efficiency; for instance, QNet uses only 2,304 parameters compared to over 1.1 million for BERT-Tiny. This suggests that the high dimensionality of the Hilbert space available to entangled qubits allows the model to capture complex linguistic relationships more efficiently than classical weights.
While current implementations are limited by NISQ noise and simulation constraints, QNet provides a scalable path for sequence processing on future quantum hardware, demonstrating that quantum-native architectures can compete with and even surpass classical models in specific NLP domains.
Summary updated