WO2023061441A1 - 文本的量子线路确定方法、文本分类方法及相关装置 - Google Patents

文本的量子线路确定方法、文本分类方法及相关装置 Download PDF

Info

Publication number
WO2023061441A1
WO2023061441A1 PCT/CN2022/125081 CN2022125081W WO2023061441A1 WO 2023061441 A1 WO2023061441 A1 WO 2023061441A1 CN 2022125081 W CN2022125081 W CN 2022125081W WO 2023061441 A1 WO2023061441 A1 WO 2023061441A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
vocabulary
quantum
text corpus
qubits
Prior art date
Application number
PCT/CN2022/125081
Other languages
English (en)
French (fr)
Inventor
窦猛汉
孔小飞
李蕾
方圆
Original Assignee
合肥本源量子计算科技有限责任公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN202111194504.8A external-priority patent/CN115982312A/zh
Priority claimed from CN202111193343.0A external-priority patent/CN115964458A/zh
Application filed by 合肥本源量子计算科技有限责任公司 filed Critical 合肥本源量子计算科技有限责任公司
Publication of WO2023061441A1 publication Critical patent/WO2023061441A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying

Definitions

  • the present application belongs to the field of natural language processing, and in particular relates to a text quantum circuit determination method, a text classification method and related devices.
  • NLP Natural Language Processing
  • An object of the embodiments is to provide a text quantum circuit determination method, a text classification method and related devices, so as to at least partially improve the above problems.
  • An embodiment of the present application provides a text quantum circuit determination method, the method comprising:
  • the qubits of the quantum circuit and the sub-logic gates containing parameters are determined.
  • the embodiment of the present application provides a quantum circuit-based text classification method, the method comprising:
  • a prediction classification result of the text corpus is obtained according to the operation result.
  • the embodiment of the present application provides a text classification method, the method comprising:
  • association includes the relationship between each vocabulary and other vocabulary in the text corpus
  • a prediction classification result of the text corpus is obtained according to the operation result.
  • the embodiment of the present application provides a text quantum circuit determination device, including:
  • the first obtaining device is configured to obtain the part of speech of each vocabulary in the text corpus
  • the second obtaining device is configured to obtain the relevance between each vocabulary according to the semantics of the text corpus
  • the determining device is configured to determine the qubits of the quantum circuit and the sub-logic gates containing parameters according to the part of speech and the relevance.
  • the embodiment of the present application provides a quantum circuit-based text classification device, including:
  • the quantum circuit determination device is configured to construct the quantum circuit of the text to be classified by the above method
  • the prediction unit is configured to determine the operational parameter value of the parameter-containing subcircuit in the quantum circuit according to the meaning of each word in the text corpus, and to run and obtain the operation result of the quantum circuit, and to obtain all the parameters according to the operation result. Predictive classification results of the above text corpus.
  • the embodiment of the present application provides a text classification device, the device comprising:
  • association includes the relationship between each vocabulary and other vocabulary in the text corpus
  • the processing unit is further configured to obtain an operation result of the target quantum circuit, wherein the operation result includes an output result of qubits each time the target quantum circuit is operated;
  • the prediction unit is configured to obtain the prediction classification result of the text corpus according to the operation result.
  • the embodiment of the present application provides a storage medium, on which a computer program is stored, and the above method is implemented when the computer program is executed by a processor.
  • the embodiment of the present application provides an electronic device, the electronic device includes: a processor and a memory, and the memory is used to store one or more programs; when the one or more programs are executed by the processor When executing, implement the above method.
  • the text quantum circuit determination method includes obtaining the part of speech of each vocabulary in the text corpus; obtaining each vocabulary according to the semantics of the text corpus The correlation between them; according to the part of speech and the correlation, the qubits of the quantum circuit and the sub-logic gates containing parameters are determined. Therefore, quantum network technology is closely combined with text classification, and quantum circuits are used to accurately and quickly classify text.
  • FIG. 1 is a schematic flow chart of a text classification method provided in an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a method for determining a textual quantum circuit provided in an embodiment of the present application
  • FIG. 4 is a schematic flowchart of another method for determining quantum circuits in text provided in the embodiment of the present application.
  • Figure 5a is a schematic diagram of the n+tv+n syntax type provided by the embodiment of the present application.
  • Figure 5b is a schematic diagram of adj+n+tv+n syntax types provided by the embodiment of the present application.
  • Figure 5c is a schematic diagram of the n+tv+adj+n syntax type provided by the embodiment of the present application.
  • Figure 6a is a schematic diagram of the simplified syntax type of n+tv+n provided by the embodiment of the present application.
  • Figure 6b is a schematic diagram of the simplified syntax type of adj+n+tv+n provided by the embodiment of the present application.
  • Figure 6c is a schematic diagram of the simplified syntax type of n+tv+adj+n provided by the embodiment of the present application.
  • FIG. 7a is a schematic diagram of a parameter-containing subcircuit corresponding to the n+tv+n syntax type provided by the embodiment of the present application;
  • Fig. 7b is a schematic diagram of a parameter-containing subcircuit corresponding to the adj+n+tv+n syntax type provided by the embodiment of the present application;
  • FIG. 7c is a schematic diagram of a parameter-containing subcircuit corresponding to the n+tv+adj+n syntax type provided by the embodiment of the present application;
  • FIG. 8 is one of the schematic flow diagrams of a quantum circuit-based text classification method provided in the embodiment of the present application.
  • FIG. 9 is one of the schematic flowcharts of another quantum circuit-based text classification method provided by another embodiment of the present application.
  • FIG. 10 is a schematic diagram of the sub-steps of S107 provided in FIG. 9 of the embodiment of the present application.
  • FIG. 11 is one of the schematic flowcharts of a text classification method provided in another embodiment of the present application.
  • Fig. 12 is a schematic unit diagram of a textual quantum circuit determination device provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of units of a quantum circuit-based text classification device provided in an embodiment of the present application.
  • Fig. 14 is a schematic diagram of units of a text classification device provided by another embodiment of the present application.
  • setting and “connection” should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection, or Integral connection; it can be mechanical connection or electrical connection; it can be direct connection or indirect connection through an intermediary, and it can be the internal communication of two components.
  • connection should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection, or Integral connection; it can be mechanical connection or electrical connection; it can be direct connection or indirect connection through an intermediary, and it can be the internal communication of two components.
  • the existing technology converts the original text sequence information into a matrix through word embedding (Word Embedding), and uses the converted matrix as the input of the neural network in the next step.
  • word embedding is usually completed by the static word vector Word2Vec method.
  • LSTM Long Short Term Memory
  • the current natural language processing (nature language processing, NLP) Chinese classification task focuses on semantic construction and heavy computing power; the current NLP Chinese classification task utilizes the semantic information that exists in unstructured text is not sufficient, such as The syntactic components of words in the text, etc.; current NLP Chinese text classification relies on the semantic vectors of all words.
  • NLP native language processing
  • the embodiment of the present application provides a quantum-friendly Chinese text classification method, specifically a text quantum circuit determination method, a text classification method and related devices, which can explore the application of quantum computing in linguistics and benefit
  • NISQ noisy Intermediate-Scale Quantum
  • the text classification method provided by the embodiment of the present application completely directly encodes the text language, so that the interaction between words is used for entanglement to obtain a deeper and wider semantic and grammatical encoding.
  • FIG. 2 is a schematic structural diagram of an electronic device.
  • the electronic device includes a processor 10 , a memory 11 and a bus 12 .
  • the processor 10 and the memory 11 are connected through a bus 12 , and the processor 10 is used to execute executable modules stored in the memory 11 , such as computer programs.
  • the processor 10 may be an integrated circuit chip with signal processing capabilities.
  • each step of the text classification method can be completed by an integrated logic circuit of hardware in the processor 10 or instructions in the form of software.
  • processor 10 can be general-purpose processor, comprises central processing unit (Central Processing Unit, be called for short CPU), network processor (Network Processor, be called for short NP) etc.; Can also be digital signal processor (Digital Signal Processor, be called for short DSP) ), Application Specific Integrated Circuit (ASIC for short), Field Programmable Gate Array (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
  • CPU central processing unit
  • Network Processor Network Processor
  • NP Network Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • the memory 11 may include a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory.
  • RAM Random Access Memory
  • non-volatile memory such as at least one disk memory.
  • the bus 12 may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Only one bidirectional arrow is used in FIG. 2 , but it does not mean that there is only one bus 12 or one type of bus 12 .
  • ISA Industry Standard Architecture
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the memory 11 is used to store programs, such as programs corresponding to the text quantum circuit determining device and programs corresponding to the text classifying device.
  • Both the text quantum circuit determination device and the text classification device include at least one software function module that can be stored in the memory 11 in the form of software or firmware (firmware) or solidified in the operating system (operating system, OS) of the electronic device.
  • the processor 10 executes the program to implement the text classification method.
  • the electronic device provided in this embodiment of the present application further includes a communication interface 13 .
  • the communication interface 13 is connected to the processor 10 through a bus.
  • the electronic device can receive text information transmitted by other terminals through the communication interface 13 .
  • FIG. 2 is only a schematic structural diagram of a part of the electronic device, and the electronic device may also include more or fewer components than those shown in FIG. 2 , or have a configuration different from that shown in FIG. 2 .
  • Each component shown in Fig. 2 may be implemented by hardware, software or a combination thereof.
  • the embodiment of the present application provides a text quantum circuit determination method, as shown in Figure 3,
  • the qubits of the quantum circuit and the sub-logic gates containing parameters are used to realize the quantum coding of the text corpus, and the interaction between words is used. Entanglement obtains more deep and wide semantic and grammatical codes, and converts more deep and wide semantic and grammatical codes into quantum circuits.
  • a text corpus with certain semantics usually includes features representing the structure of the text corpus itself, as well as features that play a role in modifying the text corpus.
  • the resulting semantic changes are recessive features.
  • obtaining the relevance between each vocabulary according to the semantics of the text corpus described in step S32 includes:
  • the first association characterizing the salient features of the text corpus is obtained, including the association between “small” and “cow”, and the association between “cow” and “eat”. Sex, the correlation between “eat” and “grass”, the correlation between “tender” and “grass”.
  • the second association characterizing the latent features of the text corpus is obtained, including the association between "small” and “eat”, and the association between "eat” and “tender” sex.
  • the determining the qubits of the quantum circuit and the quantum logic gates containing parameters according to the part of speech and the relevance shown in step S33 includes:
  • the lexical representation for determining the part of speech of a noun is a qubit and Rx( ⁇ ), Rz( ⁇ ) and Rx( ⁇ ) gates acting on the qubit in turn; or,
  • the vocabulary that determines the part of speech of the adjective is represented as two qubits and an IQP layer acting on the two qubits, wherein: the IQP layer includes a Hadamard gate acting on each qubit respectively, and a gate acting on the two qubits simultaneously. CRz( ⁇ ) gates on qubits; or,
  • the vocabulary for determining the part of speech of transitive verbs is characterized by three sequentially adjacent qubits and an IQP layer acting on two groups of adjacent two qubits, wherein: the IQP layer includes Hadamard respectively acting on each qubit gate, and the CRz( ⁇ ) gate acting on two qubits simultaneously.
  • the sub-qubits representing the vocabulary with the first relevance are partially combined to obtain the total qubits representing the structure of the text corpus as the qubits of the quantum circuit.
  • Exemplary parametric sub-logic gates that determine the latent features representing the text corpus according to the second relevance are H gate and CNOT gate, and the encoding of latent features is realized through the entanglement gate CNOT gate.
  • step S33 determines the qubits of the quantum circuit and the sub-logic gates containing parameters according to the part of speech and the relevance, as shown in FIG. 4, the method further includes:
  • the quantum circuit encoding method of the text corpus is realized through the vector, and the graph represents the text corpus for quantum circuit encoding. Convenience and friendliness are easy to implement.
  • representing the text corpus with a graph according to the part-of-speech of each vocabulary in the text corpus and the relevance between each vocabulary in step S30 includes:
  • the text corpus represented by the graph can be directly mapped to the quantum circuit.
  • mapping When mapping, the vocabulary of each part of speech is mapped to the corresponding sub-qubits and sub-qubits containing parameters, and the sub-qubits corresponding to different parts of speech are merged according to the first relevance, and then the second relevance is mapped to the corresponding quantum logic gates.
  • the lexical mapping of the noun part of speech is a qubit and the Rx( ⁇ ), Rz( ⁇ ) and Rx( ⁇ ) gates that act on the qubit in turn;
  • the lexical mapping of the adjective part of speech is two qubits and the gates acting on the An IQP layer on the two qubits, wherein: the IQP layer includes a Hadamard gate acting on each qubit respectively and a CRz ( ⁇ ) gate acting on two qubits simultaneously;
  • the vocabulary mapping of the part of speech is three sequentially adjacent qubits and an IQP layer acting on two groups of adjacent two qubits, wherein: the IQP layer includes a Hadamard gate acting on each qubit respectively, and simultaneously CRz( ⁇ ) gate acting on two qubits.
  • the vocabulary mapping of the adjective part of speech is two qubits q3 and q4, and an IQP layer acting on the two qubits, the IQP layer includes acting on the qubits respectively The Hadamard gate on q3 and q4, and the CRz( ⁇ ) gate acting on two qubits q3 and q4 at the same time; the lexical mapping of the part of speech of transitive verbs is three sequentially adjacent qubits q0, q1 and q2.
  • FIG. 6a to FIG. 7a, and FIG. 6c to FIG. 7c is similar to the process of FIG. 6b to FIG. 7b, and will not be described in detail here.
  • a quantum circuit-based text classification method provided by another embodiment of the present application can be applied to the electronic device shown in FIG. 2 , but is not limited to it.
  • the text classification method includes: S81, S82.
  • S83 Determine the operational parameter value of the parameter-containing sub-circuit in the quantum circuit according to the meaning of each word in the text corpus, and run and obtain the operation result of the quantum circuit, and obtain the text corpus according to the operation result predict classification results.
  • the running results include the output results of the qubits each time the quantum circuit is run.
  • the quantum circuit is not only related to the part of speech and meaning of the vocabulary, but also closely related to the relevance.
  • a quantum circuit includes a plurality of qubits, a logic gate set on each qubit, and a logic gate set between the qubits.
  • the number of times the quantum circuit is run is set on the quantum computer, and each time the quantum circuit is run, the input of the quantum circuit is set to a pre-specified initial state. At the end of the run, all qubits of the quantum circuit are measured to obtain the result of the run.
  • the embodiment of the present application provides a text classification method based on quantum circuits.
  • the quantum circuit of the text to be classified is constructed; the quantum circuit is determined according to the meaning of each vocabulary in the text corpus.
  • Initialize the parameter value of the parameter-containing sub-circuit in the circuit run and obtain the operation result of the quantum circuit, and obtain the prediction classification result of the text corpus according to the operation result.
  • the running results include the output results of the qubits each time the quantum circuit is run. Therefore, quantum network technology is closely combined with text classification, and quantum circuits are used to accurately and quickly classify text.
  • the embodiment of the present application also provides a possible implementation method, the construction of the quantum circuit of the text to be classified in S81 is performed using the above method for determining the quantum circuit of the text.
  • this embodiment of the present application also provides a possible implementation.
  • the quantum circuit for constructing the text to be classified described in S81 includes S81-1, S81-2, S81-3, and S81-4.
  • FIG. 5a, FIG. 5b and FIG. 5c respectively represent different sentence grammar types.
  • FIG. 5a shows n+tv+n syntax type
  • FIG. 5b shows adj+n+tv+n syntax type
  • FIG. 5c shows n+tv+adj+n syntax type.
  • n is a name
  • tv is a transitive verb
  • adj is an adjective.
  • the target parameter-containing subcircuit is a parameter-containing subcircuit corresponding to the syntax type of the sentence.
  • FIG. 7 a shows the parameter-containing sub-circuit corresponding to the n+tv+n syntax type
  • Figure 7b shows the parameter-containing sub-circuit corresponding to the adj+n+tv+n syntax type
  • Figure 7c shows the parameter-containing sub-circuit corresponding to the n+tv+adj+n syntax type Contains parametric subcircuits.
  • the parametric sub-circuit in the embodiment of the present application may also be understood as a parametric sub-circuit.
  • words with the same part of speech may have different meanings.
  • school and home which are both nouns, have different meanings
  • eating and throwing both of which are verbs
  • verbs have different meanings.
  • the sentence grammar types of the two sentences are the same, and they correspond to the same parameter-containing subcircuit. However, the meanings of eating and falling are different, and the initial parameters of the logic gates in the parametric sub-circuits are different.
  • FIG. 6a, FIG. 6b and FIG. 6c respectively represent different sentence grammar types after simplification.
  • FIG. 6a shows the condensed grammar type of n+tv+n
  • FIG. 6b shows the condensed grammar type of adj+n+tv+n
  • FIG. 6c shows the condensed grammar type of n+tv+adj+n.
  • the sub-circuits containing parameters correspond to the simplified syntax types, so as to avoid exceeding the capability of quantum computers.
  • the parametric subcircuit includes at least one IQP layer acting on the two qubits, wherein: the IQP layer includes an IQP layer acting on each qubit respectively Hadamard gate, and CRz( ⁇ ) gate acting on two qubits simultaneously.
  • the initialization parameters of the logic gates in the parameter sub-circuit can be an example initialization parameter of adj [[0.1133103]], an example initialization parameter of n [0.26733895, 0.6874017, 0.93166275], an example initialization parameter of tv [[0.07656308 , 0.6977936]].
  • the process of determining the parameter-containing sub-circuit corresponding to the syntax type of the sentence is carried out using the method for determining the quantum circuit of the text as above.
  • the method further includes:
  • S82 specifically includes:
  • step S822 according to the operation result, the predicted classification result of the text corpus is obtained; including:
  • the definition of the cost function is as follows:
  • L ⁇ (P) represents the operation result
  • L(P) represents the real label
  • C( ⁇ ) represents the cost function
  • the general state of a qubit is a linear combination of superposition:
  • 2 1.
  • each sentence of Chinese text has been encoded into a quantum circuit, and the corresponding output quantum state is represented by
  • , which defines the running result i 0 or 1,
  • 0> state which can also be understood as the measurement value corresponding to the collapse of the quantum state to the 0 state, and the measurement value is used as the operation result
  • 1> state Indicates the operation result represented by the quantum state
  • step S823 modifying the initialization parameter value according to the predicted classification result to obtain an updated parameter value includes:
  • the text classification method provided by the embodiment of the present application uses quantum coding syntax to focus on the semantic information of the interaction between words, so as to obtain deeper and more diverse semantic information compared with traditional semantic coding information.
  • a semantic vector that can be represented by billions of bits in classical bits can be realized through a small number of qubits, thus showing quantum advantages.
  • a text classification method provided in the embodiment of the present application can be applied to, but not limited to, the electronic device shown in FIG. 2 . Please refer to FIG. 9 for a specific process.
  • the text classification method includes: S107 , S108 and S109 .
  • relevance includes the relationship between each word and other words in the text corpus.
  • the target quantum circuit is not only related to the part of speech and meaning of the vocabulary, but also closely related to the relevance.
  • the entanglement between words is used to obtain a deeper and wider semantic and grammatical encoding, and the deeper and wider semantic and grammatical encoding is converted into the target quantum circuit.
  • the target quantum circuit includes a plurality of qubits, logic gates on each qubit and logic gates between the qubits.
  • the running result includes the output result of the qubit each time the target quantum circuit is run.
  • the number of times to run the target quantum circuit is set on the quantum computer, and each time the target quantum circuit is run, the input of the target quantum circuit is set to a pre-specified initial state. At the end of the run, all qubits of the target quantum circuit are measured to obtain the run result.
  • the embodiment of the present application provides a text classification method, which converts the text corpus into the target quantum circuit according to the part of speech, meaning and relevance of each vocabulary in the text corpus; wherein, the relevance includes each vocabulary and text The relationship between other words in the corpus; the operation result of the target quantum circuit is obtained, wherein the operation result includes the output result of the qubit each time the target quantum circuit is run; the prediction classification result of the text corpus is obtained according to the operation result. Therefore, quantum network technology is closely combined with text classification, and the target quantum circuit is used to accurately and quickly classify text.
  • DisCoPy Distributional Compositional Categorical Python
  • DisCoPy can generate sentence grammatical types from the meaning of text sentences, calculate a state vector, and then convert the state vector into binary classification labels. Different labels correspond to different sentence grammatical types.
  • the advantage of DisCoPy is that it can generate tensor networks.
  • S107 includes S107-1, S107-2, S107-3, and S107-4.
  • FIG. 5a, FIG. 5b and FIG. 5c respectively represent different sentence grammar types.
  • FIG. 5a shows n+tv+n syntax type
  • FIG. 5b shows adj+n+tv+n syntax type
  • FIG. 5c shows n+tv+adj+n syntax type.
  • n is a name
  • tv is a transitive verb
  • adj is an adjective.
  • the target quantum frame is a quantum frame corresponding to the syntax type of the sentence.
  • FIG. 7a, FIG. 7b and FIG. 7c show different quantum frames respectively.
  • Figure 7a shows the quantum frame corresponding to the n+tv+n syntax type
  • Figure 7b shows the quantum frame corresponding to the adj+n+tv+n syntax type
  • Figure 7c shows the quantum frame corresponding to the n+tv+adj+n syntax type.
  • the quantum frame in the embodiment of the present application can also be understood as a subcircuit with parameters.
  • FIG. 6a, FIG. 6b and FIG. 6c respectively represent different sentence grammar types after simplification.
  • FIG. 6a shows the condensed grammar type of n+tv+n
  • FIG. 6b shows the condensed grammar type of adj+n+tv+n
  • FIG. 6c shows the condensed grammar type of n+tv+adj+n.
  • the quantum frameworks correspond to the simplistic syntax types respectively, avoiding exceeding the capabilities of quantum computers.
  • the quantum framework includes an IQP layer located between two qubits, the IQP layer includes Hadamard gates acting on the two qubits respectively, and acting on the two qubits simultaneously CRz gate.
  • the number of Hadamard gates is the same as the number of vocabulary, and the number of CRz gates is related to the number of adjectives and verbs in a sentence.
  • the initialization parameters of the adj example [[0.1133103]]
  • the initialization parameters of the n example [0.26733895, 0.6874017, 0.93166275]
  • the example initialization parameters of tv [[0.07656308, 0.6977936] ]].
  • the embodiment of the present application also provides a possible implementation, please refer to Figure 11, based on the part of speech, meaning and relevance of each vocabulary in the text corpus, the Before the text corpus is converted into the target quantum circuit, the text classification method also includes: S101, S102, S103, S104, S105 and S106.
  • the expression of the cost function for optimizing the training parameters is:
  • L ⁇ (P) represents the predicted classification result
  • L(P) represents the real label
  • C( ⁇ ) represents the cost function
  • the quantum circuit is optimized using a method of simultaneous perturbation stochastic approximation (Simultaneous Perturbation Stochastic Approximation).
  • the embodiment of the present application also provides a possible implementation method for obtaining the expression of the predicted classification result of the text corpus according to the operation result, please refer to the following:
  • L ⁇ (P) characterizes the predicted classification result, Indicates the operation result represented by the quantum state
  • quantum computing it represents an orthogonal basis vector, which is related to 0 and 1 in the running results of the measurement, and the general state of the qubit is a linear combination of superposition: , where.
  • 0> state which can also be understood as the measurement value corresponding to the collapse of the quantum state to the 0 state, and the measurement value is used as the operation result;
  • 1> state similarly, it can also be understood as the measurement value corresponding to the collapse of the quantum state to the 1 state, and the measurement value is used as the operation result;
  • the text classification method provided by the embodiment of the present application uses quantum coding syntax to focus on the semantic information of the interaction between words, so as to obtain deeper and more diverse semantic information compared with traditional semantic coding information.
  • a semantic vector that can be represented by billions of bits in classical bits can be realized through a small number of qubits, thus showing quantum advantages.
  • FIG. 12 is a textual quantum circuit determination device provided by an embodiment of the present application.
  • the textual quantum circuit determination device can be applied to the above-mentioned electronic equipment.
  • the device for determining the quantum circuit of the text includes: a first obtaining device 91 , a second obtaining device 92 and a determining device 93 .
  • the first obtaining means 91 is configured to obtain the part of speech of each vocabulary in the text corpus
  • the second obtaining means 92 is configured to obtain the relevance between each vocabulary according to the semantics of the text corpus
  • the determining means 93 is configured to determine the qubits of the quantum circuit and the sub-logic gates containing parameters according to the part of speech and the relevance.
  • FIG. 13 is a quantum circuit-based text classification device provided by an embodiment of the present application.
  • the text classification device can be applied to the above-mentioned electronic equipment.
  • the quantum circuit determination device of the text includes:
  • a quantum circuit determination device 101 and a prediction unit 102 are connected to each other.
  • the quantum circuit determination device 101 is configured to construct the quantum circuit of the text to be classified according to the above method
  • the prediction unit 102 is configured to determine the operational parameter value of the parameter-containing subcircuit in the quantum circuit according to the meaning of each word in the text corpus, and to run and obtain the operation result of the quantum circuit, and obtain A predicted classification result of the text corpus.
  • FIG. 14 is a text classification device provided by an embodiment of the present application.
  • the text classification device is applied to the above-mentioned electronic device.
  • the text classification device includes: a processing unit 201 and a prediction unit 202 .
  • the processing unit 201 is configured to convert the text corpus into target quantum circuits according to the part of speech, meaning and relevance of each vocabulary in the text corpus.
  • the processing unit 201 may execute the above S107.
  • the processing unit 201 is also configured to acquire the running result of the target quantum circuit, wherein the running result includes the output result of the qubits each time the target quantum circuit is run.
  • the processing unit 201 may execute the above S108.
  • the prediction unit 202 is configured to obtain the predicted classification result of the text corpus according to the running result.
  • the predicting unit 202 may perform the above S109.
  • the processing unit 201 is also used to determine the sentence grammar type corresponding to the text corpus according to the part-of-speech and relevance of each vocabulary in the text corpus; determine the target quantum frame according to the sentence grammar type; wherein, the target quantum frame is The quantum frame corresponding to the sentence grammar type; according to the meaning of each vocabulary in the text corpus, determine the initial parameters of the logic gate in the target quantum frame; set the parameters of the logic gate in the target quantum frame according to the initial parameters, and complete the goal Transformation of quantum circuits.
  • the processing unit 201 may execute the above S107-1 to S107-4.
  • the embodiment of the present application also provides a storage medium, the storage medium stores computer instructions and programs, and when the computer instructions and programs are read and run, execute the text classification method of the above-mentioned embodiments.
  • the storage medium may include memory, flash memory, registers, or a combination thereof.
  • an electronic device is provided below, which may be a computer or a server device. As shown in FIG. 2, the electronic device can implement the above-mentioned text quantum circuit determination method and text classification method; specifically, the electronic device includes: a processor 10, Memory 11, bus 12. Processor 10 may be a CPU. The memory 11 is used to store one or more programs, and when the one or more programs are executed by the processor 10, the text classification method of the above-mentioned embodiment is executed.
  • each block in a flowchart or block diagram may represent a module, program segment, or part of code that includes one or more Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.
  • each functional module in each embodiment of the present application may be integrated to form an independent part, each module may exist independently, or two or more modules may be integrated to form an independent part.
  • the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)

