Skip to main content
QUICK REVIEW

[Paper Review] A multiclass Q-NLP sentiment analysis experiment using DisCoCat

Victor D. Martínez, Guilhaume Leroy-Meline|arXiv (Cornell University)|Sep 7, 2022
Topic ModelingComputer Science6 citations
TL;DR

This paper presents a multiclass sentiment analysis framework using the DisCoCat model and variational quantum circuits on NISQ-era quantum hardware, extending prior two-class work to four emotions (happiness, fear, anger, sadness). It achieves 78% F1-score on a 180-sample dataset using quantum circuit training with COBYLA optimizer, demonstrating scalability of DisCoCat for quantum NLP tasks.

ABSTRACT

Sentiment analysis is a branch of Natural Language Processing (NLP) which goal is to assign sentiments or emotions to particular sentences or words. Performing this task is particularly useful for companies wishing to take into account customer feedback through chatbots or verbatim. This has been done extensively in the literature using various approaches, ranging from simple models to deep transformer neural networks. In this paper, we will tackle sentiment analysis in the Noisy Intermediate Scale Computing (NISQ) era, using the DisCoCat model of language. We will first present the basics of quantum computing and the DisCoCat model. This will enable us to define a general framework to perform NLP tasks on a quantum computer. We will then extend the two-class classification that was performed by Lorenz et al. (2021) to a four-class sentiment analysis experiment on a much larger dataset, showing the scalability of such a framework.

Motivation & Objective

  • To extend prior two-class quantum sentiment classification to a four-class multiclass sentiment analysis task.
  • To evaluate the scalability and feasibility of applying the DisCoCat model to quantum natural language processing (QNLP) on near-term quantum hardware.
  • To demonstrate that quantum-enhanced NLP pipelines can handle larger, more complex sentiment classification tasks using tensor product representations and post-selection.
  • To assess the performance of variational quantum circuits trained via cross-entropy loss on a real-world sentiment dataset with four emotional classes.
  • To explore the potential of quantum advantage in NLP through kernel-based learning in high-dimensional Hilbert spaces induced by quantum data encoding.

Proposed method

  • Parse sentences into syntax trees and represent them as DisCoCat diagrams using DiscoPy, an open-source monoidal category toolkit.
  • Encode sentence meaning via tensor product representations (TPR) of word embeddings, leveraging the exponential scaling advantage of quantum systems over classical ones.
  • Map DisCoCat diagrams to parameterized quantum circuits (Ansatz) with two qubits per word, using controlled Z-rotation and Hadamard gates for entanglement and superposition.
  • Train the quantum circuit parameters using a cross-entropy loss function and the COBYLA optimizer, a gradient-free method suitable for noisy intermediate-scale quantum (NISQ) devices.
  • Apply post-selection to retain only measurement runs where ancilla qubits (r qubits) are measured as 0, ensuring valid outcomes for the final sentiment classification.
  • Execute the quantum circuit multiple times to collect outcome probabilities for the measured qubits, which directly correspond to predicted sentiment classes (e.g., |00⟩, |01⟩, etc.).

Experimental results

Research questions

  • RQ1Can the DisCoCat model be effectively extended from two-class to four-class sentiment classification on a quantum NLP pipeline?
  • RQ2How does the performance of a variational quantum circuit trained on a multiclass sentiment dataset compare to classical baselines in terms of F1-score and confusion patterns?
  • RQ3To what extent does the quantum circuit's architecture and post-selection mechanism support scalable sentiment analysis on near-term quantum hardware?
  • RQ4What is the impact of sentence length and vocabulary size on the resource requirements and performance of the quantum NLP pipeline?
  • RQ5Does the quantum-enhanced kernel mapping via quantum circuit encoding provide a path toward quantum advantage in sentiment analysis tasks?

Key findings

  • The proposed quantum NLP pipeline achieved an F1-score of 78% on a 180-sample test set for four-class sentiment classification (happiness, fear, anger, sadness).
  • The normalized confusion matrix showed high concentration along the diagonal, indicating strong predictive accuracy and low misclassification between emotion classes.
  • The training process converged stably, as evidenced by the decreasing cross-entropy loss over epochs in the training curve (Figure 7).
  • Post-selection on ancilla qubits was successfully applied to filter measurement outcomes, ensuring reliable classification from the remaining valid runs.
  • The method demonstrated linear or sublinear scaling of vocabulary, sentence count, and sentence length with respect to the number of qubits, supporting future scalability.
  • Despite promising results, classical baselines (e.g., TF-IDF + Naive Bayes) outperformed the quantum model with 95% accuracy, highlighting current limitations in quantum circuit depth and noise.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.