Parametrized Quantum Circuits of Synonymous Sentences in Quantum Natural Language Processing

In this paper, we develop a compositional vector-based semantics of positive transitive sentences in quantum natural language processing for a non-English language, i.e. Persian, to compare the parametrized quantum circuits of two synonymous sentences in two languages, English and Persian. By considering grammar+meaning of a transitive sentence, we translate DisCoCat diagram via ZX-calculus into quantum circuit form. Also, we use a bigraph method to rewrite DisCoCat diagram and turn into quantum circuit in the semantic side.


Introduction
Natural language processing (NLP) is a subgroup of linguistics and artificial intelligence used for language interactions between computers and human, e.g. programming computers to analyze natural language data with large volumes. A computer can understand the meanings and concepts of the texts in documents, recognises speech, and generates natural language via NLP. In fact, NLP was proposed first in 1950 by Alan Turing [1] i.e. now called the Turing test as a criterion of intelligence for automated interpretation and generation of natural language. Recently a group of researchers at OpenAI have developed Generative Pre-trained Transformer 3 (GPT-3) language model [2], as the largest non-sparse language model with higher number of parameters and a higher level of accuracy versus previous models with capacity of ten times larger than that of Microsoft's Turing-NLG to date. On the arXiv:2102.02204v1 [quant-ph] 2 Feb 2021 other side, some quantum approaches for NLP have been developed that may reach some quantum advantages over classical counterparts in future [3,4]. Protocols for quantum Natural Language Processing (QNLP) have two aspects: semantic and syntax. Both aspects are performed by a mathematical framework. Compact closed categories are used to provide semantics for quantum protocols [5]. The use of quantum maps for describing meaning in natural language was started by Bob Coecke [6]. Coecke has introduced diagrammatic language to speak about processes and how they compose [7]. The diagrammatic language of non-commutative categorical quantum logic represents reduction diagrams for sentences, and allows one to compare the grammatical structures of sentences in different languages. Sadrzadeh has used pregroups to provide an algebraic analysis of Persian sentences [8]. Pregroups are used to encode the grammar of languages. One can fix a set of basic grammatical roles and a partial ordering between them, then freely can generate a pregroup of these types [6]. The category of finite dimensional vector spaces and pregroups are monoidal categories. Models of the semantic of positive and negative transitive sentences are given in ref. [6]. Moreover, Frobenius algebras are used to model the semantics of subject and object relative pronouns [9]. Brian Tyrrell [10] has used vector space distributional compositional categorical models of meaning to compare the meaning of sentences in Irish and in English. Here, we use vectorbased models of semantic composition to model the semantics of positive transitive sentences in Persian. According to [3] the DisCoCat diagram is simplified to some other diagram and is turned into a quantum circuit, which can be compiled via noisy intermediate-scale (NISQ) devices. The grammatical quantum circuits are spanned by a set θ. The meaning of the words and hence whole sentence are encoded in the created semantic space. Finally, we rewrite the diagram as a bipartite graph to turn a quantum circuit. ZX-calculus, like a translator, turns a linguistic diagram into a quantum circuit. According to [11] we consider both grammar and meaning of a grammatical sentence in Persian and turn DisCoCat diagram into a quantum circuit form.

Preliminaries
In this section, we provide some content, which will be used throughout this paper.
See the references [9] and [6] for more details. • for every two morphisms f ∈ C(A, B) and g ∈ C(B, C), a morphism g • f ∈ C(A, C). These must satisfy the following properties, for all objects A, B, C, D and all morphisms f ∈ C(A, B), g ∈ C(B, C), h ∈ C(C, D): we have category is a category C with the following properties: • a functor ⊗ : C × C → C, called the tensor product and we have • there is a unit object I such that • for each ordered pair morphisms f ∈ C(A, C), g ∈ C(B, D) we have f ⊗ g : Monoidal categories are used to encode semantic and syntax of sentences in different languages. Definition 1.3 A symmetric monoidal category is a monoidal category C such that the tensor product is symmetric. This means that there is a natural isomorphism η such that for all objects A, Graphical language is a high-level language for researching in quantum processes, which has applications in many areas such as QNLP and modelling quantum circuits.

