Bidirectional information retrieval enhancement generation method for large language model

By using a bidirectional semantic-aware retrieval enhancement generation method, the problems of noisy document mixing and missing key evidence caused by unidirectional similarity retrieval in the RAG method are solved. This method improves the accuracy and relevance of large language models in knowledge-intensive tasks and is applicable to scenarios such as open-domain question answering, multi-hop question answering, and fact-checking.

CN121979997APending Publication Date: 2026-05-05中华人民共和国大连海关

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
中华人民共和国大连海关
Filing Date
2026-02-10
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing RAG methods suffer from problems such as the inclusion of noisy documents and the lack of key evidence due to one-way similarity retrieval during the retrieval process. Furthermore, they cannot fully utilize the semantic similarity between the query and the document, making it difficult to meet the high requirements of complex tasks such as multi-hop reasoning, numerical facts, and fine-grained entities.

Method used

A bidirectional semantic-aware retrieval enhancement generation method is adopted. By constructing a two-level training objective of differential matching + reflection matching, the bidirectional correlation probability between the query and the document is explicitly modeled, and the aggregation is performed in a Bayesian fusion manner during the inference stage to achieve noise suppression and key information completion.

Benefits of technology

It significantly improves the question-answering accuracy and context relevance of large language models in knowledge-intensive tasks, while balancing low-cost deployment and high transferability, and enhances the generation credibility and factual consistency of LLM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121979997A_ABST
    Figure CN121979997A_ABST
Patent Text Reader

Abstract

The invention discloses a bidirectional information retrieval enhancement generation method for a large language model, and belongs to the technical field of artificial intelligence. In order to overcome the defects that noise is introduced and key evidences are omitted due to the fact that traditional RAG only executes'query-document 'one-way retrieval, a two-way semantic perception retrieval enhancement generation model and a two-stage training framework are constructed, wherein in the first stage, the positive / negative example distance is increased in an embedded space in a contrast learning self-supervision mode; in the second stage, fine-grained correlation discrimination is carried out on query-document bidirectional sentences through supervised dichotomy, and probabilistic correlation scores are output; in the reasoning stage, the bidirectional probabilities are fused according to Bayesian to obtain final relevancy, document reordering is carried out, and plug and play can be achieved without fine adjustment of LLM in the whole process. According to the method, the accuracy and consistency of single-hop and multi-hop questions and answers and fact checking tasks are remarkably improved, and the method has the advantages of light weight and low deployment cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, and in particular relates to a retrieval enhancement generation method based on a bidirectional semantic matching mechanism, which is used to improve the accuracy and context relevance of large language models in knowledge-intensive tasks. Background Technology

[0002] Large Language Models (LLMs) have demonstrated powerful capabilities in open-domain question answering, dialogue, and content creation. However, their knowledge is entirely embedded in the parameters, resulting in high update costs, poor timeliness, and a tendency to output inaccurate information due to "illusions." Retrieval-Enhanced Generation (RAG), through a two-level paradigm of "retrieve first, then generate," injects real-time external documents into the context, enabling LLMs to acquire the latest knowledge without incremental training. This has become the mainstream technical approach for improving credibility. Compared to further expanding the parameter scale, RAG achieves "instant learning" with minimal computational power, offering significant advantages in professional knowledge service fields such as healthcare, finance, and law.

[0003] Most existing RAG methods follow the classic information retrieval chain: first, candidate segments are initially screened using a sparse (BM25) or dense vector (DPR) model; then, the top-K segments are ranked by single-point similarity; finally, documents are appended to the end of the prompt words for LLM reading. Recent improvements have focused on training better embedding models, introducing lightweight re-ranking machines, or using summary compression to reduce length, but the core remains "one-way" retrieval—only calculating the relevance score for "query → document," without verifying whether "document → query" is also true. This results in a large number of seemingly relevant but actually irrelevant noise segments being included in the context. Furthermore, existing technologies treat retrieval and generation as independent black boxes, failing to utilize the deep semantic capabilities of LLM for contextualized secondary verification of candidate segments. This makes it difficult to meet the higher requirements of "complete, mutually exclusive, and traceable" evidence for complex tasks such as multi-hop reasoning, numerical facts, and fine-grained entities. Therefore, how to fully utilize the semantic similarity between queries and documents for retrieval has received increasing attention. Currently, the following methods are used to attempt to solve this problem:

[0004] (a) Keyword-based retrieval model

[0005] For text data, this can be represented by an inverted index format. An inverted index is a data structure that maps document content to keywords. It contains only the keyword, the document ID of the occurrence of that keyword, the term frequency, and a list of positions, yet it can represent the complete semantics of whether any piece of text contains a certain keyword and in which documents and where that keyword appears. We can retrieve all relevant documents from massive amounts of text and provide a relevance ranking by following the process of querying keywords → merging inverted lists → sorting by weight. However, this method has some problems: First, keywords cannot fully capture relevance information. For example, the same concept may have multiple expressions or synonyms / near-synonyms. Traditional inverted indexes can only precisely match literal forms and cannot identify semantic equivalence, causing the model to fail to fully utilize similarity information and affecting the final performance. Second, keyword matching is easily affected by word order, grammatical variations, and noise. For example, "apple" may refer to fruit or Apple Inc., lacking contextual semantic judgment, leading to false positives or false negatives. Furthermore, inverted indexes have weak support for long-tail queries or fuzzy queries. When user input is not standardized or slightly off, the system is unlikely to return valid results, further limiting the robustness of the retrieval.

[0006] (ii) Vector-based retrieval model

[0007] Another effective way to depict similarity information is to use a vector space model to map text (words, sentences, or entire documents) into dense, high-dimensional vectors. This makes semantically similar content closer in the vector space, allowing the correlation between texts to be directly measured through vector similarity calculations (such as cosine similarity and dot product). However, a key problem with vector space models is the semantic gap: word frequency-based vector representations cannot capture synonyms, contextual semantics, or polysemy (e.g., does "apple" refer to a fruit or a company), leading to semantically similar but literally different texts being misclassified as unrelated.

[0008] (III) Language Model-Based Retrieval Model

[0009] In addition, another effective way to depict similarity information is to use a probabilistic language model, treating queries and documents as sequences of random variables respectively, and using the probability of generating a document from a query as a relevance score; the higher the score, the more "likely" the document is to answer the user's query, thus transforming the ranking problem into a probability estimation problem. Summary of the Invention

[0010] To address the issues of noisy documents and missing key evidence caused by unidirectional similarity retrieval in traditional RAG frameworks, this invention proposes a bidirectional information retrieval enhancement generation method for large-scale language models, specifically a bidirectional semantic-aware retrieval enhancement generation framework. By constructing a two-level training objective of "differential matching + reflection matching," the bidirectional relevance probability between queries and documents is explicitly modeled. During the inference phase, bidirectional scores are aggregated using Bayesian fusion to achieve noise suppression and key information completion. The entire module is pluggably embedded into existing RAG systems, significantly improving question-answering accuracy and factual consistency without fine-tuning the LLM, while also achieving low-cost deployment and high transferability.

[0011] To achieve the above objectives, the present invention adopts the following technical solution:

[0012] A bidirectional information retrieval enhancement generation method for large language models includes:

[0013] The first step is to construct a bidirectional semantic-aware retrieval enhancement generative model;

[0014] The bidirectional semantic-aware retrieval enhancement generative model is based on the existing RAG system and is used to replace the existing retrieval machine, including:

[0015] The encoder uses a pre-trained language model as the encoder to generate bidirectional concatenation sequences with the query-first and document-first orders based on query-document pairs, and obtain the corresponding hidden states.

[0016] The bidirectional probability fusion module is used to map the hidden state to the corresponding relevant probability through the classification head, and to calculate the joint probability using the Bayesian fusion formula.

[0017] The second step is to construct samples;

[0018] For query Corresponding candidate documents { The relevance is ranked, and positive and negative examples are sampled based on the relevance scores. False positive examples are randomly selected from each group. and pseudo-negative examples And label them with pseudo-labels to form a set of pseudo-positive examples. With the set of pseudo-negative examples The triple is composed of the query, the pseudo-positive example, and the pseudo-negative example. , , ), as input samples.

