A method and system for intelligent document retrieval generation based on RAG technology

The intelligent document retrieval generation method based on RAG technology solves the problem of insufficient accuracy of information retrieval in specific fields of traditional language models, improves the accuracy and exhaustiveness of information retrieval, and provides users with rich and accurate content. Dynamically adjust and optimize processes to provide convenient and reliable text content retrieval and generation services.

CN118332072BActive Publication Date: 2024-09-06SHANDONG INSPUR SCI RES INST CO LTD

Patent Information

Application Number
CN202410756036.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-09-06
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

Traditional large-scale language models are limited in their ability to provide precise and detailed information in specific fields, and cannot effectively improve the accuracy and detailedness of information retrieval.

Method used

Adopting an intelligent document retrieval generation method based on RAG technology, by collecting documents in various formats from diverse data sources, converting them into text data, slicing and vectorizing indexing, combined with user queries for hybrid retrieval and content generation, and dynamic adjustment processing processes to improve the accuracy and exhaustiveness of information retrieval and optimize system performance through feedback.

Benefits of technology

It has improved the accuracy and detail of information retrieval, provided users with richer and more accurate content, and provided convenient and reliable text content retrieval and generation services through dynamic adjustment and optimization processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332072B
    Figure CN118332072B
Patent Text Reader

Abstract

The present invention relates to the technical field of natural language processing, and in particular to an intelligent document retrieval generation method and system based on RAG technology, which collects data from documents of various formats from diverse data sources into text data, processes the text data, slices and vectorizes the processed text data to establish an index, then retrieves the text data from the established index according to a query input by a user, generates text results that meet user needs from the retrieved text data, performs quality assessment on the text results, and performs re-retrieval or outputs the final text results based on the quality assessment results, thereby forming a complete process from retrieval enhancement to content generation, which can not only improve the accuracy and thoroughness of information retrieval and provide users with richer and more accurate content, but also provide users with convenient and reliable text content hallucination detection and correction services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to an intelligent document retrieval generation method and system based on RAG technology. Background Art

[0002] Retrieval-Augmented Generation (RAG) technology is an advanced question-answering system that can process and understand files and databases in various formats to build a comprehensive knowledge base. RAG technology cleverly combines the accuracy of information retrieval with the creativity of content generation, aiming to enhance the comprehensive capabilities of language models by leveraging huge data sets. The core advantage of this technology lies in its organic combination of large-scale language models and efficient retrieval systems. This combination gives the model a dual advantage in generating answers: it can rely on its built-in knowledge base and access external massive information resources, so that it can provide more accurate and comprehensive answers.

[0003] Traditional large-scale language models usually only rely on their preset knowledge to generate answers, which to some extent limits their ability to provide accurate and detailed information in specific fields. In order to solve this problem, the present invention provides an intelligent document retrieval generation method, system and storage medium based on RAG technology. Summary of the invention

[0004] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides an intelligent document retrieval generation method and system based on RAG technology, which can not only improve the accuracy and thoroughness of information retrieval, but also provide users with richer and more accurate content, showing great research value and broad application potential.

[0005] In order to implement the above technical solution, in a first aspect, the present invention provides an intelligent document retrieval generation method based on RAG technology, comprising:

[0006] Step 1: Collect documents in various formats from diverse data sources;

[0007] Step 2: Convert the data in documents of various formats into text data and process the text data;

[0008] Step 3: Slice and vectorize the processed text data to create an index;

[0009] Step 4: Retrieve text data based on the query input by the user;

[0010] Step 5: Generate text results that meet user needs;

[0011] Step 6: Performing a quality assessment on the text results, and dynamically adjusting the processing flow according to the quality assessment results, wherein the dynamically adjusting the processing flow includes returning to step 4 and proceeding to step 7;

[0012] Step 7: Display the final text result.

[0013] Furthermore, the steps also include:

[0014] Receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans;

[0015] Based on the analysis results of feedback data, the system is updated regularly.

[0016] Furthermore, the step 2 comprises:

[0017] Convert data in various formats of documents into text data;

[0018] Apply machine learning algorithms to perform mean analysis and maximum and minimum length statistics on text data;

[0019] Perform data cleaning and text summary extraction on text data;

[0020] Key information is added to the processed text data, wherein the key information includes page number, text name and author.

[0021] Furthermore, the step three comprises:

