Query matching method and device based on document embedding

By generating predictive query questions and titles for documents using a large language model and generating vectors based on document embeddings, the problem of semantic relevance not being accurately reflected in traditional information retrieval is solved, achieving more efficient query matching results.

CN119272768APending Publication Date: 2025-01-07SHENZHEN ZHIXIAN FUTURE IND SOFTWARE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411390011.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

In traditional information retrieval, due to the limitations of the embedded model window, segmenting text by fixed length or punctuation marks results in the separation of semantically related texts. Furthermore, similarity-based retrieval methods cannot accurately reflect semantic relevance, thus there is an urgent need to improve retrieval performance.

Method used

A large language model is used to generate multiple predicted query questions and titles for the target document. Based on the document embedding method, vectors of text blocks, predicted query questions and titles are generated. The query results are determined by calculating the similarity between the query vector and the target vector.

Benefits of technology

It expands the semantic expression types of target documents, enriches semantic expression knowledge, and enables more effective similarity calculation, thereby improving query matching results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272768A_ABST
    Figure CN119272768A_ABST
Patent Text Reader

Abstract

The invention provides a query matching method based on document embedding, which is applied to a query matching system, the system comprises a plurality of target documents, and the method comprises the following steps: in an offline stage, segmenting each target document to obtain a plurality of text blocks; determining a predicted query problem and a document title of the target document; generating vectors respectively corresponding to each text block, the prediction query problem and the document title; generating target vectors corresponding to the text blocks according to the vectors; in a query stage, user query is received, and a corresponding query vector is calculated; and for each target document, respectively calculating the similarity between the query vector and a plurality of target vectors corresponding to the target document, and determining a query result of the user query according to the maximum similarity. Therefore, by generating the prediction query problem and the title for the target document, the semantic expression type of the target document can be expanded to realize more effective similarity calculation, so that the query matching effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information retrieval technology, and in particular to a query matching method and device based on document embedding. Background Art

[0002] In traditional information retrieval, documents are usually segmented into multiple small pieces, which are then stored in search and analysis engines (such as Elasticsearch) for vectorization and retrieval. However, due to the limitations of the embedding model window, segmentation by fixed length or punctuation will cause semantically related texts to be separated. In addition, traditional retrieval methods based on similarity sometimes fail to accurately reflect semantic relevance. Therefore, it is urgent to propose more effective query matching methods to improve retrieval performance. Summary of the invention

[0003] In order to solve the above problems, the present application proposes a query matching method, apparatus, computer-readable storage medium and computing device based on document embedding, which can realize semantic query matching with high efficiency and performance.

[0004] In a first aspect, the present application provides a query matching method based on document embedding, which is applied to a query matching system, wherein the query matching system includes a plurality of target documents, and the method includes:

[0005] During the offline phase:

[0006] For each target document, segment the target document based on a preset segmentation rule to obtain multiple text blocks;

[0007] Determine multiple prediction query questions for target documents, and document titles;

[0008] Based on the document embedding method, generate a text block vector for each text block, a prediction query vector corresponding to each of the multiple prediction query questions, and a title vector corresponding to the document title;

[0009] Generate a target vector for each text block according to the text block vector, the predicted query vector, and the title vector of each text block in the multiple text blocks, thereby obtaining multiple target vectors;

[0010] During the query phase:

[0011] Receive user queries and calculate the corresponding query vector;

[0012] For each target document, respectively calculate the similarity between the query vector and multiple target vectors corresponding to the target document to obtain multiple corresponding similarities;

[0013] The maximum similarity among multiple similarities is used as the document similarity of the target document. For multiple document similarities of multiple target documents, the target document corresponding to the maximum document similarity is used as the query result of the user query.

[0014] Therefore, on the basis of dividing the target document into multiple text blocks, the large language model is used to generate predictive query questions and titles for the target document, which can expand the semantic expression type of the target document to achieve more effective similarity calculation, thereby improving the query matching effect.

[0015] In a second aspect, the present application provides a query matching device based on document embedding, which is deployed with a query matching system, the query matching system includes multiple target documents, and the device includes:

[0016] A segmentation module is used to segment each target document based on a preset segmentation rule in an offline stage to obtain multiple text blocks;

