A method and device for text generation enhancement applied to retrieval enhancement generation

Optimizing retrieval enhancement generation technology through deep learning models and large language models solves the problem of real-time information updating and retrieval strategy adaptation, improves retrieval efficiency and accuracy, and improves user interaction experience and information update frequency.

CN118377844BActive Publication Date: 2024-10-08BEIJING BAOLANDE SOFTWARE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410512961.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2024-10-08
Estimated Expiration
2044-04-26

AI Technical Summary

Technical Problem

Existing retrieval enhancement generation technology has shortcomings in real-time information updating, retrieval strategy adaptation, query processing integration, and intelligent routing, resulting in low retrieval efficiency and low accuracy of results.

Method used

Adopt deep learning models and adaptive algorithms, build efficient indexes through Transformer models and FAISS tools, dynamically adjust retrieval strategies and parameters, use large language models for query processing and chat context compression, and combine with intelligent query routing systems to select optimal data sources and indexes strategies to optimize search results.

Benefits of technology

It improves the accuracy and efficiency of retrieval, enhances user interaction experience, ensures information update frequency and accuracy, and reduces manual maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118377844B_ABST
    Figure CN118377844B_ABST
Patent Text Reader

Abstract

The present invention relates to retrieval enhancement generation (RAG) technology in the fields of computer software, natural language processing and information retrieval, and improves the text generation process by combining search technology with a large language model, and in particular to a method and device for text generation enhancement applied to retrieval enhancement generation, the method comprising: S1, query preprocessing and feature extraction; S2, adaptive retrieval optimization fine-tuning; S3, historical performance analysis and intelligent query routing decision; S4, query conversion, context compression, vectorized retrieval; S5, result rearrangement and filtering; S6, response synthesis and final response Response. The present invention improves the accuracy and efficiency of retrieval through adaptive retrieval optimization, strengthens the coherence and memory ability of the dialogue context, provides a smoother interactive experience, and at the same time retrieves the latest reliable knowledge source, improves the information update frequency and accuracy of the RAG system, and improves the retrieval efficiency of the RAG technology and the accuracy of the retrieval results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, in particular to retrieval enhanced generation (RAG) technology in the fields of computer software, natural language processing and information retrieval, combining search technology with a large language model to improve the text generation process, and more particularly to a method and device for text generation enhancement applied to retrieval enhanced generation. Background Art

[0002] Retrieval-augmented generation (RAG) technology greatly improves the quality and accuracy of text generation by combining the answers generated by a large language model with the information retrieved from the data source. Many products are almost entirely built on RAG, ranging from web search engines and question-answering services based on large language models to various data interactive chat applications.

[0003] At present, in the field of retrieval enhancement generation technology processing, the following technologies are mainly covered:

[0004] 1. Document segmentation, vectorization, and indexing to support efficient information retrieval. This process includes segmenting the text into small paragraphs, converting them into vectors using the Transformer model, and storing them in the index. In addition, contextual prompts are created for the large language model based on the retrieved information to answer user questions.

[0005] 2. Advanced query transformation technology, which uses large language models to optimize queries, introduces chat logic to handle complex conversations, and intelligent query routing to automatically select the most suitable data source or indexing strategy.

[0006] 3. Generate appropriate answers based on the retrieved context through intelligent agents and response synthesizers, while taking into account the fine-tuning of encoders and large language models, improving the overall performance of the system and the naturalness of interaction.

[0007] The comprehensive application of the above technologies not only enhances the model's ability to handle complex queries, but also provides users with a smoother and more natural interactive experience.

[0008] Although RAG technology has been applied in many products and has greatly improved the quality and accuracy of text generation, there is still much room for optimization because the technology is still in a booming stage:

[0009] 1. Existing RAG systems usually rely on static external knowledge sources, which means they cannot dynamically integrate the latest information or adapt to real-time updates of knowledge. This leads to the problem that the relevance and accuracy of the generated content decreases over time;

[0010] 2. The search strategies used by current RAG technologies are usually preset and cannot be adaptively adjusted according to the specific nature and context of the query, which results in low search efficiency and low accuracy of results;

[0011] 3. The existing technology lacks efficient integrated methods in query conversion and chat logic processing, especially it does not make full use of large language models as inference engines to automatically process query content decomposition, backtracking prompts and chat context compression;