[0022] Extract text data from documents;

[0023] Using recursive character text segmentation technology, the text data is cut into multiple structured text blocks;

[0024] Use semantic representation models to accurately understand the deep semantics of each text block through sparse retrieval technology;

[0025] Convert these text blocks into numerical vectors based on the text embedding model;

[0026] The numeric vector of the text block and its corresponding text data are stored as indices.

[0027] Furthermore, the step 4 includes:

[0028] Optimize user queries;

[0029] Use hybrid retrieval to retrieve the text data most relevant to the user query from the index;

[0030] The text data is reordered, compressed and merged to obtain the retrieval text data.

[0031] Furthermore, the step five comprises:

[0032] Design prompt engineering based on user queries or needs to guide the large language model to generate text content that meets user needs;

[0033] The generated text content and retrieved text data are optimized to produce the final text result.

[0034] Furthermore, the step six comprises:

[0035] Check the text results for fluency, grammatical correctness, and completeness and accuracy of information;

[0036] Use semantic analysis technology to identify and remove redundant information in text results, and retain key information and core ideas in text results;

[0037] Perform fact checking and data verification on the text results to generate a quality assessment result. If the generated quality assessment result shows that the quality needs to be improved, return to step 4. If the generated quality assessment result shows that the quality is good, output the final text result.

[0038] On the other hand, the present invention provides an intelligent document retrieval generation system based on RAG technology, comprising:

[0039] Data collection module, used to collect documents in various formats from diverse data sources;

[0040] A data processing module is used to convert data in documents of various formats into text data and process the text data;

[0041] Index building module, used to slice and vectorize the processed text data to build an index;

[0042] Intelligent retrieval module, used to retrieve text data based on user queries;

[0043] Content generation module, used to generate text results that meet user needs;

[0044] The post-processing module is used to evaluate the quality of the text results and dynamically adjust the processing flow according to the evaluation results;

[0045] The result display module is used to display the final text results.

[0046] Furthermore, it also includes:

[0047] Feedback module, which is used to receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans;

[0048] The system optimization module is used to perform regular iterative updates based on the analysis results of feedback data to provide higher quality services and meet user needs.

[0049] On the other hand, the present invention provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned intelligent document retrieval and generation method based on RAG technology.

[0050] The beneficial effects of the present invention are:

[0051] (1) The present invention collects data from documents of various formats from diverse data sources and converts them into text data, processes the text data, segments and vectorizes the processed text data to establish an index, and then retrieves text data from the established index according to a query input by a user, generates text results that meet the user's needs from the retrieved text data, and performs quality assessment on the text results. Based on the quality assessment results, the present invention performs another retrieval or outputs the final text results, thereby forming a complete process from retrieval enhancement to content generation. This process can not only improve the accuracy and thoroughness of information retrieval and provide users with richer and more accurate content, but also provide users with a convenient and reliable text content hallucination detection and correction service.

[0052] In addition, the present invention can also be updated and optimized according to user feedback to enhance user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0054] Figure 1 The present invention is a flowchart of an intelligent document retrieval generation method based on RAG technology.

[0055] Figure 2 The flowchart of data conversion and processing in the document of the present invention.

[0056] Figure 3 A flowchart for indexing of the present invention.

[0057] Figure 4 Flowchart for query retrieval of the present invention.

[0058] Figure 5 A flowchart of generating text results for the present invention.

[0059] Figure 6 It is a quality assessment flow chart of the present invention. DETAILED DESCRIPTION

[0060] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0061] It should be noted that the following detailed descriptions are all illustrative and are intended to provide further explanation of the present invention. Unless otherwise specified, each technical and scientific term used in this embodiment has the same meaning as commonly understood by those skilled in the art to which the present invention belongs.

[0062] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0063] In the present invention, terms such as "upper", "lower", "left", "right", "front", "back", "vertical", "horizontal", "side", "bottom", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings. They are relational words determined only for the convenience of describing the structural relationships of the various parts or elements of the present invention, and do not specifically refer to any part or element in the present invention and should not be understood as limitations on the present invention.

[0064] In the present invention, terms such as "fixed connection", "connected", "connection", etc. should be understood in a broad sense, indicating that it can be fixedly connected, integrally connected or detachably connected; it can be directly connected or indirectly connected through an intermediate medium. Relevant scientific research or technical personnel in this field can determine the specific meanings of the above terms in the present invention according to specific circumstances, and they should not be understood as limiting the present invention.

