Document retrieval method, system and equipment based on retrieval enhancement generation and medium

By adopting a method based on search enhancement generation in document retrieval, the initial query is optimized and optimized query is generated, and the search inaccuracy problem caused by hallucination problems in document retrieval is solved, achieving higher search accuracy and accuracy.

CN120104743APending Publication Date: 2025-06-06ELECTRIC POWER RES INST OF STATE GRID ZHEJIANG ELECTRIC POWER COMAPNY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510177879.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-18
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

During document retrieval, it is difficult to generate accurate and specific information due to hallucinations when using large language models, resulting in low retrieval accuracy and recall rate.

Method used

Using a document search method based on search enhancement generation, we use a search enhancement generation model, which includes a searcher and a large language model, optimize the initial query, generate optimized queries, and re-retrieve to reduce hallucination phenomena.

Benefits of technology

By improving the quality of matching between queries and documents, it alleviates hallucinations, improves retrieval accuracy, and generates more specific and accurate queries and document sets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104743A_ABST
    Figure CN120104743A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of document retrieval, and particularly relates to a document retrieval method, system and equipment based on retrieval enhancement generation and a medium. Aiming at the defect that incorrect or misleading information is generated due to an illusion problem when a large language model is adopted in the existing document retrieval, the invention adopts the following technical scheme: the document retrieval method based on retrieval enhancement generation comprises the following steps of: setting an initial query for a specific database; the method comprises the following steps: constructing a retrieval enhancement generation model comprising a retriever and a large language model, retrieving documents in a database by adopting the retriever and an initial query, calculating a query-document alignment score and sorting, and obtaining a related document set according to a sorting result; inputting the initial query and the related document set into a large language model of a retrieval enhancement generation model, generating an optimized query, and performing retrieval again to obtain an optimized document set; and inputting the optimized document set and the optimized query into the large language model and outputting a final answer. According to the document retrieval method, the retrieval accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of document retrieval, and in particular relates to a document retrieval method, system, device and medium based on retrieval enhancement generation. Background Art

[0002] In the process of information retrieval, when the query entered by the user is short and contains vague or incomplete information, it is difficult for the system to accurately understand the user's intention, resulting in inaccurate retrieval results or the presence of a large number of irrelevant documents, which is usually manifested as low retrieval precision and recall rate (relevant documents retrieved by the system / total number of all relevant documents in the system).

[0003] In recent years, with the emergence of large language models, researchers have begun to explore the use of large language models to optimize document retrieval algorithms. These models are trained on large-scale corpora and can learn deeper language features, thereby improving the matching quality between queries and documents.

[0004] However, large language models inevitably have the problem of hallucination. In the context of large language models, hallucination is defined as information generated by the model that is inconsistent with the facts or meaningless. At present, the methods to reduce the hallucination of large models are mainly based on two principles: improving the capabilities of large models and providing large models with more knowledge about the real world through training samples or inductive biases. For example, the complexity of large models can be enhanced by increasing model parameters and the amount of training data, or retrieval-based techniques, prompting strategies, and new decoding methods can be used to reduce hallucination phenomena. However, these measures have their limitations. For example, when the large model cannot capture the real-world function, simply increasing parameters and data is ineffective.

[0005] Related article: Hallucination is Inevitable: An Innate Limitation of Large Language Models, Ziwei Xu, Sanjay Jain and Mohan Kankanhalli. Summary of the invention

[0006] The present invention aims at the problem that incorrect or misleading information is generated due to the hallucination problem when a large language model is used in document retrieval, and provides a document retrieval method based on retrieval enhancement generation, which generates specific and accurate queries by optimizing queries, alleviates the hallucination problem, and realizes retrieval enhancement generation in the document retrieval process. The present invention also provides a document retrieval system, a computer device, and a computer-readable storage medium based on retrieval enhancement generation.