[0012] 4. When processing queries, the current RAG technology lacks an intelligent query routing mechanism to automatically identify and select the most appropriate data source or indexing strategy, resulting in suboptimal retrieval efficiency and accuracy;

[0013] To sum up, the existing RAG technology still has many defects, which makes the retrieval efficiency and accuracy of the retrieval results of the RAG technology low. Based on this, the present invention has developed a method and device for text generation enhancement applied to retrieval enhancement generation, which can improve the retrieval efficiency and the accuracy of the retrieval results. Summary of the invention

[0014] In order to improve the retrieval efficiency of RAG technology and the accuracy of retrieval results, the present invention provides a method and device for text generation enhancement applied to retrieval enhancement generation, which aims to solve the core problems of real-time information update, adaptive adjustment of retrieval strategy, query processing integration, intelligent routing selection, etc. in RAG technology, and improve retrieval accuracy, efficiency and user interaction experience.

[0015] The text generation enhancement method used for retrieval enhancement generation relies on deep learning models and adaptive algorithms. Through the Transformer model and FAISS tool, text content and queries are converted into vectors and efficient indexes are constructed to achieve fast and accurate retrieval of large-scale databases. Natural language processing technology is used to analyze queries, dynamically adjust retrieval strategies and parameters, and develop detailed fine-tuning strategies for small sample scenarios. In addition, through the intelligent query routing system, the optimal data source or indexing strategy is selected according to the nature of the query and historical performance data. In query conversion and chat logic, the large language model is used as an inference engine to optimize query processing and chat context compression. Finally, the post-processor is used to re-arrange and filter the retrieval results, and high-quality responses are synthesized by combining chat logic processing and intelligent agent interaction.

[0016] In a first aspect, the present invention provides a method for text generation enhancement for retrieval enhancement generation, which adopts the following technical solution:

[0017] A method for text generation enhancement applied to retrieval enhancement generation comprises the following steps:

[0018] S1, query preprocessing and feature extraction;

[0019] Use the BERT model or Transformer model to convert the query and document content into query vectors and document content vectors respectively, and use the FAISS tool to build an efficient vector index to preprocess the user query Q and extract the query feature F;

[0020] Query feature extraction:

[0021] F(Q)={f 1 (Q),f 2 (Q),...,f n (Q)}; where f i (Q) represents the i-th feature of query Q;

[0022] S2, adaptive retrieval optimization fine-tuning;

[0023] Use natural language processing (NLP) to deeply analyze the complexity, domain characteristics and urgency of user queries, identify the domain and needs of the query through comprehensive semantic analysis, and perform semantic analysis and conversion of user queries, including rewriting queries and splitting queries into subqueries. b ;

[0024] Dynamically adjust search strategy parameters;

[0025] Adjust the balance between accuracy and speed when searching for query vectors by adjusting the nprobe parameter of FAISS, and select the appropriate hierarchical index level. Initially set a low nprobe value, and then gradually increase the nprobe value until the search accuracy reaches the expected level.

[0026] Assume that Q is the vector representation of the user query, D is the set of document content vector representations, f(Q,D) is a scoring function that represents the similarity between the query and the document; C is the context information of the query, and the dynamic parameter adjustment is represented by a function g(Q,C), and the output is the retrieval parameter set P. The retrieval process can be expressed by the following formula:

[0027] R = arg max D∈S(g(Q,C)) f(Q,D);

[0028] Among them, S(g(Q,C)) is the search strategy and index range determined based on the retrieval parameter set P;

[0029] S3, historical performance analysis and intelligent query routing decision;

[0030] By classifying and specifically searching external knowledge sources, we can learn more domain-specific knowledge, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly;

[0031] Based on the query features F(Q) and historical performance data H, evaluate the historical performance of each data source and indexing strategy, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query;

[0032] P(S|F(Q))=MLModel(F(Q));

[0033] Among them, MLModel represents the machine learning model used to predict the effectiveness of each strategy. Based on the effectiveness prediction P(S|F(Q)), the optimal data source and index strategy S* are selected;

[0034] Convert the query Q into a vector V(Q) and use the selected indexing strategy S* to wait for vector retrieval in the corresponding data source;

[0035] V(Q) = Embed(Q);

[0036] Among them, Embed represents the query embedding function;

[0037] S4, query transformation, context compression, vectorized retrieval;

[0038] Compress the chat context Ctx and use the advanced large language model to compress the chat context Ctx into key information Ctx core ;

