Document retrieval method based on quantum neural network

Through a document retrieval method based on quantum neural networks, quantum entangled sub-block coding and quantum interference similarity measurement are used to solve the problems of semantic dilution and nonlinear relationships in long text retrieval, and achieve efficient document retrieval performance improvement.

CN120804289APending Publication Date: 2025-10-17NUCLEAR TECH SUPPORT CENT OF THE STATE ADMINISTRATION OF SCI TECH & IND FOR NAT DEFENSE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510948623.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing document retrieval methods suffer from semantic dilution problems and difficulty in capturing nonlinear relationships when faced with long texts, resulting in degraded retrieval performance and limiting the application prospects of long document retrieval.

Method used

A quantum neural network-based method is used to segment documents into words and encode them into word embeddings. The documents are then divided into local semantic units through a quantum entangled sub-block coding mechanism. The quantum interference similarity metric is used to capture nonlinear interactions, and secondary compression and nonlinear similarity calculation are performed to improve retrieval performance.

Benefits of technology

Through quantum coding and nonlinear similarity measurement, the semantic dilution problem of long texts is solved, the performance of document retrieval is significantly improved, the hardware requirements and information volume are reduced, and the retrieval efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804289A_ABST
    Figure CN120804289A_ABST
Patent Text Reader

Abstract

The invention discloses a document retrieval method based on a quantum neural network, which comprises the following steps of: performing word segmentation on a document, and encoding into word embedding; embedding and inputting the obtained words into a language model to obtain document representation; obtaining a high-dimensional text compression code of the quantum entanglement sub-block based on the document representation; performing nonlinear similarity calculation of quantum interference based on the obtained quantum state; and sorting the candidate documents based on the nonlinear similarity of quantum interference to realize document retrieval. According to the method, the quantum neural network is adopted to perform quantum coding on the document, and the problem of long text semantic dilution is solved through a quantum entanglement sub-block coding mechanism; quantum interference similarity measurement is provided, nonlinear interaction between document states is captured through adjustable phase transformation, and the nonlinear representation capacity is improved. The quantum state is adopted to represent the high-dimensional dense semantic vector, the required information amount is greatly reduced, the dimension information required by the language model is compressed, the required occupied space is reduced in an exponential level, and the hardware requirement is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of document retrieval, and particularly relates to a document retrieval method based on a quantum neural network. BACKGROUND

[0002] Document retrieval aims to retrieve a document similar to an input document from a document database, and the core thereof is to find a representation of a target document most similar to a representation of the input document in a vector space. Existing document retrieval methods represent documents to obtain rich semantic information of the documents, so that the models can better find the similarity between the documents in the vector space. However, the existing methods usually need to represent the documents by using multiple high-dimensional dense vectors, and as the length of the text increases, the semantic expression of the vectors is diluted, which leads to a decrease in the performance of document retrieval. Meanwhile, cosine similarity is usually used for retrieval in the retrieval process, and the cosine similarity as a linear method is difficult to capture the nonlinear relationship between the document vectors. In summary, the above problems will lead to poor performance of the document retrieval model, especially when facing long text retrieval, which limits the application prospect of the existing methods to long document retrieval. SUMMARY

[0003] In view of the above problems in the prior art, the application provides a document retrieval method based on a quantum neural network, which solves the problem that the existing document retrieval method cannot perform well in long text retrieval, and overcomes the difficulty that the existing method cannot encode long text and the difficulty that the nonlinear relationship between documents cannot be measured in natural language processing.

[0004] To solve the above technical problems, the application is implemented in the following manner:

[0005] A document retrieval method based on a quantum neural network comprises the following steps:

[0006] S1, cutting a document and encoding the document into word embeddings;

[0007] S2, inputting the word embeddings obtained in step S1 into a language model to obtain document representations;

[0008] S3, obtaining a quantum state with a secondary compression dimension based on the document representations in step S2;

[0009] S4, performing nonlinear similarity calculation of quantum interference based on the quantum state obtained in step S3;

[0010] S5, ranking candidate documents based on the nonlinear similarity of quantum interference in step S4, thereby realizing document retrieval.

[0011] Further, the specific method of step S1 is as follows:

[0012] S11, given an input document D, input the document into a tokenizer to obtain a set of tokens, the specific expression is as follows:

[0013]

[0014] wherein, denotes the set of tokens after tokenization, n denotes the number of tokens, T(·) denotes a tokenizer, which can be jieba tokenization, BERT Tokenizer, etc.;

[0015] S12, input the token set into a word embedding encoder to obtain the word embedding of the token, the specific expression is as follows:

[0016]