[0007] To achieve the above object, the present invention adopts the following technical solution: a document retrieval method based on retrieval enhancement generation, the document retrieval method based on retrieval enhancement generation comprises:

[0008] Step S1, setting an initial query for a specific database;

[0009] Step S2: construct a retrieval enhancement generation model including a retriever and a large language model, use the retriever and the initial query to retrieve documents in the database, calculate the query-document alignment score and sort them, and obtain a relevant document set according to the sorting result;

[0010] Step S3: input the initial query and the relevant document set into the large language model of the retrieval enhancement generation model to generate an optimized query, and re-retrieve to obtain the optimized document set;

[0011] Step S4: input the optimized document set and the optimized query into the large language model and output the final answer.

[0012] The document retrieval method based on retrieval enhancement generation of the present invention improves the quality of query instructions through query-text alignment scores, optimizes initial queries through a retrieval enhancement generation model including a retriever and a large language model, generates optimized queries, and finally outputs answers that may include sentences and optimized document sets, thereby solving the hallucination problem of the large language model in the retrieval enhancement generation task and improving retrieval accuracy.

[0013] As an improvement, in step S2, multiple retrievers are constructed for retrieval, and the query-document alignment scores obtained by the various retrievers are calculated, including:

[0014] Build a BM25 retriever for sparse retrieval and calculate the query-document alignment score for sparse retrieval;

[0015] Build a dense retriever for dense retrieval and calculate the query-document alignment score for dense retrieval;

[0016] Construct BM25 and dense hybrid retrievers for the hybrid case and calculate the query-document alignment score for hybrid retrieval.

[0017] As an improvement, in step S2, the process of building a BM25 retriever for sparse retrieval and calculating the query-document alignment score for sparse retrieval includes:

[0018] All the words in a query Q are represented as {q 0 ,q 2 ,q 3 ,…,q n}, calculate each word q i The frequency of word occurrence in document D is called word frequency. The specific formula of word frequency is:

[0019]

[0020] Among them, d t refers to all words in document D, and T refers to the number of words in document D;

[0021] Calculate word q i The inverse document frequency of , the specific formula of inverse document frequency is expressed as:

[0022]

[0023] Where N is the total number of documents in the document collection, n(q i ) is a string containing the word q i The number of documents;

[0024] The query-document alignment score for sparse retrieval is calculated based on the term frequency and inverse document frequency. The specific formula is:

[0025]

[0026] Among them, L avg refers to the average length of the document, |D| is the length of document D, and k 1 and b are adjustable hyperparameters;

[0027] The process of building a dense retriever and computing the query-document alignment score for dense retrieval involves:

[0028] Use the bge-base-en-v1.5 model to query q i Encode with document D to get query q i The dense embedding vector of and the dense embedding vector E of document D D ;

[0029] Calculate the query-document alignment score for dense retrieval, the specific formula is:

[0030]

[0031] The process of building a hybrid retriever and calculating the query-document alignment score for hybrid retrieval includes:

[0032] Hybrid(q i ,D)=α*BM25(q i ,D)+Dense(q i ,D);

[0033] Among them, α is a hyperparameter that balances the BM25 score and the dense score.

[0034] As an improvement, in step S2, the obtained query-document alignment scores are weighted averaged to calculate the comprehensive query-document alignment score. The specific formula is:

[0035]

[0036] Among them, λ 1 , 2 , 3 are the weighting coefficients of each query-document alignment score;

[0037] In step S2, a top-k algorithm is used to select several documents with the highest comprehensive query-document alignment scores to obtain a set of relevant documents.

[0038] As an improvement, in step S3, the process of obtaining the optimized document set includes:

[0039] Step S31, generating an extended query by combining the initial query and the relevant document set;

[0040] Step S32: Optimize the extended query using the large language model to generate an optimized query;

[0041] Step S33: Re-search based on the optimized query to obtain an optimized document set.

[0042] As an improvement, in step S31, the process of generating an extended query includes:

[0043] Step S311, extracting keywords that are highly relevant to the initial query from the relevant document set;

[0044] Step S312: using a synonym dictionary and a natural language processing model to perform synonym expansion on the extracted keywords to generate synonyms or related words;

[0045] Step S313: construct an extended query statement by combining the extracted keywords and their synonyms or related words;

[0046] In step S32, optimizing the extended query using the search enhancement generation model includes:

[0047] Step S321, splicing the extended query and the related document set into a unified input sequence, and performing text preprocessing;

[0048] Step S322: using the multi-layer Transformer encoder in the retrieval enhancement generation model, the input expanded query and related document set are contextually understood, and the semantic association between the expanded query and related documents is captured through the self-attention mechanism;

[0049] Step S323: Based on the model's understanding of the query intent, automatically generate relevant supplementary words and phrases to enrich the query content;

[0050] Step S324: reconstructing the semantically expanded and grammatically optimized query fragments into a complete optimized query statement, including merging multiple clauses into a compound sentence, or splitting a complex sentence as needed, so as to improve the query comprehensibility and retrieval effect.

[0051] As an improvement, in step S4,

[0052] First, input the optimized query and the relevant document set into the large language model;

[0053] Then, based on the content of the relevant document set, a specific answer to the user query is generated;

[0054] Finally, the final answer result is generated by combining the contents of multiple documents.

[0055] A document retrieval system based on retrieval enhancement generation, the document retrieval system based on retrieval enhancement generation comprises:

[0056] An initial query setting module, used to set an initial query for a specific database;

[0057] The retriever module is used to retrieve documents in the database according to the initial query and the optimized query, calculate the query-document alignment score and sort them, and obtain the relevant document set and the optimized document set according to the sorting results;

[0058] A large language model module is used to generate an optimized query based on the input initial query and the related document set, and input the optimized query into the retriever module;

[0059] The answer output module is used to input the optimized document set and the optimized query into the large language model to output the final answer, which includes the sentence and the optimized document set.

[0060] The computer device includes a processor and a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by the processor, the document retrieval method based on retrieval enhancement generation is implemented.

[0061] A computer-readable storage medium stores a computer program thereon, and when the computer program is executed, the aforementioned document retrieval method based on retrieval enhancement generation is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 It is a flowchart of a document retrieval method based on retrieval enhancement generation according to an embodiment of the present invention.

[0063] Figure 2 It is a schematic diagram of a document retrieval system based on retrieval enhancement generation according to an embodiment of the present invention. DETAILED DESCRIPTION

[0064] The technical solutions of the embodiments of the present invention are explained and described below, but the following embodiments are only preferred embodiments of the present invention, not all. Based on the embodiments in the implementation mode, other embodiments obtained by those skilled in the art without creative work are all within the protection scope of the present invention.

[0065] See also Figure 1 and Figure 2 , the document retrieval method based on retrieval enhancement generation according to an embodiment of the present invention, the document retrieval method based on retrieval enhancement generation comprises:

[0066] Step S1, setting an initial query for a specific database;

[0067] Step S2: construct a retrieval enhancement generation model including a retriever and a large language model, use the retriever and the initial query to retrieve documents in the database, calculate the query-document alignment score and sort them, and obtain a relevant document set according to the sorting result;

[0068] Step S3: input the initial query and the relevant document set into the large language model of the retrieval enhancement generation model to generate an optimized query, and re-retrieve to obtain the optimized document set;

[0069] Step S4: input the optimized document set and the optimized query into the large language model and output a final answer, which includes the sentence and the optimized document set.

[0070] In this embodiment, in step S2, multiple search engines are constructed to perform search, and query-document alignment scores obtained by the search engines are calculated, including:

[0071] Build a BM25 retriever for sparse retrieval and calculate the query-document alignment score for sparse retrieval;

[0072] Build a dense retriever for dense retrieval and calculate the query-document alignment score for dense retrieval;