Abstract

一种文本的量子线路确定方法、文本分类方法及相关转置,文本的量子线路确定方法包括获取文本语料中各个词汇的词性(S31);根据文本语料的语义获得各个词汇之间的关联性(S32);根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门(S33)。从而量子网络技术与文本分类紧密的结合在一起,利用量子线路准确快速地对文本进行分类。

Description

文本的量子线路确定方法、文本分类方法及相关装置
相关申请的交叉引用
本专利申请要求于2021年10月13日提交的、发明名称为“一种文本分类方法、装置、存储介质及电子设备”、申请号为CN 202111194504.8的中国专利申请的优先权;以及2021年10月13日提交的、发明名称为“文本的量子线路确定方法、装置、存储介质及电子设备”、申请号为CN 202111193343.0的中国专利申请的优先权,所述专利申请在此全部引入作为参考。
技术领域
本申请属于自然语言处理领域,具体而言,涉及一种文本的量子线路确定方法、文本分类方法及相关装置。
背景技术
随着网络的发展,网络中的数据文本的数量越大。在大数据快速发展的今天,对于网络中的数据文本进行处理的自然语言处理(NLP,Natural Language Processing)被人们所关注。而在自然语言处理中一个很重的分支是文本分类。
量子网络作为当下的前沿技术,在各个领域都在崭露头角。如何将文本分类与量子网络进行结合,成为了当下亟待解决的问题。
发明内容
实施例的一个目的是提供一种文本的量子线路确定方法、文本分类方法及相关装置,以至少部分改善上述问题。
本申请的一个实施例提供了一种文本的量子线路确定方法,所述方法包括:
获取文本语料中各个词汇的词性;
根据文本语料的语义获得各个词汇之间的关联性;
根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
第二方面,本申请实施例提供一种基于量子线路的文本分类方法,所述方法包括:
根据上述的方法构建待分类文本的量子线路;
依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果;
依据所述运行结果获取所述文本语料的预测分类结果。
第三方面,本申请实施例提供一种文本分类方法,所述方法包括:
依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路;
其中,所述关联性包括每一个词汇与所述文本语料中的其他词汇之间的关系;
获取所述目标量子线路的运行结果,其中,所述运行结果包括每一次运行所述目标量子线路时量子位的输出结果;
依据所述运行结果获取所述文本语料的预测分类结果。
第四方面,本申请实施例提供一种文本的量子线路确定装置,包括:
第一获取装置,被配置为获取文本语料中各个词汇的词性;
第二获取装置,被配置为根据文本语料的语义获得各个词汇之间的关联性;
确定装置,被配置为根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
第五方面,本申请实施例提供一种基于量子线路的文本分类装置,包括:
量子线路确定装置,被配置为上述的方法构建待分类文本的量子线路;
预测单元,被配置为依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果。
第六方面,本申请实施例提供一种文本分类装置,所述装置包括:
处理单元,用于依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路;
其中,所述关联性包括每一个词汇与所述文本语料中的其他词汇之间的关系;
所述处理单元还用于获取所述目标量子线路的运行结果,其中,所述运行结果包括每一次运行所述目标量子线路时量子位的输出结果;
预测单元,用于依据所述运行结果获取所述文本语料的预测分类结果。
第七方面,本申请实施例提供一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述的方法。
第八方面,本申请实施例提供一种电子设备,所述电子设备包括:处理器和存储器,所述存储器用于存储一个或多个程序;当所述一个或多个程序被所述处理器执行时,实现上述的方法。
相对于现有技术,本申请实施例所提供的一种文本的量子线路确定方法以及文本分类方法,文本的量子线路确定方法包括获取文本语料中各个词汇的词性;根据文本语料的语义获得各个词汇之间的关联性;根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。从而量子网络技术与文本分类紧密的结合在一起,利用量子线路准确快速地对文本进行分类。
为使本申请的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它相关的附图。
图1为本申请实施例提供的一种文本分类方法的流程示意图;
图2为本申请实施例提供的电子设备的结构示意图;
图3为本申请实施例提供的一种文本的量子线路确定方法的流程示意图;
图4为本申请实施例提供的另一种文本的量子线路确定方法的流程示意图;;
图5a为本申请实施例提供的n+tv+n语法类型示意图;
图5b为本申请实施例提供的adj+n+tv+n语法类型示意图;
图5c为本申请实施例提供的n+tv+adj+n语法类型示意图;
图6a为本申请实施例提供的n+tv+n精简后的语法类型示意图;
图6b为本申请实施例提供的adj+n+tv+n精简后的语法类型示意图;
图6c为本申请实施例提供的n+tv+adj+n精简后的语法类型示意图;
图7a为本申请实施例提供的n+tv+n语法类型对应的含参量子线路示意图;
图7b为本申请实施例提供的adj+n+tv+n语法类型对应的含参量子线路示意图;
图7c为本申请实施例提供的n+tv+adj+n语法类型对应的含参量子线路示意图;
图8为本申请实施例提供的一种基于量子线路的文本分类方法的流程示意图之一;
图9为本申请另一实施例提供的另一种基于量子线路的文本分类方法的流程示意图之一;
图10为本申请实施例图9提供的S107的子步骤示意图;
图11为本申请另一实施例提供的文本分类方法的流程示意图之一;
图12为本申请实施例提供的一种文本的量子线路确定装置的单元示意图;
图13为本申请实施例提供的一种基于量子线路的文本分类装置的单元示意图。
图14为本申请另一实施例提供的一种文本分类装置的单元示意图。
具体实施方式
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。
因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本申请的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
在本申请的描述中,需要说明的是,术语“上”、“下”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,或者是该申请产品使用时惯常摆放的方位或位置关系,仅是为了便于描述本申请和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本申请的限制。
在本申请的描述中,还需要说明的是,除非另有明确的规定和限定,术语“设置”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本申请中的具体含义。
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
现有技术如图1所示,将原始文本序列信息通过词嵌入(Word Embedding)方式转 化为矩阵,将转换获得的矩阵作为下一步神经网络的输入。其中,词嵌入通常采用静态词向量Word2Vec方法完成。或者,将词嵌入得到的矩阵输入到长短时记忆网络(Long Short Term Memory,LSTM),进行句子语义特征的学习,通过遗忘、记忆等策略提取句子的深度语义特征,最后通过一层全连接进行情感标签(积极,中立,消极)的输出。
经发明人大量实践和总结发现:当前自然语言处理(nature language processing,NLP)中文分类任务重对于语义构建重算力;当前NLP中文分类任务利用非结构化文本存在的语义信息并不充分,比如文本中词的句法成分等;当前NLP中文文本分类依赖于所有词的语义向量。
为了克服以上问题,本申请实施例提供了一种针对量子友好的中文文本分类方法,具体为文本的量子线路确定方法、文本分类方法及相关装置,可以探索量子计算在语言学中的应用,利于深究语言深度的含义,对于含噪声的中型量子(Noisy Intermediate-Scale Quantum,NISQ)时代,不同于当前的深度学习等AI技术对于语法结构和含义是进行大量的学习习得的。本申请实施例提供的文本分类方法完全是对于文字语言进行直接的编码,从而利用词之间的相互作用进行纠缠得到更加深度和广度的语义和语法的编码。
具体地,本申请实施例提供了一种电子设备,可以是计算机设备或服务器设备。请参照图2,电子设备的结构示意图。电子设备包括处理器10、存储器11、总线12。处理器10、存储器11通过总线12连接,处理器10用于执行存储器11中存储的可执行模块,例如计算机程序。
处理器10可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,文本分类方法的各步骤可以通过处理器10中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器10可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital Signal Processor,简称DSP)、专用集成电路(Application Specific Integrated Circuit,简称ASIC)、现场可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
存储器11可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。
总线12可以是ISA(Industry Standard Architecture)总线、PCI(Peripheral Component Interconnect)总线或EISA(Extended Industry Standard Architecture)总线等。图2中仅用一个双向箭头表示,但并不表示仅有一根总线12或一种类型的总线12。
存储器11用于存储程序,例如文本量子线路确定装置对应的程序、文本分类装置对应的程序。文本量子线路确定装置及文本分类装置均包括至少一个可以软件或固件(firmware)的形式存储于存储器11中或固化在电子设备的操作系统(operating system,OS)中的软件功能模块。处理器10在接收到执行指令后,执行所述程序以实现文本分类方法。
可能地,本申请实施例提供的电子设备还包括通信接口13。通信接口13通过总线与处理器10连接。电子设备可以通过通信接口13接收其他终端传输的文本信息。
应当理解的是,图2所示的结构仅为电子设备的部分的结构示意图,电子设备还可包括比图2中所示更多或者更少的组件,或者具有与图2所示不同的配置。图2中所示的各组件可以采用硬件、软件或其组合实现。
本申请的实施例提供了一种文本的量子线路确定方法,如图3所示,
S31、获取文本语料中各个词汇的词性;
S32、根据文本语料的语义获得各个词汇之间的关联性;其中,关联性包括每一个词汇与文本语料中的其他词汇之间的关系;
S33、根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
本实施例通过对文本语料中的各个词汇的词性、各个词汇之间的关联性确定量子线路的量子比特以及含参量子逻辑门,实现了文本语料的量子编码,利用词之间的相互作用进行纠缠得到更具有深度和广度的语义和语法的编码,将更具有深度和广度的语义和语法的编码转换为量子线路。
可以理解的是,具有一定语义的文本语料通常包括表示文本语料结构本身的特征,以及在文本语料中起修饰作用的特征,表示文本语料结构本身的特征为显性特征,而起修饰作用的特征引起的语义变化为隐性特征。
示例性的,“牛吃草”是结构本身的特征,“小牛吃嫩草”,“小”和“嫩”则是在文本语料中起修饰作用的特征。
可选的,步骤S32所述的根据文本语料的语义获得各个词汇之间的关联性,包括:
S321,根据文本语料的语义获取表征所述文本语料的显性特征的第一关联性;
示例性的,根据文本语料的语义获取表征所述文本语料的显性特征的第一关联性,有“小”与“牛”之间的关联性,“牛”与“吃”之间的关联性,“吃”与“草”之间的关联性,“嫩”与“草”之间的关联性。
S322,根据文本语料的语义获取表征所述文本语料的隐性特征的第二关联性;
示例性的,根据文本语料的语义获取表征所述文本语料的隐性特征的第二关联性,有“小”与“吃”之间的关联性,“吃”与“嫩”之间的关联性。
可选的,步骤S33所示的所述根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门,包括:
S331、确定表示每种词性的词汇的子量子比特、以及含参量子逻辑门;
示例性的,确定名词词性的词汇表征为一个量子比特和依次作用在该量子比特上的Rx(θ)、Rz(θ)和Rx(θ)门;或,
确定形容词词性的词汇表征为两个量子比特和作用在所述两个量子比特上的一个IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门;或,
确定及物动词词性的词汇表征为三个依次相邻的量子比特和作用在两组相邻两个量子比特上的IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门。
S332、根据所述第一关联性对所述子量子比特进行处理获得表征文本语料结构的总量子比特作为量子线路的量子比特;
示例性的,对表征具有所述第一关联性的词汇的所述子量子比特进行处理部分合并处理获得表征文本语料结构的总量子比特作为量子线路的量子比特。
S333、根据所述第二关联性确定表征所述文本语料的隐性特征的量子逻辑门。
示例性的根据所述第二关联性确定表征所述文本语料的隐性特征的含参量子逻辑门为H门和CNOT门,通过纠缠门CNOT门实现隐性特征的编码。
可选的,步骤S33根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门之前,如图4所示,所述方法还包括:
S30、根据所述文本语料中各个词汇的词性和各个词汇之间的关联性用图表示所述文本语料。
通过图表示文本语料,然后直接基于图表示的文本语料进行量子线路的映射,相比文本语料转换为向量,在通过向量实现文本语料的量子线路的编码方式,图表示文本语料进行量子线路的编码方便友好容易实现。
可选的,步骤S30所述的根据所述文本语料中各个词汇的词性和各个词汇之间的关联性用图表示所述文本语料,包括:
S301、根据所述文本语料中各个词汇的词性和各个词汇之间的关联性确定所述文本语料的结构初始图,所述结构初始图中不同词性的各个词汇水平放置,各个词汇之间的关联性以U型折线表示;如图5a至图5c所示。
S302、对所述结构初始图进行简化处理得到结构简图,所述结构简图中不同词性的各个词汇错落放置,各个词汇之间的关联性以U型折线或直线表示。如图6a至图6c所示。
然后将图表示的文本语料直接映射为量子线路即可。
映射时,每种词性的词汇映射为对应的子量子比特、以及含参量子逻辑门,并根据第一关联性进行不同词性对应的子量子比特的合并,然后将第二关联性映射为的对应的量子逻辑门。
具体的,名词词性的词汇映射为一个量子比特和依次作用在该量子比特上的Rx(θ)、Rz(θ)和Rx(θ)门;形容词词性的词汇映射为两个量子比特和作用在所述两个量子比特上的一个IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门;及物动词词性的词汇映射为三个依次相邻的量子比特和作用在两组相邻两个量子比特上的IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门。
以图6b到图7b为例进行说明,形容词词性的词汇映射为两个量子比特q3和q4,及作用在所述两个量子比特上的一个IQP层,所述IQP层包括分别作用在量子比特q3和q4上的Hadamard门、以及同时作用在两个量子比特q3和q4上的CRz(θ)门;及物动词词性的词汇映射为三个依次相邻的量子比特q0、q1和q2,作用在相邻两个量子比特q0和q1上的IQP层以及q1和q2上的IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门。主语名词由于与形容词之间存在第一关联关系,所以,映射主语名词的一个量子比特Q4与映射形容词的量子比特q4合并;宾语名词由于与及物动词之间存在第一关联关系,所以,映射宾语名词的一个量子比特Q2与映射及物动词的量子比特q2合并;而形容词和及物动词之间存在第二关联关系,所以将该第二关联关系映射为作用在表征形容词的量子比特q3和表征形容词的量子比特q0;具体的,映射为作用在q3上的H门,以及作用在q3和q0上的CNOT门,由于且在图6b所示的文本预料中,形容词在及物动词之前,其中,q3为CNOT门的控制比特,q0为CNOT门的被控比特。
图6a到图7a、以及图6c到图7c的过程类似图6b到图7b的过程,在此并不展开详细描述。
本申请另一实施例提供的一种基于量子线路的文本分类方法,可以但不限于应用于图2所示的电子设备,具体的流程,请参考图8,文本分类方法包括:S81、S82。
S81,根据上述的文本的量子线路确定方法构建待分类文本的量子线路;
S83,依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果。其中,运行结果包括每一次运行量子线路时量子位的输出结果。
本实施例中量子线路不仅仅与词汇的词性、含义相关,还与关联性的关系密切。通过对文字语言进行直接的编码,利用词之间的相互作用进行纠缠得到更具有深度和广度的语义和语法的编码,将更具有深度和广度的语义和语法的编码转换为量子线路。
可以理解地,量子线路包括多个量子位、每一个量子位上设置的逻辑门以及量子位 之间设置的逻辑门。
可以理解地,在量子计算机上设置运行量子线路次数,每一次运行量子线路开始时,都将量子线路的输入设置为预先规定的初始状态。在运行结束时,测量量子线路的所有量子位,从而获得运行结果。
综上所述,本申请实施例提供了一种基于量子线路的文本分类方法,根据上述的文本的量子线路确定方法构建待分类文本的量子线路;依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的初始化参数值,并运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果。其中,运行结果包括每一次运行量子线路时量子位的输出结果。从而量子网络技术与文本分类紧密的结合在一起,利用量子线路准确快速地对文本进行分类。
在一种实施例中,对于S81中的内容,本申请实施例还提供了一种可能的实现方式,S81所述的构建待分类文本的量子线路采用如上的文本的量子线路的确定方法进行。
在一种实施例中,在图8的基础上,对于S81中的内容,本申请实施例还提供了一种可能的实现方式,S81所述的构建待分类文本的量子线路包括S81-1、S81-2、S81-3以及S81-4。
S81-1,依据文本语料中各个词汇的词性和关联性确定文本语料对应的句子语法类型。
请参考图5a、图5b以及图5c,图5a、图5b以及图5c分别表示不同的句子语法类型。其中,图5a表示n+tv+n语法类型,图5b表示adj+n+tv+n语法类型,图5c表示n+tv+adj+n语法类型。其中,n为名字,tv为及物动词,adj为形容词。
S81-2,依据句子语法类型确定目标含参量子线路。
其中,目标含参量子线路为与句子语法类型对应的含参量子线路。
需要说明的是,不同的句子语法类型对应不同的含参量子线路。请参考图7a、图7b以及图7c,图7a、图7b以及图7c分别表示不同的含参量子线路。图7a表示n+tv+n语法类型对应的含参量子线路,图7b表示adj+n+tv+n语法类型对应的含参量子线路,图7c表示n+tv+adj+n语法类型对应的含参量子线路。本申请实施例中的含参量子线路也可以理解为带参量子线路。
可以理解地,不同的含参量子线路中量子线路数量和逻辑门排布不同。
S81-3,依据文本语料中各个词汇的含义,确定对目标含参量子线路中的逻辑门的初始参数,完成量子线路的转换。
可以理解地,相同词性的词汇含义可以不同。例如都是名词的学校和家含义不同,都是动词的吃和摔含义不同。以两个句子进行示例说明,小明吃西瓜和小明摔西瓜,两个句子的句子语法类型相同,对应的相同的含参量子线路。但是吃和摔的含义不同,含参量子线路中的逻辑门的初始参数不相同。
在一种可能的实现方式中,受限于当前量子计算机的计算能力,需要对句子类型进行精简。请参考图6a、图6b以及图6c,图6a、图6b以及图6c分别表示精简后不同的句子语法类型。其中,图6a表示n+tv+n精简后的语法类型,图6b表示adj+n+tv+n精简后的语法类型,图6c表示n+tv+adj+n精简后的语法类型。含参量子线路分别与精简后的语法类型对应,避免超出了量子计算机的能力范围外。
请继续参考图7a、图7b以及图7c,含参量子线路包括至少一层作用在所述两个量子比特上的一个IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门。
可以预先设定,名词n=Word('女人',n),使用一个量子比特代表;形容词adj=Word('高兴',n@n.l),使用两个量子比特代表;及物动词tv=Word(款待,n.r@s@n.l),使用三个量子比特代表。请继续参考图7a、图7b以及图7c,及物动词对应的三个量子位通过 两个IPQ层作用,形容词对应的两个量子位通过一个IPQ层作用。
一种实施方式中,关于含参量子线路中的逻辑门的初始化参数,可以为adj示例初始化参数[[0.1133103]],n示例初始化参数[0.26733895、0.6874017、0.93166275],tv示例初始化参数[[0.07656308、0.6977936]]。
需要说明的是,图7a、图7b以及图7c中量子线路的线路深度为depth=1,即IQP层数为1,在一种可能的实现方式中线路深度可以更改,在此不做赘述。
可以理解的,句子语法类型对应的含参量子线路的确定过程采用如上的文本的量子线路的确定方法进行。在图8的基础上,可选的,步骤S82所述依据文本语料中各个词汇的含义确定所述含参量子线路的运行化参数值之前,所述方法还包括:
S82,训练所述量子线路获得所述各个含义词汇对应的用于确定所述运行化参数值的参数值。
可以理解的,S82具体包括:
S821,依据文本语料中各个词汇的含义确定待训练含参量子线路的初始化参数值,并运行和获取所述待训练量子线路的运行结果;
S822,依据所述运行结果获取所述文本语料的预测分类结果;
S823,根据所述预测分类结果修正所述初始化参数值得到更新参数值,然后重新执行运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果的步骤,直至预测分类结果接近真实结果;
S824,获得预测分类结果接近真实结果时的更新参数值用于确定所述运行化参数值的参数值。
可选到的,步骤S822所述依据所述运行结果获取所述文本语料的预测分类结果;包括:
根据所述运行结果获得对应真实标签的代价函数,根据代价函数获取所述文本语料的预测分类结果,其中:所述代价函数的定义如下:
C(Θ):=∑L(P) T·log(L Θ(P));
其中,LΘ(P)表征所述运行结果,L(P)表征所述真实标签,C(Θ)表征代价函数。
需要说明的是,在量子计算中,量子位的一般状态是叠加的线性组合:
Figure PCTCN2022125081-appb-000001
|0>,|1>表示正交基向量,与测量的运行结果中0和1相关,其中α,β∈C,|α| 2+|β| 2=1。
概率是由伯恩法则给出,
Figure PCTCN2022125081-appb-000002
i=0,1,其中P(0)=|α| 2,P(1)=|β| 2
经过上述步骤每个中文文本的句子已经编码为量子线路,相应输出的量子态用|P(Θ)>|表示,定义运行结果
Figure PCTCN2022125081-appb-000003
i=0或1,
Figure PCTCN2022125081-appb-000004
表示通过量子态|0>态表示的运行结果,也可以理解为测量是量子态坍塌到0态对应测测量值,该测量值作为运行结果;
Figure PCTCN2022125081-appb-000005
表示通过量子态|1>态表示的运行结果,类似的,也可以理解为测量是量子态坍塌到1态对应测测量值,该测量值作为运行结果;从而可以推导出:
Figure PCTCN2022125081-appb-000006
可选的,步骤S823所述根据所述预测分类结果修正所述初始化参数值得到更新参数值,包括:
根据所述预测分类结果基于同步扰动随机逼近算法修正所述初始化参数值得到更新参数值。
本申请实施例提供的文本分类方法采用量子编码语法-关注词之间的相互作用的语义信息,从而相对于传统的语义编码信息得到更深维度更多元的语义信息。通过少量的量子比特即可实现在经典比特中数以十亿计才能表示的语义向量,从而显现量子优势。
本申请实施例提供的一种文本分类方法,可以但不限于应用于图2所示的电子设备,具体的流程,请参考图9,文本分类方法包括:S107、S108以及S109。
S107,依据文本语料中各个词汇的词性、含义以及关联性,将文本语料转换为目标量子线路。
其中,关联性包括每一个词汇与文本语料中的其他词汇之间的关系。
目标量子线路不仅仅与词汇的词性、含义相关,还与关联性的关系密切。通过对文字语言进行直接的编码,利用词之间的相互作用进行纠缠得到更具有深度和广度的语义和语法的编码,将更具有深度和广度的语义和语法的编码转换为目标量子线路。
可以理解地,目标量子线路包括多个量子位、每一个量子位上设置的逻辑门以及量子位之间设置的逻辑门。
S108,获取目标量子线路的运行结果。
其中,运行结果包括每一次运行目标量子线路时量子位的输出结果。
可以理解地,在量子计算机上设置运行目标量子线路次数,每一次运行目标量子线路开始时,都将目标量子线路的输入设置为预先规定的初始状态。在运行结束时,测量目标量子线路的所有量子位,从而获得运行结果。
S109,依据运行结果获取文本语料的预测分类结果。
综上所述,本申请实施例提供了一种文本分类方法,依据文本语料中各个词汇的词性、含义以及关联性,将文本语料转换为目标量子线路;其中,关联性包括每一个词汇与文本语料中的其他词汇之间的关系;获取目标量子线路的运行结果,其中,运行结果包括每一次运行目标量子线路时量子位的输出结果;依据运行结果获取文本语料的预测分类结果。从而量子网络技术与文本分类紧密的结合在一起,利用目标量子线路准确快速地对文本进行分类。
在一种可能的实现方式中,为了将原始的文本语料编码为量子线路,需要用到DisCoPy(Distributional Compositional Categorical Python)工具。DisCoPy可以从文本句子的词义生成句子语法类型,计算出一个状态向量,然后将状态向量转化为二进制分类标签,不同的标签对应不同的句子语法类型。DisCoPy的优势在于可以生成张量网络。
在图9的基础上,对于S107中的内容,本申请实施例还提供了一种可能的实现方式,请参考图10,S107包括S107-1、S107-2、S107-3以及S107-4。
S107-1,依据文本语料中各个词汇的词性和关联性确定文本语料对应的句子语法类型。
请参考图5a、图5b以及图5c,图5a、图5b以及图5c分别表示不同的句子语法类型。其中,图5a表示n+tv+n语法类型,图5b表示adj+n+tv+n语法类型,图5c表示n+tv+adj+n语法类型。其中,n为名字,tv为及物动词,adj为形容词。
S107-2,依据句子语法类型确定目标量子框架。
其中,目标量子框架为与句子语法类型对应的量子框架。
需要说明的是,不同的句子语法类型对应不同的量子框架。请参考图7a、图7b以及图7c,图7a、图7b以及图7c分别表示不同的量子框架。图7a表示n+tv+n语法类型对应 的量子框架,图7b表示adj+n+tv+n语法类型对应的量子框架,图7c表示n+tv+adj+n语法类型对应的量子框架。本申请实施例中的量子框架也可以理解为带参量子线路。
可以理解地,不同的量子框架中量子线路数量和逻辑门排布不同。
S107-3,依据文本语料中各个词汇的含义,确定对目标量子框架中的逻辑门的初始参数。
可以理解的,相同词性的词汇含义可以不同。例如都是名词的学校和家含义不同,都是动词的吃和摔含义不同。以两个句子进行示例说明,小明吃西瓜和小明摔西瓜,两个句子的句子语法类型相同,对应的相同的量子框架。但是吃和摔的含义不同,目标量子框架中的逻辑门的初始参数不相同。
S107-4,依据初始参数对目标量子框架中的逻辑门的参数进行设定,完成目标量子线路的转换。
在一种可能的实现方式中,受限于当前量子计算机的计算能力,需要对句子类型进行精简。请参考图6a、图6b以及图6c,图6a、图6b以及图6c分别表示精简后不同的句子语法类型。其中,图6a表示n+tv+n精简后的语法类型,图6b表示adj+n+tv+n精简后的语法类型,图6c表示n+tv+adj+n精简后的语法类型。量子框架分别与精简后的语法类型对应,避免超出了量子计算机的能力范围外。
请继续参考图7a、图7b以及图7c,量子框架包括位于两个量子比特之间的IQP层,IQP层包括分别作用在两个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz门。
需要说明的是,Hadamard门的数量与词汇数量相同,CRz门的数量与句子中形容词和动词的数量相关。
可以预先设定,名词n=Word('女人',n),使用一个量子比特代表;形容词adj=Word('高兴',n@n.l),使用两个量子比特代表;及物动词tv=Word(款待,n.r@s@n.l),使用三个量子比特代表。请继续参考图7a、图7b以及图7c,及物动词对应的三个量子位通过两个IPQ层作用,形容词对应的量子位通过一个IPQ层作用。
关于量子框架中的逻辑门的初始化参数,一种实施方式中,可以为adj示例初始化参数[[0.1133103]],n示例初始化参数[0.26733895、0.6874017、0.93166275],tv示例初始化参数[[0.07656308、0.6977936]]。
需要说明的是,图7a、图7b以及图7c中线路深度为depth=1,即IQP层数为1,在一种可能的实现方式中线路深度可以更改,在此不做赘述。
在图9的基础上,关于如何对量子线路进行训练,本申请实施例还提供了一种可能的实现方式,请参考图11,在依据文本语料中各个词汇的词性、含义以及关联性,将文本语料转换为目标量子线路之前,文本分类方法还包括:S101、S102、S103、S104、S105以及S106。
S101,依据训练文本中各个词汇的词性和关联性,获取训练文本对应的待训练的量子框架。
S102,依据训练文本中各个词汇的含义,确定对待训练的量子框架中的逻辑门的训练参数。
S103,依据训练参数对待训练的量子框架中的逻辑门的参数进行设定,完成待训练的量子线路的转换。
S104,获取待训练的量子线路的训练结果。
S105,依据训练结果获取训练文本的训练分类结果。
S106,依据训练文本的真实标签和训练分类结果对训练参数进行优化,其中,优化后的训练参数用于作为文本分类时目标量子框架中的逻辑门的初始参数。
可选地,对训练参数进行优化的代价函数表达式为:
C(Θ):=∑L(P) T·log(L Θ(P));
其中,LΘ(P)表征预测分类结果,L(P)表征真实标签,C(Θ)表征代价函数。
可选地,使用同步扰动随机近似(Simultaneous Perturbation Stochastic Approximation)的方法优化量子线路。
在图9的基础上,关于依据运行结果获取文本语料的预测分类结果的表达式,本申请实施例还提供了一种可能的实现方式,请参考下文:
Figure PCTCN2022125081-appb-000007
其中,LΘ(P)表征所述预测分类结果,
Figure PCTCN2022125081-appb-000008
表示通过量子态|0>态表示的运行结果,
Figure PCTCN2022125081-appb-000009
表示通过量子态|1>态表示的运行结果。
需要说明的是,在量子计算中,表示正交基向量,与测量的运行结果中0和1相关,量子位的一般状态是叠加的线性组合:,其中。
概率是由伯恩法则给出,,i=0,1,其中。
经过上述步骤每个中文文本的句子已经编码为量子线路,相应输出的量子态用表示,定义运行结果,i=0,1;
Figure PCTCN2022125081-appb-000010
表示通过量子态|0>态表示的运行结果,也可以理解为测量是量子态坍塌到0态对应测测量值,该测量值作为运行结果;
Figure PCTCN2022125081-appb-000011
表示通过量子态|1>态表示的运行结果,类似的,也可以理解为测量是量子态坍塌到1态对应测测量值,该测量值作为运行结果;从而可以推导出:
Figure PCTCN2022125081-appb-000012
本申请实施例提供的文本分类方法采用量子编码语法-关注词之间的相互作用的语义信息,从而相对于传统的语义编码信息得到更深维度更多元的语义信息。通过少量的量子比特即可实现在经典比特中数以十亿计才能表示的语义向量,从而显现量子优势。
请参阅图12,图12为本申请实施例提供的一种文本的量子线路确定装置,可选的,该文本的量子线路确定装置可被应用于上文所述的电子设备。
文本的量子线路确定装置包括:第一获取装置91、第二获取装置92和确定装置93。
第一获取装置91,被配置为获取文本语料中各个词汇的词性;
第二获取装置92,被配置为根据文本语料的语义获得各个词汇之间的关联性;
确定装置93,被配置为根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
请参阅图13,图13为本申请实施例提供的一种基于量子线路的文本分类装置,可选的,该文本分类装置可被应用于上文所述的电子设备。
文本的量子线路确定装置包括:
量子线路确定装置101和预测单元102。
量子线路确定装置101,被配置为根据上述的方法构建待分类文本的量子线路;
预测单元102,被配置为依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果。
需要说明的是,本实施例所提供的文本分类装置,其可以执行上述方法流程实施例所示的方法流程,以实现对应的技术效果。为简要描述,本实施例部分未提及之处,可参考上述的实施例中相应内容。
请参阅图14,图14为本申请实施例提供的一种文本分类装置,可选的,该文本分类装置被应用于上文所述的电子设备。
文本分类装置包括:处理单元201和预测单元202。
处理单元201,用于依据文本语料中各个词汇的词性、含义以及关联性,将文本语料转换为目标量子线路。
其中,关联性包括每一个词汇与文本语料中的其他词汇之间的关系。可选地,处理单元201可以执行上述的S107。
处理单元201还用于获取目标量子线路的运行结果,其中,运行结果包括每一次运行目标量子线路时量子位的输出结果。可选地,处理单元201可以执行上述的S108。
预测单元202,用于依据运行结果获取文本语料的预测分类结果。可选地,预测单元202可以执行上述的S109。
在一种可能的实现方式中,处理单元201还用于依据文本语料中各个词汇的词性和关联性确定文本语料对应的句子语法类型;依据句子语法类型确定目标量子框架;其中,目标量子框架为与句子语法类型对应的量子框架;依据文本语料中各个词汇的含义,确定对目标量子框架中的逻辑门的初始参数;依据初始参数对目标量子框架中的逻辑门的参数进行设定,完成目标量子线路的转换。可选地,处理单元201可以执行上述的S107-1至S107-4。
需要说明的是,本实施例所提供的文本分类装置,其可以执行上述方法流程实施例所示的方法流程,以实现对应的技术效果。为简要描述,本实施例部分未提及之处,可参考上述的实施例中相应内容。
本申请实施例还提供了一种存储介质,该存储介质存储有计算机指令、程序,该计算机指令、程序在被读取并运行时执行上述实施例的文本分类方法。该存储介质可以包括内存、闪存、寄存器或者其结合等。
下面提供一种电子设备,可以是计算机或服务器设备,该电子设备如图2所示,可以实现上述的文本的量子线路确定方法及文本分类方法;具体的,该电子设备包括:处理器10,存储器11、总线12。处理器10可以是CPU。存储器11用于存储一个或多个程序,当一个或多个程序被处理器10执行时,执行上述实施例的文本分类方法。
在本申请所提供的实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用 的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。
所述功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其它的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化囊括在本申请内。不应将权利要求中的任何附图标记视为限制所涉及的权利要求。

