Method of processing text semantic similarity using quantum neural network model

By introducing quantum data encoding, feature extraction and similarity calculation modules into quantum neural networks, the problem of inefficient efficiency of existing quantum neural networks when processing complex text semantic data is solved, and more efficient text semantic similarity analysis is achieved.

CN118821790BActive Publication Date: 2025-03-07HANGZHOU INNOVATION RES INST OF BEIJING UNIV OF AERONAUTICS & ASTRONAUTICS +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411304955.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-03-07
Estimated Expiration
2044-09-19

AI Technical Summary

Technical Problem

Existing quantum neural networks are less efficient when processing complex text semantic data, making it difficult to effectively analyze the correlation between semantics and perform cross-text comprehension.

Method used

A quantum neural network model is proposed, including a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a qubit measurement module and a network parameter optimization module. Through the encoding, evolution and measurement of quantum states, the similarity of text features can be extracted and calculated.

Benefits of technology

It significantly improves the performance of handling complex text semantic similarity analysis tasks, can effectively capture semantic information in text, breaks through the limitations of traditional quantum neural networks in complex text data processing, and expands its application fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118821790B_ABST
    Figure CN118821790B_ABST
Patent Text Reader

Abstract

The invention provides a method for processing text semantic similarity using a quantum neural network model, comprising: collecting a data set for a text semantic similarity analysis task, and performing standardized data preprocessing on the data set; constructing a quantum neural network model, comprising: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module, and a network parameter optimization module; using quantum states of a training set and a verification set to iteratively train and verify the quantum neural network model until a set threshold condition is met, and then terminating the training and verification, and obtaining a quantum neural network model for processing text semantic similarity analysis with optimal performance after terminating the training and verification; using the quantum state of a test set to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis, the method can process complex text semantic similarity analysis tasks, and improve the processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method for processing text semantic similarity using a quantum neural network model. Background Art

[0002] The rapid development of information technology has led to a surge in the amount of data, which in turn has increased the difficulty of handling large-scale and complex tasks, bringing unprecedented challenges to traditional machine learning algorithms. Neural networks, as a core technology in machine learning, have demonstrated significant performance in many fields. However, when dealing with large and complex tasks, the development and training of neural networks requires huge computing resources. With the gradual decline of the effect of Moore's Law and the gradual emergence of the physical limits of classical computing, the ability of traditional computing devices to handle these demanding tasks is increasingly restricted.

[0003] In this context, quantum computing, as a new way of physical computing, provides a unique solution to counter traditional computing technology and thermodynamic limitations. This computing method utilizes the basic principles of quantum mechanics, such as quantum state superposition and quantum entanglement, and can theoretically achieve exponential storage capacity and parallel processing capabilities that exceed traditional computing, opening up new ways to solve complex problems in traditional machine learning algorithms. With the emergence of noisy medium-scale quantum processors with stable computing performance, quantum machine learning and quantum neural networks have become a hot topic in academia and industry. It combines the efficiency of machine learning technology with the computing power of quantum systems, showing great potential in promoting the development of artificial intelligence.

[0004] Currently, the surge in natural language text data has triggered a new round of data analysis. These data integrate text information from different sources and types and contain a large number of semantic features, which greatly increases the complexity and amount of information in the data. However, processing the complexity of these text data, analyzing the correlation between semantics, and efficiently performing cross-text understanding poses a huge challenge to traditional machine learning algorithms. In response to this challenge, the advantages of quantum neural networks are used to deal with it.

[0005] However, currently existing quantum neural networks can only handle simple tasks related to text data, and their processing efficiency for complex tasks with rich semantic text data is relatively low. Summary of the invention

[0006] The present invention provides a method for processing text semantic similarity using a quantum neural network model, which is used to solve the defect that the quantum neural network in the prior art has low efficiency in processing complex text semantic data.

[0007] In a first aspect, the present invention provides a method for processing text semantic similarity using a quantum neural network model, comprising:

