Retrieval system and method based on knowledge base generated from search augmentation

CN118779429BActive Publication Date: 2026-10-16BEIJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410945806.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2026-10-16
Estimated Expiration
2044-07-15

AI Technical Summary

Technical Problem

[0003]然而现有的检索器在检索信息的类型和准确性方面往往存在着不足,大多数现有技术方案专注于文本类型数据,经常忽略了表格以及图片类型的信息,即使对表格信息进行了处理也较为粗糙,切分不合理、丢失表格结构信息的问题常有发生

Benefits of technology

[0045] The beneficial effects of this invention are as follows: The solution is based on image-text embedding vectors and optimizes the table structure, enabling the storage of three types of information: text, tables, and images. The entire storage process is stable and reliable, adaptable to a wider range of business scenarios, and supports multimodal question-answering models. The solution optimizes the segmentation and storage scheme for table-type information, using Markdown-formatted tables as the framework. While preserving the table structure, it employs a more intelligent and reasonable segmentation scheme, enabling segmentation even for extremely long tables with almost no loss of structural information. This helps improve the question-answering model's understanding of the document after the table is retrieved. A two-stage retrieval scheme is used, gradually narrowing the scope of the retrieved documents through a retrieval + reordering method, significantly improving the reliability of the retrieval results. Simultaneously, the dynamic adjustment of the retrieval document block window enhances the robustness of the retrieval scheme. The use of two different reordering methods ensures a comprehensive understanding of the document while highlighting the main question, adapting to more complex user questions and providing a crucial foundation for generating high-quality answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779429B_ABST
    Figure CN118779429B_ABST
Patent Text Reader

Abstract

The application discloses a knowledge base storage retrieval system and method based on retrieval enhancement generation, and mainly comprises the following steps: (1) a document extraction and blocking module, which divides the document added to the knowledge base into document blocks to form a document list and a keyword list; (2) a document vectorization and storage module, which stores the vectorized document list and keyword list into a vector library; (3) a document window setting module, which determines the size of the document window value W according to the user's query information; (4) a preliminary retrieval module, which extracts the first W documents with the maximum document similarity value as the preliminary retrieval result; and (5) a hybrid reordering module, which returns W / 2 documents from the preliminary retrieval result as the final retrieval result according to the size of the comprehensive similarity s value. The application has supporting capability for a multi-modal question and answer large model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a knowledge base storage and retrieval system and method based on retrieval enhancement, belonging to the field of information technology, and particularly to the field of knowledge base storage and retrieval technology. Background Technology

[0002] Retrieval-enhanced generation (RAG) is a technique that assists large models in generating answers. Users pose questions to the large model's knowledge base system. If the relevant knowledge for the question does not exist in the large model's knowledge reserves, the retrieval tool searches the knowledge base to find the relevant answer to the question and provides it to the large model, thus avoiding the large model from encountering illusion problems.

[0003] However, existing search engines often fall short in terms of the type and accuracy of the information retrieved. Most existing technical solutions focus on text data and often ignore table and image information. Even when table information is processed, it is often crude, with problems such as unreasonable segmentation and loss of table structure information frequently occurring.

[0004] How to effectively utilize search enhancement generation technology to solve the aforementioned problems in existing knowledge base storage and retrieval systems is a pressing technical challenge in the field of knowledge base storage and retrieval technology. Summary of the Invention

[0005] In view of this, the purpose of this invention is to invent a knowledge base storage and retrieval system and method based on retrieval enhancement generation, which can realize multimodal storage and retrieval of text, tables and images, and has the characteristics of high retrieval efficiency and high robustness.

[0006] To achieve the above objectives, this invention proposes a knowledge base storage and retrieval system based on retrieval enhancement generation, the system comprising the following modules:

[0007] The document extraction and segmentation module has the following functions:

[0008] (1) The documents added to the knowledge base are divided into document blocks using a specific tool; the document blocks are divided into three types: text, images, and tables. Images are encoded in base64 format, and tables are encoded in markdown format; long table document blocks are further divided and stored; if there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list.