[0073] Construct BM25 and dense hybrid retrievers for the hybrid case and calculate the query-document alignment score for hybrid retrieval.

[0074] In this embodiment, in step S2, the process of constructing a BM25 searcher for sparse search and calculating the query-document alignment score for sparse search includes:

[0075] All the words in a query Q are represented as {q 0 ,q 2 ,q 3 ,…,q n}, calculate each word q i The frequency of word occurrence in document D is called word frequency. The specific formula of word frequency is:

[0076]

[0077] Among them, d t refers to all words in document D, and T refers to the number of words in document D;

[0078] Calculate word q i The inverse document frequency of , the specific formula of inverse document frequency is expressed as:

[0079]

[0080] Where N is the total number of documents in the document collection, n(q i ) is a string containing the word q i The number of documents;

[0081] The query-document alignment score for sparse retrieval is calculated based on the term frequency and inverse document frequency. The specific formula is:

[0082]

[0083] Among them, L avg refers to the average length of the document, |D| is the length of document D, and k 1 and b are adjustable hyperparameters;

[0084] The process of building a dense retriever and computing the query-document alignment score for dense retrieval involves:

[0085] Use the bge-base-en-v1.5 model to query q i Encode with document D to get query q i The dense embedding vector of and the dense embedding vector E of document D D ;

[0086] Calculate the query-document alignment score for dense retrieval, the specific formula is:

[0087]

[0088] The process of building a hybrid retriever and calculating the query-document alignment score for hybrid retrieval includes:

[0089] Hybrid(q i ,D)=α*BM25(q i ,D)+Dense(q i ,D);

[0090] Among them, α is a hyperparameter that balances the BM25 score and the dense score.

[0091] In this embodiment, in step S2, the obtained query-document alignment scores are weighted averaged to calculate the comprehensive query-document alignment score, and the specific formula is:

[0092]

[0093] Among them, λ 1 , 2 , 3 are the weighting coefficients of each query-document alignment score;

[0094] In step S2, a top-k algorithm is used to select several documents with the highest comprehensive query-document alignment scores to obtain a set of relevant documents.

[0095] In this embodiment, in step S3, the process of obtaining the optimized document set includes:

[0096] Step S31, generating an extended query by combining the initial query and the relevant document set;

[0097] Step S32: Optimize the extended query using the large language model to generate an optimized query;

[0098] Step S33: Re-search based on the optimized query to obtain an optimized document set. The specific search process is the same as step S2, except that the input query is different.

[0099] In this embodiment, in step S31, the process of generating an extended query includes:

[0100] Step S311, extracting keywords that are highly relevant to the initial query from the relevant document set;

[0101] Step S312: using a synonym dictionary and a natural language processing model to perform synonym expansion on the extracted keywords to generate synonyms or related words;

[0102] Step S313: construct an extended query statement by combining the extracted keywords and their synonyms or related words;

[0103] In step S32, optimizing the extended query using the search enhancement generation model includes:

[0104] Step S321, splicing the extended query and the related document set into a unified input sequence, and performing text preprocessing;

[0105] Step S322: using the multi-layer Transformer encoder in the retrieval enhancement generation model, the input expanded query and related document set are contextually understood, and the semantic association between the expanded query and related documents is captured through the self-attention mechanism;

[0106] Step S323: Based on the model's understanding of the query intent, automatically generate relevant supplementary words and phrases to enrich the query content;

[0107] Step S324: reconstructing the semantically expanded and grammatically optimized query fragments into a complete optimized query statement, including merging multiple clauses into a compound sentence, or splitting a complex sentence as needed, so as to improve the query comprehensibility and retrieval effect.

[0108] In this embodiment, in step S4,

[0109] First, input the optimized query and the relevant document set into the large language model;

[0110] Then, based on the content of the relevant document set, a specific answer to the user query is generated;

[0111] Finally, the final answer result is generated by combining the contents of multiple documents.