[0008] Collecting a data set for a text semantic similarity analysis task, including text input data pairs and their corresponding target outputs, and dividing the data set into a training set, a validation set, and a test set according to a preset ratio;

[0009] Performing standardized data preprocessing on the data set;

[0010] Construct a quantum neural network model for processing text semantic similarity analysis, including: quantum data encoding module, quantum text feature extraction module, quantum text feature similarity calculation module, quantum bit measurement module and network parameter optimization module;

[0011] The quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; the quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to determine the similarity between the text data features and then apply a measurement operation to a randomly selected quantum bit, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error;

[0012] Iteratively training and verifying the quantum neural network model using the quantum states of the training set and the verification set until the training and verification are terminated after a set threshold condition is met, and after the training and verification are terminated, a quantum neural network model with optimal performance for processing text semantic similarity analysis can be obtained;

[0013] The quantum state of the test set is used to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis.

[0014] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the quantum data encoding module is specifically used for:

[0015] Normalizing the vector of the preprocessed text data;

[0016] Initialize the initial state of the quantum circuit to state, represents the number of qubits in the quantum circuit;

[0017] The elements in the normalized vector are encoded into the quantum state through a parameterized quantum gate by using angle encoding or amplitude encoding.

[0018] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the quantum circuit includes a wire and a quantum gate;

[0019] The quantum gate is used to manipulate the state of the quantum bit and determine the evolution of the entire quantum system;

[0020] The evolution of the quantum system is described by quantum gates, which satisfy Unitary operator Indicates that for The conjugate transpose of express dimensional identity matrix, quantum gate Acts on The following transformation will be obtained:

[0021] ;

[0022] in, express The ground state of qubits corresponds to the integer The binary representation of represents the amplitude of the quantum state, Represents the amplitude of the quantum state.

[0023] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, encoding the elements in the normalized vector into a quantum state through a parameterized quantum gate comprises:

[0024] Encoding classical data points into Rotating quantum gates, Rotational quantum gates and In the rotation quantum gate;

[0025] The encoded quantum state is expressed as:

[0026] ;

[0027] in, represents a rotation quantum gate, =0、1、…、N-1 ; Represents the corresponding classical data.

[0028] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the Rotating quantum gates, Rotational quantum gates and The expression of the rotation quantum gate is:

[0029] ;

[0030] ;

[0031] ;

[0032] in, represents an integer, Represents the corresponding classical data.

[0033] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the quantum text feature extraction module is specifically used for:

[0034] Applying a universal single-qubit gate to each single-qubit in the quantum text feature extraction module circuit respectively;

[0035] Then, a two-qubit gate is used to set different step sizes to be applied to the qubits to achieve interaction between qubits, realize the evolution of the quantum state and extract the features of the text data.

[0036] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the two-qubit gate is a controlled NOT gate without parameters, and its corresponding mathematical expression is:

[0037] ;

[0038] Here, CNOT represents a controlled NOT gate, and the CNOT is applied to the quantum bit in a module with different step sizes.

[0039] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the quantum text feature similarity calculation module is specifically used for:

[0040] Auxiliary quantum bits are used to calculate the semantic similarity of text pairs by performing controlled exchange test operations on different text features obtained from multiple quantum text feature extraction modules.

[0041] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the network parameter optimization module is specifically used for:

[0042] Using a mean square error loss function as a measurement indicator, determining the error between the output result and the similarity value of the target output corresponding to the text input data pair;

[0043] The mean square error loss function is:

[0044] ;

[0045] in, represents the target output in the training set, Represents the size of the training set, and E represents the output result of the text similarity analysis task.

[0046] According to a method for processing text semantic similarity using a quantum neural network model provided by the present invention, the method of updating the adjustable parameters in the quantum neural network model according to the analysis result of the error comprises:

[0047] Use the parameter shift rule and the chain rule to determine the gradient of the loss function;

[0048] The parameters of the quantum neural network are updated according to the descending direction of the gradient of the loss function, as follows:

[0049] ;