[0065] It should be noted that there are three types of models involved in the present invention. The first type is the semantic vector model, which is used to convert natural language into vectors that can be numerically calculated by computers. The currently selected model is BGE-M3, which is an open source model. The second type is the semantic large model (large language model, LLM in English), which is used to input questions and directly output answers based on the questions. The Qwen1.5-72B-Chat model currently used for output in the patent is an open source model. The third type is the topic model (LDA), which is used to summarize the topic of the document. Gensim is currently used, which is an open source third-party Python library.

[0066] Embodiment 1:

[0067] like Figures 1 to 6As shown, this embodiment provides an intelligent document retrieval generation method based on RAG technology, including the following steps:

[0068] S1: Collect documents in various formats from diverse data sources to ensure comprehensiveness and diversity.

[0069] Among them, documents in various formats include documents in PDF, HTML, WORD and other formats.

[0070] S2: Convert data in documents of various formats into text data and process the text data.

[0071] Specifically, Figure 2 The following steps are shown:

[0072] S21: Text conversion.

[0073] Specifically, the collected data in documents of various formats (such as PDF, HTML, WORD, etc.) are converted into text data using OCR (Optical Character Recognition) technology and natural language processing tools to improve data processing efficiency and accuracy.

[0074] S22: In-depth text data analysis.

[0075] Machine learning algorithms are used to perform mean analysis and maximum and minimum length statistics on text data to understand the characteristics and distribution of text data, which facilitates mining and knowledge discovery of text data. The algorithm is a similarity calculation algorithm that obtains the most similar answers based on the index and vector established above.

[0076] S23: Text data processing.

[0077] The text data is preprocessed by data cleaning and text summary extraction based on the characteristics and distribution of the understood text data. In the preprocessing process, data cleaning removes irrelevant information, noise is filtered, and text data is standardized to provide clear and standardized text data, thereby improving the accuracy of analysis and processing. Then, a large language model is used to extract text summaries from the text data, and the extracted text summaries are stored in metadata to retain core information and facilitate information retrieval and content understanding.

[0078] S24: Add key information and store it.

[0079] Finally, key information is added to the preprocessed text data to improve the efficiency and accuracy of content screening and condition filtering. The text data with added key information is stored in a document of a specified format. Among them, key information includes page number, text name and author.

[0080] It should be noted that the specified format is not a fixed format, and various formats can be specified for text data from different data sources.

[0081] S3: Slice and vectorize the processed text data to create an index.

[0082] Specifically, Figure 3 As shown, the following steps are included:

[0083] S31: Extract text data.

[0084] The document content extraction strategy is customized according to the specified format of the document in which the text data is stored, so as to extract the text data in the document of the specified format. By customizing the document content extraction strategy according to the format, efficient acquisition of the document content is ensured.

[0085] S32: Recursive text segmentation.

[0086] Then, the recursive character text segmentation technology is used to cut the text data into multiple structured text blocks according to separators such as line breaks, spaces, and punctuation. Among them, when the recursive character text segmentation unit is cutting, the size of the text block is dynamically adjusted according to the contextual restrictions of the large language model, thereby achieving the optimal cutting of the text data, which not only meets the accuracy requirements but also adapts to texts of different lengths. In addition, the sliding window technology is used to improve the accuracy of retrieval through small text blocks, and the context is retained by synthesizing large text blocks, thereby balancing the retrieval accuracy and the richness of contextual information.

[0087] S33: Semantic representation.

[0088] Load an efficient semantic representation model, which uses sparse retrieval technology to accurately understand the deep semantics of each text block to further improve the accuracy and efficiency of analysis and retrieval.

[0089] S34: Text vector representation.

[0090] Based on the text embedding model, these text blocks are converted into text block numerical vectors, and the text block numerical vectors are stored to capture semantic information for easy calculation and analysis.

[0091] S35: Build an index.

[0092] Based on the vectorized data, the numerical vector of the text block and its corresponding text data are stored as index items, completing the entire process of index storage.

[0093] S4: Retrieve text data based on the query input by the user;

[0094] Specifically, the query input by the user is optimized, and the text data most relevant to the user query is retrieved from the index items using hybrid retrieval, and the text data is re-ordered, compressed and merged to obtain the retrieved text data, such as Figure 4 As shown, the following steps are included:

[0095] S41: Understand user query intent.

[0096] The pre-search module understands the in-depth intent of the query entered by the user to ensure the targeted and accurate processing.

[0097] S42: Query expansion.

[0098] Rewrite and correct user queries based on the understood intent to improve the clarity and accuracy of the query. Among them, the user's single query can be decomposed into multiple related queries to enrich the query content and improve the comprehensiveness and diversity of the retrieval. For example, the adaptive RAG model generates multiple equivalent queries based on the query entered by the user, and uses single-step retrieval, multi-step retrieval and knowledge graph retrieval methods to comprehensively cover all information points.

[0099] S43: Filter query.

[0100] The query that best matches the user's intent is selected from multiple related queries to ensure the relevance and accuracy of the retrieval results. The selected queries are converted into query numerical vectors, which helps capture the semantic information of the question and provide support for retrieval.

[0101] S44: Content recall.

[0102] According to the query numerical vector, the numerical vector of the text block most relevant to the query numerical vector is retrieved from the index item through an algorithm to obtain the text data. In the retrieval process, the keyword retriever, sparse retriever and dense retriever are used to process sparse and dense retrieval in parallel through the BGE-M3 model, and work together to improve the retrieval performance.

[0103] S45: Priority sorting.

[0104] The obtained text data is prioritized so that the most relevant and useful text data is displayed first, so as to provide the most direct and valuable query results.

[0105] S46: Text data compression.

[0106] The text data is effectively compressed to retain key information, speed up processing, and adapt to the processing length limit of LLM.

[0107] S47: Text data fusion.

[0108] Integrate text data from different data sources and in different forms to obtain retrieval text data, thereby providing comprehensive and in-depth text knowledge reference.

[0109] S5: Generate text results that meet user needs.

[0110] Specifically, Figure 5 As shown, the following steps are included:

[0111] S51: Build prompt project.

[0112] Design prompt engineering based on user queries or needs to guide the large language model to generate text content that meets user needs, ensuring that the generated content is highly relevant to user queries and covers all possible information points.

[0113] S52: Loading a large language model.

[0114] Use large language models (e.g., ChatGPT) to generate coherent and logical text content, and imitate different writing styles and language habits to provide diverse content.

[0115] S53: Optimize integration.

[0116] The generated text content and search text data are optimized to generate the final text results. The optimization includes removing duplicate information, correcting errors, adding details, and unifying the format and style to ensure the comprehensiveness and system of the text results. Then all the optimized text content and search text data are integrated to generate text results that contain all key information and are optimized and proofread, thus ensuring the accuracy and readability of the text results.

[0117] S6: Perform a quality assessment on the text result to determine whether the generated quality assessment result needs to be improved. If so, return to step S4; if not, output the final text result (such as Figure 6 as shown).

[0118] Specifically, the steps include:

[0119] S61: Text result check.

[0120] Check the text results for fluency, grammatical correctness, and completeness and accuracy of information.

[0121] S62: semantic analysis and recognition.

[0122] Semantic analysis technology is used to identify and remove redundant information (repeated sentences and unnecessary filler words) in text results to improve the compactness and readability of text results, as well as to identify and retain key information and core ideas in text results.

[0123] S63: Accuracy check.

[0124] The text results are fact-checked and data-validated to generate quality assessment results, and the processing flow is dynamically adjusted based on the quality assessment results. Specifically, if the generated quality assessment result is that the quality needs to be improved, the query entered by the user is retrieved, for example, using an adaptive RAG model to generate multiple equivalent queries based on the query entered by the user, using single-step retrieval, multi-step retrieval, and knowledge graph retrieval methods to comprehensively cover the use of all information points; if the generated quality assessment result is of good quality, the recognized text results are formatted and output, where formatting includes adjusting paragraph structure, applying titles and lists, etc., to provide clear and professional output text.

[0125] S7: Display the final text result.

[0126] Specifically, the intelligent document retrieval function of the server is first started to enhance the upper-level service.

[0127] Then, the user asks a question, and the server calls the API to perform retrieval and generate text content to display the final text results through an interactive interface.

[0128] S8: Used to receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans.

[0129] Specifically, set up obvious feedback channels on the interactive interface to encourage users to provide feedback on the content. Then analyze the user feedback, identify problems and improvement points, develop an optimization plan, and make corresponding adjustments.