[0009] (2) Based on two methods, namely rule-based and large model-based prompting engineering, the stored text and table information is filtered to extract keyword information and form a keyword list; the keyword information refers to entities and relationships.

[0010] The document vectorization and storage module has the following function: using a multimodal vectorization embedding model, it vectorizes the document list and keyword list generated by the document extraction and segmentation module, and then stores the vectorized document list and keyword list in a vector library.

[0011] The document window settings module determines the size of the document window value W based on the user's query information. The document window value W refers to the number of documents that the knowledge base needs to return based on the user's query information.

[0012] The preliminary retrieval module's function is to first vectorize the user's query, then calculate the document similarity s1 between the user's query and the documents to be screened in the knowledge base, and extract the top W documents with the highest document similarity values ​​according to the document window value W, as the preliminary retrieval results.

[0013] The hybrid reordering module has the following functions: (1) Calculate the keyword similarity s2 between the user's question and the document in the preliminary search results based on the keywords contained in each document in the preliminary search results; (2) Calculate the overall semantic similarity s3 between the user's question and the document in the preliminary search results through the document reordering device; (3) Calculate the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; (4) Return W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value.

[0014] The specific details of the two methods for extracting keyword information, namely rule-based and large model suggestion engineering, are as follows: the rule-based method is mainly used for keyword extraction from table documents; the large model suggestion engineering method is mainly used for keyword extraction from long cells or text information.

[0015] The large model prompts the project to return entities and relationships in the document in JSON format and then perform post-processing to extract the JSON. As for table extraction, if the text length in a cell is less than the preset value M, it means that its content is a basic entity or relationship; if the length is greater than the preset value M, it means that the content of the current cell is a narrative text, and the large model method is used for extraction.

[0016] The document extraction and segmentation module performs secondary segmentation and storage for excessively long table document blocks as follows: First, it determines the total length of the table document block. If the total length does not exceed the system's preset length limit K, then the table document block does not need to be segmented. Otherwise, it performs a secondary segmentation process based on the table structure information of the table document block. The table structure information refers to the table orientation and header structure.

[0017] The orientation of the table is determined using a large model. Before sending the table into the large model, the table structure and content need to be reduced to prevent the table from exceeding the context window. The table reduction includes two parts: the first part is cell reduction, which truncates the part of the cell whose number of characters exceeds the preset value M; the second part is row-by-row judgment, which judges whether the current table length exceeds the preset length limit value K after processing each row. If it does not exceed the limit, it continues; otherwise, it directly returns to the processed part.

[0018] The specific content of the secondary segmentation process is as follows: (1) No header, header on the left, i.e., horizontal table, meaning that each attribute corresponds to one row. This type of table can be directly segmented by row without additional processing; (2) Header at the top, and only one header row, i.e., vertical table, meaning that each attribute corresponds to one column. This type of table needs to add a header to each sub-table block when segmenting; (3) Header at the top, with multiple header rows, i.e., vertical nested table. This type of table also needs to add a header to each sub-table block when segmenting, except that multiple rows need to be added.

[0019] The document list consists of multiple Element type data, each Element containing four fields: doc_id, type, text, and uri. The doc_id field is of type string and is used to uniquely identify the Element. The type field is of type string and is used to identify the type of the Element, including Image, Text, and Table. The text field is of type string and is used to store text information. In the text type, this field stores the text string; in the table type, it stores the combination of the table and its caption; in the image type, this field stores the caption information. The uri field is of type string and is only valid in the image type; in other types, this field is empty and is used to store the path of the image.

[0020] The keyword list consists of multiple KeyWords type data. These KeyWords type data are extracted from the text field of the corresponding Element type data through rule design and large-scale model hinting engineering. The KeyWords type data includes three fields: doc_id, type, and keylist. The doc_id field is of type string and is used to uniquely identify the KeyWords type data. The type field is of type string and is used to identify the type of KeyWords, including Text and Table. The keylist field is of type list and consists of a list containing multiple keywords extracted from the text field of the Element type data.