Claims (25)

  1. 一种文本的量子线路确定方法,其特征在于,所述方法包括:
    获取文本语料中各个词汇的词性;
    根据文本语料的语义获得各个词汇之间的关联性;
    根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
  2. 如权利要求1所述的方法,其特征在于,根据文本语料的语义获得各个词汇之间的关联性,包括:
    根据文本语料的语义获取表征所述文本语料的显性特征的第一关联性;
    根据文本语料的语义获取表征所述文本语料的隐性特征的第二关联性。
  3. 如权利要求2所述的方法,其特征在于,所述根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门,包括:
    确定表示每种词性的词汇的子量子比特、以及含参量子逻辑门;
    根据所述第一关联性对所述子量子比特进行处理获得表征文本语料结构的总量子比特作为量子线路的量子比特;
    根据所述第二关联性确定表征所述文本语料的隐性特征的量子逻辑门。
  4. 如权利要求3所述的方法,其特征在于,所述确定表示每种词性的词汇的子量子比特、以及含参量子逻辑门;包括:
    确定名词词性的词汇表征为一个量子比特和依次作用在该量子比特上的Rx(θ)、Rz(θ)和Rx(θ)门;或,
    确定形容词词性的词汇表征为两个量子比特和作用在所述两个量子比特上的一个IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门;或,
    确定及物动词词性的词汇表征为三个依次相邻的量子比特和作用在两组相邻两个量子比特上的IQP层,其中:所述IQP层包括分别作用在每个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz(θ)门。
  5. 如权利要求3所述的方法,其特征在于,根据所述第一关联性对所述子量子比特进行处理获得表征文本语料结构的总量子比特作为量子线路的量子比特;
    对表征具有所述第一关联性的词汇的所述子量子比特进行部分合并处理获得表征文本语料结构的总量子比特作为量子线路的量子比特。
  6. 如权利要求3所述的方法,其特征在于,根据所述第二关联性确定表征所述文本语料的隐性特征的量子逻辑门,包括:
    根据所述第二关联性确定表征所述隐性特征的量子逻辑门为H门和CNOT门。
  7. 如权利要求1-6任一项所述的方法,其特征在于,根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门之前,所述方法还包括:
    根据所述文本语料中各个词汇的词性和各个词汇之间的关联性用图表示所述文本语料。
  8. 如权利要求7所述的方法,其特征在于,根据所述文本语料中各个词汇的词性和各个词汇之间的关联性用图表示所述文本语料,包括:
    根据所述文本语料中各个词汇的词性和各个词汇之间的关联性确定所述文本语料的结构初始图,所述结构初始图中不同词性的各个词汇水平放置,各个词汇之间的关联性以U型折线表示;
    对所述结构初始图进行简化处理得到结构简图,所述结构简图中不同词性的各个词汇错落放置,各个词汇之间的关联性以U型折线或直线表示。
  9. 一种基于量子线路的文本分类方法,其特征在于,所述方法包括:
    根据权利要求1-8任一项所述的方法构建待分类文本的量子线路;
    依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果;
    依据所述运行结果获取所述文本语料的预测分类结果。
  10. 如权利要求9所述的文本分类方法,其特征在于,所述依据文本语料中各个词汇的含义确定所述含参量子线路的初始化参数值之前,所述方法还包括:
    训练所述量子线路获得所述各个含义词汇对应的用于确定所述运行化参数值的参数值。
  11. 如权利要求10所述的文本分类方法,其特征在于,所述训练所述量子线路获得所述各个含义词汇对应的用于确定所述初始化参数值的参数具体值,包括:
    依据文本语料中各个词汇的含义确定待训练含参量子线路的初始化参数值,并运行和获取所述待训练量子线路的运行结果;
    依据所述运行结果获取所述文本语料的预测分类结果;
    根据所述预测分类结果修正所述初始化参数值得到更新参数值,然后重新执行运行和获取所述量子线路的运行结果,依据所述运行结果获取所述文本语料的预测分类结果的步骤,直至预测分类结果接近真实结果;
    获得预测分类结果接近真实结果时的更新参数值用于确定所述运行化参数值的参数值。
  12. 如权利要求11所述的文本分类方法,其特征在于,依据所述运行结果获取所述文本语料的预测分类结果;包括:
    根据所述运行结果获得对应真实标签的代价函数,根据代价函数获取所述文本语料的预测分类结果,其中:所述代价函数的定义如下:
    C(Θ):=ΣL(P)T·log(L Θ(P));
    其中,LΘ(P)表征所述运行结果,L(P)表征所述真实标签,C(Θ)表征代价函数。
  13. 如权利要求11所述的文本分类方法,其特征在于,根据所述预测分类结果修正所述初始化参数值得到更新参数值,包括:
    根据所述预测分类结果基于同步扰动随机逼近算法修正所述初始化参数值得到更新参数值。
  14. 一种文本分类方法,其特征在于,所述方法包括:
    依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路;
    其中,所述关联性包括每一个词汇与所述文本语料中的其他词汇之间的关系;
    获取所述目标量子线路的运行结果,其中,所述运行结果包括每一次运行所述目标量子线路时量子位的输出结果;
    依据所述运行结果获取所述文本语料的预测分类结果。
  15. 如权利要求14所述的文本分类方法,其特征在于,所述依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路的步骤,包括:
    依据所述文本语料中各个词汇的词性和所述关联性确定所述文本语料对应的句子语法类型;
    依据所述句子语法类型确定目标量子框架;
    其中,所述目标量子框架为与所述句子语法类型对应的量子框架;
    依据所述文本语料中各个词汇的含义,确定对所述目标量子框架中的逻辑门的初始参数;
    依据所述初始参数对所述目标量子框架中的逻辑门的参数进行设定,完成所述目标量子线路的转换。
  16. 如权利要求15所述的文本分类方法,其特征在于,所述量子框架包括位于两个量子比特之间的IQP层,所述IQP层包括分别作用在两个量子比特上的Hadamard门、以及同时作用在两个量子比特上的CRz门。
  17. 如权利要求15所述的文本分类方法,其特征在于,在依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路之前,所述方法还包括:
    依据训练文本中各个词汇的词性和关联性,获取训练文本对应的待训练的量子框架;
    依据所述训练文本中各个词汇的含义,确定对所述待训练的量子框架中的逻辑门的训练参数;
    依据所述训练参数对所述待训练的量子框架中的逻辑门的参数进行设定,完成待训练的量子线路的转换;
    获取所述待训练的量子线路的训练结果;
    依据所述训练结果获取所述训练文本的训练分类结果;
    依据所述训练文本的真实标签和所述训练分类结果对所述训练参数进行优化,其中,优化后的训练参数用于作为文本分类时目标量子框架中的逻辑门的初始参数。
  18. 如权利要求17所述的文本分类方法,其特征在于,对所述训练参数进行优化的代价函数表达式为:
    C(Θ):=ΣL(P)T·log(L Θ(P));
    其中,LΘ(P)表征所述预测分类结果,L(P)表征所述真实标签,C(Θ)表征代价函数。
  19. 如权利要求14所述的文本分类方法,其特征在于,所述依据所述运行结果获取所述文本语料的预测分类结果的表达式为:
    Figure PCTCN2022125081-appb-100001
    其中,LΘ(P)表征所述预测分类结果,
    Figure PCTCN2022125081-appb-100002
    表示通过量子态|0>态表示的运行结果,
    Figure PCTCN2022125081-appb-100003
    表示通过量子态|1>态表示的运行结果。
  20. 一种文本的量子线路确定装置,其特征在于,包括:
    第一获取装置,被配置为获取文本语料中各个词汇的词性;
    第二获取装置,被配置为根据文本语料的语义获得各个词汇之间的关联性;
    确定装置,被配置为根据所述词性和所述关联性确定量子线路的量子比特以及含参量子逻辑门。
  21. 一种文本分类装置,其特征在于,包括:
    量子线路确定装置,被配置为根据权利要求1-8任一项所述的方法构建待分类文本的量子线路;
    预测单元,被配置为依据文本语料中各个词汇的含义确定所述量子线路内的含参量子线路的运行化参数值,并运行和获取所述量子线路的运行结果,依据所述运行结果获取 所述文本语料的预测分类结果。
  22. 一种文本分类装置,其特征在于,所述装置包括:
    处理单元,用于依据文本语料中各个词汇的词性、含义以及关联性,将所述文本语料转换为目标量子线路;
    其中,所述关联性包括每一个词汇与所述文本语料中的其他词汇之间的关系;
    所述处理单元还用于获取所述目标量子线路的运行结果,其中,所述运行结果包括每一次运行所述目标量子线路时量子位的输出结果;
    预测单元,用于依据所述运行结果获取所述文本语料的预测分类结果。
  23. 如权利要求22所述的文本分类装置,其特征在于,所述处理单元还用于依据所述文本语料中各个词汇的词性和所述关联性确定所述文本语料对应的句子语法类型;依据所述句子语法类型确定目标量子框架;其中,所述目标量子框架为与所述句子语法类型对应的量子框架;依据所述文本语料中各个词汇的含义,确定对所述目标量子框架中的逻辑门的初始参数;依据所述初始参数对所述目标量子框架中的逻辑门的参数进行设定,完成所述目标量子线路的转换。
  24. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该计算机程序被处理器执行时实现如权利要求1-8或9-13或14-19中任一项所述的方法。
  25. 一种电子设备,其特征在于,包括:处理器和存储器,所述存储器用于存储一个或多个程序;当所述一个或多个程序被所述处理器执行时,实现如权利要求1-8或9-13或14-19中任一项所述的方法。
