NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Quantum Recurrent Architectures for Text Classification

Wenduan Xu, Stephen Clark, Douglas Brown, Gabriel Matos, Konstantinos MeichanetzidisEMNLP 2024

Abstract

Recent advancements in quantum machine learning have opened new avenues for natural language processing (NLP). This paper explores the application of Quantum Recurrent Neural Networks (QRNNs) to text classification tasks. By leveraging the unitary nature of quantum gates, these architectures naturally address the vanishing gradient problem inherent in classical recurrent models. We propose two hybrid quantum-classical architectures—a QRNN with discarding ($QRNN_d$) and a simple QRNN—and evaluate them on the Rotten Tomatoes sentiment analysis dataset. Our results demonstrate that QRNNs can achieve performance comparable to classical LSTMs while utilizing significantly fewer parameters and qubits, highlighting the potential for quantum-native models in near-term quantum devices.

Introduction

Recurrent Neural Networks (RNNs) have historically been a cornerstone of sequential data processing in NLP. However, they are plagued by the vanishing and exploding gradient problems, which hinder their ability to capture long-range dependencies. While classical architectures like Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRU) mitigate these issues through complex gating mechanisms, quantum computing offers a more fundamental solution.

Quantum gates are unitary transformations, meaning they are norm-preserving. This mathematical property ensures that the "signal" or energy of the input is preserved throughout the sequence, theoretically preventing gradients from vanishing. This work investigates whether small-scale, hybrid quantum-classical RNNs can compete with established classical baselines on real-world text classification tasks using current Noisy Intermediate-Scale Quantum (NISQ) hardware and simulators.

Methods

The proposed approach maps classical word embeddings into a quantum Hilbert space using two distinct hybrid architectures.

QRNN Architectures

  1. QRNN with Discarding ($QRNN_d$): In this model, each word is encoded into a "word ansatz" on two qubits. This state is then entangled with a two-qubit "hidden state" carried over from the previous time step. To maintain a constant state size, a partial trace operation is performed to "discard" two qubits, leaving a two-qubit quantum hidden state for the subsequent step.
  2. Simple QRNN: This architecture simplifies the process by directly parameterizing a Parametrized Quantum Circuit (PQC) with angles derived from classical word embeddings. The 4-qubit state is updated sequentially as each word in the sentence is processed.
Proposed QRNN architectures: (a) QRNN with discarding ($QRNN_d$) and (b) Simple QRNN.

Technical Implementation

Data is encoded using angle encoding, where classical values are mapped to rotation angles for $RX, RY,$ and $RZ$ gates. The models utilize "Ansatz 14," a circuit design known for its high expressibility. Training is conducted via a hybrid quantum-classical loop, using standard backpropagation and the Adam optimizer, with quantum operations simulated on classical GPUs.

Experimental Setup

The models were benchmarked on the Rotten Tomatoes dataset for binary sentiment classification. The dataset consists of 8,530 training sentences and 1,066 sentences each for development and testing.

Results and Discussion

The QRNN models demonstrated remarkable efficiency and performance compared to classical baselines.

Performance and Parameter Efficiency

Despite having orders of magnitude fewer parameters, the QRNN achieved a test accuracy of 78.7%, slightly outperforming the LSTM baseline.

Model Test Accuracy Hidden State Dim Parameter Count
QRNN 78.7% 16 (4 qubits) 1.6K
LSTM 78.5% 200 240K
GRU 77.2% 200 180K
RNN 76.8% 200 60K

The 4-qubit system operates in a 16-dimensional complex Hilbert space, which proved sufficient to match the performance of a 200-dimensional classical hidden state. This highlights the extreme parameter efficiency of quantum-native representations.

Training Dynamics

A key finding was the rapid convergence of quantum models. While classical LSTMs typically required approximately 50-60 epochs to reach peak accuracy, the QRNN models converged within fewer than 10 epochs.

Accuracy vs. Epoch for QRNN and $QRNN_d$ models, showing rapid convergence within the first few epochs.

Hardware Robustness

Tests on a noisy emulator of the Quantinuum H1-1E hardware yielded an accuracy of 80.1%. This suggests that these architectures are not only feasible for NISQ hardware but may also benefit from inherent quantum noise as a form of regularization.

Conclusion and Future Work

This study demonstrates that small-scale quantum recurrent architectures can achieve competitive performance in NLP tasks with a fraction of the parameters required by classical models. However, challenges remain, including the risk of "barren plateaus" in the gradient landscape as qubit counts increase and the computational cost of simulating larger circuits. Future research will focus on scaling these models to more complex datasets and exploring their application in broader NLP tasks such as machine translation.

Summary updated

BibTeX
@inproceedings{xu2024quantum,
  author = {Wenduan Xu and Stephen Clark and Douglas Brown and Gabriel Matos and Konstantinos Meichanetzidis},
  title = {{Quantum Recurrent Architectures for Text Classification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1000},
}
Figure