[0130] S9: Based on the analysis results of feedback data, regular iterative updates are carried out to provide higher quality services and meet user needs.

[0131] Specifically, based on user feedback and data analysis results, the system will be continuously adjusted and optimized, and regularly updated to provide higher quality services and meet user needs. This is a process of continuous improvement. Iterative updates include content updates, functional improvements, or interface design.

[0132] This embodiment extracts necessary documents from diverse data sources, and provides clear and standardized data input for subsequent processing flows through preprocessing steps such as denoising, standardization, and format conversion. The text data is sliced ​​and vectorized, and indexed. The most relevant text to the user query is quickly and accurately retrieved from a large amount of information through strategies such as user query optimization, hybrid retrieval, reordering, and prompt compression. Using a large language model, a prompt project is set based on the retrieved information to generate text content that meets user needs. At the same time, it can be fine-tuned according to specific tasks or fields, and the generated text is optimized by the post-processing module to remove redundant information, retain key content, and further improve the relevance and accuracy of the answer.

[0133] In addition, the processing flow is dynamically adjusted according to the quality of the generated results to determine whether further retrieval or optimization is needed. Finally, the retrieval results or generated content from different sources are effectively integrated to provide users with comprehensive and systematic answers. The retrieved documents are sorted and displayed according to relevance, and may also include value-added services such as highlighting query terms and providing document summaries. The user feedback module collects user feedback on the retrieval results in order to continuously adjust and optimize the retrieval algorithm and improve the user experience.

[0134] Embodiment 2: This embodiment provides an intelligent document retrieval generation system based on RAG technology, including:

[0135] (I) Data collection module, which is used to collect documents in various formats from diverse data sources to ensure the comprehensiveness and diversity of the documents. The various formats of documents include PDF, HTML, WORD and other formats.

[0136] (ii) A data processing module, which is used to convert data in documents of various formats into text data and process the text data.

[0137] Specifically, the data processing module has the following units:

[0138] The document format conversion unit is used to convert the data in the collected documents in various formats (such as PDF, HTML, WORD, etc.) into text data using OCR (Optical Character Recognition) technology and natural language processing tools to improve data processing efficiency and accuracy;

[0139] The data analysis unit is used to apply machine learning algorithms to perform mean analysis and maximum and minimum length statistics on text data, understand the characteristics and distribution of text data, and conduct text data mining and knowledge discovery.

[0140] A data preprocessing unit, used for preprocessing the text data such as data cleaning and extracting text summaries according to the characteristics and distribution of the understood text data;

[0141] The preprocessing unit includes: a data cleaning unit and a text summary extraction unit.

[0142] The data cleaning unit is used to perform data cleaning to remove irrelevant information, filter noise, and standardize text data to provide clear and standardized text data, thereby improving the accuracy of analysis and processing.

[0143] The text summary extraction unit is used to extract text summaries from text data using a large language model, and store the extracted text summaries in metadata so as to retain core information and facilitate information retrieval and content understanding.

[0144] The key information adding unit is used to add key information to the preprocessed text data to improve the efficiency and accuracy of content screening and condition filtering. The key information includes page number, text name and author.

[0145] The data storage unit is used to store the text data with added key information into a document of a specified format.

[0146] It should be noted that the specified format is not a fixed format, and various formats can be specified for text data from different data sources.

[0147] (iii) Index building module, used to segment and vectorize the processed text data to build an index.

[0148] Specifically, the index building module includes the following units:

[0149] The document loading unit is used to customize the document content extraction strategy according to the specified format of the document in which the text data is stored, so as to extract the text data in the document of the specified format. By customizing the document content extraction strategy according to the format, efficient acquisition of the document content is ensured.

[0150] The text segmentation unit is used to segment text data into multiple structured text segments to lay the foundation for subsequent analysis.

[0151] The text segmentation unit includes a recursive character text segmentation unit and a recursive chunking unit.

[0152] The recursive character text segmentation unit is used to cut text data into multiple structured text blocks according to separators such as line breaks, spaces and punctuation marks by using recursive character text segmentation technology.

[0153] The recursive chunking unit is used to dynamically adjust the size of the text chunk according to the contextual constraints of the large language model when the recursive character text segmentation unit is cutting, thereby achieving optimal cutting of the text data, which not only meets the accuracy requirements but also adapts to texts of different lengths.