[0017] A processing module for determining a plurality of predicted query questions of a target document and a document title in an offline stage;

[0018] The processing module is further used to generate a text block vector for each text block, a prediction query vector corresponding to each of the multiple prediction query questions, and a title vector corresponding to the document title based on the document embedding method in an offline stage;

[0019] A first calculation module is used to generate a target vector for each text block according to a text block vector, a predicted query vector, and a title vector of each text block in the multiple text blocks in an offline stage, so as to obtain multiple target vectors;

[0020] A receiving module, used to receive user queries in the query phase and calculate the corresponding query vector;

[0021] The second calculation module is used to calculate the similarity between the query vector and multiple target vectors corresponding to the target document for each target document in the query phase, and obtain multiple corresponding similarities;

[0022] The output module is used to use the maximum similarity among multiple similarities as the document similarity of the target document in the query stage, and for multiple document similarities of multiple target documents, use the target document corresponding to the maximum document similarity as the query result of the user query.

[0023] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect or any possible implementation of the first aspect.

[0024] In a fourth aspect, the present application provides a computing device, comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect.

[0025] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 It is a document-embedded query matching system provided by an embodiment of the present application;

[0028] Figure 2 This is a flow chart of a document embedded query matching method provided by an embodiment of the present application;

[0029] Figure 3 This is a flow chart of a document embedded query matching method provided by an embodiment of the present application;

[0030] Figure 4 It is a schematic diagram of a document-embedded query matching device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0032] In the description of the embodiments of the present application, words such as "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a concrete way.

[0033] In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, B exists alone, and A and B exist at the same time. In addition, unless otherwise specified, the term "multiple" means two or more. For example, multiple systems refers to two or more systems, and multiple screen terminals refers to two or more screen terminals.

[0034] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprises", "has" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0035] In traditional information retrieval, documents are usually segmented into multiple small chunks for storage; however, segmenting by fixed length or punctuation can cause semantically related texts to be separated due to the limitations of the embedding model window.

[0036] Large language models (LLMs) are a hot topic in the current field of artificial intelligence. They use deep learning technology to train on large amounts of text data to understand and generate natural language. In the field of information retrieval, they can be used to expand the semantic representation of documents, thereby providing richer semantic knowledge for embedding models.

[0037] In view of this, in the offline stage, the embodiment of the present application uses a large language model to generate multiple predicted query questions and titles for the target document, and divides the target document into multiple text blocks, generates vectors corresponding to multiple text blocks, multiple predicted query questions and titles based on the document embedding method, and generates multiple target vectors for the multiple text blocks based on the corresponding vectors. In the query stage, the query vector of the user query is generated using the document embedding method, and the similarity is calculated based on the query vector and the multiple target vectors generated above, and the query result of the user query is obtained based on the calculation result.

[0038] Therefore, on the basis of dividing the target document into multiple text blocks, a large language model is used to generate multiple predictive query questions and titles for the target document, which can expand the semantic expression type of the target document and enrich the semantic expression knowledge to achieve more effective similarity calculation, thereby improving the query matching effect for user queries.

[0039] For example, Figure 1A query matching system based on document embedding provided by an embodiment of the present application is shown. The system can be deployed on any device, apparatus, platform, server, device cluster, etc. with computing and processing capabilities.

[0040] like Figure 1 As shown, the query matching system 100 includes a document library 110, a prompt project 120, a large language model 130, a document segmentation module 140, a document embedding module 150 and a vector calculation module 160. The modules have the following Figure 1 The input and output connection relationship is shown.

[0041] The processing process of the query matching system 100 is divided into an offline phase and a query phase. The offline phase refers to a series of preparatory work performed by the system before the actual query occurs. The query phase refers to the real-time processing process performed by the system after the user submits a query request.

[0042] In the offline stage, the document library 110 is used to store a plurality of target documents related to the target field that are collected in advance, and the target documents are documents that the user hopes to find through search, retrieval or query operations. The document format of the target documents is a computer editable and searchable text format, such as WORD, PDF or PPT.

[0043] The prompt project 120 is used to design a special prompt word Prompt according to the target task to help the large language model understand the target task and control the output content.