[0019] Step 3: Perform self-supervised training based on semantic comparison;

[0020] The input samples are fed into a bidirectional semantic-aware retrieval-enhanced generative model, utilizing an encoder. Obtain the hidden vectors for the query, pseudo-positive examples, and pseudo-negative examples respectively:

[0021] (1)

[0022] In the formula, , , These represent the hidden vectors for the query, pseudo-positive example, and pseudo-negative example, respectively.

[0023] A contrastive loss is performed within the embedding space to drive the query vector closer to spurious positives and further away from spurious negatives. The contrastive loss function is as follows:

[0024] (2)

[0025] in, Preset margins This represents the hinge function. This is the set of triples in the current batch. Minimize... The encoder parameters are updated to establish a low-noise semantic space with preliminary discriminative capabilities.

[0026] Step 4: Perform bidirectional probability matching training;

[0027] Based on the low-noise semantic space, and according to the pseudo-labels annotated in the second step, for each query... Corresponding document Assigning true labels In this context, 1 represents relevant and 0 represents irrelevant, constituting the basis for supervision. , forming a set of supervisory sentences The supervisory clauses are concatenated into a bidirectional concatenation sequence, arranged in two directions: query-first and document-first. ① , ② The bidirectional concatenated sequences are fed independently into the encoder trained in the previous step to obtain the [CLS] hidden states. and The splicing sequences in both directions share the same encoder to ensure consistent parameters.

[0028] Hidden state for each direction and Apply the same classification head ,in for function, Given trainable weights, output the corresponding relevant probabilities: , .

[0029] The training objective is to minimize the binary cross-entropy loss, where the loss function is as follows:

[0030] (3)

[0031] In the formula Take respectively and The calculated losses in the two directions are summed and averaged to obtain the binary cross-entropy loss, which is then fed back to jointly update the encoder parameters. The bidirectional semantic-aware retrieval enhancement generative model was obtained after training.

[0032] Through this stage of training, the bidirectional semantic perception retrieval enhancement generative model acquires bidirectional discrimination capability, providing fusionable probabilistic relevance for subsequent reasoning stages, and achieving noise suppression and preservation of key evidence.

[0033] Step 5: Re-ranking retrieval based on bidirectional probability fusion;

[0034] Receive new queries First, a vector search engine is used to quickly retrieve data from the full-text database. Candidate documents This forms an initial candidate set, reducing the scale of subsequent precise calculations. For each candidate document... These are used to form query-document pairs, which are then concatenated into bidirectional sequences in two directions: query-first and document-first. These sequences are then fed independently into the encoder to obtain the [CLS] hidden states.

[0035] (5)

[0036] (6)

[0037] Classification head These are mapped to the relevant probabilities in the two directions respectively:

[0038] (7)

[0039] (8)

[0040] Treating the two probabilities as independent evidence, the joint probability of "at least one side being relevant" is calculated using the Bayesian fusion formula. The final relevant score is obtained:

[0041] (9)

[0042] according to Reorder candidate documents in descending order and take the first few. The documents form a refined evidence set, which is then fed into a large language model to generate the answer. The parameters of the large language model are frozen during answer generation, requiring no fine-tuning. This bidirectional probabilistic fusion method preserves high-confidence one-way hits while suppressing one-way false positives, making the ranking results robust.

[0043] Compared with the prior art, the present invention has the following advantages:

[0044] This invention employs deep learning to establish a bidirectional semantic-aware retrieval enhancement generative model. Using open-domain question answering, multi-hop question answering, and fact-checking corpora from the KILT benchmark as raw data, the model further constructs "query-positive example-negative example" triples and "query ↔ document" bidirectional sentence pairs after rule cleaning, deduplication, and paragraph segmentation, serving as subsequent training inputs. By fusing contrastive learning and supervised binary classification, the model simultaneously extracts bidirectional semantic matching features from query to document and from document to query, significantly suppressing noise from unidirectional similarity, achieving refined relevance estimation, and using it for retrieval re-ranking, significantly improving the quality and consistency of contextual evidence. Furthermore, this invention's model is lightweight and pluggable, directly replacing existing retrieval systems without fine-tuning the LLM, resulting in low deployment costs. Simultaneously, this invention achieves industry-leading results in single-hop, multi-hop question answering, and fact-checking tasks, improving the factual accuracy and generation credibility of the LLM. Attached Figure Description