[0154] Among them, the text switching unit also uses sliding window technology to improve accuracy by retrieving small text blocks, while retaining context by synthesizing large text blocks, thereby balancing retrieval accuracy and the richness of contextual information.

[0155] The semantic representation unit is used to load an efficient semantic representation model. The semantic representation model uses sparse retrieval technology to accurately understand the deep semantics of each text block to further improve the accuracy and efficiency of analysis and retrieval.

[0156] The text vectorization unit is used to convert text blocks into text block numerical vectors based on the text embedding model, and store the text block numerical vectors to capture semantic information for easy calculation and analysis.

[0157] The index building unit is used to store the text block numerical vector and its corresponding text data as index items.

[0158] (iv) Intelligent retrieval module, used to retrieve text data based on user queries.

[0159] The intelligent retrieval module is used to optimize user queries and use hybrid retrieval to retrieve text data most relevant to the user query from index items, and reorder, compress and merge the text data to obtain the retrieved text data.

[0160] The intelligent retrieval module includes the following units:

[0161] The pre-retrieval unit is used to understand the intent of the query entered by the user to ensure the pertinence and accuracy of the processing.

[0162] The query optimization unit is used to rewrite and correct user queries to improve the clarity and accuracy of the query.

[0163] The query expansion unit is used to split a user's single query into multiple related queries to enrich the query content and improve the comprehensiveness and diversity of the retrieval.

[0164] The query verification unit is used to filter out the query that best meets the user's intention from multiple related queries to ensure the relevance and accuracy of the retrieval results.

[0165] The semantic representation model unit is used to convert the screened queries into query numerical vectors, which helps to capture the semantic information of the questions and provide support for retrieval.

[0166] The recall unit is used to retrieve the text block numerical vector that is most relevant to the query numerical vector from the index item through an algorithm according to the query numerical vector, so as to obtain text data.

[0167] Specifically, during the retrieval process, the keyword retriever, sparse retriever, and dense retriever are used to process sparse and dense retrieval in parallel through the BGE-M3 model, working together to improve the retrieval performance.

[0168] The sorting unit is used to prioritize the obtained text data so that the most relevant and useful text data are displayed first, so as to provide the most direct and valuable query results.

[0169] The compression unit is used to compress the text data effectively, thereby retaining key information, speeding up processing, and adapting to the processing length limit of LLM.

[0170] The fusion unit is used to integrate text data from different data sources and in different forms to obtain retrieval text data, thereby providing a comprehensive and in-depth text knowledge reference.

[0171] (V) Content generation module, used to generate text results that meet user needs.

[0172] The content generation module includes the following units:

[0173] The prompt engineering creation unit is used to design prompts based on user queries or needs in order to guide the large language model to generate text content that meets user needs, to ensure that the generated content is highly relevant to the user query and can cover all possible information points.

[0174] The text content generation unit is used to utilize a large language model (e.g., ChatGPT) to generate coherent and logical text content, and can imitate different writing styles and language habits to provide diverse content.

[0175] The text post-processing unit is used to optimize and integrate the generated text content and retrieved text data to generate the final text result.

[0176] Specifically, the generated text content and search text data are optimized, where the optimization includes removing duplicate information, correcting errors, supplementing details, and unifying the format and style to ensure the comprehensiveness and system of the text results. The optimized text content and search text data are then integrated to generate optimized and proofread text results containing all key information, thereby ensuring the accuracy and readability of the text results.

[0177] (VI) Post-processing module, which is used to evaluate the quality of text results and output the final text results or perform retrieval again based on the evaluation results.

[0178] Specifically, the post-processing module includes the following units:

[0179] The checking unit is used to check the fluency, grammatical correctness, and completeness and accuracy of the text results.

[0180] Recognition unit, used for semantic analysis technology, identifies and removes redundant information (repeated sentences and unnecessary filler words) in text results to improve the compactness and readability of text results, as well as identifies and retains key information and core ideas in text results.

[0181] The quality assessment unit is used to perform fact checking and data verification on the text results to generate quality assessment results.

[0182] Intelligent decision-making unit, used to dynamically adjust the processing flow according to the quality assessment results.