[0021] The document list and the keyword list have a one-to-one correspondence. Each Element type data has a unique corresponding KeyWords type data, and the doc_id field of the corresponding Element type data and KeyWords type data is the same.

[0022] The preliminary retrieval module calculates the similarity s1 according to the following formula:

[0023] s1 = 1 / (1+d)

[0024] In the above formula, d represents the Euclidean distance between the vectorized user query and the vectorized document to be filtered stored in the document vectorization and storage module.

[0025] The document window settings module determines the size of the document window based on the user's query information as follows:

[0026] (1) The prompting process breaks down the user's question into multiple sub-questions, and then extracts the main keywords from the question;

[0027] (2) Calculate the document window value W according to the following formula:

[0028]

[0029] In the above formula, k represents the number of main keywords extracted from the user's question; P and U are preset values, where U represents the number of basic documents and P represents the number of documents that increase with the number of main keywords. This indicates rounding up to the nearest integer.

[0030] The method for calculating the keyword similarity s² between the user's question and the document is as follows:

[0031] s2=(max(k1,k2,...,km)+avg(k1,k2,...,km)) / 2

[0032] In the above formula, ki, i = 1, 2, ..., m represents the similarity between the user's question and the i-th keyword of the document, the function max() represents taking the maximum value, and the function avg() represents taking the average value;

[0033] ki is calculated according to the following formula:

[0034] ki = 1 / (1+di)

[0035] In the above formula, di represents the Euclidean distance between the vectorized user question and the i-th keyword of the document; the comprehensive similarity s is obtained by calculating the average of the keyword similarity s2 and the overall semantic similarity s3.

[0036] The overall semantic similarity s3 is calculated as follows:

[0037] s3=2 / (1+exp(-r))-1

[0038] In the above formula, r represents the re-ranking score of the document reorderer based on the vectorized user query for the preliminary search results documents, and the value of r ranges from 0 to +∞.

[0039] This invention also proposes a knowledge base storage and retrieval method based on retrieval enhancement, the method comprising the following steps:

[0040] (1) The document extraction and segmentation module divides the documents added to the knowledge base into document blocks using a specific tool. The document blocks are divided into three types: text, images, and tables. Images are encoded in base64 format, and tables are encoded in markdown format. For excessively long table document blocks, secondary segmentation and storage are performed. If there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list. Based on two methods, rule-based and large model prompting engineering, the stored text and table information are filtered to extract keyword information and form a keyword list. The keyword information refers to entities and relationships.

[0041] (2) Document vectorization and storage module: using a multimodal vectorization embedding model, the document list and keyword list generated by the document extraction and segmentation module are vectorized, and then the vectorized document list and keyword list are stored in the vector library.

[0042] (3) Document window setting module, which determines the size of document window value W based on the user's question information; the document window value W refers to the number of documents that the knowledge base needs to return based on the user's question information;

[0043] (4) The preliminary retrieval module vectorizes the user's question, then calculates the document similarity s1 between the user's question and the documents to be screened in the knowledge base, and extracts the top W documents with the largest document similarity values ​​according to the document window value W, as the preliminary retrieval results;

[0044] (5) The hybrid reordering module calculates the keyword similarity s2 between the user's question and the documents in the preliminary search results based on the keywords contained in each document in the preliminary search results; calculates the overall semantic similarity s3 between the user's question and the documents in the preliminary search results through the document reordering device; calculates the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; and returns W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value.