[0017] wherein, denotes the encoded word embedding, f e (·) denotes a word embedding encoder, θ e denotes the parameter of the word embedding encoder, which can be BERT embedding, Word2Vec, etc.

[0018] Further, the specific method of step S2 is as follows:

[0019] input the word embedding obtained in step S1 into the text encoder of the language model to obtain the text representation, the expression is as follows:

[0020]

[0021] wherein, denotes a language model, the output of which is generated by an internal text encoder, denotes the text encoder parameter, the language model (such as LSTM) is a complete semantic processing system, and the core component is the text encoder; the text encoder, as a functional submodule of the language model, is responsible for mapping the sequence of word embeddings to context-dependent document representation .

[0022] Further, the step S3 includes the following sub-steps:

[0023] S31, divide the text representation into m sub-blocks , each sub-block contains consecutive k vectors, the expression is as follows:

[0024]

[0025] wherein, represents the jth semantic sub-block, which solves the semantic dilution problem of long texts. k represents a hyperparameter used to adjust the sub-block length and control the local semantic granularity.

[0026] S32. For each semantic sub-block Perform parameterized quantum entanglement encoding, the specific expression is as follows:

[0027]

[0028] in, represents a trainable quantum entanglement gate, θ j represents the optimization parameters, represents the Euclidean norm of the sub-block vector, represents the jth quantum state, represents the computational ground state;

[0029] S33. Constructing the query document quantum state after secondary compression dimension , the specific expression is as follows:

[0030]

[0031] in, Represents the importance weight of the sub-block, generated by the attention mechanism , w represents the parameters optimized in model training, represents the control-target bit entanglement structure, Indicates the control register. dimensional vector compressed to Quantum bit, after compression, the scale is O(n 1 / 2 ) level, compression rate O(n / n 1 / 2 )=O(n 1 / 2 ) to achieve secondary compression.

[0032] Furthermore, the step S4 includes the following sub-steps:

[0033] S41, query document q and target document d are encoded as quantum states respectively and , query the quantum state of document q Generated by step S33, the quantum state of the target document d Generated by the same principle;

[0034] S42. The nonlinear similarity calculation is performed by quantum interference. The expression is as follows:

[0035]

[0036] in, Represents the conjugate transpose of the query document state, which is a left vector; denotes a target document state, is a right arrow; denotes a parameterized unitary transformation layer (for example: - a rotation gate + a Hadamard gate), denotes an optimizable phase;

[0037] are the core components of quantum machine learning, commonly including variational quantum algorithms and quantum neural networks, are composed of basic gates, and the expression is as follows:

[0038]

[0039] H denotes a Hadamard gate, realizing quantum superposition, denotes a controlled phase rotation gate, denotes a parameter, and I denotes a unit gate, keeping part of the quantum bits unchanged.

[0040] Further, the step S5 comprises the following sub-steps:

[0041] S51, the system calculates the quantum interference nonlinear similarity between each candidate document and the query document, the candidate document being all target documents to be matched stored in the retrieval database, according to the quantum interference nonlinear similarity of step S42, the expression is as follows:

[0042]

[0043] wherein, denotes a candidate document, , denotes the total number of documents in the database;

[0044] According to the value of from large to small, the candidate documents are sorted, and the expression is as follows:

[0045] S52, according to the result of step S51, the first P documents (P is the number of returned results set by the user) are returned as the final retrieval documents.

[0046] Compared with the prior art, the present application has the beneficial effects:

[0047] The application adopts quantum neural network to quantum encode the document, solves the long text semantic dilution problem by designing quantum entanglement sub-block coding mechanism, splitting the document into local semantic units and applying trainable entanglement operation, proposes quantum interference similarity measurement, captures the nonlinear interaction between document states by adjustable phase transformation, and improves nonlinear representation capability. At the same time, the quantum compression advantage is maintained, the innovation is significantly improved through trainable quantum components and hierarchical coding structure; and the high-dimensional dense semantic vector is represented by quantum state, which greatly reduces the required information amount, compresses the dimension information required by the language model, exponentially reduces the required occupation space, and reduces the hardware demand. BRIEF DESCRIPTION OF DRAWINGS

[0048] Figure 1 The flowchart of the document retrieval method of the application is shown. DETAILED DESCRIPTION

[0049] The specific implementation of the application will be further described in detail in combination with the drawings and specific embodiments.

[0050] As shown in the figure, a document retrieval method based on quantum neural network includes the following steps: Figure 1

[0051] S1, cut the document and encode it into word embedding, the specific method is as follows:

[0052] S11, given the input document D, input the document into the tokenizer tokenizer to cut the word, obtain the word set, the specific expression is as follows:

[0053]