[0044] The large language model 130 is used to generate multiple predicted query questions for the target document under the guidance of the prompt word Prompt. In addition, the large language model 130 is also used to generate a title for the target document under the guidance of the prompt word Prompt, or to optimize and adjust the original title to obtain a more accurate title. The title is a text that can directly express the content of the target document. The predicted query question is a user query predicted for the target document.

[0045] The document segmentation module 140 is used to segment the target document into multiple text blocks for easy processing and retrieval. A text block is a segment or paragraph in a text, which can be a sentence, phrase, paragraph or any other meaningful text unit.

[0046] The document embedding module 150 is used to generate fixed-length vector representations for the above-mentioned multiple prediction query questions, the title of the target document and multiple text blocks, and to generate target vectors for each text block based on these fixed-length vector representations, thereby obtaining multiple target vectors for further analysis or query.

[0047] In the query phase, the input of the query matching system 100 is a user query, which is a query question or query request raised by a user on the user interaction platform provided by the query matching system 100. The user can submit the user query to the user interaction platform by voice or text input.

[0048] The document embedding module 150 is also used to generate a fixed-length query vector for a user query.

[0049] The vector calculation module 160 is used to calculate the similarities between the query vector and the multiple target vectors corresponding to the target document, respectively, to obtain the corresponding multiple similarities. The document similarity of the target document is obtained according to the maximum similarity among the multiple similarities. For the multiple document similarities of the multiple target documents, the target document corresponding to the maximum document similarity is used as the query result of the user query. The query result is at least one target document among the multiple target documents, which is the output of the query matching system 100.

[0050] Therefore, on the basis of dividing the target document into multiple text blocks, a large language model is used to generate multiple predictive query questions and titles for the target document, which can expand the semantic expression type of the target document and enrich the semantic expression knowledge.

[0051] The query matching method is applied to the query matching system 110, which includes a plurality of target documents. The method includes an offline phase and a query phase.

[0052] For example, Figure 2 A flow chart of a document-embedded query matching method provided in an embodiment of the present application is shown.

[0053] like Figure 2 As shown, the query matching method includes the following steps in the offline stage:

[0054] Step S201 : for each target document, segment the target document based on a preset segmentation rule to obtain a plurality of text blocks.

[0055] In one implementation, the preset segmentation rules include segmenting the target document into blocks based on the block size dynamically determined based on the length and semantic content of the target document. For example, the text can be segmented at the semantic boundary of the target document, while considering the maximum length limit of the text block to dynamically determine the block size for segmentation. The target document can be segmented based on the preset segmentation rules to obtain multiple text blocks. The text blocks are smaller units into which the content of the target document is divided based on the preset segmentation rules. These units can be sentences, paragraphs, chapters or other meaningful text fragments.

[0056] Step S202, determining multiple predicted query questions of the target document and the document title.

[0057] In one implementation, the target document and preset prompt words are input into the large language model, so that the large language model generates multiple predicted query questions and document titles based on the target document under the guidance of the preset prompt words.

[0058] The large language model can be an open source or closed source model based on the Transformer structure. The preset prompt word Prompt acts as a bridge to communicate with the large language model, ensuring that the large language model can understand the task requirements and provide accurate output.

[0059] For example, a special prompt word can be designed based on the search history, behavior patterns or current popular query trends of users in the target field, so that the large language model can output predicted query questions based on the target document. The predicted query question is the user query predicted for the target document.

[0060] Under the guidance of other prompt words, the large language model can be used to generate a title for the target document, or a new title can be obtained by optimizing and adjusting the original title. The title is a text that can directly express the content of the target document.

[0061] Therefore, on the basis of dividing the target document into multiple text blocks, a large language model is used to output multiple predicted query questions and titles according to the input target document, which can expand the semantic expression type of the target document and enrich the semantic expression knowledge.

[0062] Step S203: Based on the document embedding method, a text block vector for each text block, a prediction query vector corresponding to each of the plurality of prediction query questions, and a title vector corresponding to the document title are generated.