Graphical language for monoidal category
According to [6], morphisms are depicted by boxes, with input and output wires.
For example, the morphisms where f : A → B and g : B → C, are depicted as follows: States and effects of an object A are defined as follows, respectively from left to right: Definition 1.4 A compact closed category is a monoidal category where for each object A there are objects A r and A l , and morphisms such that: The above equations are called yanking equations. In the graphical language the η maps are depicted by caps, and maps are depicted by cups [6]. The yanking equation results in a straight wire . For example, the diagrams for η l : A l Definition 1.5 As defined in [6], a partially ordered non-commutative monoid P is called a pregroup, to which we refer as P reg. Each element p ∈ P has both a left adjoint p l ∈ P and a right adjoint p r ∈ P . A partially ordered monoid is a set (P, . , 1, ≤, (−) l , (−) r ) with a partial order relation on P and a binary operation − · − : P × P → P that preserves the partial order relation. The multiplication has the unit 1, that is p = 1.p = p.1. Explicitly we have the following axioms: We refer the above axioms as reductions.

Preg and FVect as compact closed categories
P reg is a compact closed category. Morphisms are reductions and the operation " . " is the monoidal tensor of the monoidal category. As mentioned in [6], the category P reg can be used to encoding the grammatical structure of a sentence in a language. Objects and morphisms are grammatical types and grammatical reductions, respectively. The operation " . " is the juxtaposition of types. According to [9], let F V ect be the category of finite dimensional vector spaces over the field of reals R. F V ect is a monoidal category, in which vector spaces, linear maps and the tensor product are as objects, morphisms and the monoidal tensor, respectively. In this category the tensor product is commutative, i.e. V ⊗ W ∼ = W ⊗ V , and hence where V l , V r and V * are left adjoint, right adjoint and a dual space of V . We consider a fixed base, so we have an inner-product. Consider a vector Consider the monoidal functor F : P reg → F V ect, which assigns the basic types to vector spaces as follows: The compact structure is preserved by Monoidal functors; this means that for more details see [9].

Positive transitive Sentence
The simple declarative Persian sentence with a transitive verb has the following structure: subject + object + objective sign + transitive verb. For example, the following is the Persian sentence for 'sara bought the book'.
English: Sara bought the book.
In this sentence, 'Sara' is the subject, 'ketab' is the direct object, 'ra' is the objective sign and 'kharid' is the transitive verb in simple past tense, see [8].

Vector Space Interpretation
Vector spaces and pregroups are used to assign meanings to words and grammatical structure to sentences in a language. The reductions and types are interpreted as linear maps and vector spaces, obtained by a monoidal functor F from P reg to F V ect. In this paper we present one example from persian: positive transitive sentence, for which we fix the following basic types, n: noun s: declarative statement o: object According to [6] if the juxtaposition of the types of the words in a sentence reduces to the basic type s, the sentence is called grammatical. We use an arrow → for ≤ and drop the " . " between juxtaposed types. The example sentence 'sara ketab ra kharid', has the following type assignment by [8]: Sara ketab ra kharid.
A positive sentence with a transitive verb in Persian has the pregroup type nn(n r o)(o r n r s). The interpretation of a transitive verb is computed as follows: So the meaning vector of a Persian transitive verb is a vector in N ⊗ N ⊗ S. The pregroup reduction of a transitive sentence is computed as follows: and depicted as: The distributional meaning of 'Sara ketab ra kharid' is as follows: where − → ra is the vector corresponding to the meaning of 'ra'. We set and in this case we have − → ra η N : R → N ⊗ N.
We obtain diagrammatically:

subject object verb
Which by the diagrammatic calculus of compact closed categories [12], is equal to: subject object verb Consider the vector Ψ in the tensor space which represents the type of verb: where for each i, − → w i is the meaning vector of object and − → v j is the meaning vector of subject. Then

Truth theoretic meaning and concrete instantiation
According to [9] we let N to be the vector space spanned by a set of individuals { − → n i } and S to be the one dimensional space spanned by the unit vector − → 1 . The unit vector and the zero vector represent truth value 1 and truth value 0 respectively. A transitive verb Ψ ∈ N ⊗ N ⊗ S is represented as follows: where k and l range over the sets of basis vectors representing the respective common nouns, the truth-theoretic meaning of a transitive sentence is computed as follows: A transitive verb is represented as a two dimensional matrix. The corresponding vector of this matrix is − − → verb = ji c ji ( − → n j ⊗ − → n i ). Note that the sum of the tensor product of the objects and subjects of the verb throughout a corpus represents the meaning vector of the verb. So the meaning of the transitive sentence is: The meaning vector is decomposed to point-wise multiplication of two vectors as follows: where is the point-wise multiplication.