[0050] in, represents the updated parameters of the quantum neural network, represents the parameters of the quantum neural network before updating, represents the learning rate, and L represents the mean square error loss function.

[0051] In a second aspect, the present invention further provides a device for processing text semantic similarity using a quantum neural network model, comprising:

[0052] The acquisition module is used to acquire a data set for a text semantic similarity analysis task, including a text input data pair and its corresponding target output, and divide the data set into a training set, a validation set, and a test set according to a preset ratio;

[0053] A preprocessing module, used for performing standardized data preprocessing on the data set;

[0054] A construction module, for constructing a quantum neural network model for processing text semantic similarity analysis, comprising: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module and a network parameter optimization module; the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; the quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to apply a measurement operation to a randomly selected quantum bit after determining the similarity between the text data features, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error;

[0055] A training module, used for iteratively training and verifying the quantum neural network model using the quantum states of the training set and the verification set, until the training and verification are terminated after a set threshold condition is met, and after the training and verification are terminated, a quantum neural network model with optimal performance for processing text semantic similarity analysis can be obtained;

[0056] An evaluation module is used to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis using the quantum state of the test set.

[0057] In a third aspect, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for processing text semantic similarity using a quantum neural network model as described above is implemented.

[0058] In a fourth aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for processing text semantic similarity using a quantum neural network model as described in any one of the above.

[0059] In a fifth aspect, the present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method for processing text semantic similarity using any of the above-mentioned quantum neural network models.

[0060] The method for processing text semantic similarity using a quantum neural network model provided by the present invention is as follows: the quantum neural network model can efficiently encode classical data into quantum states through a quantum data encoding module; the quantum text feature extraction module uses a quantum circuit with high expressiveness and strong entanglement to capture rich semantic information in the text to extract effective features of the text; the quantum text feature similarity calculation module uses a specific controlled exchange test architecture to calculate the semantic similarity between text pairs, thereby significantly improving the performance of the model in processing similarity analysis tasks of text data with complex semantic features, and the quantum neural network model can effectively use the advantages of quantum computing to process complex text semantic similarity analysis tasks, breaking through the limitation of quantum neural networks that are limited to processing simple text data tasks, and can process text data with complex semantic information, significantly expanding the application field of current quantum neural networks. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0062] Figure 1 It is a flowchart of a method for processing text semantic similarity using a quantum neural network model provided in this embodiment;

[0063] Figure 2 is a quantum circuit schematic diagram of the quantum neural network model provided in this embodiment;

[0064] Figure 3 is a quantum circuit schematic diagram of a quantum data encoding module provided in this embodiment;

[0065] Figure 4 is a quantum circuit schematic diagram of the quantum text feature extraction module provided in this embodiment;

[0066] Figure 5 is a quantum circuit schematic diagram of a quantum text feature similarity calculation module provided in this embodiment;

[0067] Figure 6 is a quantum circuit schematic diagram of the quantum bit measurement module provided in this embodiment;

[0068] Figure 7 is a schematic diagram of the structure of a device for processing text semantic similarity using a quantum neural network model provided in this embodiment;

[0069] Figure 8 It is a schematic diagram of the structure of the electronic device provided in this embodiment. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0071] Figure 1 It is a flowchart of the method for processing text semantic similarity using a quantum neural network model provided in this embodiment.

[0072] like Figure 1 As shown, a method for processing text semantic similarity using a quantum neural network model provided by an embodiment of the present invention mainly includes the following steps:

[0073] 101. Collect a data set for text semantic similarity analysis tasks, including text input data pairs and their corresponding target outputs, and divide the data set into a training set, a validation set, and a test set according to a preset ratio.

[0074] In a specific implementation process, the data set used for the text semantic similarity analysis task is a supervised learning data set, which includes not only the original text data pairs, but also the semantic similarity labels corresponding to the text data pairs. The preset ratio can be set according to user needs.

[0075] 102. Perform data preprocessing to standardize the dataset.