[0045] Figure 1 This is a flowchart illustrating the enhanced retrieval process based on a large language model, according to the present invention.

[0046] Figure 2 This is a flowchart illustrating the training process of bidirectional retrieval enhancement based on a large language model according to the present invention.

[0047] Figure 3 This is a structural block diagram of the RAG system based on joint retrieval optimization according to the present invention. Detailed Implementation

[0048] The technical solution of the present invention will be further described below with reference to specific embodiments and accompanying drawings, but the present invention is not limited to specific embodiments.

[0049] Example: Application of a retrieval enhancement generation method based on bidirectional semantic awareness in open-domain question answering tasks

[0050] This embodiment uses the Natural Questions (NQ) open-domain question answering dataset from the KILT benchmark as the training and testing source to construct the original dataset. The method of the present invention is further explained with reference to the accompanying drawings.

[0051] This embodiment provides a bidirectional information retrieval enhancement generation method for large-scale language models, such as... Figure 1-3As shown, it includes the following steps:

[0052] S1. Construct a bidirectional semantic-aware retrieval enhanced generative model;

[0053] The bidirectional semantic-aware retrieval enhancement generative model is based on the existing RAG system and is used to replace the existing retrieval machine, including:

[0054] The encoder uses a pre-trained language model as the encoder to generate bidirectional concatenation sequences with the query-first and document-first orders based on query-document pairs, and obtain the corresponding hidden states.

[0055] The bidirectional probability fusion module is used to map the hidden state to the corresponding correlation probability through the classification head, and to calculate the joint probability using the Bayesian fusion formula; wherein, the classification head is a single hidden layer multilayer perceptron, and the correlation probability is output using the Sigmoid function.

[0056] S2. Construct samples;

[0057] The raw data in JSON format from the original dataset is processed through the following steps:

[0058] S201. Remove HTML tags, non-English characters, and short phrases with a length of less than 20 characters;

[0059] S202. Deduplication: Hash the paragraph text using SHA-256 and discard duplicate samples;

[0060] S203. Paragraph segmentation: Using natural periods as boundaries, Wikipedia paragraphs with a maximum length of 512 tokens are segmented into multiple segments, while retaining the title and URL as metadata;

[0061] S204. Pseudo-tag construction: Using BM25 for each query The top 100 candidate documents are recalled, and they are sorted from high to low relevance scores. The top 30% are then used as false positives. This forms a set of pseudo-positive examples, D+; the last 30% are taken as pseudo-negative examples. A set of pseudo-negative examples, D-, is formed, and pseudo-positive and pseudo-negative examples are labeled with pseudo-labels, thereby completing the self-labeling step without manual labeling to construct the pseudo-labels required for training; specifically in this embodiment, approximately 1.2 M triples are obtained ( , , ) as input samples.

[0062] S3. Perform self-supervised training based on semantic comparison;

[0063] The input samples are fed into the encoder of the bidirectional semantic-aware retrieval enhanced generative model. Based on formula (1), the hidden vectors of the query, pseudo-positive example, and pseudo-negative example are obtained respectively. , , .

[0064] Construct a comparative loss function as shown in formula (2). To minimize To achieve the training objective, the encoder parameters are updated, and a low-noise semantic space with preliminary discriminative capabilities is established, providing low-noise initial features for the subsequent fine-matching stage.

[0065] Specifically, in this embodiment, hardware is used: CUDA ;software: , .

[0066] Select The pre-trained model acts as an encoder, initializing the dimensions. Batch processing: Single card Gradient accumulation steps Optimizer: , Linear preheating Steps, total training Formula (2) Comparative loss function Middle, margin The final output is an encoder weight file that can distinguish semantic spaces. .