[0039] Build a search index to store the vectorized content of documents and queries;

[0040] Subquery Q sub And the compressed chat context Ctx core Vectorization: Select the appropriate data source DS to perform vectorized retrieval. According to the transformed vector representation, quickly retrieve the most relevant information in the data source DS. The retrieval process can be expressed by the following formula:

[0041] Results = Search (V (Q sub ),V(Ctx core ),DS);

[0042] Among them, V(Q sub ) and V(Ctx core ) represent the vector representation of the subquery and the vector representation of the compressed context respectively, and the Search function represents the vectorized search operation performed according to the selected data source DS, and the output is the search result set Results;

[0043] S5, result rearrangement and filtering;

[0044] Using LlamaIndex's post-processor, we weighted each search result based on similarity scores, keywords, and metadata, and optimized the final search results by filtering and re-ranking;

[0045] Combine the optimized result set Filtered_Results with the chat context Ctx;

[0046] a. Context update: Based on Filtered_Results and the original chat context Ctx, update the chat context to form Updated_Ctx;

[0047] b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx;

[0048] S6, response synthesis;

[0049] Based on the optimized search results, the final response Response is synthesized by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

[0050] Preferably, the preprocessing of the user query Q includes denoising and standardization.

[0051] Preferably, the extracted query features F include the length of the query, the keyword density of the query and the semantic features of the query.

[0052] Preferably, the weighted formula in S5 is:

[0053] Similarity Rating:

[0054]

[0055] Among them, V(Q) represents the vector representation of the query, and V(R) represents the vector representation of the result. ;

[0056] Score(R)=w 1 Similarity(R,Q)+w 2 Complexity(R)+w 3 .

[0057] Relevance(R,Ctx)+w 4 ·KeywordDensity(R);

[0058] Among them, R represents a single retrieval result, Q is the user's query, Ctx represents the query context, and w1, w2, w3 and w4 are the weights of these factors respectively. According to the above scoring mechanism, the results with scores below the threshold are screened out.

[0059] In a second aspect, the present invention provides a device for text generation enhancement for retrieval enhancement generation, which adopts the following technical solution:

[0060] A device for text generation enhancement for retrieval enhancement generation, comprising the following modules:

[0061] Query preprocessing and feature extraction module, including:

[0062] A conversion module, used to convert the query and document content into a query vector and a document content vector respectively using a BERT model or a Transformer model;

[0063] Vector index building module, used to build efficient vector indexes using FAISS tools;

[0064] A preprocessing module, used for preprocessing the query vector;

[0065] A feature extraction module, used to extract query features F;

[0066] Adaptive retrieval optimization fine-tuning module, including:

[0067] Natural Language Processing (NLP) module, which is used to deeply analyze the complexity, domain characteristics and urgency of user queries, and identify the domain and needs to which the query belongs through comprehensive semantic analysis;

[0068] Parsing and transformation module, used to perform semantic parsing and transformation of user queries, including rewriting queries and splitting queries into subqueries Q sub ;

[0069] Dynamically adjust the retrieval strategy parameter module, which is used to adjust the accuracy and speed balance of query vector search by adjusting the nprobe parameter of FAISS, and select a suitable hierarchical index level. Initially set a low nprobe value, and then gradually increase the nprobe value until the search accuracy reaches the expected level;

[0070] Historical performance analysis and intelligent query routing decision module,

[0071] The learning module is used to learn more domain-specific knowledge by classifying and specifically searching external knowledge sources, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly;

[0072] The evaluation module is used to evaluate the historical performance of each data source and indexing strategy based on the query features F(Q) and historical performance data H, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query;

[0073] The vector conversion and retrieval module converts the query Q into a vector V(Q) and waits for vector retrieval in the corresponding data source using the selected index strategy S*;

[0074] Context compressor vectorized retrieval module, including:

[0075] The context compression module is used to compress the chat context Ctx and compress the chat context Ctx into key information Ctx using an advanced large language model. core ;

[0076] Search index building module, used to build search indexes to store vectorized content of documents and queries;

[0077] Vectorized AND retrieval module, used to convert subquery Q sub And the compressed chat context Ctx core Vectorization: Select the appropriate data source DS to perform vectorized retrieval, and quickly retrieve the most relevant information in the data source DS based on the converted vector representation;