[0076] First, the dataset is cleaned by removing punctuation, normalizing upper and lower case, segmenting, removing stop words, and restoring words. The cleaned text data is converted into a fixed-dimensional vector representation by using discrete representation (such as one-hot encoding) or distributed representation methods (such as word embedding technology). Distributed representation methods effectively map text data into a dense, low-dimensional vector space, maintaining the semantic information of the text while reducing the dimensional complexity of the data.

[0077] 103. Construct a quantum neural network model for processing text semantic similarity analysis, including: quantum data encoding module, quantum text feature extraction module, quantum text feature similarity calculation module, quantum bit measurement module and network parameter optimization module.

[0078] like Figure 2The figure shows a quantum circuit diagram of a quantum neural network model. Before building a quantum neural network model, the parameters of the quantum neural network model can be initialized. Since quantum hardware can only process quantum data, the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer. Specifically, the vector of the preprocessed text data is normalized to ensure that the numerical range of the data is suitable for quantum encoding. Then the initial state of the quantum circuit is initialized to state, Represents the number of quantum bits in the quantum circuit. Finally, the elements in the normalized vector are encoded into the quantum state through parameterized quantum gates using angle encoding or amplitude encoding. This encoding method enables classical data to be mapped into the phase of the quantum state, realizing the conversion from classical data to quantum state.

[0079] In quantum computing, the basic unit of information storage and processing is the quantum bit, which is similar to the classical bit in classical computing. It is physically realized by a two-level quantum system. Its quantum state is mathematically represented by a two-dimensional complex vector in Hilbert space. Specifically, a single quantum bit state can be expressed as:

[0080] (1)

[0081] in, and are the two ground states of a single quantum bit, with coefficients and Satisfy the normalization condition .

[0082] Multiple qubits can form a multi-qubit system, whose quantum state space is the tensor product of the quantum state of each qubit, which can be expressed as:

[0083] (2)

[0084] in, yes The ground state of qubits corresponds to the integer The binary representation of .

[0085] Quantum circuits consist of wires and quantum gates to transmit and manipulate quantum information. Quantum gates are used to manipulate the state of quantum bits and determine the evolution of the entire quantum system. The evolution of the quantum system is described by quantum gates (unitary transformations) that satisfy Unitary operator Indicates that for The conjugate transpose of express dimensional identity matrix, quantum gate Acts on The following transformation will be obtained:

[0086] (3)

[0087] in, express The ground state of qubits corresponds to the integer The binary representation of represents the amplitude of the quantum state, Represents the amplitude of the quantum state.

[0088] The angle encoding method encodes classical data into the phase angle of the quantum state. Specifically, given a classical vector , where each component is mapped to a phase angle of the quantum state. The elements in the normalized vector are encoded into the quantum state through parameterized quantum gates, including: encoding the classical data points into the phase of the corresponding quantum bit through the rotation gate, that is, encoding into Rotating quantum gates, Rotational quantum gates and In the rotation quantum gate, Figure 3 As shown;

[0089] The encoded quantum state is expressed as:

[0090] (4)

[0091] in, represents a rotation quantum gate, =0、1、…、N-1 ; Represents the corresponding classical data.

[0092] Assume that qubits to encode dimensional vector ( indivual The gate acts on each quantum bit separately). Of course, the number of quantum bits is not a specific value. For the case where the dimension is smaller than the classical vector, it can be implemented through cyclic coding. Rotating quantum gates, Rotational quantum gates and The expression of the rotation quantum gate is:

[0093] (5)

[0094] (6)

[0095] (7)

[0096] in, represents an integer, Represents the corresponding classical data.

[0097] The quantum text feature extraction module is used to design the corresponding quantum circuit configuration for the quantum state text data, perform quantum state evolution, and extract text data features. The general configuration of this module adopts an architecture similar to a fully connected neural network to fully capture the semantic features in the text.

[0098] Specifically, a universal single-qubit gate is applied to each single qubit in the quantum text feature extraction module circuit; then a two-qubit gate is used to set different step sizes and applied to the qubit to achieve interaction between qubits. These quantum gates are used to operate on the qubits to realize the evolution of the quantum state and extract the text data features.