[0067] S4. Perform bidirectional probability matching training;

[0068] Based on the low-noise semantic space already obtained, this stage performs bidirectional, fine-grained relevance discrimination on query-document pairs to establish stable and interpretable probability output.

[0069] Based on the pseudo-labels in S2, for each query Corresponding document Assigning true labels This constitutes a supervisory body , forming a set of supervisory sentences The supervisory clauses are concatenated in two directions: query-first and document-first, to generate a bidirectional concatenation sequence. and Specifically, in this embodiment, a total of [number] were generated. Supervision sentence pairs;

[0070] The bidirectional concatenated sequence is input into the encoder trained in S3 to obtain the [CLS] hidden state. and During this process, continue loading the encoder weight file. No freezing;

[0071] Apply the same classification head to the hidden states in both directions. Output the corresponding probabilities: , Specifically, in this embodiment, the classification head adopts a single hidden layer. ,hide ,activation , Output ;

[0072] Construct the binary cross-entropy loss as shown in Equation (3). The losses in both directions are calculated separately, summed, and averaged. The encoder parameters and trainable weights are then jointly updated by minimizing the binary cross-entropy loss. The trained bidirectional semantic-aware retrieval enhancement generative model is obtained; specifically in this embodiment, the training hyperparameters are: , Stop early Finally, the final weights are obtained. (including) ).

[0073] S5. Perform reflective retrieval and reordering;