[0078] The result re-ranking and filtering module is used to use the post-processor of LlamaIndex to weight each result of the search results based on similarity scores, keywords, and metadata, and optimize the final search results through filtering and re-ranking;

[0079] A combining module is used to combine the optimized result set Filtered_Results with the chat context Ctx;

[0080] a. Context update: Based on Filtered_Results and the original chat context Ctx, update the chat context to form Updated_Ctx;

[0081] b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx;

[0082] The response module is used to synthesize the final response Response based on the optimized search results by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

[0083] Preferably, the preprocessing module comprises:

[0084] A denoising module, used to denoise the query vector;

[0085] The normalization module is used to normalize the query vector.

[0086] Preferably, the feature extraction module includes:

[0087] Length feature extraction module, used to extract the length of query feature F

[0088] A keyword density extraction module, used to extract the keyword density of the query feature F;

[0089] The semantic feature extraction module is used to extract the semantic features of the query feature F.

[0090] In a third aspect, the present application provides an electronic device, which adopts the following technical solution:

[0091] An electronic device comprising:

[0092] One or more processors;

[0093] Memory;

[0094] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to: execute a method for text generation enhancement applied to retrieval enhanced generation as described in the first aspect above.

[0095] In a fourth aspect, the present invention provides a device for text generation enhancement for retrieval enhancement generation, which adopts the following technical solution:

[0096] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a method for text generation enhancement for retrieval enhancement generation as described in any one of the first aspects above.

[0097] In summary, the present invention includes the following beneficial technical effects:

[0098] 1. The adaptive retrieval optimization of the present invention improves the accuracy and efficiency of retrieval.

[0099] 2. The present invention enhances the coherence and memory capacity of the conversation context through processes such as context compression and combination, and provides a smoother interactive experience.

[0100] 3. The present invention improves the information update frequency and accuracy of the RAG system by searching the latest reliable knowledge sources, and improves the retrieval efficiency of the RAG technology and the accuracy of the retrieval results.

[0101] 4. The present invention replaces manual maintenance with automatic maintenance, reduces labor intensity, and reduces labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0102] Figure 1 It is a flowchart of a method for text generation enhancement applied to retrieval enhancement generation in an embodiment of the present invention. DETAILED DESCRIPTION

[0103] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0104] The embodiment of the invention discloses a method for text generation enhancement applied to retrieval enhancement generation.

[0105] Reference Figure 1 , the method comprises the following steps:

[0106] S1, query preprocessing and feature extraction;

[0107] Use the BERT model or Transformer model to convert the query and document content into query vectors and document content vectors respectively, and use the FAISS tool to build an efficient vector index to preprocess the user query Q and extract the query feature F;

[0108] In order to improve retrieval efficiency, especially when facing large-scale databases, a summary index is built to quickly filter out document blocks with higher relevance, and then a more in-depth search is performed on these document blocks.

[0109] The preprocessing of user query Q includes operations such as denoising and standardization.

[0110] The query feature extraction can be expressed as follows:

[0111] F(Q)={f 1 (Q),f 2 (Q),...,f n (Q)};

[0112] Among them, f i (Q) represents the i-th feature of query Q;

[0113] The extracted query features F include query length, query keyword density, and query semantic features, which provide necessary input information for subsequent adaptive retrieval strategies.

[0114] Finally, a large language model is used to semantically understand and automatically decompose the query, by automatically decomposing complex queries into more manageable sub-queries Qsub and generating backtracking hints to enrich the contextual information of the query.

[0115] S2, adaptive retrieval optimization fine-tuning;

[0116] Natural language processing (NLP) is used to deeply analyze the complexity, domain characteristics and urgency of user queries, and through comprehensive semantic analysis, the domain and needs to which the query belongs are identified, providing a basis for subsequent retrieval strategy adjustments. This process involves semantic parsing and transformation of user queries, including rewriting queries and splitting them into more manageable subqueries. sub .

[0117] Dynamically adjust search strategy parameters;

[0118] Based on the results of the query analysis, the retrieval strategy parameters are further adjusted dynamically. This includes adjusting the nprobe parameter of FAISS to adjust the balance between accuracy and speed when searching for query vectors, and selecting a suitable hierarchical index level. Initially, a low nprobe value is set to ensure the search speed, and then the nprobe value is gradually increased until the search accuracy reaches the expected level;

[0119] For scenarios with few samples, we develop refined fine-tuning strategies. Through transfer learning technology, we select pre-trained models that perform well on the source task to migrate the feature extractor, fine-tune the model, and enhance the performance of the model in specific fields.