[0063] In one implementation, the document embedding method includes using a text embedding model (Embedding) to generate a fixed-length vector representation for its input. The vector representation is an embedding vector (Embedding Vector), which is used to represent the sentiment, semantics, theme and other features of the input text of the text embedding model. The fixed length is a pre-set value, indicating the dimension of the vector, such as 512, 1024, etc. Text embedding models include but are not limited to BERT, GPT and other models based on the Transformer architecture, which are pre-trained on a large amount of text data and can capture complex language patterns and contextual semantics.

[0064] Specifically, each text block in the multiple text blocks, each query question in the multiple predicted query questions, and the document title are respectively input into the text embedding model to generate a fixed-length text block vector, a predicted query vector, and a title vector.

[0065] Step S204, generating a target vector for each text block according to the text block vector, the predicted query vector, and the title vector of each text block in the multiple text blocks, and obtaining multiple target vectors.

[0066] In one implementation, the text embedding model further generates a target vector for each text block according to the text block vector, the predicted query vector, and the title vector of each text block in the multiple text blocks, thereby obtaining multiple target vectors. Each text block corresponds to a target vector.

[0067] Optionally, the text block vector, the predicted query vector, and the title vector each have different weights. When generating the target vector of each text block, calculations are performed based on the text block vector, the predicted query vector, the title vector of each text block in the multiple text blocks, and the weights thereof to obtain multiple target vectors.

[0068] For example, Figure 3 A flow chart of a document-embedded query matching method provided in an embodiment of the present application is shown.

[0069] like Figure 3 As shown, the query matching method includes the following steps in the query phase:

[0070] Step S301: receiving a user query and calculating a corresponding query vector.

[0071] In one embodiment, the user query is an input to the query matching system 100, which involves query matching based on the query. The query matching system 100 can receive the user query of the user through the user interface, and the user query can be a text input type, such as a simple keyword, a complex sentence, or a specific inquiry.

[0072] Optionally, in order to improve the accuracy of the query, the query matching system 100 may expand the user's original query before querying according to the user's query, such as enriching the query content by adding synonyms, related words or context information based on parsing the user's query intent.

[0073] Exemplarily, the text embedding model in the above step S203 may also be used to generate a corresponding fixed-length query vector for the user query.

[0074] Step S302: for each target document, respectively calculate the similarity between the query vector and multiple target vectors corresponding to the target document to obtain multiple corresponding similarities.

[0075] Exemplarily, for each target document, during the query matching process for the user query, the query matching system 100 further calculates the similarities between the query vector corresponding to the user query and the multiple target vectors.

[0076] Specifically, the following formula can be used to calculate document similarity:

[0077] sim(q, d) = max i s(q,(c i +∑ f w f *e f )) (1)

[0078] In formula (1), q is the query vector, d is the target document, (c i +∑ f w f *e f ) is the i-th target vector corresponding to the target document, c i is the i-th text block vector, 1≤i≤N, i∈Z, and N is the total number of text blocks obtained by segmenting the target document. f The vector c is the average of multiple text block vectors, or the vector qs is the average of multiple predicted query vectors, or the title vector t, w f for e f The corresponding weights, weights w of vector c, vector q and title vector t f They are w c 、w q and w t , where w c +w q +w t =1.

[0079] Similarity calculations include but are not limited to cosine similarity calculations. Cosine similarity is a measurement method for measuring the degree of directional similarity between two vectors in a multidimensional space. It determines the similarity between the two vectors by calculating the cosine value of the angle between the two vectors. The range of cosine similarity is from -1 to 1, where 1 indicates that the vectors are in exactly the same direction, and -1 indicates that the directions are completely opposite. When the cosine similarity value is 1 or -1, it means that the two vectors have a strong correlation, while 0 means that the two vectors are orthogonal, that is, there is no correlation.

[0080] The calculation formula of cosine similarity is as follows:

[0081]

[0082] In formula (2), V1 and V2 are two vectors of the same dimension used for similarity calculation, sim(V1, V2) is the cosine similarity. V1·V2 represents the dot product of V1 and V2, and ||V1|| and ||V2|| are the Euclidean norms of vectors V1 and V2, respectively.

[0083] Step S303: taking the maximum similarity among the multiple similarities as the document similarity of the target document, and taking the target document corresponding to the maximum document similarity among the multiple document similarities of the multiple target documents as the query result of the user query.