[0054] Wherein, represents the word set after cutting, n represents the number of words, T(·) represents tokenizer, tokenizer can be jieba segmentation, BERT Tokenizer, etc.

[0055] S12, input the word set to the word embedding encoder to obtain the word embedding of the word, the specific expression is as follows:

[0056]

[0057] Wherein, represents the encoded word embedding, f e (·) represents word embedding encoder, θ e represents the parameter of word embedding encoder, word embedding encoder can be BERT embedding, Word2Vec, etc.

[0058] ​S2, input the word embedding obtained in step S1 into the language model to obtain the document representation, the specific method is as follows:

[0059] Input the word embedding obtained in step S1 into the text encoder of the language model to obtain the text representation, the expression is as follows:

[0060]

[0061] Wherein, represents the language model, the output of which is generated by the text encoder inside the language model, is the text encoder parameter.

[0062] The language model (such as BERT, LSTM) is a complete semantic processing system, and the core component is the text encoder; the text encoder, as a functional submodule of the language model, is responsible for mapping the word embedding sequence to the context-dependent document representation .

[0063] S3, obtain the high-dimensional text compression code of quantum entanglement sub-block based on the document representation of step S2, including the following steps:

[0064] S31, divide the text representation into m sub-blocks , each sub-block contains continuous k vectors, the expression is as follows:

[0065]

[0066] Wherein, represents the jth semantic sub-block, which solves the problem of long text semantic dilution, and k represents the hyperparameter, which is used to adjust the sub-block length and control the local semantic granularity;

[0067] S32, parameterize quantum entanglement coding for each semantic sub-block , the specific expression is as follows:

[0068]

[0069] Wherein, represents the trainable quantum entanglement gate, θ j represents the optimization parameter, represents the Euclidean norm of the sub-block vector, represents the jth quantum state (output state), which depends on the index j, which represents a specific quantum state in a certain sequence or step, represents the ground state, which represents an orthogonal basis vector of the quantum system;

[0070] S33, construct the query document quantum state after secondary compression dimension , the specific expression is as follows:

[0071]

[0072] wherein, represents a sub-block importance weight, which is generated by an attention mechanism , w represents a parameter optimized in model training, and is used to learn the importance of different sub-blocks; represents a control-target bit entanglement structure, represents a control register, which compresses an n dimensional vector into an n dimensional quantum bit (qubit), and the scale after compression is O(n 1 / 2 ) order, the compression rate is O(n / n 1 / 2 )=O(n 1 / 2 ), and secondary compression is realized.

[0073] S3, obtaining a quantum state of a secondary compression dimension based on the document representation of step S2; further, the step S3 comprises the following sub-steps:

[0074] S31, dividing the text representation into m sub-blocks (n ), each sub-block containing consecutive k vectors, and the expression is as follows:

[0075]

[0076] wherein, represents the jth semantic sub-block, solves the problem of long text semantic dilution, and k represents a hyperparameter, which is used to adjust the length of the sub-block and control the local semantic granularity;

[0077] S32, performing parameterized quantum entanglement coding on each semantic sub-block , and the specific expression is as follows:

[0078]

[0079] wherein, represents a trainable quantum entanglement gate, θ j represents an optimization parameter, represents the Euclidean norm of the sub-block vector, represents the jth quantum state, represents a ground state;

[0080] S33, constructing a query document quantum state after secondary compression dimension , and the specific expression is as follows:

[0081]

[0082] wherein, denotes the sub-block importance weight, generated by attention mechanism , w denotes the parameters optimized in model training, denotes the control-target bit entanglement structure, denotes the control register, which compresses the dimensional vector to quantum bits, and the scale after compression is O(n 1 / 2 ) order, and the compression rate is O(n / n 1 / 2 )=O(n 1 / 2 ), realizing secondary compression.

[0083] S4, nonlinear similarity calculation of quantum interference based on the quantum state obtained in step S3, including the following steps:

[0084] S41, query document q and target document d are respectively encoded into quantum states and The quantum state of the query document q is generated by step S33, and the quantum state of the target document d is generated by the same principle.

[0085] S42, nonlinear similarity calculation by quantum interference, the expression is as follows:

[0086]

[0087] wherein, denotes the conjugate transpose of the query document state, which is a left vector; denotes the target document state, which is a right vector; denotes the parameterized unitary transformation layer (for example: - rotation gate + Hadamard gate), denotes the optimizable phase;

[0088] is the core component of quantum machine learning, commonly including variational quantum algorithm and quantum neural network, etc. composed of basic gates, the expression is as follows:

[0089]

[0090] H denotes Hadamard gate, realizing quantum superposition, denotes the controlled phase rotation gate, denotes the parameter, and I denotes the unit gate, keeping part of the quantum bits unchanged.