[0183] Specifically, if the generated quality assessment result shows that the quality needs to be improved, the query entered by the user is retrieved. For example, an adaptive RAG model is used to generate multiple equivalent queries based on the query entered by the user, and single-step retrieval, multi-step retrieval, and knowledge graph retrieval methods are used to comprehensively cover the use of all information points. If the generated quality assessment result shows that the quality is good, the recognized text results are formatted. Specifically, the paragraph structure, application titles and lists are adjusted to provide clear and professional output text.

[0184] (VII) Result display module, used to display the final text results.

[0185] Specifically, the intelligent document retrieval function of the server is first started to enhance the upper-level service.

[0186] Then, the user asks a question, and the server calls the API to perform retrieval and generate text content to display the final text results through an interactive interface.

[0187] (8) Feedback module, which is used to receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans.

[0188] (IX) System optimization module, which is used to perform regular iterative updates based on the analysis results of feedback data to provide higher quality services and meet user needs.

[0189] Specifically, iterative updates include content updates, functional improvements, and interface design updates.

[0190] The system provided in this implementation covers multiple key modules, including data collection module, data processing, index construction, intelligent retrieval, content generation, post-processing, result display and user feedback. The data collection module is responsible for extracting necessary documents from a variety of data sources. The data processing module is used to perform pre-processing steps such as denoising, standardization, and format conversion on the extracted documents to provide clear and standardized data input for subsequent processing processes. The index construction module slices and vectorizes the text data and establishes an index. The intelligent retrieval module quickly and accurately retrieves the most relevant text to the user query from a large amount of information through user query optimization, hybrid retrieval, re-ranking, prompt compression and other strategies. The content generation module uses large language models, such as ChatGPT, to set prompt engineering (Prompt) based on the retrieved information to generate text content that meets user needs. At the same time, it can be fine-tuned according to specific tasks or fields, so that the generated text is optimized by the post-processing module, removing redundant information, retaining key content, and further improving the relevance and accuracy of the answer. In addition, the post-processing module dynamically adjusts the processing flow according to the quality of the generated results, determines whether further retrieval or optimization is needed, and finally effectively integrates the retrieval results or generated content from different sources to provide users with comprehensive and systematic answers. The result display module sorts and displays the retrieved documents by relevance, and may also include value-added services such as highlighting query terms and providing document summaries. The user feedback module collects user feedback on the retrieval results, and the system optimization module is used to continuously adjust and optimize the retrieval algorithm to enhance the user experience. Through these nine carefully designed modules, a complete process from retrieval enhancement to content generation is formed, which not only improves the accuracy of text content, but also provides a new direction for the development of text generation technology, and provides users with convenient and reliable text content hallucination detection and correction services. At the same time, the system also has good scalability and can be applied to different fields and scenarios.

[0191] Embodiment 3:

[0192] This embodiment provides a computer-readable storage medium, which includes a stored program. When the program is running, the device where the computer-readable storage medium is located is controlled to execute the intelligent document retrieval and generation method based on RAG technology described in Example 1.

[0193] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

[0194] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.

[0195] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0196] In addition, it should be noted that the flowchart in the accompanying drawings shows the method of the embodiment of the present disclosure. In the corresponding description in the flowchart or block diagram in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in an order different from that disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be performed substantially in parallel, and they can sometimes be performed in the opposite order, which can depend on the functions involved. Each block in the block diagram and / or flow chart, and the combination of blocks in the block diagram and / or flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0197] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An intelligent document retrieval generation method based on RAG technology, characterized in that: include: Step 1: Collect documents in various formats from diverse data sources; Step 2: Convert the data in documents of various formats into text data and process the text data; Step 3: Slice and vectorize the processed text data to create an index; Step 4: Retrieve text data based on the query input by the user; Step 5: Generate text results that meet user needs; Step 6: Performing a quality assessment on the text results, and dynamically adjusting the processing flow according to the quality assessment results, wherein the dynamically adjusting the processing flow includes returning to step 4 and proceeding to step 7; Step 7: Display the final text result; The second step comprises: Use OCR technology and natural language processing tools to convert the collected data in various formats of documents into text data; Apply machine learning algorithms to perform mean analysis and maximum and minimum length statistics on text data to understand the characteristics and distribution of text data; Perform data cleaning and text summary preprocessing on the text data based on the characteristics and distribution of the understood text data; Add key information to preprocessed text data to improve the efficiency and accuracy of content screening and conditional filtering; The fourth step comprises: Understand the user's in-depth intent of the query entered through the pre-search module; Rewrite and correct user queries based on the understood intent, where a single user query can be decomposed into multiple related queries; Filter out the query that best matches the user's intention from multiple related queries, and convert the filtered query into a query numerical vector; According to the query numerical vector, the numerical vector of the text block most relevant to the query numerical vector is retrieved from the index item through an algorithm, thereby obtaining the text data; Prioritize the obtained text data; Text data obtained through effective compression; Integrate text data from different data sources and in different forms to obtain searchable text data.