[0120] Assume that Q is the vector representation of the user query, D is the set of document content vector representations, f(Q,D) is a scoring function that represents the similarity between the query and the document; C is the context information of the query, and the dynamic parameter adjustment is represented by a function g(Q,C), and the output is the retrieval parameter set P. The retrieval process can be expressed by the following formula:

[0121] R = arg max D∈S(g(Q,C)) f(Q,D);

[0122] Among them, S(g(Q,C)) is the search strategy and index range determined based on the retrieval parameter set P;

[0123] S3, historical performance analysis and intelligent query routing decision;

[0124] By implementing an intelligent query routing system that automatically selects the most appropriate data source or indexing strategy, developing advanced query routing mechanisms, and optimizing selections based on the nature of the query and historical performance data, we can improve retrieval efficiency and accuracy, ultimately providing users with higher quality responses.

[0125] By classifying and specifically searching external knowledge sources, we can learn more domain-specific knowledge, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly;

[0126] Based on the query features F(Q) and historical performance data H, evaluate the historical performance of each data source and indexing strategy, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query;

[0127] P(SF(Q))=MLModel(F(Q));

[0128] Among them, MLModel represents the machine learning model used to predict the effectiveness of each strategy. Based on the effectiveness prediction P(S|F(Q)), the optimal data source and index strategy S* are selected;

[0129] Convert the query Q into a vector V(Q) and use the selected indexing strategy S* to wait for vector retrieval in the corresponding data source;

[0130] V(Q) = Embed(Q);

[0131] Among them, Embed represents the query embedding function;

[0132] S4, query transformation, context compression, vectorized retrieval;

[0133] In query conversion and chat logic, the quality and efficiency of RAG interaction are further improved by innovatively using large language models as inference engines, taking advantage of automatic decomposition of query content, backtracking prompt technology, and compression technology of chat context.

[0134] In order to optimize the processing efficiency of the chat engine and enhance the accuracy of information, the chat context Ctx is first compressed and the chat context Ctx is compressed into key information Ctx using an advanced large language model. core ;

[0135] The above process involves extracting the most relevant contextual information to the current query so that subsequent query processing and information retrieval can be more focused and efficient.

[0136] Then, we build a search index to store the vectorized content of documents and queries. In order to adapt to data sets of different sizes and improve the search speed, we use a variety of vector indexing methods including faiss, nmslib and annoy. These methods use the approximate nearest neighbor algorithm to achieve fast and accurate search. At the same time, in order to efficiently manage large-scale document databases, we use a hierarchical indexing strategy. First, we quickly filter out document blocks with high relevance through summary indexes, and then conduct in-depth searches on these document blocks.

[0137] Subquery Q sub And the compressed chat context Ctx coreVectorization: Select the appropriate data source DS to perform vectorized retrieval. According to the transformed vector representation, quickly retrieve the most relevant information in the data source DS. The retrieval process can be expressed by the following formula:

[0138] Results = Search (V (Q sub ),V(Ctx core ),DS),

[0139] Among them, V(Q sub ) and V(Ctx core ) represent the vector representation of the subquery and the vector representation of the compressed context respectively, and the Search function represents the vectorized search operation performed according to the selected data source DS, and the output is the search result set Results;

[0140] S5, result rearrangement and filtering;

[0141] Using LlamaIndex's post-processor, we weighted each search result based on similarity scores, keywords, and metadata, and optimized the final search results by filtering and re-ranking;

[0142] The weighted processing process is:

[0143] Similarity Rating:

[0144]

[0145] Among them, V(Q) represents the vector representation of the query, and V(R) represents the vector representation of the result. ;

[0146] Score(R)=w 1 Similarity(R,Q)+w 2 Complexity(R)+w 3 .

[0147] Relevance(R,Ctx)+w 4 ·KeywordDensity(R);

[0148] Among them, R represents a single search result, Q is the user's query, Ctx represents the query context, and w1, w2, w3 and w4 are the weights of these factors. According to the above scoring mechanism, the results with scores below the threshold are filtered out to ensure that each item in the output result set Filtered_Results has high relevance and quality.

[0149] The optimized result set Filtered_Results is combined with the chat context Ctx to further process the user's follow-up questions and references to improve the coherence of the interaction and user satisfaction.