Diagrams rewriting and quantum circuits
As mentioned in the previous sections a sentence in a corpus is parsed according to its grammatical structure. According to [3] we simplify the DisCoCat diagram to some other diagram and turn into a quantum circuit, which can be compiled via NISQ devices. Two methods are presented for this purpose. The bigraph method and snake removal method. Both methods are done in the symmetric version of the pregroup grammar. We consider the grammatical sentence from (1), and use a bigraph method to turn the diagram (2) into a bipartite graph. Words at odd distance from the root word are transposed into effects: Transposition turns states into effects, see [12]. According to [3], One can use the bigraph algorithm to form quantum circuits of the semantic side of the meaning. In the pregroup type of the sentence 'Sara ketab ra kharid' set o = n. For atomic types n and s consider two qubits and one qubit respectively.
The number of qubits for each type t is the sum of the number of qubits associated to all atomic types in t. For example the transitive verb 'kharid' has five qubits.
For each word in the sentence we have a quantum circuit as follows: The quantum circuit of the whole sentence is as follows: The reduction diagram of the sentence 'sara bought the book' in English is: n n r s n l n n l n So the quantum circuit of the whole sentence is as follows: The two sentences 'Sara Ketab ra kharid' and 'Sara bought the book' have the same meaning but are grammatically different. We expect the above two circuits to have the same output. According to [11] we present grammar+meaning as quantum circuit for the above two sentences. Consider the states | ψ ns and | ψ no correspond to the subject and the object, respectively. Also a transitive verb as a map η tv that takes | ψ ns ∈ C 2 and | ψ no ∈ C 2 and produces | ψ ns.no.tv ∈ C 2k , diagrammatically: . Because the quantum model relies on the tensor product, an exponential blow-up occurs for meaning spaces of words. In order to avoid this obstacle in experiments decrease the dimension of the spaces in which meanings of transitive verbs live. For the transitive verb, instead of state in the large space | ψ kharid ∈ C 2 ⊗ C 2 ⊗ C 2k consider state in a smaller space | ψ * kharid * ∈ C 2 ⊗ C 2 , diagrammatically: Then copy each of the wires and bundle two of the wires together to make up the thick wire. Thus 'kharid' is obtained: * kharid * For more details see [11]. Now inter Sara and Ketab into the picture: * kharid * Ketab Sara = * kharid * Ketab Sara We Pull some spiders out: * kharid * Ketab Sara (4) and by Using the Choi-Jamiolkowski correspondence we obtain: * kharid * Ketab Sara * kharid * Ketab Sara = The circuit (4) requires 4 qubits and has two CNOT-gates in parallel, but the circuit (5) requires 3 qubits and has sequential CNOT-gates. Indeed, the use of the Choi-Jamiolkowski correspondence has reduced the number of qubits, but has increased the depth of the CNOT-gates. As mentioned in [11] ion trap hardware has less qubits, but performs better for greater circuit depth. In ZX-calculus and via Euler decomposition any one-qubit unitary gate is represented as follows: Bought Book Sara that is equal to: Indeed we ignore 'the' and 'ra' of positive transitive sentences in English and Persian respectively. Therefore according to [11] the parametrised quantum circuit of the diagram (6) is as follows:

Conclusion and Future Works
This paper extended the compact categorical semantics to analyse meanings of positive transitive sentences in Persian. It is necessary to introduce linear maps to represent the meaning of negative transitive sentences and grammatically more complex sentences in Persian. In this work the two sentences 'Sara ketab ra kharid' (in Persian) and 'Sara bought the book' (in English) are instantiated as parametrised quantum circuits. The meaning of the two sentences are the same but the appearence of the obtained quantum circuits are different. These circuits need to be compiled correctly, thus it is necessary to introduce a test measurement at the terminal of the circuits to give almost similar results for the meaning of the synonymous sentences in different languages. As a future prospect one may use the compiler t| ket to this aim, and run the circuits on the IBMQ and analyze the results.