[0045] The beneficial effects of this invention are as follows: The solution is based on image-text embedding vectors and optimizes the table structure, enabling the storage of three types of information: text, tables, and images. The entire storage process is stable and reliable, adaptable to a wider range of business scenarios, and supports multimodal question-answering models. The solution optimizes the segmentation and storage scheme for table-type information, using Markdown-formatted tables as the framework. While preserving the table structure, it employs a more intelligent and reasonable segmentation scheme, enabling segmentation even for extremely long tables with almost no loss of structural information. This helps improve the question-answering model's understanding of the document after the table is retrieved. A two-stage retrieval scheme is used, gradually narrowing the scope of the retrieved documents through a retrieval + reordering method, significantly improving the reliability of the retrieval results. Simultaneously, the dynamic adjustment of the retrieval document block window enhances the robustness of the retrieval scheme. The use of two different reordering methods ensures a comprehensive understanding of the document while highlighting the main question, adapting to more complex user questions and providing a crucial foundation for generating high-quality answers. Attached Figure Description

[0046] Figure 1 This is a schematic diagram of the knowledge base storage and retrieval system based on retrieval enhancement proposed in this invention.

[0047] Figure 2 This is a flowchart illustrating the knowledge base storage and retrieval method based on retrieval enhancement proposed in this invention. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings.

[0049] See Figure 1This invention proposes a knowledge base storage and retrieval system based on retrieval enhancement, which includes the following modules:

[0050] The document extraction and segmentation module has the following functions:

[0051] (1) The documents added to the knowledge base are divided into document blocks using a specific tool; the document blocks are divided into three types: text, images, and tables. Images are encoded in base64 format, and tables are encoded in markdown format; long table document blocks are further divided and stored; if there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list.

[0052] In this embodiment, the specific tools for segmentation are Unstructured (https: / / unstructured.io / ) and langchain (https: / / python.langchain.com / v0.2 / docs / introduction / ). Unstructured is an open-source component for extracting and preprocessing images and text documents, while langchain is a standard interface for LLM that can provide components such as Document.

[0053] (2) Based on two methods, namely rule-based and large model-based prompting engineering, the stored text and table information is filtered to extract keyword information and form a keyword list; the keyword information refers to entities and relationships.

[0054] The document vectorization and storage module has the following function: using a multimodal vectorization embedding model, it vectorizes the document list and keyword list generated by the document extraction and segmentation module, and then stores the vectorized document list and keyword list in a vector library.

[0055] In this embodiment, the inventors added the `embed_image` function to the FAISS (https: / / pypi.org / project / faiss / ) vector library to make its interface more suitable for vectorized image storage. Visualized-BGE (https: / / github.com / FlagOpen / FlagEmbedding / tree / master / FlagEmbedding / visual) was used as the vectorization embedding model. This embedding model supports multimodal capabilities and is convenient for vectorizing both text and image information.

[0056] In this embodiment, the relevant code for the embed_image function is shown in Table 1.

[0057] Table 1

[0058]

[0059]

[0060]

[0061]

[0062] The document window settings module determines the size of the document window value W based on the user's query information. The document window value W refers to the number of documents that the knowledge base needs to return based on the user's query information.

[0063] The preliminary retrieval module's function is to first vectorize the user's query, then calculate the document similarity s1 between the user's query and the documents to be screened in the knowledge base, and extract the top W documents with the highest document similarity values ​​according to the document window value W, as the preliminary retrieval results.

[0064] The hybrid reordering module has the following functions: (1) Calculate the keyword similarity s2 between the user's question and the document in the preliminary search results based on the keywords contained in each document in the preliminary search results; (2) Calculate the overall semantic similarity s3 between the user's question and the document in the preliminary search results through the document reordering device; (3) Calculate the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; (4) Return W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value.

[0065] The specific details of the two methods for extracting keyword information, namely rule-based and large model suggestion engineering, are as follows: the rule-based method is mainly used for keyword extraction from table documents; the large model suggestion engineering method is mainly used for keyword extraction from long cells or text information.

[0066] In this embodiment, the large model used is ChatGLM4 (see Zhipu Open Platform: https: / / maas.aminer.cn / ), which is called via API.

[0067] The large model prompts the project to return entities and relationships in the document in JSON format and then perform post-processing to extract the JSON. As for table extraction, if the text length in a cell is less than the preset value M, it means that its content is a basic entity or relationship; if the length is greater than the preset value M, it means that the content of the current cell is a narrative text, and the large model method is used for extraction.