[0099] Among them, the universal single-qubit gate used in the quantum text feature extraction module It can realize arbitrary quantum state conversion and improve the expressiveness of the module, such as Figure 3 In this embodiment, the universal single-qubit gate is decomposed into three basic rotation quantum gates ( and ). The two-qubit gate in this module is a controlled NOT gate without parameters, and its corresponding mathematical expression is:

[0100] (8)

[0101] Among them, CNOT represents a controlled NOT gate, and CNOT is applied to the quantum bit in the module with different step sizes, such as Figure 4 As shown, the step sizes used to apply the CNOT gate are 1 and 2.

[0102] The quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through quantum circuit structure and determine the similarity between text data features. By using auxiliary quantum bits, the controlled exchange test (Control SWAP Test) operation of different text features obtained from multiple quantum text feature extraction modules can be used to calculate the semantic similarity of text pairs. Figure 5 As shown, the architecture of the controlled exchange test circuit is given. Taking three quantum bits as an example, this architecture can effectively and directly realize the calculation of quantum text feature similarity.

[0103] The quantum bit measurement module is used to determine the similarity between text data features and then apply measurement operations to randomly selected quantum bits, obtaining the expected value of the measurement as the output result of the text similarity analysis task.

[0104] Specifically, the quantum bit measurement module is applied after the quantum text feature similarity calculation module. By performing measurement operations on specific quantum bits and running the quantum circuit multiple times, the expected value of the measurement is obtained as the output of the quantum neural network model. It can also be used as the output result of the model for processing text similarity analysis tasks in machine learning.

[0105] In quantum computing, quantum measurements can extract information from quantum states. Specifically, for projection measurements, assuming is a quantum observable, which can be represented by a Hermitian operator. According to the spectral decomposition theorem, It can be expressed as:

[0106] (9)

[0107] in, Express Possible results when performing projection measurements, Representatives and The eigenvalue of The corresponding feature space projector.

[0108] Assume that the quantum system is in the state , then the measurement observable The expected value of is calculated as: (10)

[0109] A qubit measurement module can be constructed by performing projection measurement on a specific qubit, such as Figure 6 Specifically, by repeatedly executing the entire quantum circuit and using quantum observables To measure the last qubit, the measurement result can be expressed as:

[0110] (11)

[0111] in, and They are the quantum states obtained after the quantum text feature extraction module is applied.

[0112] The network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the error analysis results.

[0113] Specifically, the network parameter optimization module uses the mean square error loss function as a measurement indicator to evaluate the error between the output of the quantum neural network and the target output corresponding to the input data. The mean square error loss function is:

[0114] (12)

[0115] in, represents the target output in the training set, Represents the size of the training set, and E represents the output result of the text similarity analysis task.

[0116] According to the error analysis results, the gradient calculation method suitable for parameterized quantum circuits and the gradient descent optimization algorithm are used to update the adjustable parameters in the model to minimize the loss function.

[0117] First, determine the gradient of the loss function. Use the gradient calculation method applicable to parameterized quantum circuits, namely the parameter shift rule and the chain rule, to calculate the gradient. Specifically, to simplify the expression, give (the same applies to the case of multiple samples), For parameters The derivative of is:

[0118] (13)

[0119] in, The calculation is done by adjusting To achieve, It is a A vector with 1 elements and the rest 0.

[0120] Then, using the stochastic gradient optimization algorithm, the parameters of the quantum neural network are updated according to the gradient descent direction of the loss function, as follows:

[0121] (14)

[0122] in, represents the updated parameters of the quantum neural network, represents the parameters of the quantum neural network before updating, Represents the learning rate, which controls the step size of parameter update, and L represents the mean square error loss function. Through this iterative process, the network parameters can be gradually adjusted so that the output of the quantum neural network model is closer to the target output of the training data.