[0084] Exemplarily, the maximum similarity among the multiple similarities is used as the document similarity of the target document, and the query result of the user's query is finally determined according to the document similarity.

[0085] For example, for the target document in the document library 110, when N=2, it means that the target document is segmented according to the preset segmentation rule to obtain two text blocks, and the two text blocks correspond to text block vectors c1 and c2 respectively. The number of predicted query questions output by the large language model is also two, and the two predicted query questions correspond to predicted query vectors qs1 and qs2 respectively. The title vector is represented by t, then let qs=(qs1+qs2) / 2, c=(c1+c2) / 2, and the target vector is represented by (c i +w q *qs+w t *t+w c *c), calculate the cosine similarity twice according to formula (2). Compare sim1(q, (c1+w q *qs+w t *t+w c *c)) and sim2(q,(c2+w q *qs+w t *t+w c The largest value in *c) is the maximum similarity. The maximum similarity is used as the document similarity of the target document.

[0086] For example, assuming that the value of sim1(q, d1) is the largest, then the maximum similarity sim1(q, d1) is the document similarity of the target document.

[0087] For the multiple target documents included in the document library 110, the above document similarity is calculated for each target document in turn, and the multiple document similarities of the multiple target documents are compared to obtain the maximum document similarity. The target text corresponding to the maximum document similarity is the query result of the user query. It can be understood that the maximum document similarity corresponds to at least one target document among the multiple target documents.

[0088] Therefore, this application, based on dividing the target document into multiple text blocks, uses a large language model to generate multiple predictive query questions and titles for the target document, which can expand the semantic expression type of the target document and enrich the semantic expression knowledge to achieve more effective similarity calculation, thereby improving the query matching effect for user queries.

[0089] It should be noted that although the operations of the method of the embodiment of the present application are described in a specific order in the above embodiment, this does not require or imply that these operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flow chart can change the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution.

[0090] Based on the method in the above embodiment, illustratively, Figure 4 The query matching device 400 is provided with a query matching system, which includes a plurality of target documents, such as Figure 4 As shown, the query matching device 400 includes:

[0091] The segmentation module 410 is used to segment each target document based on a preset segmentation rule in an offline stage to obtain multiple text blocks.

[0092] The processing module 420 is used to determine multiple predicted query questions and document titles of the target document in an offline stage.

[0093] The processing module 420 is further used to generate a text block vector for each text block, a prediction query vector corresponding to each of the multiple prediction query questions, and a title vector corresponding to the document title based on the document embedding method in an offline stage.

[0094] The first calculation module 430 is used to generate a target vector for each text block according to the text block vector, the predicted query vector, and the title vector of each text block in the multiple text blocks in the offline stage to obtain multiple target vectors.

[0095] The receiving module 440 is used to receive user queries in the query phase and calculate corresponding query vectors.

[0096] The second calculation module 450 is used to calculate the similarities between the query vector and multiple target vectors corresponding to the target document for each target document in the query phase, and obtain corresponding multiple similarities.

[0097] Output module 460 is used to use the maximum similarity among multiple similarities as the document similarity of the target document in the query stage, and for multiple document similarities of multiple target documents, use the target document corresponding to the maximum document similarity as the query result of the user query.

[0098] Based on the method in the above embodiment, an embodiment of the present application provides a computing device. The computing device may include: at least one memory for storing programs; at least one processor for executing the programs stored in the memory. Wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the above embodiment. Exemplarily, the computing device may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a server, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook, and a cellular phone, a personal digital assistant (personal digital assistant, PDA), an augmented reality (augmented reality, AR) device, a virtual reality (virtual reality, VR) device, an artificial intelligence (artificial intelligence, Al) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device. The embodiment of the present application does not impose any special restrictions on the specific category of the computing device.

[0099] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0100] It is understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. It should be understood that in the embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0101] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the scope of protection of the present application.

Claims