[0150] a. Context update: Based on Filtered_Results and the original chat context Ctx, the chat context is updated to form Updated_Ctx; this includes integrating new information points and adjusting the focus of the context to more accurately respond to subsequent user queries.

[0151] b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx, making the entire chat process more natural and smooth.

[0152] S6, response synthesis;

[0153] Based on the optimized search results, the final response Response is synthesized by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

[0154] The present application also discloses a device for text generation enhancement for retrieval enhancement generation, the device comprising the following modules:

[0155] Query preprocessing and feature extraction module, used for query preprocessing and feature extraction;

[0156] Adaptive retrieval optimization fine-tuning module, used for adaptive retrieval optimization fine-tuning;

[0157] Historical performance analysis and intelligent query routing decision module, used to analyze historical performance and make intelligent query routing decisions;

[0158] Context compressor vectorized retrieval module, used for compressed context and vectorized retrieval;

[0159] The result rearrangement and filtering module is used to rearrange and filter the results and combine the optimized result set Filtered_Results with the chat context Ctx;

[0160] Response module, used to respond to the final result.

[0161] Among them, the query preprocessing and feature extraction module includes:

[0162] A conversion module, used to convert the query and document content into a query vector and a document content vector respectively using a BERT model or a Transformer model;

[0163] Vector index building module, used to build efficient vector indexes using FAISS tools;

[0164] A preprocessing module, used for preprocessing the query vector;

[0165] The preprocessing modules include:

[0166] A denoising module, used to denoise the query vector;

[0167] The normalization module is used to normalize the query vector.

[0168] A feature extraction module, used to extract query features F;

[0169] The feature extraction module includes:

[0170] Length feature extraction module, used to extract the length of query feature F

[0171] A keyword density extraction module, used to extract the keyword density of the query feature F;

[0172] The semantic feature extraction module is used to extract the semantic features of the query feature F.

[0173] Among them, the adaptive retrieval optimization fine-tuning module includes:

[0174] Natural Language Processing (NLP) module, which is used to deeply analyze the complexity, domain characteristics and urgency of user queries, and identify the domain and needs to which the query belongs through comprehensive semantic analysis;

[0175] Parsing and transformation module, used to perform semantic parsing and transformation of user queries, including rewriting queries and splitting queries into subqueries Q sub ;

[0176] Dynamically adjust the retrieval strategy parameter module, which is used to adjust the accuracy and speed balance of query vector search by adjusting the nprobe parameter of FAISS, and select a suitable hierarchical index level. Initially set a low nprobe value, and then gradually increase the nprobe value until the search accuracy reaches the expected level;

[0177] Among them, the historical performance analysis and intelligent query routing decision module includes:

[0178] The learning module is used to learn more domain-specific knowledge by classifying and specifically searching external knowledge sources, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly;

[0179] The evaluation module is used to evaluate the historical performance of each data source and indexing strategy based on the query features F(Q) and historical performance data H, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query;

[0180] The vector conversion and retrieval module is used to convert the query Q into a vector V(Q) and wait for vector retrieval in the corresponding data source using the selected index strategy S*;

[0181] Among them, the context compressor vectorized retrieval module includes:

[0182] The context compression module is used to compress the chat context Ctx and compress the chat context Ctx into key information Ctx using an advanced large language model. core ;

[0183] Search index building module, used to build search indexes to store vectorized content of documents and queries;

[0184] Vectorized and retrieved modules, subquery Q sub And the compressed chat context Ctx core Vectorization: Select the appropriate data source DS to perform vectorized retrieval, and quickly retrieve the most relevant information in the data source DS based on the converted vector representation;

[0185] Among them, the result re-ranking and filtering module is specifically used to utilize the post-processor of LlamaIndex and weight each result of the search results based on similarity score, keywords, and metadata, and optimize the final search results through filtering and re-ranking;

[0186] The result rearrangement and filtering module also includes a combining module for combining the optimized result set Filtered_Results with the chat context Ctx;

[0187] a. Context update: Based on Filtered_Results and the original chat context Ctx, update the chat context to form Updated_Ctx;

[0188] b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx;

[0189] The response module is specifically used to synthesize the final response Response based on the optimized search results by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

[0190] An embodiment of the present invention further provides an electronic device, the electronic device comprising: a processor and a memory. The processor and the memory are connected, such as through a bus. Optionally, the electronic device may further include a transceiver. It should be noted that in actual applications, the transceiver is not limited to one, and the structure of the electronic device does not constitute a limitation on the embodiment of the present invention.