[0123] 104. The quantum neural network model is iteratively trained and verified using the quantum states of the training set and the verification set until the set threshold conditions are met and the training and verification are terminated. After the training and verification are terminated, a quantum neural network model with optimal performance for processing text semantic similarity analysis can be obtained.

[0124] Through iterative training and verification of training sets and verification sets, the quantum neural network model is continuously optimized, thus ensuring that the optimal quantum neural network model can output results more accurately.

[0125] 105. Use the quantum state of the test set to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis.

[0126] By evaluating the performance of the optimal quantum neural network model through the quantum state of the test set, we can better understand the performance parameters of the optimal quantum neural network model, and thus optimize the model through feedback to achieve efficient processing of complex text semantics.

[0127] The quantum neural network model in this embodiment has a flexible overall structure and can adapt to the processing and analysis of different text data sets. The quantum data encoding module and quantum text feature extraction module within the model are both adjustable. This embodiment provides a general setting that can be optimized and configured according to the characteristics of different machine learning tasks and the requirements of data sets.

[0128] The quantum neural network model of the present invention can effectively utilize the advantages of quantum computing to process complex text semantic similarity analysis tasks, breaking through the limitation that quantum neural networks are limited to processing simple text data tasks, and can process text data with complex semantic information, significantly expanding the application field of current quantum neural networks. In addition, the quantum neural network model of the present invention can efficiently encode classical data into quantum states through a quantum data encoding module; the quantum text feature extraction module uses a quantum circuit with high expressiveness and strong entanglement to capture rich semantic information in the text to extract effective features of the text; the quantum text feature similarity calculation module uses a specific controlled exchange test architecture to calculate the semantic similarity between text pairs, thereby significantly improving the performance of the model in processing similarity analysis tasks of text data with complex semantic features. Finally, the quantum neural network model for processing text semantic similarity of the present invention shows excellent generalization ability and is suitable for processing a variety of text data sets with complex semantics. The model design is flexible and can be customized and expanded according to different task requirements or data characteristics, so as to maintain efficient data processing capabilities in a variety of application scenarios.

[0129] Based on the same general inventive concept, the present invention also protects a device for processing text semantic similarity using a quantum neural network model. The device for processing text semantic similarity using a quantum neural network model provided by the present invention is described below. The device for processing text semantic similarity using a quantum neural network model described below and the method for processing text semantic similarity using a quantum neural network model described above can be referenced to each other.

[0130] Figure 7 It is a schematic diagram of the structure of the device for processing text semantic similarity using the quantum neural network model provided in this embodiment.

[0131] like Figure 7 As shown, the present embodiment provides a device for processing text semantic similarity using a quantum neural network model, comprising:

[0132] The acquisition module 701 is used to acquire a data set for a text semantic similarity analysis task, including a text input data pair and its corresponding target output, and divide the data set into a training set, a validation set, and a test set according to a preset ratio;

[0133] A preprocessing module 702, used for performing standardized data preprocessing on the data set;

[0134] The construction module 703 is used to construct a quantum neural network model for processing text semantic similarity analysis, including: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module and a network parameter optimization module; the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; the quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to perform a measurement operation on a randomly selected quantum bit after determining the similarity between the text data features, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error;

[0135] A training module 704 is used to iteratively train and verify the quantum neural network model using the quantum states of the training set and the verification set until the training and verification are terminated after a set threshold condition is met, and after the training and verification are terminated, a quantum neural network model with optimal performance for processing text semantic similarity analysis can be obtained;

[0136] The evaluation module 705 is used to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis using the quantum state of the test set.

[0137] Figure 8 It is a schematic diagram of the structure of the electronic device provided in this embodiment.