PCT/CN2022/125081 2021-10-13 2022-10-13 文本的量子线路确定方法、文本分类方法及相关装置 WO2023061441A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202111193343.0 2021-10-13
CN202111194504.8A CN115982312A (zh) 2021-10-13 2021-10-13 一种文本分类方法、装置、存储介质及电子设备
CN202111193343.0A CN115964458A (zh) 2021-10-13 2021-10-13 文本的量子线路确定方法、装置、存储介质及电子设备
CN202111194504.8 2021-10-13

Publications (1)

Publication Number Publication Date
WO2023061441A1 true WO2023061441A1 (zh) 2023-04-20

Family

ID=85987270

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/125081 WO2023061441A1 (zh) 2021-10-13 2022-10-13 文本的量子线路确定方法、文本分类方法及相关装置

Country Status (1)

Country Link
WO (1) WO2023061441A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556817A (zh) * 2024-01-10 2024-02-13 国开启科量子技术(安徽)有限公司 基于量子电路的文本检测方法、装置、设备及介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180267958A1 (en) * 2017-03-16 2018-09-20 Abbyy Development Llc Information extraction from logical document parts using ontology-based micro-models
CN111027702A (zh) * 2019-12-11 2020-04-17 合肥本源量子计算科技有限责任公司 一种实现量子线路替换的方法、装置、存储介质和电子装置
CN112712901A (zh) * 2021-01-14 2021-04-27 西京学院 基于语法量子长短时记忆模型及药物相互作用提取方法
CN112884153A (zh) * 2019-11-30 2021-06-01 华为技术有限公司 处理数据的方法和相关装置
CN112905736A (zh) * 2021-01-27 2021-06-04 郑州轻工业大学 一种基于量子理论的无监督文本情感分析方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180267958A1 (en) * 2017-03-16 2018-09-20 Abbyy Development Llc Information extraction from logical document parts using ontology-based micro-models
CN112884153A (zh) * 2019-11-30 2021-06-01 华为技术有限公司 处理数据的方法和相关装置
CN111027702A (zh) * 2019-12-11 2020-04-17 合肥本源量子计算科技有限责任公司 一种实现量子线路替换的方法、装置、存储介质和电子装置
CN112712901A (zh) * 2021-01-14 2021-04-27 西京学院 基于语法量子长短时记忆模型及药物相互作用提取方法
CN112905736A (zh) * 2021-01-27 2021-06-04 郑州轻工业大学 一种基于量子理论的无监督文本情感分析方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117556817A (zh) * 2024-01-10 2024-02-13 国开启科量子技术(安徽)有限公司 基于量子电路的文本检测方法、装置、设备及介质
CN117556817B (zh) * 2024-01-10 2024-05-24 国开启科量子技术(安徽)有限公司 基于量子电路的大模型生成文本检测方法、装置、设备