[0191] The processor may be a CPU central processing unit, a general processor, a DSP data signal processor, an ASIC application specific integrated circuit, an FPGA field programmable gate array or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0192] The bus may include a path to transmit information between the above components. The bus may be a PCI peripheral component interconnect standard bus or an EISA extended industry standard architecture bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc.

[0193] The memory can be a ROM read-only memory or other types of static storage devices that can store static information and instructions, a RAM random access memory or other types of dynamic storage devices that can store information and instructions, or an EEPROM electrically erasable programmable read-only memory, a CD-ROM read-only disc or other optical disc storage, an optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0194] The memory is used to store application code for executing the solution of the present invention, and the execution is controlled by the processor. The processor is used to execute the application code stored in the memory to implement the contents shown in the method for text generation enhancement for retrieval enhancement generation disclosed in the above embodiment.

[0195] The electronic devices include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and fixed terminals such as digital TVs, desktop computers, etc. It can also be a server, etc.

[0196] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer-readable storage medium is run on a computer, the computer can execute the corresponding content of a method for text generation enhancement for retrieval enhancement generation disclosed in the above embodiment.

[0197] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0198] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for text generation enhancement applied to retrieval enhancement generation, characterized in that: The following steps are involved: S1, query preprocessing and feature extraction; Use the BERT model or Transformer model to convert the query and document content into query vectors and document content vectors respectively, and use the FAISS tool to build an efficient vector index to preprocess the user query Q and extract the query feature F; Query feature extraction: ; Among them, f i (Q) represents the i-th feature of query Q; S2, adaptive retrieval optimization fine-tuning; Use natural language processing (NLP) to deeply analyze the complexity, domain characteristics and urgency of user queries, and identify the domain and needs of the query through comprehensive semantic analysis, and perform semantic analysis and conversion of user queries, including rewriting queries and splitting queries into subqueries. sub ; Dynamically adjust search strategy parameters; By adjusting the nprobe parameter of FAISS to adjust the balance between accuracy and speed when searching for query vectors, and selecting the appropriate hierarchical index level, initially set an nprobe value, and then gradually increase the nprobe value until the search accuracy meets the requirements; Assume that Q is the vector representation of the user query, D is the set of document content vector representations, f(Q,D) is a scoring function that represents the similarity between the query and the document; C is the context information of the query, and the dynamic parameter adjustment is represented by a function g(Q,C), and the output is the retrieval parameter set P. The retrieval process can be expressed by the following formula: ; Among them, S(g(Q,C)) is the search strategy and index range determined based on the retrieval parameter set P; S3, historical performance analysis and intelligent query routing decision; By classifying and specifically searching external knowledge sources, we can learn more domain-specific knowledge, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly; Based on the query features F(Q) and historical performance data H, evaluate the historical performance of each data source and indexing strategy, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query; ; Among them, MLModel represents the machine learning model used to predict the effectiveness of each strategy. Based on the effectiveness prediction P(S|F(Q)), the optimal data source and index strategy S* are selected; Convert the query Q into a vector V(Q) and use the selected indexing strategy S* to wait for vector retrieval in the corresponding data source; ; Among them, Embed represents the query embedding function; S4, query transformation, context compression, vectorized retrieval; Compress the chat context Ctx and use the advanced large language model to compress the chat context Ctx into key information Ctx core ; Build a search index to store the vectorized content of documents and queries; Subquery Q sub And the compressed chat context Ctx core Vectorization: Select the appropriate data source DS to perform vectorized retrieval. According to the transformed vector representation, quickly retrieve the most relevant information in the data source DS. The retrieval process can be expressed by the following formula: ; Among them, V(Q sub ) and V(Ctx core ) represent the vector representation of the subquery and the vector representation of the compressed context respectively, and the Search function represents the vectorized search operation performed according to the selected data source DS, and the output is the search result set Results; S5, result rearrangement and filtering; Using LlamaIndex's post-processor, we weighted each search result based on similarity scores, keywords, and metadata, and optimized the final search results by filtering and re-ranking; Combine the optimized result set Filtered_Results with the chat context Ctx; a. Context update: Based on Filtered_Results and the original chat context Ctx, update the chat context to form Updated_Ctx; b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx; S6, response synthesis; Based on the optimized search results, the final response Response is synthesized by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