[0138] like Figure 8As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the method for processing text semantic similarity using a quantum neural network model, the method comprising: collecting a data set for a text semantic similarity analysis task, including a text input data pair and its corresponding target output, and dividing the data set into a training set, a verification set and a test set according to a preset ratio; performing standardized data preprocessing on the data set; constructing a quantum neural network model for processing text semantic similarity analysis, including: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module and a network parameter optimization module; the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; the quantum text feature similarity calculation module is used to calculate the quantum bit similarity through quantum information. The subcircuit structure realizes the interaction between different quantum text feature extraction modules to determine the similarity between the text data features; the quantum bit measurement module is used to determine the similarity between the text data features and then apply a measurement operation to the randomly selected quantum bit, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error; the quantum states of the training set and the verification set are used to iteratively train and verify the quantum neural network model until the set threshold conditions are met and the training and verification are terminated. After the training and verification are terminated, the quantum neural network model with the best performance for processing text semantic similarity analysis can be obtained; the performance of the optimal quantum neural network model for processing text semantic similarity analysis is evaluated using the quantum state of the test set.

[0139] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention 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 a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0140] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method for processing text semantic similarity using a quantum neural network model provided by the above methods, the method including: collecting a data set for a text semantic similarity analysis task, including a text input data pair and its corresponding target output, and dividing the data set into a training set, a verification set and a test set according to a preset ratio; performing standardized data preprocessing on the data set; constructing a quantum neural network model for processing text semantic similarity analysis, including: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module and a network parameter optimization module; the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, and perform quantum state evolution, extracting text data features; the quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to apply a measurement operation to a randomly selected quantum bit after determining the similarity between the text data features, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error; the quantum states of the training set and the verification set are used to iteratively train and verify the quantum neural network model until the set threshold conditions are met and the training and verification are terminated. After the training and verification are terminated, the quantum neural network model with the best performance for processing text semantic similarity analysis can be obtained; the performance of the optimal quantum neural network model for processing text semantic similarity analysis is evaluated using the quantum state of the test set.

[0141] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for processing text semantic similarity using a quantum neural network model provided by the above methods, the method comprising: collecting a data set for a text semantic similarity analysis task, comprising a text input data pair and its corresponding target output, and dividing the data set into a training set, a verification set and a test set according to a preset ratio; performing standardized data preprocessing on the data set; constructing a quantum neural network model for processing text semantic similarity analysis, comprising: a quantum data encoding module, a quantum text feature extraction module, a quantum text feature similarity calculation module, a quantum bit measurement module and a network parameter optimization module; the quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; The quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to determine the similarity between the text data features and then apply a measurement operation to the randomly selected quantum bits, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error; the quantum states of the training set and the verification set are used to iteratively train and verify the quantum neural network model until the set threshold conditions are met and the training and verification are terminated. After the training and verification are terminated, the quantum neural network model with the best performance for processing text semantic similarity analysis can be obtained; the quantum state of the test set is used to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis.

[0142] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for processing text semantic similarity using a quantum neural network model, characterized in that: include: Collecting a data set for a text semantic similarity analysis task, including text input data pairs and their corresponding target outputs, and dividing the data set into a training set, a validation set, and a test set according to a preset ratio; Performing standardized data preprocessing on the data set; Construct a quantum neural network model for processing text semantic similarity analysis, including: quantum data encoding module, quantum text feature extraction module, quantum text feature similarity calculation module, quantum bit measurement module and network parameter optimization module; The quantum data encoding module is used to encode the preprocessed text data into a quantum state that can be processed by a quantum computer; the quantum text feature extraction module is used to design a corresponding quantum circuit configuration for the text data in the quantum state, perform quantum state evolution, and extract text data features; the quantum text feature similarity calculation module is used to realize the interaction between different quantum text feature extraction modules through a quantum circuit structure, and determine the similarity between the text data features; the quantum bit measurement module is used to determine the similarity between the text data features and then apply a measurement operation to a randomly selected quantum bit, and obtain the expected value of the measurement as the output result of the text similarity analysis task; the network parameter optimization module is used to determine the error between the output result and the similarity value of the target output corresponding to the text input data pair, and update the adjustable parameters in the quantum neural network model according to the analysis result of the error; Iteratively training and verifying the quantum neural network model using the quantum states of the training set and the verification set until the training and verification are terminated after a set threshold condition is met, and after the training and verification are terminated, a quantum neural network model with optimal performance for processing text semantic similarity analysis can be obtained; The quantum state of the test set is used to evaluate the performance of the optimal quantum neural network model for processing text semantic similarity analysis.