Similar Documents

Publication Publication Date Title
WO2020001373A1 (zh) 一种本体构建方法及装置
CN112528672B (zh) 一种基于图卷积神经网络的方面级情感分析方法及装置
US20230196014A1 (en) Stylistic Text Rewriting for a Target Author
US20230196127A1 (en) Method and device for constructing legal knowledge graph based on joint entity and relation extraction
US20220050967A1 (en) Extracting definitions from documents utilizing definition-labeling-dependent machine learning background
Zhang et al. A quantum-inspired sentiment representation model for twitter sentiment analysis
Augenstein et al. Lodifier: Generating linked data from unstructured text
CN110704576B (zh) 一种基于文本的实体关系抽取方法及装置
WO2022218186A1 (zh) 个性化知识图谱的生成方法、装置及计算机设备
WO2020244475A1 (zh) 用于语言序列标注的方法、装置、存储介质及计算设备
GB2587913A (en) System and method for language translation
Sarker A customizable pipeline for social media text normalization
WO2021208460A1 (zh) 语句补全方法、设备及可读存储介质
Tyagi et al. Demystifying the role of natural language processing (NLP) in smart city applications: background, motivation, recent advances, and future research directions
WO2023159767A1 (zh) 目标词语的检测方法、装置、电子设备及存储介质
WO2023061441A1 (zh) 文本的量子线路确定方法、文本分类方法及相关装置
Kabakus et al. TwitterSentiDetector: a domain-independent Twitter sentiment analyser
WO2019218809A1 (zh) 一种篇章级文本翻译方法及装置
Wei et al. Sentiment classification of tourism reviews based on visual and textual multifeature fusion
Barik et al. Analysis of customer reviews with an improved VADER lexicon classifier
Xiao et al. A practice of tourism knowledge graph construction based on heterogeneous information
CN115964458A (zh) 文本的量子线路确定方法、装置、存储介质及电子设备
Almansor et al. Transferring informal text in arabic as low resource languages: State-of-the-art and future research directions
Kearns et al. Resource and response type classification for consumer health question answering
CN111858899A (zh) 语句处理方法、装置、系统和介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22880377

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022880377

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022880377

Country of ref document: EP

Effective date: 20240513