[0091] ​S5、based on the quantum interference nonlinear similarity in step S4, ranking the candidate documents, thereby realizing document retrieval, including the following steps:

[0092] S51、the system calculates the quantum interference nonlinear similarity between each candidate document and the query document, the candidate document being all target documents to be matched stored in the retrieval database, the quantum interference nonlinear similarity being expressed as follows according to step S42:

[0093]

[0094] wherein, represents the candidate document, , represents the total number of documents in the database;

[0095] According to the value of from large to small, the candidate documents are ranked, and the expression is as follows:

[0096] S52、according to the result of step S51, returning the first P documents (P being the number of returned results set by the user) as the final retrieval documents.

[0097] The above is only an embodiment of the present application, and it is declared again that for those skilled in the art, without departing from the principle of the present application, the present application can be improved in several ways, and these improvements are also included in the protection scope of the claims of the present application.

Claims

1. A document retrieval method based on quantum neural network, characterized by: The following steps are involved: S1. Segment the document into words and encode them into word embeddings; S2. Input the word embedding obtained in step S1 into the language model to obtain the document representation; S3, obtaining a quantum state of a second-order compressed dimension based on the document representation in step S2; S4, performing nonlinear similarity calculation of quantum interference based on the quantum state obtained in step S3; S5. Sort the candidate documents based on the nonlinear similarity of quantum interference in step S4, thereby achieving document retrieval.

2. The document retrieval method based on quantum neural network according to claim 1, characterized in that: The specific method of step S1 is as follows: S11. Given an input document D, input the document into the word segmenter to segment the word and obtain a word set. The specific expression is as follows: in, represents the word set after word segmentation, n represents the number of words, and T(·) represents the word segmenter; S12. Gather words Input into the word embedding encoder to obtain the word embedding of the word. The specific expression is as follows: in, represents the encoded word embedding, f e (·) represents the word embedding encoder, θ e Represents the parameters of the word embedding encoder.

3. The document retrieval method based on quantum neural network according to claim 2, characterized in that: The method of step S2 is as follows: The word embedding obtained in step S1 is input into the text encoder of the language model to obtain the text representation, which is expressed as follows: in, represents the language model, whose output is generated by the internal text encoder, The text encoder parameters.

4. The document retrieval method based on quantum neural network according to claim 3, characterized in that: The step S3 includes the following sub-steps: S31, the text is represented Divide into m sub-blocks, each sub-block contains k consecutive vectors, and the expression is as follows: in, represents the jth semantic sub-block, which solves the semantic dilution problem of long texts. k represents a hyperparameter used to adjust the sub-block length and control the local semantic granularity. S32. For each semantic sub-block Perform parameterized quantum entanglement encoding, the specific expression is as follows: in, represents a trainable quantum entanglement gate, θ j represents the optimization parameters, represents the Euclidean norm of the sub-block vector, represents the jth quantum state, represents the computational ground state; S33. Constructing the query document quantum state after secondary compression dimension , the specific expression is as follows: in, Represents the importance weight of the sub-block, generated by the attention mechanism , w represents the parameters optimized in model training, represents the control-target bit entanglement structure, Indicates the control register. dimensional vector compressed to Quantum bit, after compression, the scale is O(n 1 / 2 ) level, compression rate O(n / n 1 / 2 )=O(n 1 / 2 ) to achieve secondary compression.

5. The document retrieval method based on quantum neural network according to claim 4, characterized in that: The step S4 comprises the following sub-steps: S41, query document q and target document d are encoded as quantum states respectively and , query the quantum state of document q Generated by step S33, the quantum state of the target document d Generated by the same principle; S42. The nonlinear similarity calculation is performed by quantum interference. The expression is as follows: in, Represents the conjugate transpose of the query document state, which is a left vector; Indicates the target document state, which is a right arrow; represents a parameterized unitary transformation layer, Indicates that the phase can be optimized; It is composed of basic gates and the expression is as follows: H represents the Hadamard gate, which realizes quantum superposition. represents a controlled phase revolving door, Represents parameters, I represents the unit gate, and some quantum bits remain unchanged.

6. The document retrieval method based on quantum neural network according to claim 5, characterized in that: The step S5 comprises the following sub-steps: S51, the system calculates the quantum interference nonlinear similarity between each candidate document and the query document, wherein the candidate document is stored in the search database for all target documents to be matched. According to the quantum interference nonlinear similarity of step S42, the expression is as follows: in, represents the candidate document, , Represents the total number of documents in the database; in accordance with The values ​​of are sorted from large to small to sort the candidate documents. The expression is as follows: ; S52. According to the result of step S51, the first P documents are returned as the final retrieved documents.