# Quantum Natural Language Processing: Challenges and Opportunities
## 6 Quantum Computer Approaches
For the second task, 105 noun phrases are extracted from the RelPron dataset [104], and the goal of the model is to predict whether a noun phrase contains a subject-based or an object-based relative clause. This task, identified using the acronym RP, is more challenging since it requires some syntactic awareness from the model, so it is a very reasonable choice for testing DisCoCat. Notice that, even these datasets can appear small or simple, as they already reach the limits of the currently available quantum hardware. Using DisCoCat, every different grammatical structure of a sentence \begin{table}
\begin{tabular}{l l l l l} \hline \hline
**Task** & **Device** & **Dataset** & **Train Error** & **Test Error** \\ \hline \multirow{3}{*}{Question answering} & simulation & 30 sentences & / & / \\  & & 7 words vocabulary & & \\ \cline{2-5}  & ibmq\_toronto & 16 sentences & 12.5\% & 37.5\% \\  & ibmq\_montreal & 6 words vocabulary & 0 & 37.5\% \\ \hline \multirow{2}{*}{Meaning classification (MC)} & simulation & 130 sentences & 16.9\% & 20.2\% \\  & ibmq\_bogota & 17 words vocabulary & / & 16.7\% \\ \hline \multirow{2}{*}{RelPron (RP)} & simulation & 105 sentences & 9.4\% & 27.7\% \\  & ibmq\_bogota & 115 words vocabulary & / & 32.3\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison of quantum experiments running on NISQ hardware. Note that not all details are given in the description of the experiments performed. Concering NISQ devices, all machines used have 5 qubits available and a quantum volume equal to 32.  
is mapped to different quantum circuits. A simplified version of the quantum pipeline used in this work is shown in Figure 3. In detail, in order to propose a full NLP pipeline equivalent to classical ones, sentences need to be represented in a tree form consistent using a parser. A parser, based on categorial grammar [105], has been used to obtain representation consistent with DisCoCat. Subsequently, every diagram is mapped to a specific quantum circuit. The mapping is defined by a conjunction of choices formulated as an ansatz, allowing to make choices based on the specific hardware. Every NISQ machine has a different sets of native gates indeed, of which some are more prone to error than others. These steps have been implemented using the python implementation of DisCoCAT [106]. To estimate the expectations of a hypothetical noise-free quantum device, a simulation has been performed. According to this simulation, the train and test errors reported after 500 iterations for the MC task are 16.9% and 20.2%, respectively. For the second task on the RELPRON dataset, RP train errors are equal to 9.4%, while those of the test reach 27.7%. Higher test error value for the RP task--at equal task complexity--are motivated by a broader vocabulary (115 words) with respect to the MC one (17 words). Once each sentence has been represented by a quantum circuit according the the chosen ansatz, circuits are converted into machine specific instructions using \(t\left|{\mathit{tet}}\right\rangle^{TM}\) compiler. After that, the quantum device ibmq_bogota executes the circuit \(n_{\mathit{shots}}\) times. This IBM machine is a superconducting quantum computing device with 5 qubits and a quantum volume of 32. In particular, initial states are prepared for each run, gates are applied and all qubits are measured. This step returns the count of the shots for all qubits. Every time the error cost is calculated, compiled circuits corresponding to all sentences are sent to the device as a single job. After that, each circuit is run the the maximum possible number of time offered by the machine (213 in this case). For every sentence, estimations of relative frequencies are calculated in the order of a post-processing step aimed at calculating task-specific results.