[0068] In the embodiments, M is typically taken as 20 to 30.

[0069] The document extraction and segmentation module performs secondary segmentation and storage for excessively long table document blocks as follows: First, it determines the total length of the table document block. If the total length does not exceed the system's preset length limit K, then the table document block does not need to be segmented. Otherwise, it performs a secondary segmentation process based on the table structure information of the table document block. The table structure information refers to the table orientation and header structure.

[0070] In the embodiments, K is typically set to 800 characters.

[0071] The orientation of the table is determined using a large model. Before sending the table into the large model, the table structure and content need to be reduced to prevent the table from exceeding the context window. The table reduction includes two parts: the first part is cell reduction, which truncates the part of the cell whose number of characters exceeds the preset value M; the second part is row-by-row judgment, which judges whether the current table length exceeds the preset length limit value K after processing each row. If it does not exceed the limit, it continues; otherwise, it directly returns to the processed part.

[0072] The specific content of the secondary segmentation process is as follows: (1) No header, header on the left, i.e., horizontal table, meaning that each attribute corresponds to one row. This type of table can be directly segmented by row without additional processing; (2) Header at the top, and only one header row, i.e., vertical table, meaning that each attribute corresponds to one column. This type of table needs to add a header to each sub-table block when segmenting; (3) Header at the top, with multiple header rows, i.e., vertical nested table. This type of table also needs to add a header to each sub-table block when segmenting, except that multiple rows need to be added.

[0073] Table 2

[0074]

[0075] Referring to Table 2, the document list consists of multiple Element type data. Each Element contains four fields: doc_id, type, text, and uri. The doc_id field is of type string and is used to uniquely identify the Element. The type field is of type string and is used to identify the type of the Element, including Image, Text, and Table. The text field is of type string and is used to store text information. In the text type, this field stores the text string; in the table type, it stores the combination of the table and its caption; in the image type, this field stores the caption information. The uri field is of type string and is only valid in the image type. In other types, this field is empty and is used to store the path of the image.

[0076] Table 3

[0077]

[0078] Referring to Table 3, the keyword list consists of multiple KeyWords type data. These KeyWords type data are extracted from the text field of the corresponding Element type data through rule design and large-scale model hinting engineering. The KeyWords type data includes three fields: doc_id, type, and keylist. The doc_id field is of type string and is used to uniquely identify the KeyWords type data. The type field is of type string and is used to identify the type of KeyWords, including Text and Table. The keylist field is of type list and consists of a list containing multiple keywords extracted from the text field of the Element type data.

[0079] Table 4

[0080]

[0081] Referring to Table 4, the document list and the keyword list have a one-to-one correspondence. Each Element type data has a unique corresponding KeyWords type data, and the doc_id field of the corresponding Element type data and KeyWords type data is consistent.

[0082] The preliminary retrieval module calculates the similarity s1 according to the following formula:

[0083] s1 = 1 / (1+d)

[0084] In the above formula, d represents the Euclidean distance between the vectorized user query and the vectorized document to be filtered stored in the document vectorization and storage module.

[0085] Since user questions may be complex, such as "Did the national team of this season's Premier League Golden Boot winner qualify for the European Championship?", this question can actually be broken down into three questions: "Who is this season's Premier League Golden Boot winner?", "What is his nationality?", and "Did country X qualify for the European Championship?". The document blocks corresponding to these three questions may be different, and the relevant document window value W required for this question may actually exceed that of other questions of the same length. Therefore, it is necessary to dynamically determine the value of W based on the user's question information.

[0086] The document window settings module determines the size of the document window value W based on the user's query information as follows:

[0087] (1) The prompting process breaks down the user's question into multiple sub-questions, and then extracts the main keywords from the question;

[0088] (2) Calculate the document window value W according to the following formula:

[0089]

[0090] In the above formula, k represents the number of main keywords extracted from the user's question; P and U are preset values, where U represents the number of basic documents and P represents the number of documents that increase with the number of main keywords. This indicates rounding up to the nearest integer.