[0112] The document retrieval method based on retrieval enhancement generation in the embodiment of the present invention improves the quality of query instructions through the alignment score of the query and the text, optimizes the initial query through the retrieval enhancement generation model, and inputs the initial query, the relevant document set and the optimized query statement into the large language model to generate a new query statement, thereby solving the hallucination problem of the large language model in the retrieval enhancement generation task and improving the retrieval accuracy; the final answer includes the statement and the document, thereby helping the questioner to quickly obtain the answer and have a basis to follow.

[0113] Application Examples

[0114] The following is an explanation of the specific query optimization process.

[0115] Example 1:

[0116] Suppose the initial query statement is "The effectiveness of COVID-19vaccines" and searches in the Trec-Covid dataset.

[0117] Using the traditional BM25 score search, we get:

[0118]

[0119] The document “Development and challenges of RNA-based vaccines” is not completely relevant to the core requirement of the query “effectiveness of COVID-19 vaccines”, and the resulting accuracy is low.

[0120] Based on the same initial query statement, the retrieval method based on RAG (Retrieval-augmented Generation) in the embodiment of the present invention combines the BM25 score and the dense score to obtain the following retrieval results:

[0121] document score 不同人群组中COVID-19疫苗的效力 0.92 针对病毒变体的疫苗保护作用 0.85 接种疫苗后免疫反应的长期评估 0.89 COVID-19疫苗的安全性和效力分析 0.85 全球疫苗战略与COVID-19防控 0.83

[0122] The top-k algorithm is used to select several documents with the highest comprehensive query-document alignment scores (Top-3 documents), and the relevant document set is obtained as follows:

[0123]

[0124]

[0125] The initial query is optimized using the Retrieval Augmentation Generation model (RAG) to obtain an optimized new query:

[0126]

[0127] Re-retrieve the documents using the optimized query and obtain the following top-3 highly relevant documents:

[0128]

[0129] Example 2:

[0130] Initial query: "COVID-19 vaccine efficacy in elderly populations"

[0131] Objective: To search for literature related to the effectiveness of COVID-19 vaccines in older adults, with a particular focus on immune responses, differences in vaccine effectiveness, and possible need for booster shots.

[0132] Use the retrieval model to retrieve documents and calculate the alignment score between the query and the document. Sort by the score and get the relevant document set:

[0133]

[0134] The initial query ("COVID-19 vaccine efficacy in elderly populations") and the relevant document set are input into the Retrieval Augmentation Generation (RAG) model. The model will analyze the key information in the documents and generate optimized queries based on the details in the documents.

[0135] The resulting optimized query is: "What is the long-term efficacy of COVID-19 vaccines in elderly individuals, considering immune system decline, and how do booster doses affect vaccine performance in this group?"

[0136] Re-execute document retrieval based on the optimized query. Use the optimized query to search in the relevant database to obtain a new document set. The new search results will be more accurate and can return documents that highly match the optimized query. The following is the new relevant document set (optimized document set) after re-retrieval:

[0137]

[0138] By combining the refined query with the newly retrieved relevant documents, we can generate the final answer:

[0139]

[0140] In addition, the method of the embodiment of the present invention was also used to train and test three retrieval datasets from BEIR: SciFact, Trec-Covid and FiQA, on scientific fact-checking tasks, biomedical information retrieval tasks, and question-answering tasks in the financial field, respectively.

[0141] GPT-3.5Turbo is used as the Large Language Model (LLM) optimizer. The temperature parameter is set to 1.0. The maximum number of optimization iterations is set to i=50. N=5, K=3, R 0 =3, R i = 1. Hyperparameter k 1 =1.2, b=0.75, α=0.1.

[0142] Normalized discounted cumulative gain (nDCG) is used as the evaluation indicator. The overall calculation process of nDCG is as follows: the model sorts the search results according to the similarity between the search and the search results, and returns the k most similar results as the search results. Keep the recommended order of the model, annotate each search with its score in the original data set, and calculate DCG. The formula is:

[0143]

[0144] Among them, rel i is the similarity score;

[0145] Then rearrange the marked scores from large to small and calculate DCG again. The DCG calculated this time is iDCG. Dividing the two is nDCG, which is expressed as:

[0146]

[0147] The method of the embodiment of the present invention is compared with the most advanced retrieval algorithm currently available. The document retrieval algorithm based on retrieval enhancement generation proposed in the embodiment of the present invention has achieved excellent experimental results. The following table shows the performance of various document retrieval models on the SciFact, Trec-Covid, and FiQA datasets. The method of the embodiment of the present invention exhibits high performance. The best result of 75.4 points was obtained in the SciFact dataset using BM 25 ((Best Matching 25)), and the performance was also excellent in the Trec-Covid dataset. The best result of 79.2 was obtained by mixing BM25 with dense scoring.

[0148]

[0149] The embodiment of the present invention also provides a document retrieval system based on retrieval enhancement generation, and the document retrieval system based on retrieval enhancement generation includes:

[0150] An initial query setting module, used to set an initial query for a specific database;

[0151] The retriever module is used to retrieve documents in the database according to the initial query and the optimized query, calculate the query-document alignment score and sort them, and obtain the relevant document set and the optimized document set according to the sorting results;

[0152] A large language model module is used to generate an optimized query based on the input initial query and the related document set, and input the optimized query into the retriever module;

[0153] The answer output module is used to input the optimized document set and the optimized query into the large language model to output the final answer, which includes the sentence and the optimized document set.

[0154] The embodiment of the present invention also provides a computer device, including a processor and a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by the processor, the document retrieval method based on retrieval enhancement generation is implemented.

[0155] The embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the aforementioned document retrieval method based on retrieval enhancement generation is implemented.

[0156] The above is only a specific implementation of the invention, but the protection scope of the invention is not limited thereto. Those skilled in the art should understand that the invention includes but is not limited to the contents described in the above specific implementation. Any modification that does not deviate from the functional and structural principles of the invention will be included in the scope of the claims.

Claims

1. A document retrieval method based on retrieval enhancement generation, characterized in that: The document retrieval method based on retrieval enhancement generation includes: Step S1, setting an initial query for a specific database; Step S2: construct a retrieval enhancement generation model including a retriever and a large language model, use the retriever and the initial query to retrieve documents in the database, calculate the query-document alignment score and sort them, and obtain a relevant document set according to the sorting result; Step S3: input the initial query and the relevant document set into the large language model of the retrieval enhancement generation model to generate an optimized query, and re-retrieve to obtain the optimized document set; Step S4: input the optimized document set and the optimized query into the large language model and output the final answer.

2. The document retrieval method based on retrieval enhancement generation according to claim 1, characterized in that: In step S2, multiple search engines are constructed to perform search, and the query-document alignment scores obtained by the various search engines are calculated, including: Build a BM25 retriever for sparse retrieval and calculate the query-document alignment score for sparse retrieval; Build a dense retriever for dense retrieval and calculate the query-document alignment score for dense retrieval; Construct BM25 and dense hybrid retrievers for the hybrid case and calculate the query-document alignment score for hybrid retrieval.