1. A query matching method based on document embedding, characterized in that: Applied to a query matching system, the query matching system includes a plurality of target documents, the method includes: During the offline phase: For each target document, segment the target document based on a preset segmentation rule to obtain multiple text blocks; Determining a plurality of predicted query questions for the target document, and a document title; Based on the document embedding method, generate a text block vector for each text block, a prediction query vector corresponding to each of the plurality of prediction query questions, and a title vector corresponding to the document title; Generate a target vector for each text block according to the text block vector of each text block in the multiple text blocks, the predicted query vector, and the title vector, to obtain multiple target vectors; During the query phase: Receive user queries and calculate the corresponding query vector; For each target document, respectively calculating similarities between the query vector and multiple target vectors corresponding to the target document to obtain corresponding multiple similarities; The maximum similarity among the multiple similarities is used as the document similarity of the target document, and among the multiple document similarities of the multiple target documents, the target document corresponding to the maximum document similarity is used as the query result of the user query.

2. The method according to claim 1, characterized in that The determining of the multiple predicted query questions and document titles of the target document comprises: The target document and the preset prompt words are input into the large language model, so that the large language model generates a plurality of predicted query questions and a document title based on the target document under the guidance of the preset prompt words.

3. The method according to claim 1, characterized in that The text block vector, predicted query vector, and title vector each have different weights. The step of generating a target vector for each text block according to the text block vector of each text block in the plurality of text blocks, the predicted query vector, and the title vector, and obtaining a plurality of target vectors includes: The multiple target vectors are obtained by performing calculations based on the text block vector of each text block in the multiple text blocks, the predicted query vector, the title vector, and the weights thereof.

4. The method according to claim 3, characterized in that The calculation formula of the document similarity includes: sim(q,d)=max i s(q’(c i +∑ f w f *e f )), Among them, q is the query vector, d is the target document, (c i +∑ f w f *e f ) is the i-th target vector corresponding to the target document, c i is the i-th text block vector, 1≤i≤N, i∈Z, N is the total number of the multiple text blocks; e f The vector c is the average of multiple text block vectors, or the vector qs is the average of multiple predicted query vectors, or the title vector t, w f for e f The corresponding weights, weights w of vector c, vector qs and title vector t f They are w c 、w q and w t , where w c +w q +w t =1.

5. The method according to claim 1, characterized in that The preset segmentation rule includes segmenting the target document into blocks with a block size dynamically determined based on the length and semantic content of the target document.

6. The method according to claim 1, characterized in that The generating of the text block vectors of each text block, the prediction query vectors corresponding to each of the plurality of prediction query questions, and the title vector corresponding to the document title based on the document embedding method includes: Each text block in the multiple text blocks, each query question in the multiple predicted query questions, and the document title are respectively input into the text embedding model to generate a fixed-length text block vector, a predicted query vector, and a title vector.

7. The method according to claim 1, characterized in that The similarity calculation includes cosine similarity calculation.

8. A query matching device based on document embedding, characterized in that: A query matching system is deployed, the query matching system includes a plurality of target documents, and the device includes: A segmentation module is used to segment each target document based on a preset segmentation rule in an offline stage to obtain multiple text blocks; A processing module, configured to determine a plurality of predicted query questions and a document title of the target document in an offline stage; The processing module is further used to generate a text block vector for each text block, a prediction query vector corresponding to each of the plurality of prediction query questions, and a title vector corresponding to the document title based on a document embedding method in an offline stage; A first calculation module is used to generate a target vector for each text block according to the text block vector of each text block in the multiple text blocks, the predicted query vector, and the title vector in an offline stage to obtain multiple target vectors; A receiving module, used to receive user queries in the query phase and calculate the corresponding query vector; A second calculation module is used to calculate the similarity between the query vector and multiple target vectors corresponding to the target document for each target document in the query phase, and obtain multiple corresponding similarities; The output module is used to use the maximum similarity among multiple similarities as the document similarity of the target document in the query stage, and for the multiple document similarities of the multiple target documents, use the target document corresponding to the maximum document similarity as the query result of the user query.

9. A computer storage medium storing instructions, wherein when the instructions are executed on a computer, the computer executes the method according to any one of claims 1 to 7.

10. A computing device, characterized in that: include: at least one memory for storing a program; At least one processor, configured to execute the program stored in the memory; wherein, when the program stored in the memory is executed, the processor is configured to execute the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Text generation method and device, electronic equipment and computer readable storage medium

    CN119647406A