2. The intelligent document retrieval generation method based on RAG technology according to claim 1 is characterized in that: The steps also include: Receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans; Based on the analysis results of feedback data, the system is updated regularly.

3. The intelligent document retrieval generation method based on RAG technology according to claim 1 is characterized in that: The step three comprises: Extract text data from documents; Using recursive character text segmentation technology, the text data is cut into multiple structured text blocks; Use semantic representation models to accurately understand the deep semantics of each text block through sparse retrieval technology; Convert these text blocks into numerical vectors based on the text embedding model; The numeric vector of the text block and its corresponding text data are stored as indices.

4. The intelligent document retrieval generation method based on RAG technology according to claim 1 is characterized in that: The step five comprises: Design prompt engineering based on user queries or needs to guide the large language model to generate text content that meets user needs; The generated text content and retrieved text data are optimized to produce the final text result.

5. The intelligent document retrieval generation method based on RAG technology according to claim 4 is characterized in that: The step six comprises: Check the text results for fluency, grammatical correctness, and completeness and accuracy of information; Use semantic analysis technology to identify and remove redundant information in text results, and retain key information and core ideas in text results; Perform fact checking and data verification on the text results to generate a quality assessment result. If the generated quality assessment result shows that the quality needs to be improved, return to step 4. If the generated quality assessment result shows that the quality is good, output the final text result.

6. An intelligent document retrieval generation system based on RAG technology, characterized in that: include: Data collection module, used to collect documents in various formats from diverse data sources; A data processing module is used to convert data in documents of various formats into text data and process the text data; Index building module, used to slice and vectorize the processed text data to build an index; Intelligent retrieval module, used to retrieve text data based on user queries; Content generation module, used to generate text results that meet user needs; The post-processing module is used to evaluate the quality of the text results and dynamically adjust the processing flow according to the evaluation results; The result display module is used to display the final text results; The converting of data in documents of various formats into text data and processing the text data includes: Use OCR technology and natural language processing tools to convert the collected data in various formats of documents into text data; Apply machine learning algorithms to perform mean analysis and maximum and minimum length statistics on text data to understand the characteristics and distribution of text data; Perform data cleaning and text summary preprocessing on the text data based on the characteristics and distribution of the understood text data; Add key information to preprocessed text data to improve the efficiency and accuracy of content screening and conditional filtering; The text results retrieved according to the query input by the user include: Understand the user's in-depth intent of the query entered through the pre-search module; Rewrite and correct user queries based on the understood intent, where a single user query can be decomposed into multiple related queries; Filter out the query that best matches the user's intention from multiple related queries, and convert the filtered query into a query numerical vector; According to the query numerical vector, the numerical vector of the text block most relevant to the query numerical vector is retrieved from the index item through an algorithm, thereby obtaining the text data; Prioritize the obtained text data; Text data obtained through effective compression; Integrate text data from different data sources and in different forms to obtain searchable text data.

7. The intelligent document retrieval generation system based on RAG technology according to claim 6 is characterized in that: Also includes: Feedback module, which is used to receive user feedback data, analyze the feedback data, identify problems and improvement points, and specify optimization plans; The system optimization module is used to perform regular iterative updates based on the analysis results of feedback data to provide higher quality services and meet user needs.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the intelligent document retrieval and generation method based on RAG technology as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Multi-data source data classification method and server

    CN107656958A

  • Retrieval type intelligent question and answer system and method for coal mine safety regulations

    CN114020862A

  • Knowledge vector library construction method, device, equipment, system and storage medium

    CN117422136A

  • Intelligent document question and answer method based on large model

    CN117932018A

  • Streaming question and answer illustration method and system

    CN118035416A

Cited By

  • Table content structured processing method and device, medium and product

    CN121747136A

  • Method and device for generating text dataset based on real user queries for evaluating rag systems

    RU2860362C1

  • Method and device for generating test dataset of synthetic data for evaluating rag systems

    RU2862210C1