3. The document retrieval method based on retrieval enhancement generation according to claim 2, characterized in that: In step S2, the process of building a BM25 retriever for sparse retrieval and calculating the query-document alignment score for sparse retrieval includes: All the words in a query Q are represented as {q0,q2,q3,…,q n }, calculate each word q i The frequency of word occurrence in document D is called word frequency. The specific formula of word frequency is: Among them, d t refers to all words in document D, and T refers to the number of words in document D; Calculate word q i The inverse document frequency of , the specific formula of inverse document frequency is expressed as: Where N is the total number of documents in the document collection, n(q i ) is a string containing the word q i The number of documents; The query-document alignment score for sparse retrieval is calculated based on the term frequency and inverse document frequency. The specific formula is: Among them, L avg refers to the average length of the document, |D| is the length of document D, k1 and b are adjustable hyperparameters; The process of building a dense retriever and computing the query-document alignment score for dense retrieval involves: Use the bge-base-en-v1.5 model to query q i Encode with document D to get query q i The dense embedding vector of and the dense embedding vector E of document D D ; Calculate the query-document alignment score for dense retrieval, the specific formula is: The process of building a hybrid retriever and calculating the query-document alignment score for hybrid retrieval includes: Hybrid(q i ,D)=α*BM25(q i ,D)+Dense(q i ,D); Among them, α is a hyperparameter that balances the BM25 score and the dense score.

4. The document retrieval method based on retrieval enhancement generation according to claim 3, characterized in that: In step S2, the obtained query-document alignment scores are weighted averaged to calculate the comprehensive query-document alignment score. The specific formula is: Among them, λ1, λ2, and λ3 are the weighting coefficients of each query-document alignment score; In step S2, a top-k algorithm is used to select several documents with the highest comprehensive query-document alignment scores to obtain a set of relevant documents.

5. The document retrieval method based on retrieval enhancement generation according to claim 1, characterized in that: In step S3, the process of obtaining the optimized document set includes: Step S31, generating an extended query by combining the initial query and the relevant document set; Step S32: Optimize the extended query using the large language model to generate an optimized query; Step S33: Re-search based on the optimized query to obtain an optimized document set.

6. The document retrieval method based on retrieval enhancement generation according to claim 5, characterized in that: In step S31, the process of generating an extended query includes: Step S311, extracting keywords that are highly relevant to the initial query from the relevant document set; Step S312: using a synonym dictionary and a natural language processing model to perform synonym expansion on the extracted keywords to generate synonyms or related words; Step S313: construct an extended query statement by combining the extracted keywords and their synonyms or related words; In step S32, the extended query is optimized using the large language model, and the generated optimized query includes: Step S321, splicing the extended query and the related document set into a unified input sequence, and performing text preprocessing; Step S322: using the multi-layer Transformer encoder in the retrieval enhancement generation model, the input expanded query and related document set are contextually understood, and the semantic association between the expanded query and related documents is captured through the self-attention mechanism; Step S323: Based on the model's understanding of the query intent, automatically generate relevant supplementary words and phrases to enrich the query content; Step S324: reconstructing the semantically expanded and grammatically optimized query fragments into a complete optimized query statement, including merging multiple clauses into a compound sentence, or splitting a complex sentence as needed, so as to improve the query comprehensibility and retrieval effect.

7. The document retrieval method based on retrieval enhancement generation according to claim 1, characterized in that: In step S4, First, input the optimized query and the relevant document set into the large language model; Then, based on the content of the relevant document set, a specific answer to the user query is generated; Finally, the final answer result is generated by combining the contents of multiple documents. The final answer includes sentences and optimized document sets.

8. A document retrieval system based on retrieval enhancement generation, characterized in that: The document retrieval system based on retrieval enhancement generation includes: An initial query setting module, used to set an initial query for a specific database; The retriever module is used to retrieve documents in the database according to the initial query and the optimized query, calculate the query-document alignment score and sort them, and obtain the relevant document set and the optimized document set according to the sorting results; A large language model module is used to generate an optimized query based on the input initial query and the related document set, and input the optimized query into the retriever module; The answer output module is used to input the optimized document set and the optimized query into the large language model to output the final answer, which includes the sentence and the optimized document set.

9. A computer device comprising a processor and a storage medium, wherein the storage medium stores a computer program, characterized in that: When the computer program is executed by a processor, the document retrieval method based on retrieval enhancement generation described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the document retrieval method based on retrieval enhancement generation as described in any one of claims 1 to 7 is implemented.