2. The method for processing text semantic similarity using a quantum neural network model according to claim 1, characterized in that: The quantum data encoding module is specifically used for: Normalizing the vector of the preprocessed text data; Initialize the initial state of the quantum circuit to state, represents the number of qubits in the quantum circuit; The elements in the normalized vector are encoded into the quantum state through a parameterized quantum gate by using angle encoding or amplitude encoding.

3. The method for processing text semantic similarity using a quantum neural network model according to claim 2, characterized in that: The quantum circuit includes a wire and a quantum gate; The quantum gate is used to manipulate the state of the quantum bit and determine the evolution of the entire quantum system; The evolution of the quantum system is described by quantum gates, which satisfy Unitary operator Indicates that for The conjugate transpose of express dimensional identity matrix, quantum gate Acts on The following transformation will be obtained: ; in, express The ground state of qubits corresponds to the integer The binary representation of represents the amplitude of the quantum state, Represents the amplitude of the quantum state.

4. The method for processing text semantic similarity using a quantum neural network model according to claim 3, characterized in that: The step of encoding the elements in the normalized vector into a quantum state through a parameterized quantum gate comprises: Encoding classical data points into Rotating quantum gates, Rotational quantum gates and In the rotation quantum gate; The encoded quantum state is expressed as: ; in, represents a rotation quantum gate, =0、1、…、N-1 ; Represents the corresponding classical data.

5. The method for processing text semantic similarity using a quantum neural network model according to claim 4, characterized in that: Said Rotating quantum gates, Rotational quantum gates and The expression of the rotation quantum gate is: ; ; ; in, represents an integer, Represents the corresponding classical data.

6. The method for processing text semantic similarity using a quantum neural network model according to claim 1, characterized in that: The quantum text feature extraction module is specifically used for: Applying a universal single-qubit gate to each single-qubit in the quantum text feature extraction module circuit respectively; Then, a two-qubit gate is used to set different step sizes to be applied to the qubits to achieve interaction between qubits, realize the evolution of the quantum state and extract the features of the text data.

7. The method for processing text semantic similarity using a quantum neural network model according to claim 6, characterized in that: The two-qubit gate is a controlled NOT gate without parameters, and its corresponding mathematical expression is: ; Here, CNOT represents a controlled NOT gate, and the CNOT is applied to the quantum bit in a module with different step sizes.

8. The method for processing text semantic similarity using a quantum neural network model according to claim 1, characterized in that: The quantum text feature similarity calculation module is specifically used for: Auxiliary quantum bits are used to calculate the semantic similarity of text pairs by performing controlled exchange test operations on different text features obtained from multiple quantum text feature extraction modules.

9. The method for processing text semantic similarity using a quantum neural network model according to claim 1, characterized in that: The network parameter optimization module is specifically used for: Using a mean square error loss function as a measurement indicator, determining the error between the output result and the similarity value of the target output corresponding to the text input data pair; The mean square error loss function is: ; in, represents the target output in the training set, Represents the size of the training set, and E represents the output result of the text similarity analysis task.

10. The method for processing text semantic similarity using a quantum neural network model according to claim 9, characterized in that: The step of updating the adjustable parameters in the quantum neural network model according to the analysis result of the error comprises: Use the parameter shift rule and the chain rule to determine the gradient of the loss function; The parameters of the quantum neural network are updated according to the descending direction of the gradient of the loss function, as follows: ; in, represents the updated parameters of the quantum neural network, represents the parameters of the quantum neural network before updating, represents the learning rate, and L represents the mean square error loss function.

Citation Information

Patent Citations

  • Quantum model training method, and multi-modal data processing method and device

    CN117669753A

  • Machine-learning model to predict probability of success of an operator in a paas cloud enviornment

    US20220156631A1