[0091] For example, after the above processing, we can extract five keywords: "this season, Premier League, Golden Boot, nationality, European Cup", i.e., k=5. Assuming P is 0.5 and U is 2, then W is 10. Therefore, there should be 10 candidate blocks in the initial screening, and 5 document blocks are finally determined by reordering.

[0092] The method for calculating the keyword similarity s² between the user's question and the document is as follows:

[0093] s2=(max(k1,k2,...,km)+avg(k1,k2,...,km)) / 2

[0094] In the above formula, ki, i = 1, 2, ..., m represents the similarity between the user's question and the i-th keyword of the document, the function max() represents taking the maximum value, and the function avg() represents taking the average value;

[0095] ki is calculated according to the following formula:

[0096] ki = 1 / (1+di)

[0097] In the above formula, di represents the Euclidean distance between the vectorized user question and the i-th keyword of the document; the comprehensive similarity s is obtained by calculating the average of the keyword similarity s2 and the overall semantic similarity s3.

[0098] The overall semantic similarity s3 is calculated as follows:

[0099] s3=2 / (1+exp(-r))-1

[0100] In the above formula, r represents the re-ranking score of the preliminary search results documents by the document re-ranking machine based on the vectorized user query, and the value of r ranges from 0 to +∞. In the embodiment, the document re-ranking machine is implemented using BGE-reranker-m3 (https: / / github.com / FlagOpen / FlagEmbedding / tree / master / FlagEmbedding / llm_reranker).

[0101] See Figure 2 The present invention also proposes a knowledge base storage and retrieval method based on retrieval enhancement, the method comprising the following steps:

[0102] (1) The document extraction and segmentation module divides the documents added to the knowledge base into document blocks using a specific tool. The document blocks are divided into three types: text, images, and tables. Images are encoded in base64 format, and tables are encoded in markdown format. For excessively long table document blocks, secondary segmentation and storage are performed. If there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list. Based on two methods, rule-based and large model prompting engineering, the stored text and table information are filtered to extract keyword information and form a keyword list. The keyword information refers to entities and relationships.

[0103] (2) Document vectorization and storage module: using a multimodal vectorization embedding model, the document list and keyword list generated by the document extraction and segmentation module are vectorized, and then the vectorized document list and keyword list are stored in the vector library.

[0104] (3) Document window setting module, which determines the size of document window value W based on the user's question information; the document window value W refers to the number of documents that the knowledge base needs to return based on the user's question information;

[0105] (4) The preliminary retrieval module vectorizes the user's question, then calculates the document similarity s1 between the user's question and the documents to be screened in the knowledge base, and extracts the top W documents with the largest document similarity values ​​according to the document window value W, as the preliminary retrieval results;

[0106] (5) The hybrid reordering module calculates the keyword similarity s2 between the user's question and the documents in the preliminary search results based on the keywords contained in each document in the preliminary search results; calculates the overall semantic similarity s3 between the user's question and the documents in the preliminary search results through the document reordering device; calculates the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; and returns W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value.

[0107] The inventors conducted extensive experiments on the system and method proposed in this invention, mainly including table segmentation experiments and retrieval experiments. In the table segmentation experiments, some tables that were too long to be directly incorporated into a large model were collected, including HTML and Markdown formats. Using the method of this invention, these tables were all reasonably segmented, ensuring the structural and semantic integrity of each sub-table.

[0108] The retrieval experiments were further divided into two aspects: table content retrieval and entity content retrieval. For table content retrieval, tables and related question datasets were collected for testing, and the experimental results were compared between the present invention and existing techniques for segmenting tables by character. For entity content retrieval, some semantically similar text content was collected, and the present invention's technical solution was compared with existing semantic-based technical solutions. The inventors conducted extensive experiments on these two types of retrieval problems, and the experimental results show that the retrieval accuracy of the present invention's technical solution is significantly improved. Furthermore, in other scenarios, the retrieval performance of the present invention's technical solution is also improved compared to existing technical solutions.