[0074] S501. Preliminary screening: [Using...] For the whole corpus ( (segment text) creation Dimensional vector index, the core index parameters are set as follows: number of query vectors. Retrieve cluster number ;

[0075] S502. Recall: Given a new query First, search by dense paragraphs ( The first 100 documents from the full-text library are selected as candidate documents. ;

[0076] S503. Fine arrangement: ... Candidate document segment Query-document pairs are formed, and bidirectional concatenation sequences are generated in the query-first and document-first directions, respectively. These sequences are then fed independently into the trained encoder, and the hidden states are obtained using formulas (5) and (6), respectively. and Through formulas (7) and (8), the hidden state is classified by the head. Mapped to the corresponding relevant probabilities and Calculate the joint probability S according to formula (9);

[0077] S504. Truncation: Press Reorder the candidate documents in descending order, take the top 5 candidate documents and concatenate them in the sorted order to form a coherent context text; ensure that the maximum length of the concatenated context text does not exceed [the specified length]. If it exceeds Then it can be done by truncating the previous part. Adjustments will be made in the following manner;

[0078] S505. Generation: The prompt "Please answer the question based on the following documents: {context}" will be generated. Question: "Enter freeze parameters" In the model, the following core inference parameters are set: temperature coefficient. nuclear sampling parameters Maximum generation length .

[0079] Results Analysis

[0080] exist official ( (Article) In this embodiment , relative standard promote , ;relatively promote .

[0081] The performance improvement data in this embodiment are all based on the same NQ official dev split (3610 test cases) test set and under the same testing environment to ensure the fairness and objectivity of the comparison; among them, the accuracy Acc=80% and F1 score=65.10%, compared with the standard RAG In this embodiment, the accuracy (Accc) is improved by 35.4%, and the F1 score is improved by 19.44%. Compared with Self-RAG, the accuracy (Accc) of this embodiment is improved by Acc+46.4%. The above test results fully demonstrate that this embodiment effectively improves the question-answering accuracy and overall performance, significantly outperforming existing conventional RAG and Self-RAG technical solutions, thus verifying the effectiveness and superiority of the technical solution of this invention.

[0082] The above description represents a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A bidirectional information retrieval enhancement generation method for large-scale language models, characterized in that, include: The first step is to construct a bidirectional semantic-aware retrieval enhancement generative model, including an encoder and a bidirectional probability fusion module; The second step is to sort the candidate documents, sample pseudo-positive and pseudo-negative examples and assign pseudo-labels, and form triplet pairs with query, pseudo-positive and pseudo-negative examples. The third step is to perform self-supervised training based on semantic contrast: based on triples, the hidden vectors of the query, pseudo-positive and pseudo-negative examples are obtained through the encoder. In order to minimize the contrastive loss function, the query vector is driven to move closer to the pseudo-positive examples and away from the pseudo-negative examples, the encoder parameters are updated, and a low-noise semantic space is constructed. The fourth step is to perform bidirectional probability matching training: For each query-document pair, a bidirectional concatenation sequence is constructed in the order of query first and document first, respectively. The sequence is input into the encoder to obtain the hidden state, and then the correlation probability in the two directions is output through the classification head in the bidirectional probability fusion module. With minimizing the binary cross-entropy loss as the training objective, the encoder parameters and the trainable weights of the classification head are jointly updated to complete the model training. The fifth step involves retrieving multiple candidate documents for a user query. For each candidate document, a bidirectional concatenation sequence is constructed. The relevance probabilities for the two directions are obtained through the trained bidirectional semantic awareness retrieval enhancement generation model. The joint probability is calculated using the Bayesian fusion formula, and the candidate documents are sorted according to the joint probability. The top K documents are selected as context inputs to a large language model to generate the answer.

2. The method as described in claim 1, characterized in that, The bidirectional semantic-aware retrieval enhancement generation model, based on an existing retrieval enhancement generation system, is used to replace the existing retrieval machine and includes: The encoder uses a pre-trained language model as the encoder to generate bidirectional concatenation sequences with the query-first and document-first orders based on query-document pairs, and obtain the corresponding hidden states. The bidirectional probability fusion module is used to map the hidden state to the corresponding relevant probability through the classification head, and to calculate the joint probability using the Bayesian fusion formula.

3. The method as described in claim 2, characterized in that, The classification head is a single-hidden-layer multilayer perceptron, which uses the Sigmoid function to output the correlation probability.

4. The method as described in claim 1, characterized in that, The second step specifically involves: querying... Corresponding candidate documents { The relevance is ranked, and positive and negative examples are sampled based on the relevance scores. False positive examples are randomly selected from each group. and pseudo-negative examples And label the data with pseudo-labels, forming triples from queries, pseudo-positive examples, and pseudo-negative examples. , , ).

5. The method as described in claim 1, characterized in that, The comparative loss function is as follows: (2) in, , , They represent queries respectively. False positive examples False negatives The hidden vector, Preset margins This represents the hinge function. This is the set of triplets in the current batch.

6. The method as described in claim 1, characterized in that, The fourth step specifically involves: based on the low-noise semantic space, and according to the pseudo-labels annotated in the second step, assigning each query... Corresponding document Assigning true labels In this context, 1 represents relevant and 0 represents irrelevant, constituting the basis for supervision. , forming a set of supervisory sentences The supervisory sentence pairs are concatenated into a bidirectional concatenation sequence according to both query-first and document-first directions, and then fed into the encoder to obtain the hidden states. and ; right and The application classification head outputs the corresponding relevance probability. and ; The training objective is to minimize the binary cross-entropy loss, where the loss function is as follows: (3) In the formula Take respectively and The calculated losses in the two directions are summed and averaged to obtain the binary cross-entropy loss, which is then backpropagated. The encoder parameters and the trainable weights of the classification head are jointly updated to obtain the bidirectional semantic-aware retrieval enhancement generative model after training.

7. The method as described in claim 1, characterized in that, The Bayesian fusion formula is as follows: ; in, Denotes the joint probability. and These represent the correlation probabilities in two directions, respectively.

8. The method as described in claim 1, characterized in that, In the fifth step, the parameters of the large language model are frozen when generating the answer.

Citation Information

Patent Citations

  • Scenic region interaction method and system based on intention recognition and multi-agent cooperation, terminal and medium

    CN121166848A

  • Cboth case generation method based on artificial intelligence

    CN121327128A

  • Retrieval enhancement generation system and method based on multi-view semantic fusion

    CN121434399A

  • Systems and methods for a reasoning-intensive reranking based artificial intelligence conversation agent

    US12499115B1

Cited By

  • Vulnerability detection method and system based on gain-driven retrieval and neural-symbolic enhancement

    CN122241722A