A retrieval enhancement generation method and system based on a two-layer enhancement mechanism
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-08
- Publication Date
- 2026-08-14
AI Technical Summary
然而,现有技术在这一方面还存在一些关键挑战,比如处理器量和知识结构处理方法上的不足
[0016]与现有的向量RAG相比,本发明通过形成链式层次结构信息标记增强语义表示,并结合预测用户查询意图扩展查询特征,有效提升对文本块的召回率与答案质量;与GraphRAG相比,无需构建额外构建与维护知识图谱。通过在现有向量RAG基础上进行改造,即可提升检索增强生成的效果,显著降低了RAG系统的部署成本,并且有效提高了系统的响应速度,解决了GraphRAG成本高、系统复杂性高、响应速度慢的问题。
Smart Images

Figure CN122570537A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing, and specifically to a retrieval enhancement generation method and system based on a two-layer enhancement mechanism. Background Technology
[0002] With the widespread application of Large Language Models (LLMs) across various industries, Retrieval-Enhanced Generation (RAG) technology has become an important means to address the potential illusions and insufficient timeliness of knowledge that models may encounter when handling complex tasks. The basic principle of RAG technology is to first retrieve external knowledge and then generate the answer, significantly improving the factual accuracy and traceability of the answer. Especially in fields such as power grids, law, healthcare, and finance, where the scale of knowledge bases is rapidly expanding, efficiently and accurately recalling relevant fragments from massive amounts of documents is crucial for improving RAG performance. However, existing technologies still face some key challenges in this area, such as limitations in processor capacity and knowledge structure processing methods.
[0003] Traditional vector-based RAG schemes typically employ simplified processing methods during document segmentation, failing to significantly preserve the original hierarchical structure and contextual logic of the document. Consequently, their retrieval recall is insufficient, often resulting in generated answers that are fragmented, lacking in key points, and have unclear citations. Furthermore, while the GraphRAG method proposed in recent years can effectively aggregate information across paragraphs by constructing knowledge graphs and has demonstrated superior performance in several complex tasks, the need to pre-build large and complex knowledge graphs not only increases manpower and computing power costs but also significantly reduces system response speed, failing to meet the demands of many real-time business scenarios, such as power grid dispatching and online customer service. Summary of the Invention
[0004] To address the aforementioned issues, this invention proposes a retrieval enhancement generation method and system based on a two-layer enhancement mechanism. This method aims to improve the retrieval recall and answer quality of traditional vector RAGs while reducing the cost and complexity of knowledge base construction. As a result, the system can provide users with high-quality intelligent question-answering services at a lower cost and with greater efficiency.
[0005] According to a first aspect of the present invention, a retrieval enhancement generation method based on a two-layer enhancement mechanism is provided, the method comprising: The original multi-format materials are converted into unified format documents and preprocessed to obtain a document library; The preprocessed document is split into several text blocks. The structural relationship or semantic hierarchy information of the document in which each text block is located is extracted to form a chain-like hierarchical structure information tag. This tag is then concatenated or associated with the corresponding text block content to obtain a set of text blocks carrying hierarchical structure information. A dense vector index is constructed for the text block, and an inverted index is constructed based on the keywords extracted from the text block. The text block ID is used as a unique identifier, and a mapping relationship is established between the vector index and the inverted index. This mapping relationship is used to collaboratively achieve the recall of semantically similar text blocks based on dense vectors and the recall of matching text blocks based on sparse keywords. Extract the title and chapter information of each document from the document library, predict the document title and chapter associated with the user query, and generate intent recognition results using a large language model; The intent recognition results are then combined with the original user query structure to form an enhanced user query; By utilizing enhanced user queries and original user queries, a dual-path retrieval using vectors and keywords is performed, returning several semantically similar text blocks and keyword-matched text blocks respectively. A re-ranking algorithm is then used to merge and deduplicate the dual-path retrieval results, resulting in the final dual-path retrieval result. The original user query and the dual-path retrieval results are combined to construct prompt words, which are then input into the large language model to generate a natural language answer.
[0006] Furthermore, the method also includes: converting the original multi-format materials into a unified Markdown format document; Clean all document data and encode all documents to UTF-8 format; All documents are converted into hash values using a hash algorithm, and these hash values are used as unique identifiers for each document. Duplicate documents are then eliminated by comparing the hash values.
[0007] Furthermore, the preprocessed document is split into the following steps: If splitting by semantics, prioritize splitting the document text by paragraph, chapter, or topic boundaries; If splitting according to rules, the splitting can be done by setting the delimiter, text block length, or text block overlap length.
[0008] Furthermore, the method for constructing a dense vector index includes: encoding a text block carrying hierarchical structure information to generate a dense vector, constructing a dense vector index, performing L2 normalization on the generated vector, and then storing the normalized vector in a vector database. The method for constructing an inverted index includes: performing word segmentation on the text block, splitting the continuous text into word units with independent semantics, and removing stop words; extracting the core keywords of the text block, constructing an inverted index based on the core keywords, and storing the inverted index in the full-text search engine.
[0009] Furthermore, the method also includes: integrating the title and chapter information of each document queried and extracted by the original user into prompt words according to a predefined template, predicting the documents and chapters that the user query may be associated with, and outputting the results in list form; The prompt words are input into a lightweight large language model to generate intent recognition results containing potentially related documents and chapters.
[0010] Furthermore, the method also includes: vector encoding the enhanced user query using the same embedding model as the text block to generate a query vector, performing approximate nearest neighbor retrieval, returning the Top-K1 semantically similar text blocks, and retaining their similarity scores and text block IDs; The original query is input into the full-text search engine, the BM25 algorithm is used to retrieve the inverted index, the top-K2 keyword matching text blocks are returned, and their matching scores and text block IDs are recorded. The RRF algorithm is used to merge and deduplicate the search results, and finally the top-N candidate text blocks are retained.
[0011] Furthermore, the method also includes: The text block IDs in the generated natural language answers are extracted using regular expressions and associated with the document library metadata to generate source links. Determine whether the generated natural language answer contains citations or whether the number of citations does not meet the preset threshold. If so, trigger a secondary retrieval process to recall the text block again. The generated natural language answers are converted into HTML format, with cited parts highlighted and source links embedded in the corresponding text.
[0012] According to a second aspect of the present invention, a retrieval enhancement generation system based on a two-layer enhancement mechanism is provided, comprising: The material preprocessing module is used to convert raw multi-format materials into unified format documents and perform preprocessing to obtain a document library. The chunking module is used to split the preprocessed document into several text chunks, extract the structural relationship or semantic hierarchy information of the document in which each text chunk is located, form a chain-like hierarchical structure information tag, and concatenate or associate it with the corresponding text chunk content to obtain a set of text chunks carrying hierarchical structure information. The index building module is used to build a dense vector index for text blocks and an inverted index based on keywords extracted from the text blocks. The text block ID is used as a unique identifier to establish a mapping relationship between the vector index and the inverted index. This mapping relationship is used to collaboratively achieve the retrieval of semantically similar text blocks based on dense vectors and the retrieval of matching text blocks based on sparse keywords. The query understanding module is used to extract the title and chapter information of each document from the document library, predict the document title and chapter associated with the user query, and generate intent recognition results using a large language model. The query enhancement module is used to concatenate the intent recognition results with the original user query structure to form an enhanced user query; The dual-path retrieval module is used to perform vector and keyword dual-path retrieval using enhanced user queries and original user queries, respectively returning several semantically similar text blocks and keyword-matched text blocks, and using a re-ranking algorithm to merge and deduplicate the dual-path retrieval results to obtain the dual-path retrieval results; The answer generation module combines the original user query with the dual-path retrieval results to construct prompt words, which are then input into the large language model to generate a natural language answer.
[0013] Furthermore, it also includes an integrity verification module, which is used to determine whether the generated natural language answer contains citations or whether the number of citations does not meet the preset threshold. If so, a secondary retrieval process is triggered to recall the text block again.
[0014] Furthermore, the dual-path retrieval module also includes: The vector retrieval unit is used to vectorize the enhanced user query using the same embedding model as the text block, generate a query vector, perform an approximate nearest neighbor retrieval in the vector database, return the Top-K1 semantically similar text blocks, and retain their similarity scores and text block IDs; The keyword retrieval unit is used to input the original user query into the full-text search engine, retrieve the inverted index using the BM25 algorithm, return the top-K2 keyword matching text blocks, and record their matching scores and text block IDs.
[0015] The retrieval result fusion and rearrangement unit is used to merge and deduplicate the retrieval results of the Top-K1 semantically similar text blocks and the Top-K2 keyword-matching text blocks based on the RRF algorithm, retaining the Top-N text blocks, as well as their similarity scores, matching scores and text block IDs.
[0016] Compared to existing vector RAGs, this invention enhances semantic representation by forming a chain-like hierarchical information tagging structure and expands query features by predicting user query intent, effectively improving the recall rate and answer quality for text blocks. Compared to GraphRAG, it eliminates the need to construct and maintain an additional knowledge graph. By modifying existing vector RAGs, the effect of enhanced retrieval generation can be improved, significantly reducing the deployment cost of RAG systems and effectively increasing system response speed, thus solving the problems of high cost, high system complexity, and slow response speed of GraphRAG. Attached Figure Description
[0017] Figure 1 A schematic diagram of a retrieval enhancement generation method based on a two-layer enhancement mechanism provided in an embodiment of the present invention;
[0018] Figure 2 This is a schematic diagram illustrating the process of splitting a document into text blocks, as provided in an embodiment of the present invention.
[0019] Figure 3 This is a schematic diagram illustrating the prediction of user query intent provided in an embodiment of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0021] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0022] Traditional retrieval augmentation techniques face the challenge of efficiently and accurately retrieving text fragments truly relevant to user queries from knowledge bases when processing massive amounts of documents. Traditional vector RAGs suffer from insufficient recall and limited answer generation quality due to the lack of hierarchical structure information in text blocks. While GraphRAG can aggregate information across paragraphs, its high construction and maintenance costs, system complexity, and response latency make it difficult to meet the demands of high real-time business requirements.
[0023] Example 1 To solve the above problems, see Figure 1 This embodiment proposes a retrieval enhancement generation method based on a two-layer enhancement mechanism, which specifically includes the following steps: S1. The original multi-format materials are converted into unified format documents and preprocessed to obtain a document library.
[0024] Specifically, the original multi-format materials can include documents in various common formats such as PDF, Word, Excel, HTML, Markdown, and images. These documents can be extracted using appropriate tools, such as Optical Character Recognition (OCR) technology, layout analysis, and table restoration tools, to extract the text from each document and convert it into a unified Markdown format document.
[0025] In the preprocessing stage, basic data cleaning can be performed on the format-converted documents. For example, regular expressions or rule bases can be used to remove invalid information such as HTML tags, headers and footers, advertisements, watermarks, and garbled characters from each document, while retaining key information such as technical terms, numbers, and dates. All documents are uniformly encoded into UTF-8 format. The character length of each document is calculated, and documents with too short a character length are discarded. Documents with too long a character length are split into multiple sub-documents. A hash algorithm is used to convert all documents into hash values, which serve as unique identifiers for each document. Duplicate documents are marked and removed by comparing hash values for duplicates.
[0026] The preprocessed documents and their related metadata can be stored to form a document library for subsequent management and access. Specifically, the metadata of each document, such as its title, author, source, and creation time, along with the preprocessed original document text, is written into a common relational database, such as MySQL, PostgreSQL, or Oracle. The hash value of the document is used as the primary key of the metadata, providing a basis for subsequent reading of the original text, building document indexes, tracing sources, and querying metadata.
[0027] S2. The preprocessed document is split into several text blocks. The structural relationship or semantic hierarchy information of the document in which each text block is located is extracted to form a chain-like hierarchical structure information tag. This tag is then concatenated or associated with the corresponding text block content to obtain a set of text blocks carrying hierarchical structure information.
[0028] For details, please refer to Figure 2 Because the model has limitations on the length of the input text and direct retrieval of long documents makes it difficult to locate key information, it is necessary to break down the preprocessed document into smaller text blocks. This step, while maintaining semantic integrity, divides long text within the document into appropriately sized text blocks and automatically adds chain-like hierarchical information tags, i.e., title links. Two strategies can be chosen for breaking down the preprocessed document into smaller text blocks: Strategy 1: Semantic splitting. Prioritize splitting document text by paragraph, chapter, or topic boundaries to avoid disrupting semantic coherence. Strategy 2: Split according to rules. This involves setting delimiters, such as using the segmentation character "\\n\\n" as a delimiter; setting the text block length based on the embedding model's capabilities, such as a text block length of 500-2000 characters (too short and context is easily lost, too long and semantic ambiguity is easily caused); and setting the text block overlap length, such as an overlap length of 100-200 characters, to avoid semantic breaks caused by hard splitting.
[0029] Extract the structural relationships or semantic hierarchy information of the document containing each split text block, such as the title chain. The title chain can be understood as a path identifier formed by connecting the titles of each level of the document from top to bottom, which is used to locate the logical branches of the text block in the overall structure of the document. Concatenate or associate the title chain with the corresponding text block content in the form of a string.
[0030] For example, if a text block is located in the document as "Heading 1 (I), Heading 2 1, Heading 3 a", then its heading chain is "Document Title / Heading 1 (I) / Heading 2 1 / Heading 3 a", where the document title is the title of the entire document. The heading chain is then concatenated with the corresponding text block as a string. All text blocks are processed in the same way to enhance the hierarchical structure information of the text blocks.
[0031] S3. Construct a dense vector index for the text blocks, and simultaneously construct an inverted index based on the keywords extracted from the text blocks. Using the text block ID as a unique identifier, establish a mapping relationship between the vector index and the inverted index. This mapping relationship is used to collaboratively achieve semantic similarity text block retrieval based on dense vectors and matching text block retrieval based on sparse keywords.
[0032] This step transforms the segmented text blocks into a efficiently searchable vector format, and simultaneously constructs both a vector index and an inverted index to achieve a dual recall mechanism. The specific implementation includes: S301, Dense Vector Index: An embedding model fine-tuned with a domain-specific corpus is used to encode text blocks carrying hierarchical tags to generate dense vectors and construct a dense vector index for quickly finding semantically similar vectors; L2 normalization is performed on the generated vectors, and then the normalized vectors are stored in the vector database.
[0033] Exemplarily, the bge-large-zh-v1.5 model fine-tuned with specific domain corpus is selected as the embedding model. This model is superior to general embedding models in terms of semantic encoding accuracy and domain adaptability in the Chinese domain, and can improve the domain relevance of text block vectors; encode the text blocks with hierarchical tags to generate 1024-dimensional dense vectors, and construct a dense vector index; perform L2 normalization on the generated vectors, and then store the normalized vectors in a vector database such as Milvus or Faiss, etc., to provide a data basis for subsequent semantic similarity retrieval.
[0034] S302, Inverted index: Segment the text blocks, split the continuous text into word units with independent semantics, and remove stop words; extract the core keywords of the text blocks through the TF-IDF algorithm; build an inverted index based on the core keywords, record the set of text blocks corresponding to each keyword, and store the inverted index in a full-text search engine such as Elasticsearch, etc., to provide a data basis for subsequent keyword retrieval.
[0035] Exemplarily, use the Jieba tokenization tool for tokenization. It supports Chinese tokenization and domain term recognition, and splits the continuous text into word units with independent semantics; remove stop words, such as words without actual retrieval significance like "de", "zai", etc., and use the Harbin Institute of Technology stop word list; extract the core keywords of the text blocks through the TF-IDF algorithm; build an inverted index based on the core keywords, record the set of text blocks corresponding to each keyword, and store the inverted index in a full-text search engine such as Elasticsearch, etc., for subsequent accurate keyword matching retrieval.
[0036] S303, Use the unique ID of each text block as the primary key to establish a mapping relationship table between the vector index and the inverted index; through this mapping table, the vector database and the full-text search engine can be called simultaneously during query to achieve the coordinated linkage of the two retrieval methods. At the same time, it supports incremental writing operations on the index, and sets a timed merging mechanism to regularly merge and optimize the incrementally added index segments to ensure the efficiency of the index structure.
[0037] Exemplarily, use UUID to generate the unique ID of each text block as the primary key to ensure global uniqueness, and establish a mapping relationship table between the vector index and the inverted index; through this mapping table, the vector database Milvus and the full-text search engine Elasticsearch can be called simultaneously during query to obtain semantic similar text blocks based on dense vectors and matching text blocks based on sparse keywords at one time, achieving the coordinated linkage of the two retrieval methods.
[0038] Simultaneously, incremental write operations to the index are supported. When a new text block is generated, its corresponding vector and keyword information can be directly added to the relevant index without rebuilding the entire index. A timed merging mechanism is also implemented to periodically merge and optimize incrementally added index fragments, ensuring the efficiency of the index structure. These two strategies ensure that newly added documents can be retrieved within a short time, meeting real-time retrieval requirements.
[0039] S4. Extract the title and chapter information of each document from the document library, predict the document title and chapter associated with the user query, and generate intent recognition results using a large language model.
[0040] The core function of this step is to predict the intent of the original user query, accurately identify potentially related documents and chapters, and generate query statements with enhanced recall capabilities. (See also...) Figure 3 The specific implementation process is as follows: The document library extracts structured document data from all documents, parses and extracts the titles and hierarchical chapter information of each document, such as first-level headings and second-level headings, and stores this information in standardized data formats such as JSON and XML that can be efficiently parsed, providing a structured data source for subsequent intent matching.
[0041] The original user query Q0 is integrated with the extracted document title and chapter information according to a predefined template to form the prompt word Q1. An example of the prompt word template is: Please analyze the user query '{Q0}', predict the document titles and chapter information that may be associated with it, and output the results in list form, with the format as document title: [document name], associated chapters: [chapter hierarchy chain]; call a lightweight large language model with a parameter scale of 7B, and input the prompt word Q1; the model generates an intent recognition result P1 containing the predicted associated documents and associated chapters.
[0042] S5. The intent recognition results and the original user query are structurally combined to form an enhanced user query.
[0043] Specifically, based on a predefined fusion template, an example template is: User query: {Q0}; Potentially related documents and chapters: {P1}. The intent recognition result P1 is structurally concatenated with the original user query Q0 to generate an enhanced user query Q2, strengthening the correlation between the query and document structure information. Simultaneously, the original user query Q0 is retained for subsequent result rearrangement verification and comparative analysis. This step inputs the enhanced user query Q2 and the original user query Q0 into subsequent steps for retrieval and generation.
[0044] S6. Perform vector and keyword dual-path retrieval using enhanced user query and original user query, respectively return several semantically similar text blocks and keyword matching text blocks, and use a re-ranking algorithm to merge and deduplicate the dual-path retrieval results to obtain the dual-path retrieval results.
[0045] S601. The enhanced user query Q2 is vector-encoded using the same embedding model as the text block to generate a 1024-dimensional query vector. Approximate nearest neighbor retrieval is performed in the Milvus or Faiss vector database to return the Top-K1 semantically similar text blocks, and their similarity scores and text block IDs are retained.
[0046] Preferably, K1 is set to 20 by default, but can be adjusted according to the required business precision.
[0047] S602. Send the original user query Q0 into Elasticsearch, use the BM25 algorithm to retrieve the inverted index, return the top-K2 keyword matching text blocks, and record their matching scores and text block IDs.
[0048] Preferably, K2 is set to 15 by default, but can be adjusted according to the required business precision.
[0049] S603. Use the RRF algorithm to merge and deduplicate the dual-path search results. The calculation formula is as follows:
[0050] Among them, rank i This indicates the ranking position of the text block in single-path retrieval, where k is an adjustable parameter (default value 60), and n represents the total number of text blocks in the dual-path retrieval results. A candidate text block list is generated by sorting the text blocks in descending order of RRF score, filtering out text blocks with scores below a threshold, and finally retaining the Top-N core text blocks, where N ≤ the maximum number of text blocks that the model context window can hold. The default threshold value is 0.3, which can be adjusted according to business accuracy requirements. The default value of N is 10.
[0051] S7. Combine the original user query with the dual-path retrieval results to construct prompt words, input them into the large language model, and generate a natural language answer.
[0052] Specifically, candidate text blocks are sorted in descending order of RRF score, and their IDs are concatenated with the original text to form context fragments. The context fragments and the original query Q0 are encapsulated together to form prompt words Q3. The large language model is explicitly required to: generate accurate answers based on the provided context; the factual information involved in the answer must be labeled with the IDs of the referenced text blocks; if the context is insufficient to support the answer, it is necessary to clearly indicate the lack of information and list the relevant fragments that have been retrieved.
[0053] The Qwen2-14B-Instruct model with 14B parameters is invoked, and the assembled prompt word Q3 is input. The following inference parameters are used: temperature coefficient 0.7 (0.7 balances accuracy and diversity to control answer randomness), maximum generation length 2048, and top-p=0.95 (0.95 ensures relevance of generated content to control sampling range). The model output includes the original result containing the answer body and reference markers.
[0054] This application further proposes that the method also includes: converting the original multi-format materials into a unified Markdown format document; cleaning all document data and uniformly encoding the documents into UTF-8 format; using a hash algorithm to convert all documents into hash values, using the hash values as unique identifiers for the documents, and eliminating duplicate documents by comparing the hash values.
[0055] This technical solution aims to address the processing complexity caused by the diversity of original material formats. By unifying documents of different formats into Markdown, it provides standardized input for subsequent document processing workflows. Simultaneously, this solution aims to improve the purity and consistency of document data, ensuring data quality. Furthermore, it can optimize data granularity by filtering based on character length, removing documents with excessively short character lengths or splitting them into smaller, more manageable ones.
[0056] These preprocessing measures work together to provide high-quality, non-redundant, and standardized basic data for subsequent steps, thereby significantly improving the recall accuracy of text blocks and ultimately ensuring the quality and reliability of the answers generated by the large language model, effectively avoiding the phenomenon of misinterpretation or fragmented key points caused by underlying data problems.
[0057] This application further proposes a method for constructing a dense vector index, which includes: encoding a text block carrying hierarchical structure information to generate a dense vector, constructing a dense vector index, and storing the index in a vector database; The method for constructing an inverted index includes: performing word segmentation on the text block, splitting the continuous text into word units with independent semantics, and removing stop words; extracting the core keywords of the text block, constructing an inverted index based on the core keywords, and storing the inverted index in the full-text search engine.
[0058] The above technical solution transforms the segmented text blocks into efficiently searchable vector forms. Simultaneously, it constructs vector indexes and inverted indexes to achieve a dual recall mechanism of semantic-based vector retrieval and keyword-based inverted retrieval, thereby improving the comprehensiveness and accuracy of retrieval.
[0059] This application further proposes a retrieval enhancement generation method, which further includes: The titles and chapter information of each document retrieved from the original user query are integrated into prompt words according to a predefined template. The prompt words are then used to predict the documents and chapters that may be associated with the user query and output the results in list form. A lightweight large language model is then called to input the prompt words and generate intent recognition results containing the documents and chapters that may be associated.
[0060] Specifically, integrating the title and chapter information of each document retrieved from the original user query into prompt words according to a predefined template means using a pre-defined structured format to combine this information to ensure the relevance between the user query and the document structure information. The predefined template can be a string template, for example: "Analyze the user query '{Q0}', predict the possible associated document titles and chapter information, and output the results in list form, formatted as: Document Title: [Document Name], Associated Chapters: [Chapter Hierarchy Chain]", where {Q0} is a placeholder for the original user query. The extracted title and chapter information of each document refers to the structured metadata of the document parsed and obtained from the document library, such as the document title, first-level headings, second-level headings, and other hierarchical information. This information can be standardized and stored in efficient parsing data formats such as JSON and XML, or organized in a tree structure or list format. Integrating this information into prompt words means filling the template with the document structure information retrieved from the original user query according to the format requirements of the predefined template, forming a complete, structured text or data object as input for the subsequent large language model.
[0061] The prediction of potentially related documents and chapters for a user query, outputting the results in list format, refers to inferring the scope of documents and specific chapter content that the user's query might involve by analyzing and integrating the prompt words. This prediction process can be accomplished by the generation capabilities of a large language model, which directly generates related document and chapter information based on the instructions and contextual information in the prompt words. The potentially related documents and chapters refer to document titles and their internal hierarchical chapter paths that are highly relevant to the user's query intent, as identified by the model or algorithm. Outputting the results in list format means presenting the predicted related document and chapter information in a clear and easily parsed format. For example, it can be output as a text list, with each item containing the format "Document Title: [Document Name], Related Chapters: [Chapter Hierarchical Chain]"; or as a structured data list, such as a JSON array, where each element contains fields such as document ID and chapter path.
[0062] The process of calling a lightweight large language model to input the prompt words refers to sending the integrated prompt words to a large language model with a relatively small parameter size and low computational resource requirements for processing via a program interface or function call. The lightweight large language model could be, for example, Llama 2-7B-Chat, Mistral-7B, or Qwen-7B-Chat. These models maintain high intent recognition accuracy while offering faster inference speeds and lower operating costs, meeting the needs of real-time business scenarios. The invocation method can be through an API interface sending a request to the model on a remote server, or by directly calling a function after deploying the model locally. Inputting the prompt words means using the constructed structured prompt words as input to the lightweight large language model to guide the model in intent recognition.
[0063] The generation of intent recognition results containing potentially related documents and chapters refers to the lightweight large language model, after receiving and processing prompt words, outputting a text or structured data based on its internal language understanding and generation capabilities. This text explicitly indicates the document titles and chapter information that may be related to the user's query. The intent recognition result is the model's parsing and prediction of the user's query intent, mapping the user's ambiguous query intent to a specific knowledge base structure. The generation process involves the model outputting the predicted result in natural language or a preset structured format (such as JSON) based on the instructions in the prompt words.
[0064] Through the above technical solutions, this application can more accurately locate documents and chapters related to the user's query intent, thereby significantly improving the retrieval recall rate and laying the foundation for generating high-quality, source-based natural language answers for large language models. This effectively avoids fragmented phenomena such as taking things out of context, having scattered key points, and lacking sources when generating answers.
[0065] This application further proposes a retrieval enhancement generation method, which includes: integrating the title and chapter information of each document retrieved from the original user query into prompt words according to a predefined template, predicting the documents and chapters that may be associated with the user query, and outputting the results in list form; calling a lightweight large language model to input the prompt words, and generating intent recognition results containing the documents and chapters that may be associated.
[0066] Specifically, integrating the title and chapter information of each document retrieved from the original user query into prompt words according to a predefined template means using a pre-defined structured format to combine this information to ensure the relevance between the user query and the document structure information. The extracted title and chapter information refers to the structured metadata of the documents parsed and obtained from the document library, such as the document title, first-level headings, second-level headings, and other hierarchical information. This information can be standardized and stored in efficiently parsable data formats such as JSON and XML, or organized in a tree structure or list format. Integrating this information into prompt words means filling the template with the document structure information retrieved from the original user query according to the format requirements of the predefined template, forming a complete, structured text or data object as input for the subsequent large language model.
[0067] The prediction of potentially related documents and chapters for a user query, outputting the results in list format, refers to inferring the scope of documents and specific chapter content that the user's query might involve by analyzing and integrating the suggested keywords. The potentially related documents and chapters refer to document titles and their internal hierarchical chapter paths identified by the model or algorithm as highly relevant to the user's query intent. Outputting the results in list format means presenting the predicted related document and chapter information in a clear and easily parsed format.
[0068] The step of calling the lightweight large language model to input the prompt words refers to sending the integrated prompt words to a large language model with a relatively small parameter size and low computational resource requirements for processing via a program interface or function call. The lightweight large language model could be, for example, Llama 2-7B-Chat, Mistral-7B, or Qwen-7B-Chat. These models maintain high intent recognition accuracy while offering faster inference speeds and lower operating costs, meeting the needs of real-time business scenarios. Inputting the prompt words means using the constructed structured prompt words as input to this lightweight large language model to guide the model in intent recognition.
[0069] The generation of intent recognition results containing potentially related documents and chapters refers to the lightweight large language model, after receiving and processing prompt words, outputting a text or structured data based on its internal language understanding and generation capabilities. This text explicitly indicates the document titles and chapter information that may be related to the user's query. The intent recognition result is the model's parsing and prediction of the user's query intent, mapping the user's ambiguous query intent to a specific knowledge base structure. The generation process involves the model outputting the predicted result in natural language or a preset structured format (such as JSON) based on the instructions in the prompt words.
[0070] Through the above technical solutions, this application is able to more accurately locate documents and chapters related to the user's query intent, thereby significantly improving the retrieval recall rate and laying the foundation for generating high-quality, source-based natural language answers for large language models. This effectively avoids fragmented phenomena such as taking things out of context, having scattered key points, and lacking sources when generating answers.
[0071] Example 2 This invention provides a retrieval enhancement generation system based on a two-layer enhancement mechanism. The system includes multiple collaborative functional modules, achieving efficient retrieval enhancement generation capabilities. The retrieval enhancement generation system includes a material preprocessing module, a block processing module, an index construction module, a query understanding module, a query enhancement module, a dual-path retrieval module, and an answer generation module.
[0072] The material preprocessing module is used to convert raw materials in multiple formats into unified format documents and perform preprocessing to obtain a document library. Specifically, this module first collects materials in common formats such as PDF, Word, Excel, HTML, Markdown, and images. It then uses tools such as OCR, layout parsing, and table restoration to extract text from each document and convert it into Markdown format documents. Next, data cleaning is performed, using regular expressions and rule bases to remove invalid information such as HTML tags, headers and footers, advertisements, watermarks, and garbled characters from each document, retaining key information such as technical terms, numbers, and dates. All documents are then uniformly encoded in UTF-8 format. Next, duplicate document checks are performed, using hash algorithms such as SHA-256 to convert all documents into hash values, using these hash values as unique identifiers for each document. Duplicate documents are marked and removed by comparing hash values for duplicates. Finally, the document library is built, writing the metadata of each document, such as title, author, source, and creation time, along with the preprocessed original document text, into a relational database such as MySQL, using the document's hash value as the primary key of the metadata.
[0073] The chunking module is used to split the preprocessed document into several text chunks, extract the structural relationships or semantic hierarchy information of the document in which each text chunk is located, form a chain-like hierarchical structure information tag, and concatenate or associate it with the corresponding text chunk content to obtain a set of text chunks carrying hierarchical structure information. This module first performs initial document chunking, using two strategies: semantic splitting and rule-based splitting. Semantic splitting prioritizes splitting text according to paragraph, chapter, and topic boundaries to avoid disrupting semantic coherence; rule-based splitting includes setting delimiters, setting text chunk length (500-2000 characters) based on the embedding model's capabilities, and setting text chunk overlap length (100-200 characters). Then, it extracts and merges the title links of the text chunks, extracting the title link of each text chunk. For example, if a text chunk is located in the document as "Heading 1 (I), Heading 2 1, Heading 3 a", then its title link is "Document Title / Heading 1 (I) / Heading 2 1 / Heading 3 a". The title link is then concatenated with the corresponding text chunk in string form.
[0074] The index building module is used to construct a dense vector index for text blocks and an inverted index based on keywords extracted from the text blocks. A mapping relationship is established between the vector index and the inverted index, using the text block ID as a unique identifier. This mapping relationship is used to collaboratively achieve semantic similarity text block retrieval based on dense vectors and matching text block retrieval based on sparse keywords. First, text vectorization is performed, using the bge-large-zh-v1.5 model, fine-tuned with a domain-specific corpus, as the embedding model. Text blocks carrying hierarchical tags are encoded to generate 1024-dimensional dense vectors, and a dense vector index is constructed. L2 normalization is performed on the generated vectors, and the normalized vectors are then stored in vector databases such as Milvus or Faiss. Next, the inverted index is constructed by segmenting the text blocks, removing stop words, extracting core keywords from the text blocks using the TF-IDF algorithm, constructing an inverted index based on these core keywords, and storing the inverted index in Elasticsearch. Next, a dual-index association is performed, using the unique ID of each text block as the primary key to establish a mapping table between the vector index in the vector database and the inverted index in Elasticsearch. Finally, an index update strategy is set to support incremental write operations to the index, and a timed merging mechanism is configured to periodically merge and optimize incrementally added index fragments.
[0075] The query understanding module extracts the title and chapter information of each document from the document library, predicts the documents and chapters associated with the user query, and generates intent recognition results using a large language model. This module first extracts document and chapter information. The system reads structured document data from the document library, parses and extracts the title and hierarchical chapter information of each document, and standardizes and stores this information in efficiently parsable data formats such as JSON and XML. Then, it performs user intent recognition, integrating the original user query Q0 with the extracted document title and chapter information into a prompt word Q1 according to a predefined template. An example prompt word template is: "Please analyze the user query {Q0}, predict the possible associated document titles and chapter information, and output the results in list form, with the format: Document Title: [Document Name], Associated Chapters: [Chapter Hierarchy Chain]". It then calls a lightweight large language model with 7B parameters (such as Llama 2-7B-Chat), inputs the prompt word Q1, and the model generates an intent recognition result P1 containing the predicted associated documents and chapters.
[0076] The query enhancement module is used to structurally concatenate the intent recognition results with the original user query to form an enhanced user query. This module is based on a predefined fusion template, an example of which is: User Query: {Q0}; Potentially Related Documents and Chapters: {P1}. The intent recognition result P1 is structurally concatenated with the original user query Q0 to generate the enhanced user query Q2, strengthening the correlation between the query and document structure information; simultaneously, the original user query Q0 is retained for subsequent retrieval result rearrangement verification and comparative analysis. This module includes a vector retrieval unit, a keyword retrieval unit, and a retrieval result fusion and rearrangement unit. The dual-path retrieval module utilizes both enhanced and original user queries for vector and keyword-based dual-path retrieval, returning several semantically similar text blocks and keyword-matching text blocks respectively. A re-ranking algorithm is then used to merge and deduplicate the dual-path retrieval results, yielding the final dual-path retrieval result. The vector retrieval unit encodes the enhanced user query Q2 using the same embedding model as the text blocks, generating a 1024-dimensional query vector. An approximate nearest neighbor retrieval is performed in the vector database, returning the Top-K1 semantically similar text blocks and retaining their similarity scores and text block IDs. The keyword retrieval unit inputs the original user query Q0 into the full-text search engine Elasticsearch, uses the BM25 algorithm to retrieve the inverted index, and returns the Top-K2 keyword-matching text blocks, recording their matching scores and text block IDs. The retrieval result fusion and re-ranking unit merges and deduplicates the retrieval results of the Top-K1 semantically similar text blocks and the Top-K2 keyword-matching text blocks based on the RRF algorithm, retaining the Top-N text blocks, their similarity scores, matching scores, and text block IDs.
[0077] The answer generation module combines the original user query with the results of dual-path retrieval, constructing prompt words that are then input into the large language model to generate the answer. This module first fuses and rearranges the retrieval results, using the RRF algorithm to merge and deduplicate the dual-path retrieval results. Candidate text blocks are generated by sorting them in descending order of RRF score, filtering out text blocks with scores below a threshold, and finally retaining the Top-N core text blocks. Next, context construction and prompt word assembly are performed. The candidate text blocks are sorted in descending order of RRF score, and their IDs are concatenated with the original text to form a context fragment. This context fragment and the original user query Q0 are then encapsulated together to form the prompt word Q3. The large language model is explicitly required to generate an accurate answer based on the provided context, and factual information in the answer must be labeled with the cited text block IDs. Finally, large-scale model inference and answer generation are performed. The Qwen2-14B-Instruct model with 14B parameters is called, and the assembled prompt word Q3 is input. Inference parameters include a temperature coefficient of 0.7, a maximum generation length of 2048, and top-p=0.95. The model outputs the original result containing the answer body and citation tags. Finally, answer post-processing and source link generation are performed. Text block IDs are extracted from the answer using regular expressions, associated with document library metadata, and clickable source links are generated. The answer is converted to HTML format, the quoted parts are highlighted, and the source links are embedded with the corresponding text.
[0078] The system also includes an integrity verification module to determine whether the generated natural language answer contains citations or whether the number of citations does not meet a preset threshold. If so, a secondary retrieval process is triggered to re-recall the text block. Specifically, if the answer does not contain citations or the number of citations is insufficient, such as <2, a secondary retrieval process is triggered: the retrieval threshold is lowered to 0.2 (default value), the text block is re-recalled, and the steps of fusion and rearrangement of retrieval results, context construction and prompt word assembly, large model inference, and answer generation are repeated.
[0079] The system outputs a JSON structure containing the answer body, citation list, and retrieval statistics (such as dual-path recall rate and fusion time), which is then returned to the front end for display. At the same time, user queries, retrieval results, generated answers, and citation accuracy markers are written to the log database for subsequent model fine-tuning and system optimization.
[0080] Through the collaborative work of the above modules, this retrieval enhancement generation system based on a two-layer enhancement mechanism significantly improves the recall rate and answer quality of traditional vector RAGs without relying on knowledge graphs. It utilizes a two-layer enhancement mechanism of text block hierarchical structure tagging and user query intent prediction, achieving low-cost, high-efficiency, and high-accuracy intelligent question answering.
[0081] Example 3 This example assumes that a user is consulting a detailed technical manual on the installation and troubleshooting of a smart home system and wants to know how to safely replace the battery in a smart door lock.
[0082] Limitations of traditional vector RAGs: If this manual is simply divided into fixed-size text blocks, a text block about smart lock battery replacement procedures might be retrieved. However, another text block about battery safe handling and recycling might be located in the manual's appendix: Safety and Environmental Guidelines. Its content has low semantic similarity to battery replacement, so traditional RAGs might fail to retrieve this crucial safety information, resulting in incomplete answers for users and even potential safety hazards.
[0083] The working principle of the technical solution in this application is as follows: When the system processes this technical manual, it will bind each text block to its title link. For example, a text block stating "Please ensure the power is disconnected before replacing the battery" might be labeled with the title link: Smart Home System Manual / Chapter 4: Smart Door Locks / 4.2 Installation and Maintenance / 4.2.3 Battery Replacement Procedure. Another text block stating "Used batteries should be disposed of in designated recycling bins to avoid indiscriminate disposal" might be labeled with the title link: Smart Home System Manual / Appendix A: Safety and Environmental Protection Guidelines / A.1 Battery Safety and Recycling.
[0084] The original user query Q0 was: How to safely replace the battery of a smart door lock? The system extracts structural information from the manuals, such as the Smart Home System Manual, Chapter 4: Smart Locks, and Appendix A: Safety and Environmental Protection Guidelines. The Large Language Model (LLM) combines the original user query Q0 with this structural information to predict intent, anticipating that the user is not only concerned with the battery replacement steps but may also be interested in related safety information such as battery safety and recycling. Therefore, the LLM generates an intent recognition result P1, for example, predicting relevant chapters: "Smart Home System Manual / Chapter 4: Smart Locks / 4.2.3 Battery Replacement Steps", and "Smart Home System Manual / Appendix A: Safety and Environmental Protection Guidelines / A.1 Battery Safety and Recycling". The system combines the original user query Q0 and the intent recognition result P1 to form an enhanced query, for example: User query: How to safely replace the battery in a smart lock? Predicting relevant chapters: "Smart Home System Manual / Chapter 4: Smart Locks / 4.2.3 Battery Replacement Steps", and "Smart Home System Manual / Appendix A: Safety and Environmental Protection Guidelines / A.1 Battery Safety and Recycling".
[0085] In the vector database, the system prioritizes recalling text blocks that are semantically related to safe battery replacement and whose title links highly match the predicted sections, such as 4.2.3 Battery Replacement Steps and A.1 Battery Safety and Recycling. This helps recall the text block "Used batteries should be placed in designated recycling bins," because although its direct semantics are not strong related to replacement, its hierarchical information highly matches the user's intent regarding safety. The original user query Q0 is used for keyword retrieval, recalling text blocks containing keywords such as safety, replacement, battery, and door lock. The two search results are merged and rearranged using the RRF algorithm. Text blocks that appear in both vector and keyword searches and whose hierarchical information is highly consistent with the user's intent are assigned a higher ranking.
[0086] Finally, the top-ranking text blocks and the user query Q0 are combined to form a complete prompt. For example, the top-ranking text blocks retrieved are: "Unlock the door before replacing the smart lock battery to avoid the lock jamming after a power outage.", "Use the same model of genuine battery, align the positive and negative terminals and insert it smoothly to avoid short circuits.", "Please ensure the power is disconnected before replacing the battery and dispose of used batteries in the designated recycling bin to avoid indiscriminate disposal." The complete prompt formed by combining these is: # Character Setting You are a professional Q&A expert in the field of smart locks, with in-depth knowledge of all scenarios including smart lock installation, maintenance, troubleshooting, and safe use. You are familiar with various operating procedures and safety precautions for smart locks, and rely on your exclusive knowledge base to provide users with accurate, rigorous, safe, and easy-to-understand professional answers.
[0087] # Answering Rules Answer strictly based on the given knowledge base information, do not fabricate irrelevant content or add extra steps, and ensure that the answer is true and compliant; Based on the core needs of user questions, key information from the knowledge base is clearly and logically integrated, with a focus on highlighting key points of safe operation. The language is concise and practical, fitting everyday operating scenarios, with coherent logic, making it easy for ordinary users to understand in practice. It fully covers all valid information points in the knowledge base, with no omissions or alterations to the original key specifications.
[0088] # Reference Knowledge Base Unlock the door before replacing the battery to avoid the lock jamming and preventing you from opening the door after a power outage. [Smart Home System Manual / Chapter 4: Smart Locks / 4.2.3 Battery Replacement Steps] Use a standard battery of the same model, align the positive and negative terminals, and insert it securely to prevent short circuits. [Smart Home System Manual / Chapter 4: Smart Door Lock / 4.2.3 Battery Replacement Steps] Please ensure the power is disconnected before replacing the battery. Used batteries should be disposed of in the designated recycling bin to avoid indiscriminate disposal. [Smart Home System Manual, Section 4.2.3, Appendix A.1] # User input How to safely replace the battery in a smart door lock?
[0089] Then input the prompt words into the Large Language Model (LLM). The LLM will generate a comprehensive and secure answer, such as: "Before replacing the smart lock battery, you need to unlock the door to prevent the lock from jamming after a power outage and making it impossible to open. [Source: Smart Home System Manual / Chapter 4: Smart Lock / 4.2.3 Battery Replacement Steps]. Before replacing the battery, ensure the power is disconnected, use a genuine battery of the same model, align the positive and negative terminals of the battery with the slots, and insert it smoothly to avoid short circuits. [Source: Smart Home System Manual / Chapter 4: Smart Lock / 4.2.3 Battery Replacement Steps]. After replacing the battery, the used battery should be placed in a dedicated recycling bin and should not be discarded randomly. [Source: Smart Home System Manual, Section 4.2.3, Appendix A.1]. Special reminder: It is recommended to keep your hands dry throughout the replacement process and avoid touching the battery and the metal contacts of the lock with wet hands; after installation, close the battery cover and repeatedly test the unlocking and locking functions to confirm that the lock is working properly before using it normally."
[0090] This example demonstrates that text block hierarchical tagging ensures that text blocks carry important contextual information, while user query intent prediction guides the retrieval system to more accurately understand user needs. Combined with a dual-path retrieval mechanism, it ultimately retrieves more comprehensive, accurate, and secure answers, effectively solving the recall rate and answer quality problems of traditional RAGs.
[0091] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A retrieval enhancement generation method based on a two-layer enhancement mechanism, characterized in that, The method includes: The original multi-format materials are converted into unified format documents and preprocessed to obtain a document library; The preprocessed document is split into several text blocks. The structural relationship or semantic hierarchy information of the document in which each text block is located is extracted to form a chain-like hierarchical structure information tag. This tag is then concatenated or associated with the corresponding text block content to obtain a set of text blocks carrying hierarchical structure information. A dense vector index is constructed for the text block, and an inverted index is constructed based on the keywords extracted from the text block. The text block ID is used as a unique identifier, and a mapping relationship is established between the vector index and the inverted index. This mapping relationship is used to collaboratively achieve the recall of semantically similar text blocks based on dense vectors and the recall of matching text blocks based on sparse keywords. Extract the title and chapter information of each document from the document library, predict the document title and chapter associated with the user query, and generate intent recognition results using a large language model; The intent recognition results are then combined with the original user query structure to form an enhanced user query; By utilizing enhanced user queries and original user queries, a dual-path retrieval using vectors and keywords is performed, returning several semantically similar text blocks and keyword-matched text blocks respectively. A re-ranking algorithm is then used to merge and deduplicate the dual-path retrieval results, resulting in the final dual-path retrieval result. The original user query and the dual-path retrieval results are combined to construct prompt words, which are then input into the large language model to generate a natural language answer.
2. The retrieval enhancement generation method according to claim 1, characterized in that, The method also includes: converting the original multi-format materials into a unified Markdown format document; Clean all document data and encode all documents to UTF-8 format; All documents are converted into hash values using a hash algorithm, and these hash values are used as unique identifiers for each document. Duplicate documents are then eliminated by comparing the hash values.
3. The retrieval enhancement generation method according to claim 1, characterized in that, Splitting the preprocessed document includes: If splitting by semantics, prioritize splitting the document text by paragraph, chapter, or topic boundaries; If splitting according to rules, the splitting can be done by setting the delimiter, text block length, or text block overlap length.
4. The retrieval enhancement generation method according to claim 1, characterized in that, The method for constructing a dense vector index includes: encoding a text block carrying hierarchical structure information to generate a dense vector, constructing a dense vector index, performing L2 normalization on the generated vector, and then storing the normalized vector in a vector database. The method for constructing an inverted index includes: performing word segmentation on the text block, splitting the continuous text into word units with independent semantics, and removing stop words; extracting the core keywords of the text block, constructing an inverted index based on the core keywords, and storing the inverted index in the full-text search engine.
5. The retrieval enhancement generation method according to claim 1, characterized in that, The method further includes: integrating the title and chapter information of each document queried and extracted by the original user into prompt words according to a predefined template, predicting the documents and chapters that the user query may be associated with, and outputting the results in list form; The prompt words are input into a lightweight large language model to generate intent recognition results containing potentially related documents and chapters.
6. The retrieval enhancement generation method according to claim 1, characterized in that, The enhanced user query is vector-encoded using the same embedding model as the text block to generate a query vector. Approximate nearest neighbor retrieval is performed to return the Top-K1 semantically similar text blocks, retaining their similarity scores and text block IDs. The original query is input into the full-text search engine, the BM25 algorithm is used to retrieve the inverted index, the top-K2 keyword matching text blocks are returned, and their matching scores and text block IDs are recorded. The RRF algorithm is used to merge and deduplicate the search results, and finally the top-N candidate text blocks are retained.
7. The retrieval enhancement generation method according to claim 1, characterized in that, The method further includes: The text block IDs in the generated natural language answers are extracted using regular expressions and associated with the document library metadata to generate source links. Determine whether the generated natural language answer contains citations or whether the number of citations does not meet the preset threshold. If so, trigger a secondary retrieval process to recall the text block again. The generated natural language answers are converted into HTML format, with cited parts highlighted and source links embedded in the corresponding text.
8. A retrieval enhancement generation system based on a two-layer enhancement mechanism, characterized in that, include: The material preprocessing module is used to convert raw multi-format materials into unified format documents and perform preprocessing to obtain a document library. The chunking module is used to split the preprocessed document into several text chunks, extract the structural relationship or semantic hierarchy information of the document in which each text chunk is located, form a chain-like hierarchical structure information tag, and concatenate or associate it with the corresponding text chunk content to obtain a set of text chunks carrying hierarchical structure information. The index building module is used to construct a dense vector index for text blocks and an inverted index based on keywords extracted from the text blocks. A mapping relationship is established between the vector index and the inverted index, using the text block ID as a unique identifier. This mapping relationship is used to collaboratively achieve semantically similar text block retrieval based on dense vectors and matching text block retrieval based on sparse keywords. The query understanding module is used to extract the title and chapter information of each document from the document library, predict the document title and chapter associated with the user query, and generate intent recognition results using a large language model. The query enhancement module is used to concatenate the intent recognition results with the original user query structure to form an enhanced user query; The dual-path retrieval module is used to perform vector and keyword dual-path retrieval using enhanced user queries and original user queries, respectively returning several semantically similar text blocks and keyword-matched text blocks, and using a re-ranking algorithm to merge and deduplicate the dual-path retrieval results to obtain the dual-path retrieval results; The answer generation module is used to combine the original user query with the dual-path retrieval results, construct prompt words, input them into the large language model, and generate the answer.
9. The retrieval enhancement generation system according to claim 8, characterized in that, It also includes an integrity verification module, which is used to determine whether the generated natural language answer contains citations or whether the number of citations does not meet the preset threshold. If so, a secondary retrieval process is triggered to recall the text block again.
10. The retrieval enhancement generation system according to claim 8, characterized in that, The dual-path retrieval module also includes: The vector retrieval unit is used to vectorize the enhanced user query using the same embedding model as the text block, generate a query vector, perform an approximate nearest neighbor retrieval in the vector database, return the Top-K1 semantically similar text blocks, and retain their similarity scores and text block IDs; The keyword retrieval unit is used to input the original user query into the full-text search engine, use the BM25 algorithm to retrieve the inverted index, return the top-K2 keyword matching text blocks, and record their matching scores and text block IDs; The retrieval result fusion and reordering unit is used to merge and deduplicate the retrieval results of the Top-K1 semantically similar text blocks and the Top-K2 keyword-matching text blocks based on the RRF algorithm, retaining the Top-N text blocks, as well as their similarity scores, matching scores and text block IDs.