2. The method for text generation enhancement applied to retrieval enhancement generation according to claim 1, characterized in that: The preprocessing of the user query Q includes denoising and standardization.

3. The method for text generation enhancement applied to retrieval enhancement generation according to claim 1, characterized in that: The extracted query features F include the query length, the query keyword density and the query semantic features.

4. The method for text generation enhancement applied to retrieval enhancement generation according to claim 1, characterized in that: The weighted formula in S5 is: ; ; Among them, R represents a single retrieval result, Q is the user's query, Ctx represents the query context, and w1, w2, w3 and w4 are the weights of these factors respectively. According to the scoring mechanism, the results with scores below the threshold are screened out.

5. A device for text generation enhancement for retrieval enhancement generation, characterized in that: Includes the following modules: Query preprocessing and feature extraction module, including: A conversion module, used to convert the query and document content into a query vector and a document content vector respectively using a BERT model or a Transformer model; Vector index building module, used to build efficient vector indexes using FAISS tools; A preprocessing module, used for preprocessing the query vector; A feature extraction module, used to extract query features F; Adaptive retrieval optimization fine-tuning module, including: Natural Language Processing (NLP) module, which is used to deeply analyze the complexity, domain characteristics and urgency of user queries, and identify the domain and needs to which the query belongs through comprehensive semantic analysis; Parsing and transformation module, used to perform semantic parsing and transformation of user queries, including rewriting queries and splitting queries into subqueries Q sub ; Dynamically adjust the retrieval strategy parameter module, which is used to adjust the accuracy and speed balance of query vector search by adjusting the nprobe parameter of FAISS, and select a suitable hierarchical index level. Initially set an nprobe value, and then gradually increase the nprobe value until the search accuracy meets the requirements; Historical performance analysis and intelligent query routing decision module, including: The learning module is used to learn more domain-specific knowledge by classifying and specifically searching external knowledge sources, monitor and evaluate knowledge sources in real time, integrate the latest reliable knowledge sources, generate a local knowledge source search library, record the addresses of reliable knowledge sources and update them regularly; The evaluation module is used to evaluate the historical performance of each data source and indexing strategy based on the query features F(Q) and historical performance data H, and use the machine learning model to predict the performance P(S|F(Q)) of each strategy for the current query; The vector conversion and retrieval module is used to convert the query Q into a vector V(Q) and wait for vector retrieval in the corresponding data source using the selected index strategy S*; Context compressor vectorized retrieval module, including: The context compression module is used to compress the chat context Ctx and compress the chat context Ctx into key information Ctx using an advanced large language model. core ; Search index building module, used to build search indexes to store vectorized content of documents and queries; Vectorized and retrieved modules, subquery Q sub And the compressed chat context Ctx core Vectorization: Select the appropriate data source DS to perform vectorized retrieval, and quickly retrieve the most relevant information in the data source DS based on the converted vector representation; The result re-ranking and filtering module is used to use the post-processor of LlamaIndex to weight each result of the search results based on similarity scores, keywords, and metadata, and optimize the final search results through filtering and re-ranking; A combining module is used to combine the optimized result set Filtered_Results with the chat context Ctx; a. Context update: Based on Filtered_Results and the original chat context Ctx, update the chat context to form Updated_Ctx; b. Intelligent agent interaction: Based on the context update, the intelligent agent processes and answers the user's follow-up questions or references according to Updated_Ctx; The response module is used to synthesize the final response Response based on the optimized search results by iteratively refining the answer, summarizing the retrieved context, or generating multiple answers based on different context blocks and then synthesizing the final answer.

6. The device for text generation enhancement for retrieval enhancement generation according to claim 5, characterized in that: The preprocessing module comprises: A denoising module, used to denoise the query vector; The normalization module is used to normalize the query vector.

7. The device for text generation enhancement for retrieval enhancement generation according to claim 5, characterized in that: The feature extraction module comprises: Length feature extraction module, used to extract the length of query feature F A keyword density extraction module, used to extract the keyword density of the query feature F; The semantic feature extraction module is used to extract the semantic features of the query feature F.

8. An electronic device, characterized in that: It includes: One or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to: execute a method for text generation enhancement applied to retrieval enhanced generation according to any one of claims 1 to 4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for text generation enhancement applied to retrieval enhancement generation as described in any one of claims 1 to 4 is implemented.