# Quantum Natural Language Processing: Challenges and Opportunities
## 6 Quantum Computer Approaches  
The following section presents works using real quantum hardware. All work listed below use NISQ computers [33]. In Table 3, some specifications of hardware and experiments are provided. The first implementation of an NLP task on NISQ hardware has been proposed by [63], following theoretical methods proposed in [49]. Conceptual and mathematical foundations on which these work are based are described in [31]. It uses DisCoCat, adopting the paradigm of Parameterized quantum circuits as machine learning models [77]. The core of the proposed approach is considering DisCoCat as a tensor network model of natural language meaning [97]. Meanings of words are encoded as co-occurrence frequencies or other word-embeddings produced by neural network. These tensor networks can be represented as string diagrams [98], composed of boxes with input and output wires, each of which carries a type. Boxes are composed to form process networks by wiring outputs to inputs by ensuring types are respected. Output-only processes are called states and input-only processes are called effects. The approach has been tested on a question answering task using a labeled dataset composed by 30 randomly generated sentences using a finite vocabulary and a context-free grammar (CFG) [99] and represented as a syntax tree. These sentences are converted into DisCoCat diagrams. An optimization (or training) step is needed in order to match the predicted labels with labels in the training set. The optimization has been performed using SPSA (Simultaneous Perturbation Stochastic Approximation) [100], which has been proven to perform well in noisy settings. This approach reformulates the problem as a supervised learning task of binary classification for sentences, i.e., a special case of question answering already known in the literature [101; 102]. Before each circuit can be run on a backend, it has been compiled using the quantum compiler \(t\ket{T}^{TM}\)[103]. The quantum compilation operates in this way: given a circuit and a device, quantum operations are decomposed in terms of devices native gateset, then the quantum circuit is make compatible with the device topology. In addition, the compiler tries to minimize the most noisy operations. After that, the circuits run on two IBMQ quantum computers ibmq_montreal and ibmq_toronto, whose quantum volume is 32 for both, with a maximum allowed number of shots equal to 213. Concerning results, first a classical simulation has been performed. For the QA task, sentence circuits have been evaluated using classical hardware. For this simulation, the entire corpus of 30 sentences with a vocabulary consisting of 7 words has been taken into account. The experiments running on NISQ device has instead exploited only 16 sentences with a vocabulary of 6 words. The best results achieved reach a train error of 12.5% and a test error of 37.5% on ibmq_toronto; values decrease further on ibmq_montreal, where the train error is null, while the test error stops at 37.5%. In [64], the first full experiments at a medium-scale, focused on two NLP tasks running on quantum hardware, have been performed. This work starts from earlier work [63] and--differently from previous approaches--does not intend to provide evidence of the so-called \"quantum advantage\" in terms of performance. Therefore, these experiments aim to explore the challenges and limitations of training and running an NLP model on a NISQ device. In addition, this work contributes to shifting traditional approaches to NLP tasks to a quantum-friendly form, proposing a quantum pipeline equivalent to the classical one. Two tasks are proposed, and both of them are structured as binary classification problems. The first one, namely the classification task (MC), uses a dataset of 130 sentences plain-syntax generated from a fixed vocabulary using a simple CFG that can refer to one of two possible topics, food or IT.