[0109] The above experimental results prove that the system and method proposed in this invention are effective.

Claims

1. A knowledge base storage and retrieval system based on retrieval enhancement, characterized in that: The system includes the following modules: The document extraction and segmentation module has the following functions: (1) The documents added to the knowledge base are divided into document blocks using a specific tool; the document blocks are divided into three types: text, images, and tables. Images are encoded in base64 format, and tables are encoded in markdown format; long table document blocks are split and stored in a second way; if there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list. (2) Based on two methods, namely rule-based and large model-based prompting engineering, the stored text and table information is filtered to extract keyword information and form a keyword list; the keyword information refers to entities and relationships. The document vectorization and storage module has the following function: using a multimodal vectorization embedding model, it vectorizes the document list and keyword list generated by the document extraction and segmentation module, and then stores the vectorized document list and keyword list in a vector library. The document window settings module determines the size of the document window value W based on the user's query information. The document window value W refers to the number of documents that the knowledge base needs to return based on the user's query information. The preliminary retrieval module's function is to first vectorize the user's query, then calculate the document similarity s1 between the user's query and the documents to be screened in the knowledge base, and extract the top W documents with the highest document similarity values ​​according to the document window value W, as the preliminary retrieval results. The hybrid reordering module has the following functions: (1) Calculate the keyword similarity s2 between the user's question and the document in the preliminary search results based on the keywords contained in each document in the preliminary search results; (2) Calculate the overall semantic similarity s3 between the user's question and the document in the preliminary search results through the document reordering device; (3) Calculate the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; (4) Return W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value. The document extraction and segmentation module performs secondary segmentation and storage for excessively long table document blocks as follows: First, it determines the total length of the table document block. If the total length does not exceed the system's preset length limit K, then the table document block does not need to be segmented. Otherwise, it performs a secondary segmentation process based on the table structure information of the table document block. The table structure information refers to the table orientation and header structure. The orientation of the table is determined using a large model. Before sending the table into the large model, the table structure and content need to be reduced to prevent the table from exceeding the context window. The table reduction includes two parts: the first part is cell reduction, which truncates the part of the cell with more than the preset value M; the second part is row-by-row judgment, which checks whether the current table length exceeds the preset length limit value K after processing each row. If it does not exceed the limit, it continues; otherwise, it directly returns to the processed part. The specific content of the secondary segmentation process is as follows: (1) No header, header on the left, i.e., horizontal table, meaning that each attribute corresponds to one row. This type of table can be directly segmented by row without additional processing; (2) Header at the top, and only one header row, i.e., vertical table, meaning that each attribute corresponds to one column. This type of table needs to add a header to each sub-block when segmenting; (3) Header at the top, with multiple header rows, i.e., vertical nested table. This type of table also needs to add a header to each sub-block when segmenting, except that multiple rows need to be added.

2. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The specific details of the two methods for extracting keyword information, namely rule-based and large model suggestion engineering, are as follows: the rule-based method is mainly used for keyword extraction from table documents; the large model suggestion engineering method is mainly used for keyword extraction from long cells or text information. The large model prompts the project to return entities and relationships in the document in JSON format and then perform post-processing to extract the JSON. As for table extraction, if the text length in a cell is less than the preset value M, it means that its content is a basic entity or relationship; if the length is greater than the preset value M, it means that the content of the current cell is a narrative text, and the large model method is used for extraction.

3. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The document list consists of multiple Element type data, each Element containing four fields: doc_id, type, text, and uri. The doc_id field is of type string and is used to uniquely identify the Element. The type field is of type string and is used to identify the Element's type, including Image, Text, and Table. The text field is of type string and is used to store text information; in the text type, this field stores the text string; in the table type, it stores the combination of the table and its caption; in the image type, this field stores the caption information. The uri field is of type string and is only valid in the image type; in other types, this field is empty and is used to store the path of the image. The keyword list consists of multiple KeyWords type data. These KeyWords type data are extracted from the text field of the corresponding Element type data through rule design and large-scale model hinting engineering. The KeyWords type data includes three fields: doc_id, type, and keylist. The doc_id field is of type string and is used to uniquely identify the KeyWords type data. The type field is of type string and is used to identify the type of KeyWords, including Text and Table. The keylist field is of type list and consists of a list containing multiple keywords extracted from the text field of the Element type data. (3) The document list and the keyword list are in a one-to-one correspondence. Each Element type data has a KeyWords type data that uniquely corresponds to it. The doc_id field of the corresponding Element type data and KeyWords type data is consistent.

4. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The preliminary retrieval module calculates the similarity s1 according to the following formula: In the above formula, d represents the Euclidean distance between the vectorized user query and the vectorized document to be filtered stored in the document vectorization and storage module.

5. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The document window settings module determines the size of the document window based on the user's query information as follows: (1) The user's question is broken down into multiple sub-questions through the prompting process, and then the main keywords in the question are extracted; (2) Calculate the document window value W according to the following formula: In the above formula, k represents the number of main keywords extracted from the user's question; P and U are preset values, where U represents the number of basic documents and P represents the number of documents that increase with the number of main keywords. This indicates rounding up to the nearest integer.

6. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The method for calculating the keyword similarity s² between the user's question and the document is as follows: In the above formula, ki, i=1,2,...,m represents the similarity between the user's question and the i-th keyword of the document, the function max() represents taking the maximum value, and the function avg() represents taking the average value; ki is calculated according to the following formula: In the above formula, di represents the Euclidean distance between the vectorized user question and the i-th keyword of the document; the comprehensive similarity s is obtained by calculating the average of the keyword similarity s2 and the overall semantic similarity s3.

7. The knowledge base storage and retrieval system based on retrieval enhancement generation according to claim 1, characterized in that: The overall semantic similarity s3 is calculated as follows: s3 = 2 / (1+exp(-r)) -1 In the above formula, r represents the re-ranking score of the document reorderer based on the vectorized user query for the preliminary search results documents, and the value of r ranges from 0 to +∞.

8. A knowledge base storage and retrieval method based on retrieval enhancement generation according to the system of claim 1, characterized in that: The method includes the following steps: (1) Document extraction and segmentation module: The document added to the knowledge base is segmented into document blocks using a specific tool; the document blocks are divided into three types: text, image, and table. The image is encoded in base64 format and the table is encoded in markdown format; for very long table document blocks, secondary segmentation and storage are performed; if there is caption text above or below the image or table, the caption text is organized together with the image and table information to form a document list; based on two methods, rule and large model prompting engineering, the stored text and table information are filtered to extract the keyword information and form a keyword list; the keyword information refers to entities and relationships. (2) Document vectorization and storage module: using a multimodal vectorization embedding model, the document list and keyword list generated by the document extraction and segmentation module are vectorized, and then the vectorized document list and keyword list are stored in the vector library; (3) Document window setting module, which determines the size of document window value W based on the user's question information; the document window value W refers to the number of documents that the knowledge base needs to return based on the user's question information; (4) The preliminary retrieval module vectorizes the user's question, then calculates the document similarity s1 between the user's question and the documents to be screened in the knowledge base, and extracts the top W documents with the largest document similarity values ​​according to the document window value W, as the preliminary retrieval results; (5) Hybrid reordering module: Based on the keywords contained in each document in the preliminary search results, calculate the keyword similarity s2 between the user's question and the preliminary search result documents; through the document reorderer, calculate the overall semantic similarity s3 between the user's question and the preliminary search result documents; calculate the comprehensive similarity s based on the keyword similarity s2 and the overall semantic similarity s3; and return W / 2 documents from the preliminary search results as the final search results based on the magnitude of the comprehensive similarity s value.

Citation Information

Patent Citations

  • Question and answer retrieval method and system fusing document knowledge and question and answer pair data

    CN117407505A

  • Large model retrieval enhancement system based on vector database

    CN117609286A