CN-121980003-A - Search enhancement generation method and generation device thereof, electronic device and storage medium
Abstract
The application discloses a search enhancement generation method, a generation device, electronic equipment and a storage medium thereof, wherein the method comprises the steps of obtaining a search vector of a user; searching a chapter vector database based on the search vector to obtain target chapter metadata, associating the chapter vector database with a plurality of chapter metadata of a preset document, associating each chapter metadata with at least one sub-block vector in a sub-block vector database, searching target sub-block metadata corresponding to the sub-block vector database based on the search vector to obtain search sub-block metadata, associating the target sub-block metadata with the target chapter metadata, and inputting the search sub-block metadata into a large language model to obtain a search result. The method realizes the retrieval of the preset document based on the retrieval vector, the chapter vector database and the target sub-block metadata, the target sub-block metadata is associated with the target chapter metadata of the result retrieved by the chapter vector database, and the efficiency of the retrieval enhancement generation is improved.
Inventors
- CHEN HUANMING
- SHI ZHIQIANG
- YU WEIGUO
- KONG DESHEN
- WANG JISHENG
- LI GUANGZHI
- LIANG WEIQI
- JIANG HAIHUI
- HONG SHUANG
Assignees
- 长园深瑞继保自动化有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251212
Claims (10)
- 1. A search enhancement generation method, comprising: Obtaining a retrieval vector of a user; Searching a chapter vector database based on the search vector to obtain target chapter metadata, wherein the chapter vector database is associated with a plurality of chapter metadata of a preset document, each chapter metadata is associated with at least one sub-block vector in a sub-block vector database, and each sub-block vector is associated with one sub-block metadata; Searching target sub-block metadata corresponding to the sub-block vector database based on the search vector to obtain the search sub-block metadata, wherein the target sub-block metadata are associated with the target chapter metadata; and inputting the metadata of the retrieval sub-blocks into a large language model to obtain a retrieval result.
- 2. The method of claim 1, wherein the chapter vector database includes a plurality of chapter vectors, each chapter vector being associated with one chapter metadata, wherein the retrieving the chapter vector database based on the retrieval vector to obtain the target chapter metadata includes: calculating first similarity between the search vector and each chapter vector to obtain a plurality of first similarities; selecting the first similarity greater than or equal to a first similarity threshold from the plurality of first similarities to obtain a first target similarity; and determining the chapter metadata associated with the first target similarity as the target chapter metadata.
- 3. The method of claim 1, wherein the sub-block vector database includes at least one target sub-block vector associated with at least one target sub-block metadata, wherein the retrieving the target sub-block metadata corresponding to the sub-block vector database based on the retrieval vector includes: calculating a second similarity of the search vector and each target sub-block vector to obtain at least one second similarity; selecting the second similarity greater than or equal to a second similarity threshold from the at least one second similarity to obtain a second target similarity; And determining the target sub-block metadata associated with the second target similarity as the retrieval sub-block metadata.
- 4. The search enhancement generation method according to claim 1, wherein the number of the search sub-block metadata is plural, the search enhancement generation method further comprises, before the search result is obtained by inputting the search sub-block metadata to a large language model: acquiring target chapter sub-block codes of each piece of retrieval sub-block metadata to obtain a plurality of target chapter sub-block codes, wherein the target chapter sub-block codes are used for representing chapter arrangement sequences of each piece of retrieval sub-block metadata in the preset document and sub-block arrangement sequences under the corresponding target chapter metadata; Performing text splicing on the plurality of retrieval sub-block metadata according to the plurality of target chapter sub-block codes to obtain spliced sub-block metadata; And inputting the metadata of the retrieval sub-block into a large language model to obtain a retrieval result, wherein the method comprises the following steps: And inputting the metadata of the spliced sub-blocks to the large language model to obtain the retrieval result.
- 5. The retrieval enhancement generation method according to any one of claims 1 to 4, wherein the retrieval enhancement generation method further comprises, before the retrieval vector of the user is acquired: Acquiring the preset document; according to preset chapter logic of the preset document, performing block processing on the preset document to obtain the chapter metadata and the sub-block metadata; constructing the chapter vector database according to the chapter metadata; constructing the sub-block vector database according to the plurality of sub-block metadata; And associating each chapter metadata with the at least one sub-block vector in the sub-block vector database according to chapter sub-block codes of each sub-block metadata, wherein the chapter sub-block codes are used for representing chapter arrangement sequences of the corresponding sub-block metadata in the preset document and sub-block arrangement sequences under the corresponding chapter metadata.
- 6. The retrieval enhancement generation method of claim 5, wherein the constructing the chapter vector database from the plurality of chapter metadata comprises: determining a corresponding chapter abstract according to the chapter metadata to obtain a plurality of chapter abstracts; Generating a chapter vector based on each chapter summary to obtain a plurality of chapter vectors; the chapter vector database is generated based on the plurality of chapter vectors.
- 7. The retrieval enhancement generation method of claim 5, wherein the constructing the sub-block vector database from the plurality of sub-block metadata comprises: Determining corresponding sub-block abstracts according to the sub-block metadata to obtain a plurality of sub-block abstracts; generating a sub-block vector based on each sub-block digest to obtain a plurality of sub-block vectors; the sub-block vector database is generated based on the plurality of sub-block vectors.
- 8. A search enhancement generation apparatus, comprising: the vector acquisition module is used for acquiring the retrieval vector of the user; The first retrieval module is used for retrieving a chapter vector database based on the retrieval vector to obtain target chapter metadata, the chapter vector database is associated with a plurality of chapter metadata of a preset document, each chapter metadata is associated with at least one sub-block vector in a sub-block vector database, and each sub-block vector is associated with one sub-block metadata; the second retrieval module is used for retrieving target sub-block metadata corresponding to the sub-block vector database based on the retrieval vector to obtain retrieval sub-block metadata, and the target sub-block metadata are associated with the target chapter metadata; And the input module is used for inputting the metadata of the retrieval sub-block into the large language model to obtain a retrieval result.
- 9. An electronic device, comprising: A memory; One or more processors coupled with the memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by one or more processors, the one or more applications configured to perform the retrieval enhancement generation method of any of claims 1-7.
- 10. A computer-readable storage medium, wherein the computer-readable storage medium has stored therein a program code that is callable by a processor to perform the retrieval enhancement generation method as recited in any one of claims 1 to 7.
Description
Search enhancement generation method and generation device thereof, electronic device and storage medium Technical Field The application belongs to the technical field of search enhancement generation, and particularly relates to a search enhancement generation method and device, electronic equipment and a storage medium. Background The retrieval enhancement generation (RETRIEVAL-augmented Generation, RAG) technology is used as a core technology path in the field of machine question and answer, the defects of knowledge timeliness and accuracy of a large language model are effectively overcome by integrating knowledge retrieval and natural language generation capability, and the core logic is to acquire a question-associated knowledge fragment from a preset knowledge base by means of a retrieval module, integrate knowledge and output answers by means of a generation model, so that the method is widely applied to open-domain question and answer scenes. At present, in the process of generating the retrieval enhancement, the knowledge segments associated with the problems are obtained by matching the problems with all knowledge segments in a preset knowledge base one by one. However, when there are many knowledge segments in the preset knowledge base, the process of matching the questions with all the knowledge segments one by one takes a long time, resulting in low efficiency of the search enhancement generation. Disclosure of Invention In view of the above, embodiments of the present application provide a search enhancement generation method, a generation device thereof, an electronic device, and a storage medium, so as to overcome the above problems in the prior art. In a first aspect, an embodiment of the present application provides a search enhancement generation method, including: Obtaining a retrieval vector of a user; Searching a chapter vector database based on the search vector to obtain target chapter metadata, wherein the chapter vector database is associated with a plurality of chapter metadata of a preset document, each chapter metadata is associated with at least one sub-block vector in a sub-block vector database, and each sub-block vector is associated with one sub-block metadata; Searching target sub-block metadata corresponding to the sub-block vector database based on the search vector to obtain the search sub-block metadata, wherein the target sub-block metadata are associated with the target chapter metadata; and inputting the metadata of the retrieval sub-blocks into a large language model to obtain a retrieval result. In some optional embodiments, the chapter vector database includes a plurality of chapter vectors, each chapter vector is associated with one chapter metadata, and the searching the chapter vector database based on the search vector to obtain target chapter metadata includes: calculating first similarity between the search vector and each chapter vector to obtain a plurality of first similarities; selecting the first similarity greater than or equal to a first similarity threshold from the plurality of first similarities to obtain a first target similarity; and determining the chapter metadata associated with the first target similarity as the target chapter metadata. In some optional embodiments, the sub-block vector database includes at least one target sub-block vector, the at least one target sub-block vector is associated with at least one target sub-block metadata, the retrieving, based on the retrieving vector, the target sub-block metadata corresponding to the sub-block vector database, to obtain the retrieved sub-block metadata, includes: calculating a second similarity of the search vector and each target sub-block vector to obtain at least one second similarity; selecting the second similarity greater than or equal to a second similarity threshold from the at least one second similarity to obtain a second target similarity; And determining the target sub-block metadata associated with the second target similarity as the retrieval sub-block metadata. In some optional embodiments, the number of the search sub-block metadata is a plurality of, and before the input of the search sub-block metadata to the large language model and obtaining the search result, the search enhancement generation method further includes: acquiring target chapter sub-block codes of each piece of retrieval sub-block metadata to obtain a plurality of target chapter sub-block codes, wherein the target chapter sub-block codes are used for representing chapter arrangement sequences of each piece of retrieval sub-block metadata in the preset document and sub-block arrangement sequences under the corresponding target chapter metadata; Performing text splicing on the plurality of retrieval sub-block metadata according to the plurality of target chapter sub-block codes to obtain spliced sub-block metadata; And inputting the metadata of the retrieval sub-block into a large language model to obtain a