Multi-hop reasoning method and device based on masking knowledge activation
By detecting and utilizing obscured key phrases, combined with fine-grained retrieval and single-hop termination conditions, the problem of knowledge obscuration in multi-hop reasoning is solved, improving the accuracy and efficiency of the answers.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 启元实验室
- Filing Date
- 2026-04-09
- Publication Date
- 2026-05-08
AI Technical Summary
In multi-hop reasoning scenarios, existing technologies are prone to knowledge masking, which causes the model to ignore key conditions and generate incorrect answers. Furthermore, the accumulated errors amplify during iteration, resulting in low reasoning accuracy.
By detecting obscured key phrases in the current round of queries, a dense retrieval system trained with fine-grained contrastive learning is used to retrieve candidate documents from the database, generate the next round of questions, and terminate the iteration when the single-hop termination condition is met, ensuring that the reasoning path is supported by fine-grained evidence.
It significantly reduces the risk of error accumulation in multi-hop inference, improves the accuracy of answers to complex questions, and reduces the overhead of ineffective iterative retrieval.
Smart Images

Figure CN121998104A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, for example to a multi-hop reasoning method and apparatus based on occlusion knowledge activation. Background Technology
[0002] With the rapid development of Large Language Models (LLMs), their applications in question-answering systems, decision support, and content generation are becoming increasingly widespread. However, LLMs primarily rely on the memory of parameters in the training data for generation. When faced with knowledge-intensive, time-sensitive, or long-tail entity-based questions, they are prone to generating "illusions," i.e., generating content lacking factual basis or inconsistent with the real world. To address this issue, Retrieval-Augmented Generation (RAG) technology has emerged. RAG improves the accuracy and verifiability of generated content by introducing external knowledge base retrieval before generating the answer, inputting the retrieved evidence fragments along with the user's question into the LLM. In simple single-hop question-answering scenarios, traditional single-round RAG (i.e., directly using the original question for a one-time retrieval and generating the answer) usually achieves good results. However, when faced with complex multi-hop reasoning scenarios, a single question often implies multiple reasoning steps, requiring traversal of multiple documents to find the complete answer chain. For example, in scenarios like finding the name of a famous bridge in the birthplace of a composer, a single-round retrieval is insufficient to cover all intermediate evidence. Therefore, the industry has gradually shifted towards multi-round RAG solutions. Multi-round RAG employs an iterative closed loop of "query generation—retrieval—regeneration": the model first generates the next round's sub-question or query based on the current information, uses this query to retrieve new documents, and then updates the reasoning state based on the new documents, repeating this process until the final answer is obtained.
[0003] During the iterative process of related technologies, the phenomenon of "knowledge masking" is prone to occur: when a question contains multiple parallel or combined conditions, the model, when generating the next round of query or inference text, is often dominated by the more salient, more frequent, or more "familiar" conditions, thus ignoring another equally crucial but relatively insignificant condition. The ignored condition is often precisely the "key" to advancing the next hop retrieval and inference. Once masking occurs, the model may generate content related to the dominant condition but unrelated to the actual inference chain, leading to the retrieval of irrelevant documents, further misleading the model to reinforce the incorrect direction in the next round of generation, forming a continuous chain reaction of "deviation—retrieval noise—misleading generation." In multi-hop inference, the multiple conditions of a question often have strong coupling relationships (e.g., "the name of a famous bridge in the birthplace of the composer of a certain work"). Ignoring any one condition can break the inference chain. Based on this, once a query deviates from the facts or omits a key condition, subsequent retrievals will be misguided, causing errors to accumulate and amplify in iterations, ultimately producing high-confidence but incorrect answers, thus resulting in low inference accuracy of current inference methods. Summary of the Invention
[0004] This application aims to provide a multi-hop reasoning method, apparatus, electronic device, and storage medium based on occlusion knowledge activation.
[0005] According to one aspect of this application, a multi-hop reasoning method based on occlusion knowledge activation is proposed, comprising: using a pre-set natural language processing library to determine the candidate key phrase set corresponding to the current round query from the user's initial query information, and detecting occluded key phrases in the candidate key phrase set; based on retrieval conditions, using a dense retrieval device trained through fine-grained contrastive learning, retrieving a candidate document set from the retrieval database, wherein the retrieval conditions include the current round question corresponding to the current round query and the occluded key phrases; determining the target document from the candidate document set, and based on the occluded key phrases, the current round question, and the target document, using a large language model to generate the next round question corresponding to the next round query; and determining the final answer based on the initial query information, the next round question, and a pre-set single-hop termination condition.
[0006] According to one aspect of this application, a multi-hop reasoning device based on masking knowledge activation is proposed, comprising:
[0007] The phrase detection module is used to determine the set of candidate key phrases for the current round of query from the user's initial query information using a preset natural language processing library, and to detect the masked key phrases in the set of candidate key phrases. The document set retrieval module is used to retrieve candidate document sets from the retrieval database based on retrieval conditions and using a dense retrieval tool trained through fine-grained contrastive learning. The retrieval conditions include the current round question and the masked key phrases corresponding to the current round query. The question generation module is used to determine the target document from the candidate document set, and based on the occluded key phrases, the current round question and the target document, it uses a large language model to generate the next round question corresponding to the next round query. The answer generation module is used to determine the final answer based on the initial query information, the next round of questions, and the preset single-hop termination conditions.
[0008] According to one aspect of this application, an electronic device is provided, comprising: a processor; and a memory storing a computer program that, when executed by the processor, causes the processor to perform the method described above.
[0009] According to one aspect of this application, a non-transitory computer-readable medium is proposed, on which readable instructions are stored, which, when executed by a processor, cause the processor to perform the method described above.
[0010] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application.
[0011] Beneficial effects: By dynamically detecting the obscured key phrases in the current query, the implicit missing reasoning links are made explicit as the core guidance for retrieval, thus solving the retrieval bias problem caused by semantic ambiguity in traditional multi-hop reasoning. Specifically, this application no longer relies solely on the macro-semantics of the original question for matching, but instead forces the obscured key phrases and the current question to jointly construct fine-grained composite retrieval conditions. A trained dense retrieval system accurately locates documents containing both question background and key entity evidence in a massive database, effectively filtering out interfering documents (i.e., semi-positive samples) that are only superficially related to the question but lack key reasoning clues. Based on the mapping relationship between these high-confidence target documents and obscured key phrases, the large language model can accurately complete the missing entities in the reasoning chain, generating a clearly targeted next-round question. This significantly reduces the risk of error accumulation in multi-hop reasoning, ensuring that the reasoning path from the initial query to the final answer has both fine-grained evidence support and can terminate promptly when the single-hop condition is met. This improves the accuracy of answering complex questions while significantly reducing ineffective iterative retrieval overhead. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings, without exceeding the scope of protection claimed by this application.
[0013] Figure 1 A flowchart of a multi-hop inference method based on occlusion knowledge activation provided in an embodiment of this application; Figure 2 This is a schematic diagram illustrating the sensitivity of the Gaussian noise standard deviation to the overall performance of occlusion detection, as provided in the embodiments of this application. Figure 3 A schematic diagram illustrating the similarity of output distributions of different masked key phrases under different Gaussian noise standard deviations, provided for embodiments of this application; Figure 4 A block diagram of a multi-hop inference device based on occlusion knowledge activation provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0014] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.
[0015] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0016] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0017] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0018] It should be understood that although the terms first, second, third, etc., may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Therefore, the first component discussed below may be referred to as the second component without departing from the teachings of this application. As used herein, the term "and / or" includes all combinations of any one and more of the associated listed items.
[0019] Currently, in situations where knowledge masking occurs, the system is dominated by significant conditions, key phrases / conditions are ignored, and off-target queries are performed that are unrelated to the true reasoning chain. Based on this, noisy documents are retrieved, and LLM reinforces the incorrect direction based on the noise, then further off-target queries are performed, retrieving more noise. The error gradually accumulates and amplifies, resulting in a high-confidence incorrect answer.
[0020] Based on this, this application provides a multi-hop reasoning and apparatus based on occlusion knowledge activation. By detecting occluded key phrases in the current query, retrieving the corresponding candidate document set, and further generating the next query, the reasoning process is realized step by step.
[0021] For specific implementation details, please refer to the following examples.
[0022] Figure 1 A flowchart illustrating a multi-hop inference method based on occlusion knowledge activation provided in an embodiment of this application. Figure 1 As shown, the method includes steps S10, S11, S12 and S13.
[0023] In step S10, a preset natural language processing library is used to determine the candidate key phrase set for the current round of query from the user's initial query information, and the masked key phrases in the candidate key phrase set are detected.
[0024] In this application, an initial natural language question input by the user can be received first and defined as the "current round query" at the beginning of multi-hop inference or at the start of each iteration. A natural language processing library is pre-set; this application can use the Spacy framework for the natural language processing library. The initial query information is first input into the natural language processing library, and a set of candidate key phrases is output.
[0025] The semantic structure of the current query can be analyzed to identify gaps in key information that are essential for answering the question but are not explicitly stated or are ambiguous in the current query. Each candidate key phrase in the candidate key phrase set is matched and evaluated against the context of the current query, measuring the importance (which can be a score) of each candidate phrase in completing the semantic integrity of the current query. Then, based on importance, the phrases with the highest importance—those that best represent the missing link in the current reasoning and, once discovered, can drive the reasoning to the next step—are selected from the candidate set and marked as hidden key phrases.
[0026] In some implementations, the initial question input by the user can be obtained; the initial question is then preprocessed to obtain initial query information, including sentence segmentation, normalization, and removal of meaningless symbols. The masked key phrases are then analyzed based on this initial information.
[0027] In step S11, based on the retrieval conditions, a dense retrieval system trained with fine-grained contrastive learning is used to retrieve a set of candidate documents from the retrieval database. The retrieval conditions include the current round question and the masked key phrases corresponding to the current round query.
[0028] In this application, after obtaining the masked key phrases, the search criteria for this round of retrieval are constructed. The search criteria are a composite information body, which simultaneously contains the original "current round question" text and the "masked key phrases" detected in the previous step.
[0029] A dense retrieval engine, pre-trained with fine-grained contrastive learning, is invoked. This engine is a neural network model capable of mapping text to a high-dimensional vector space. The search criteria, including the question and key phrases, are transformed into query vectors, which are then matched against a pre-built retrieval database. This database stores pre-computed vector representations of massive amounts of documents (such as encyclopedia entries, news articles, and professional literature). The dense retrieval engine calculates the semantic similarity between the query vectors and the document vectors in the database. Documents in the database are ranked according to their similarity scores, and a predetermined number of documents (e.g., ranked 10th to 20th) are selected to form a candidate document set.
[0030] In some implementations, dense retrieval systems employ vector retrieval models with dual-tower or single-tower structures and perform approximate nearest neighbor retrieval based on cosine similarity.
[0031] In step S12, the target document is determined from the candidate document set, and the next round question corresponding to the next round query is generated using a large language model based on the masked key phrase, the current round question, and the target document.
[0032] In this application, after obtaining a set of candidate documents, the system selects one or more of the most valuable documents as target documents. The selection criteria may be the relevance of the document content to the current round of questions and the hidden key phrases, that is, whether the document can effectively answer the questions about the hidden key phrases in the current round of queries, or provide key entity link information.
[0033] Once the target document is identified, Large Language Model (LLM) can be used for inference generation. The following three pieces of information are input into the Large Language Model as context: the current round question, the occluded key phrases, and the target document. Specifically, the current round question represents the original query intent; the occluded key phrases represent the missing information points that are the focus of this round; and the target document represents the latest evidence content obtained from the retrieval database.
[0034] Large language models can read and understand factual information in target documents and logically associate it with the current round of questions. If the target document reveals the specific references of hidden key phrases, the model uses this new information to reconstruct or refine the original question and generate the next round of questions.
[0035] In step S13, the final answer is determined based on the initial query information, the next round of questions, and the preset single-hop termination condition.
[0036] In this application, after generating the next round of questions, a decision-making phase is initiated to determine whether to continue iteration or output the final result. The current reasoning state can be evaluated based on preset single-hop termination conditions. This evaluation process comprehensively considers the nature of the next round of questions and the relevance of the initial query information. The nature of the next round of questions refers to analyzing whether the generated questions are sufficiently specific and whether a definitive answer can be obtained directly through a single retrieval (i.e., whether it has been transformed into a single-hop question). The relevance of the initial query information involves tracing back the user's initial query information to determine whether the currently accumulated evidence (including the target document obtained in this round) is sufficient to support a complete answer to the initial questions.
[0037] If the evaluation result meets the single-hop termination condition (e.g., the next question is atomic, or the reasoning chain is complete), the multi-hop iteration process terminates. Then, key information from the entire reasoning process can be summarized, including the user's initial query information and all target document content acquired during the iteration process (including the final round). This information is integrated and input into the generation module, or it can be input into the same large language model, allowing the generation module or the large language model to synthesize all evidence for logical reasoning and text organization, ultimately generating and outputting the final answer to the user's initial query.
[0038] If the evaluation result does not meet the termination condition, the next round of questions will be updated to the new current round query, and the process will return to step S10 to start a new round of occluded keyword detection and retrieval until the termination condition is met.
[0039] This application addresses the retrieval bias caused by semantic ambiguity in traditional multi-hop reasoning by dynamically detecting obscured key phrases in the current query round, making implicit missing reasoning links explicit as the core guide for retrieval. Specifically, instead of relying solely on the macro-semantics of the original question for matching, this application forces the obscured key phrases and the current question to jointly construct fine-grained composite retrieval conditions. A trained dense retrieval engine accurately identifies documents containing both question background and key entity evidence within a massive database, effectively filtering out interfering documents (i.e., semi-positive samples) that are only superficially related to the question but lack key reasoning clues. Based on the mapping relationship between these high-confidence target documents and obscured key phrases, the large language model accurately completes the missing entities in the reasoning chain, generating a clearly targeted next-round question. This significantly reduces the risk of error accumulation in multi-hop reasoning, ensuring that the reasoning path from the initial query to the final answer has both fine-grained evidence support and timely termination when single-hop conditions are met. This improves the accuracy of answering complex questions while significantly reducing ineffective iterative retrieval overhead.
[0040] According to some embodiments, the natural language processing library includes a Spacy framework with pre-configured key phrase masking. Specifically, initial query information can be input into the Spacy framework to determine the clean key phrases after removing stop words; the clean key phrases can be input into the Spacy framework to output a set of candidate key phrases; and masked key phrases can be detected in the set of candidate key phrases.
[0041] This application allows for the pre-determining of stop word extraction rules and keyword extraction rules using the Spacy framework. Initial query information is input into the Spacy framework, and information such as punctuation marks is removed as stop words to obtain clean key phrases. These clean key phrases are then input into the Spacy framework, from which nouns, adjectives, verbs, numerals, and adverbs from the initial query information are extracted as candidate key phrases, generating a candidate key phrase set. The candidate key phrase set is then tested to identify the masked key phrases.
[0042] In some implementations, the extraction rules include: identifying named entities (person names, place names, organization names, work names, time, etc.); retaining words or phrases with semantic carrying capacity, whose parts of speech are adjectives, common nouns, verbs, proper nouns, numerals, and adverbs; removing function words through a stop word list; and merging adjacent noun phrases or entity spans to form more stable phrases. The final result is a set of candidate key phrases.
[0043] This application constructs the Spacy framework with pre-configured key phrase masking and employs a two-stage processing logic: obtaining clean key phrases by removing stop words and outputting a candidate set based on the clean key phrases, as well as detecting the masking status. This achieves synergistic optimization of retrieval accuracy and privacy / generalization capabilities. First, leveraging the powerful linguistic features of the Spacy framework, stop words are removed, effectively filtering out noisy words with low semantic contribution, thus extracting clean key phrases with a high signal-to-noise ratio. Then, these clean key phrases are input again into the specially masked framework. While preserving the core semantic structure, sensitive, redundant, or generalizable phrases are automatically identified and marked (masked), generating a candidate key phrase set that contains rich semantic information and meets specific constraints. This not only avoids the problem of traditional simple keyword matching being easily interfered with by noise but also ensures, through the embedded masking detection step, that downstream tasks (such as the contrastive learning training of dense retrieval machines) can directly obtain refined and more discriminative key phrase features, significantly improving the robustness of natural language query understanding and the accuracy of subsequent retrieval models in fine-grained semantic matching.
[0044] According to some embodiments, the Gaussian perturbation mechanism can be used to measure the influence of each candidate key phrase in the candidate key phrase set on the output distribution of the large language model in order to determine the similarity; the candidate key phrase with the highest similarity is identified as the masked key phrase.
[0045] In this application, the above-generated candidate keyword phrase set This can be used to characterize potential entities, concepts, or reasoning gaps that may exist in the current query. Each phrase in the candidate set is iterated over sequentially. We are preparing to conduct sensitivity testing.
[0046] For each candidate keyword phrase to be tested, a perturbation experimental environment is constructed at the input of the large language model. In some implementations, the text string is not directly modified, but the operation is performed at the model's embedding layer. The system locates the lexical positions corresponding to the candidate keyword phrase in the input sequence and superimposes Gaussian-distributed random noise onto the vector representations of these positions. This noise simulates the uncertainty or slight ambiguity of semantic features during information transmission.
[0047] After injecting Gaussian noise, the system feeds the perturbed input embedding representation into the large language model for forward propagation, obtaining the perturbed output distribution of the model under this perturbed state, which is typically represented as the probability distribution of the next predicted token or the distribution of hidden layer states. Simultaneously, the system retains the original input without noise and runs it to obtain the original output distribution.
[0048] In some implementations, the perturbed input embedding is represented as: .
[0049] in, Embedded from the original input; This is a binary mask (the token position is set to 1, and the rest are set to 0); ⊙ represents bitwise multiplication; Mean 0, standard deviation Gaussian noise, The standard deviation of Gaussian noise is set within the range of 0.05-0.5 to balance detection sensitivity and robustness. In some implementations... It can achieve better results and can be tried first. This is set as the default value and then fine-tuned based on inference performance.
[0050] For each Construct a mask Its length is equal to the length of the query token sequence. The corresponding token position is 1, and the rest are 0. This follows a Gaussian distribution. Sampling noise and only Noise is injected into the corresponding embedding dimension to obtain This approach preserves the original token sequence and positional encoding, changing only the local embeddings, thus maximizing the preservation of the inference chain structure. Therefore, even in multi-hop problems with multiple constraints, the model can still output a distribution within approximately the same semantic framework, making influence measurements more interpretable.
[0051] The sensitivity to occlusion detection that has an overall impact on performance can be referenced as follows: Figure 2 The diagram shown illustrates how different masked key phrases are displayed in different contexts. The output distribution similarity can be referenced as follows: Figure 3 The schematic diagram shown is in Figure 3 The text presents the information from the perspective of three obscured key phrases: phrase a, phrase b, and phrase c.
[0052] By comparing these two distributions, the impact of the candidate key phrase on the stability of the model output is measured. If a candidate phrase is crucial for inference, i.e., the "masked" core information, then applying a small amount of Gaussian noise to its embedding representation will cause drastic fluctuations in the output distribution of the large language model, i.e., a huge difference between the original distribution and the perturbed distribution. Conversely, if the phrase is insignificant, the noise has a negligible impact on the output distribution.
[0053] The system quantifies the aforementioned degree of influence into a "similarity" metric. In this application, this similarity can reflect the ability of candidate phrases to maintain the model's original semantic output under perturbation, or it can be defined as a transformed key score. The system repeats the above Gaussian perturbation and distribution measurement steps for all candidate key phrases to obtain the similarity value corresponding to each phrase.
[0054] Then, the similarity scores of all candidate phrases are compared, and the candidate key phrase with the highest similarity score is locked as the masked key phrase for this round of query. The masked key phrase has the most significant guiding effect on the model's reasoning path in the current context, and its slight changes in semantic features are most likely to affect the model's decision boundary. Therefore, it is determined to be the key information point that urgently needs to be retrieved and activated in the current multi-hop reasoning.
[0055] This application introduces a Gaussian perturbation mechanism to measure the impact of candidate key phrases on the output distribution of a large language model, achieving a leap from semantic matching to causal sensitivity analysis. In this application, the truly obscured key phrases are the crucial link in the current inference chain, exhibiting extremely high instability or sensitivity in their internal model representation; that is, even small feature perturbations can lead to significant shifts in the model's subsequent inference path (output distribution). Therefore, by injecting Gaussian noise into candidate phrases and observing the magnitude of changes in the model's output distribution, the contribution or criticality of each candidate phrase to the current inference task can be accurately quantified, mapping this sensitivity to distribution changes to a similarity index. Finally, the phrase with the highest similarity is selected as the obscured key phrase, avoiding the superficial relevance misjudgments that may arise from traditional static keyword matching or attention weight ranking. This ensures that the detected key phrases are the true logical switches driving multi-hop inference forward, thus laying a solid semantic foundation for constructing high-precision retrieval conditions in subsequent steps and significantly improving the accuracy of identifying implicit inference gaps in complex contexts.
[0056] According to some embodiments, a binary mask corresponding to the candidate key phrase can be constructed, and Gaussian noise can be injected into the word embedding position corresponding to the binary mask in the candidate key phrase to determine the perturbed input embedding representation. The original input embedding representation and the perturbed input embedding representation are respectively input into a large language model to determine the original output distribution and the perturbed output distribution. The original output distribution and the perturbed output distribution are subjected to average pooling in the time dimension to determine the original vector and the perturbed vector. The cosine similarity between the original vector and the perturbed vector is calculated, and the candidate key phrase with the largest cosine similarity is determined as the masked key phrase.
[0057] In this application, for each candidate key phrase to be tested, the system constructs a binary mask at its corresponding text sequence position. The mask is a vector with the same length as the input sequence, where the token positions covered by the candidate key phrase are marked as 1, indicating the target region, while other parts in the current round of query, such as context and conjunctions, are marked as 0, indicating the preserved region.
[0058] Based on this mask, the system performs noise injection at the embedding layer. Only the word embedding vectors corresponding to the candidate key phrases are extracted, and Gaussian noise with a specific mean and variance is superimposed onto these vectors. At this point, the original values of the word embedding vectors for other non-masked parts of the current query must remain unchanged. By re-concatenating the noisy key phrase embeddings with the unchanged embeddings of other parts, a perturbed input embedding representation is constructed, ensuring that the perturbation effect is strictly limited to the candidate phrases themselves, thus eliminating contextual interference.
[0059] Two sets of input data are fed separately into the same large language model for forward inference. For the original path, the raw input without any noise processing is embedded into the representation input model to obtain the output probability distribution of the model at each time step, which is taken as the raw output distribution. For the perturbed path, the perturbed input generated above is embedded into the representation input model to obtain the output probability distribution of the model at the corresponding time step, which is taken as the perturbed output distribution. These two sets of distribution sequences can reflect the difference in the overall inference state of the model with and without key information perturbations.
[0060] Will The perturbation output distribution is obtained by inputting a large language model: .
[0061] in, This represents the candidate output (candidate document set) of the large language model. This is the number of the perturbation sample. This represents the total number of perturbation samples.
[0062] The original output distribution without disturbance is: .
[0063] To measure phrases The impact on the output can be... and A vector representation is obtained by performing average pooling in the time dimension. and The cosine similarity is calculated. A higher similarity indicates that the perturbation has a smaller impact on the output, and the phrase is more likely to be underutilized by the model, i.e., masking occurs.
[0064] To extract global features from sequence-level distributed data, average pooling is performed on both the original output distribution and the perturbed output distribution along the time dimension. Average pooling can be defined as: .
[0065] in, For time steps, For the first The probability vector of the step.
[0066] Specifically, the system accumulates and averages the probability distribution vectors of all time steps within the entire generated sequence or the preset attention window, thereby compressing the variable-length sequence distribution into two fixed-dimensional static vectors: the original vector and the perturbation vector. These two vectors represent the overall semantic representation center of the model in the original state and the perturbation state, respectively.
[0067] Calculate the cosine similarity between the original vector and the perturbation vector. This similarity value quantifies the degree of deviation of the overall output representation direction of the model after the introduction of Gaussian noise. If the cosine similarity is close to 1, it indicates that the perturbation has not caused a significant change in the model's output direction, and the candidate phrase has little impact on inference. If the cosine similarity is low, it indicates that a small amount of noise has caused a large shift in the model's output representation, suggesting that the phrase is crucial.
[0068] Finally, the system can iterate through all candidate key phrases, repeat the above steps, compare their calculated cosine similarity scores, and ultimately lock the candidate key phrase with the highest cosine similarity score as the masked key phrase. , .
[0069] This application achieves a refined measurement of global representation stability from local perturbations by constructing a binary mask to accurately isolate candidate phrases and injecting Gaussian noise, combined with temporal average pooling and cosine similarity calculation. Specifically, the binary mask ensures that noise only affects the phrase being tested, eliminating interference from redundant contextual information and allowing the measurement results to purely reflect the semantic contribution of the phrase. Meanwhile, the temporal average pooling process smooths the dynamic fluctuations of large language models during long sequence generation into stable global semantic vectors, effectively eliminating evaluation bias caused by random noise at a single time step, making the comparison results more robust. Based on this, cosine similarity is used to measure the directional consistency between the original and perturbation vectors. In this application, the phrase with the highest cosine similarity is identified as the masked key phrase. This indicates that the phrase can still maintain the original topological structure of the model output distribution to the greatest extent after being subjected to Gaussian perturbation, or under this specific definition, it represents the strongest constraint or consistency on the reasoning path. This quantification method based on the geometric distance of the vector space can better reflect the stability of the deep semantic space than the simple difference in probability values. Thus, in the complex context of multi-hop reasoning, it can accurately screen out the core entities that play a decisive role in maintaining the logical coherence of reasoning, avoid misjudgment caused by local probability fluctuations, and significantly improve the granularity and reliability of key information detection.
[0070] According to some implementations, it can be determined whether the next round question meets the single-hop termination condition; if the next round question does not meet the single-hop termination condition, the next round question is used as the new current round question corresponding to the new current round query for reasoning iteration; if the next round question meets the single-hop termination condition, the iteration is terminated after the last round of retrieval; the target document and initial query information during the iteration process are obtained, and the target document and initial query information are input into the large language model to generate the final answer.
[0071] In this application, the decision logic is initiated immediately after the next round of questions is generated. This logic compares the text content, semantic features, or metadata of the next round of questions with preset single-hop termination conditions.
[0072] Termination conditions can take the form of specific end markers, missing specific interrogative words, semantic confidence thresholds (such as the probability that the model determines that no further retrieval is needed exceeding a set value), or reaching the preset maximum number of iterations.
[0073] If the next round of questions hits any of the above termination rules, it is determined that the single-hop termination condition is met; otherwise, if the next round of questions still contains clear unsolved entities or reasoning gaps, it is determined that the single-hop termination condition is not met.
[0074] When the determination result indicates that the single-hop termination condition is not met, the system enters iterative update mode. The system directly overwrites or assigns the current next-round question to the new current-round query's corresponding new current-round question. Using this updated question as input, the key phrase detection, retrieval, and new question generation processes in the previous steps are retried. Each iteration proposes deeper questions based on the findings of the previous round, until no more valid sub-questions can be proposed.
[0075] When the determination result shows that the single-hop termination condition is met, the system immediately stops the above loop, no longer generates new sub-problems, but performs a final round of retrieval. For the last sub-problem that meets the termination condition (usually a question with complete context that only requires final confirmation or a direct answer), the system performs a final document retrieval. After the retrieval is completed, the iteration process officially terminates, and the system locks all intermediate data generated during the entire reasoning process.
[0076] After all iterations are complete, the system integrates the target document set and the initial query information. The target document set comprises all highly relevant document fragments acquired throughout the entire iteration process (including the final retrieval round). The initial query information is the user's original question input. The system concatenates these two parts of data to construct the final prompt words, which are then input into the large language model. At this point, the large language model is no longer responsible for asking questions but focuses on synthesis and answering. It uses the accumulated target documents as factual basis, combined with the intent of the initial query, to perform global logical organization and text generation, outputting the final, multi-hop validated answer.
[0077] This application achieves a qualitative leap from fixed-step reasoning to adaptive deep reasoning by introducing a single-hop termination condition as a dynamic controller for multi-hop reasoning. Solving complex problems relies on information chains with uncertain layers, and a fixed number of reasoning rounds can easily lead to insufficient or excessive reasoning. Therefore, by dynamically adjusting the reasoning depth based on the actual complexity of the problem after generating a new question in each round to determine whether the termination condition is met, the system can solve the problem. When the problem is not yet solved, a new question is automatically transformed into the input for the next round of iteration, ensuring that the reasoning chain continues to extend until the truth is reached. Once the reasoning is detected to be complete (the termination condition is met), a final targeted retrieval is immediately executed, forcibly stopping the iteration. This not only cuts off invalid and redundant computations but also ensures the completeness of information at the termination point through the final retrieval mechanism. By inputting the target documents accumulated throughout the entire chain and the initial query into the model to generate the answer, fragmented evidence scattered across multiple iterations is globally aggregated and logically closed-looped. This allows the large language model to make comprehensive judgments based on a complete evidence chain, significantly improving the accuracy, logical coherence, and computational resource utilization efficiency when handling complex multi-hop question-answering tasks.
[0078] According to some embodiments, the next round of questions is input into a large language model so that the large language model can determine whether the next round of questions is a single-hop query; if the determination result is a single-hop query, then the single-hop termination condition is determined to be met; if the determination result is a non-single-hop query and the preset maximum number of iterations has not been reached, then the single-hop termination condition is determined not to be met; if the preset maximum number of iterations has been reached, then the single-hop termination condition is determined to be forcibly met.
[0079] In this application, the generated next-round question is first used as an input prompt and fed into a large language model for metacognitive judgment. In this step, the large language model can analyze the semantic structure of the question.
[0080] Single-hop query determination: If the model recognizes that the question can be answered directly based on the known context or a single search result without further breaking down sub-questions or performing chained reasoning, then the model output is a single-hop query determination label.
[0081] Non-single-hop query determination: If the model identifies that the question still contains undefined entity dependencies and requires further retrieval of external information to answer, i.e. the question has multi-hop dependencies, the model outputs a non-single-hop query determination label.
[0082] This application can pre-set a global iteration counter to record the number of inference rounds currently executed, and preset a maximum iteration threshold. After obtaining the semantic judgment result of the large language model, if the judgment result of the large language model is "single-hop query", regardless of the current counter value, the system directly determines that the single-hop termination condition is met. This means that the inference chain has naturally closed semantically and does not need to be further explored. If the judgment result of the large language model is "non-single-hop query", and the current counter is less than the preset maximum iteration count, the system determines that the single-hop termination condition is not met. At this time, the inference process will continue, and the system will take this problem as a new starting point to enter the next round of loop. If the current counter reaches the preset maximum iteration count, regardless of whether the semantic judgment result of the large language model for this problem is "single-hop" or "non-single-hop", the system executes forced logic and directly determines that the "single-hop termination condition is forcibly met". This step can act as a safety valve to forcibly terminate the inference process that may fall into an infinite loop or excessive divergence.
[0083] Based on the above process, the system outputs a final Boolean signal, namely True / False, to control whether the main process enters the "iterative update" or "termination of retrieval and response" stage.
[0084] This application constructs a dual termination mechanism that combines intelligent adaptability and system robustness by integrating the semantic self-evaluation capability of a large language model with a pre-set hard constraint on the maximum number of iterations. Simply relying on model judgment may lead to infinite loops due to model illusion or over-reasoning tendencies, where the model always believes more jumps are needed. Conversely, relying solely on a fixed number of rounds may result in premature interruption of reasoning or waste of resources due to differences in question complexity. Therefore, this application introduces a large language model to perform real-time single-hop / multi-hop attribute identification for the next round of questions. This allows for the keen capture of the natural convergence point of the reasoning chain at the semantic level. Once the question is transformed into an atomic query that can be directly answered, termination is automatically triggered, achieving on-demand reasoning. Simultaneously, the superimposed forced truncation logic of the maximum number of iterations sets absolute boundary conditions for the system, ensuring that even when model judgment fails or extremely complex long-tail questions are encountered, the reasoning process can still converge within limited resources. This avoids infinite consumption of computational resources and response latency, significantly improving the stability, response speed, and controllability of the final answer in complex open-domain scenarios.
[0085] According to some embodiments, a training sample set can be constructed, which includes positive sample documents, semi-positive sample documents, and negative sample documents. Positive sample documents are related to both the question and the masked key phrases. Semi-positive sample documents are related to the question but not directly related to the masked key phrases. Negative sample documents are not related to either the question or the masked key phrases. Based on the training sample set, a fine-grained contrastive learning loss function is used to train the retrieval machine to generate a trained dense retrieval machine. The fine-grained contrastive learning loss function includes a first loss term, a second loss term, and a total loss term. The first loss term is used to maximize the ratio of the retrieval score of positive sample documents to the sum of the retrieval scores of semi-positive sample documents and negative sample documents. The second loss term is used to maximize the ratio of the sum of the retrieval scores of positive sample documents and semi-positive sample documents to the sum of the retrieval scores of negative sample documents. The total loss term is the weighted sum of the first loss term and the second loss term.
[0086] In this application, a structured training sample set is first constructed, in which each training instance contains a query question and three different types of documents with different relevance: Positive sample documents These documents are highly relevant to the current query and explicitly contain or are closely related to the obscured key phrases corresponding to that query. They are indispensable core evidence in the chain of reasoning.
[0087] Semi-positive sample documents These documents are relevant to the query in terms of topic or background and provide some contextual support, but their content does not directly contain or have a substantial semantic connection with the obscured key phrases. They are relevant but non-core distractors.
[0088] Negative sample documents Documents of this type are neither relevant to the query question nor related to the masked key phrases; they are essentially irrelevant and noisy data.
[0089] The dense retrieval system employs a fine-grained contrastive learning loss during training, ensuring that the scoring meets the requirements. The ranking preference.
[0090] Based on the aforementioned training sample set, the system optimizes the retrieval engine using a fine-grained contrastive learning loss function that includes two independent loss terms. The retrieval engine calculates a retrieval score for each document, reflecting its degree of match with the query.
[0091] Regarding the first loss item The loss term is designed to widen the gap between positive sample documents, semi-positive sample documents, and negative sample documents. In some implementations, a ratio can be constructed where the numerator corresponds to the retrieval score of a positive sample document, and the denominator corresponds to the sum of the retrieval scores of semi-positive sample documents and negative sample documents. The training objective is to maximize this ratio, enabling the retrieval machine to learn to score positive sample documents significantly higher than semi-positive samples that, while relevant to the question, do not contain key phrases, thereby achieving precise targeting of key information.
[0092] Regarding the second loss item This loss term aims to widen the gap between the relevant document set (positive samples + half-positive samples) and the negative sample documents. In some implementations, a ratio is constructed where the numerator corresponds to the sum of the retrieval scores of positive sample documents and the half-positive sample documents, and the denominator corresponds to the sum of the retrieval scores of negative sample documents. The training objective is to maximize this ratio, ensuring that the retrieval machine can accurately separate all question-relevant documents from completely irrelevant negative samples, guaranteeing the basic accuracy of recall.
[0093] The system performs a weighted sum of the first and second loss items to generate the final total loss item. The weighting parameter is used to balance the importance of core keyword identification and overall relevance filtering.
[0094] In some implementations, let This represents the cosine similarity between the question representation and the document representation. The question is input into the query encoder, and the output vector represents the question representation; the document is input into the document encoder, and the output vector represents the document representation. Definition The loss function can be defined as: ; ; .
[0095] in This is the weighting coefficient, which can be set to 0.7. The positive samples are relatively higher than the half-positive and negative samples. This further promotes a higher relative level of positive samples compared to negative samples, thereby achieving three-layer correlation differentiation.
[0096] During training, the system can minimize the total loss function using the backpropagation algorithm, continuously adjusting the internal parameters of the dense retrieval engine. After multiple iterations, the retrieval engine eventually converges into a well-trained dense retrieval engine that can not only distinguish between relevant and irrelevant documents, but also accurately identify core documents containing key inference entities.
[0097] In the specific implementation process, let's assume Indicates time The question indicates that, This represents the core key phrase representation (document representation) identified at that moment, with the symbol ⊕ indicating a vector concatenation operation. Query encoder. Receive the concatenated representation as input and generate a query vector. ,Right now: .
[0098] set up The document encoder represents the text in the candidate document set. Encode the candidate document text to generate document vectors. ,Right now: .
[0099] Query vector With document vectors The degree of matching between them can be measured by cosine similarity, which is... .
[0100] In some implementations, a contrastive learning objective can be constructed based on the query vector and document vector, and the query encoder and document encoder can be jointly trained to improve the model's ability to recognize documents containing key reasoning entities. The training parameters, such as the optimizer type, learning rate, batch size, loss weights, and stopping conditions, can be set and adjusted according to the specific application scenario.
[0101] This application constructs a three-level fine-grained sample set containing positive, semi-positive, and negative samples, and designs a hierarchical contrastive loss function with dual optimization objectives, achieving a leap in the retrieval system's ability from coarse-grained relevance matching to refined key entity perception. Traditional retrieval training often only distinguishes between relevant and irrelevant samples, making it difficult for the model to differentiate between semi-positive samples that are relevant to the question but lack key inference entities and positive samples that truly contain key entities. Consequently, the model is easily lost in background noise during multi-hop inference. Therefore, semi-positive sample documents are introduced as intermediate references, and the first loss term forces the maximization of the score ratio of positive samples relative to the sum of semi-positive and negative samples. This directly forces the model to learn the unique semantic features of the masked key phrases, enabling it to accurately focus on core evidence containing key entities when faced with similar background documents. The second loss term, by maximizing the ratio of the sum of positive and semi-positive samples to the sum of negative samples, ensures that the model, while pursuing fine-grained distinction, does not lose its ability to judge the relevance of the overall topic of the question, maintaining a basic recall rate. This weighted synergy of the two-layer loss mechanism enables the trained dense retrieval system to both filter out completely irrelevant noise and highlight core documents carrying key reasoning clues from a pile of relevant documents, thus significantly improving the accuracy of the first-step retrieval in multi-hop question answering tasks and laying a solid and high-precision data foundation for subsequent key phrase extraction and reasoning chain construction.
[0102] According to some embodiments, the current round question is concatenated or fused with the masked key phrase to generate a retrieval input vector; based on the retrieval conditions, a dense retrieval tool is used to calculate the similarity between the retrieval input vector and the corresponding document vectors in the retrieval database, so as to determine the preset number of documents with the highest similarity as the candidate document set.
[0103] In this application, the query question for the current round and the masked key phrases identified in the previous steps are first obtained. To enhance the targeting of the retrieval, the original question vector is not used directly; instead, concatenation or fusion processing is performed. The text sequence of the current round's question is physically concatenated with the text sequence of the masked key phrases, for example, by appending the key phrases to the end of the question, using specific delimiters, or performing feature fusion at the vector space level. The concatenated or fused combined text is then input into an encoding network to generate a unified retrieval input vector. This vector simultaneously encodes the user's query intent and the key entity information to be verified in the semantic space, enabling the generated vector representation to simultaneously reflect the dual features of "what is being asked" and "which word is being searched."
[0104] The system loads a pre-built retrieval database containing pre-computed document vectors for a massive number of documents. Based on the set retrieval criteria, the system performs similarity calculations on a subset of filtered documents. In some implementations, a dense retrieval tool is used to calculate the similarity score between the generated retrieval input vector and each candidate document vector in the database for the same latent semantic concept. This similarity score reflects the overall matching degree between the retrieval input and the document in terms of containing key phrases and answering questions. Multiple document vectors in the database are traversed or accessed through an efficient index structure, and their similarity scores with the retrieval input vector are obtained one by one.
[0105] After calculating the similarity of all relevant documents, the calculated similarity scores are arranged in descending order. Based on a preset threshold (e.g., the top 10), a preset number of documents with the highest similarity (the preset number can be set between 3 and 10) are selected, and duplicate documents are removed to form a candidate document set, which serves as input data for subsequent steps. In some implementations, a hybrid retrieval method (BM25 + vector) can be used as an alternative, but the core principle remains the explicit introduction of masking phrases as search criteria.
[0106] This application achieves a paradigm shift from fuzzy intent matching to entity-oriented targeting by explicitly concatenating or fusing the current question with obscured key phrases to construct the retrieval input vector, and then using a dense retrieval engine to calculate the conceptual similarity between the input vector and the document vector to filter the candidate set. In multi-hop reasoning scenarios, retrieval based solely on the question often leads to the retrieval engine recalling a large number of documents that are relevant to the topic but lack key reasoning entities, i.e., obscured key phrases, due to the generality or ambiguity of the question's wording. This causes subsequent reasoning steps to be interrupted due to a lack of core evidence. Therefore, by directly integrating the identified obscured key phrases as strong feature signals into the retrieval input vector, the dense retrieval engine is forced to consider not only the macroscopic consistency between the document and the question topic when calculating similarity, but also to require that the document be highly aligned with the key phrase in the microscopic semantic space. This fusion mechanism makes the generated retrieval input vector closer to document regions that simultaneously contain the question context and key entities in the vector space, thus naturally elevating core documents containing key evidence to the top during the similarity ranking stage. By extracting a preset number of documents with the highest similarity, the system can output a candidate set with an extremely high signal-to-noise ratio. This avoids interference from irrelevant noise and ensures the complete recall of key reasoning clues, significantly improving the ability of the retrieval process in multi-hop question answering systems to support complex reasoning paths and the accuracy of the final answer.
[0107] According to some embodiments, the current round question can be paired with each candidate document in the candidate document set and input into a large language model to output the relevance judgment result between each candidate document and the current round question, wherein the judgment result is a probability value of yes or no; the candidate document with the highest probability value is determined as the target document; based on the target document and the masked key phrases, the information in the current round query is completed to generate the next round question.
[0108] In this application, a candidate document set generated by the aforementioned steps and the current round question are obtained. This question contains at least one masked key phrase, which represents core entity information that is missing, ambiguous, or requires further confirmation in the current query. To accurately evaluate the utility of each document, the current round question is paired with each candidate document in the candidate document set. For the first document in the set... 1 document, construct a document containing the current round's question and the 1st round's question. Independent input suggestions for each document's content.
[0109] Each pair of inputs is sequentially fed into the large language model. The large language model is instructed to perform a binary classification task, that is, to determine whether a specific document contains the key information or evidence needed to answer the current question. For each classification, the large language model does not directly output a "yes" or "no" text label, but instead outputs a probability value representing "relevance" (e.g., a confidence score indicating the document's relevance to the question). This probability value quantifies the reliability of the document as a basis for reasoning. Ultimately, a list of probability values is obtained, with a list length consistent with the size of the candidate document set, and each probability value corresponds to one candidate document.
[0110] Iterate through all output probability values and find the maximum value. The candidate document with the highest probability value is officially designated as the target document. In some implementations, if multiple documents have the same highest probability value, one can be selected as the target document based on document length, source priority, etc. However, this embodiment emphasizes selecting the document with the highest probability value as the core reasoning basis, ensuring that subsequent reasoning is based solely on the most relevant and reliable single document, avoiding noise interference from multiple documents.
[0111] After identifying the target document, the original intent of the current round of questions is deeply integrated with the specific facts, entities, or clues extracted from the target document. The large language model can analyze the target document and identify the specific content that can fill the information gaps in the current round of questions, i.e., the key phrases that were previously obscured or unclear.
[0112] Based on the completed information chain, the large language model generates the next round of questions. This new question is no longer a repetition of the original question, but an evolved query that incorporates key evidence from the target document, pointing to deeper reasoning or the final answer. If the target document already contains the final answer, the generated next round of questions will be a self-contained query that meets the termination condition; if further reasoning is needed, the question will carry newly discovered entities pointing to the next retrieval target. In the specific implementation, the system constructs a prompt instruction from the full text of the target document, the text of the current round of questions, and the masked key phrases, and inputs it into the large language model. During this process, the large language model first performs retrieval and reasoning in the target document, locating specific entity words, attribute values, or factual descriptions that can explain or replace the masked key phrases. Then, it uses the located specific content to perform in-situ replacement or semantic expansion of the masked key phrases in the current round of questions, thereby eliminating the information gaps in the original question. Finally, it outputs a semantically complete and clearly referential string as the next round of questions. This next round of questions no longer contains masked markers but directly carries specific information mined from the target document, used to initiate deeper queries.
[0113] In some implementations, the prompt words can be set as follows: Next round of questions There should be an intermediate entity or intermediate attribute (e.g., deriving "author-place of birth" from "work-author"). Instead of reiterating all the conditions of the current round of Qt problems, highlight the unresolved gaps; It should be searchable natural language questions or keyword combinations as much as possible.
[0114] This application significantly improves the evolution quality and retrieval accuracy of query intent in multi-turn dialogues by constructing a collaborative technical mechanism that combines pairwise relevance probability discrimination with targeted completion based on occluded key phrases. First, a large language model is used to perform fine-grained pairwise semantic matching between the current round question and the candidate document set, outputting quantified relevance probability values. This discrimination method overcomes the limitation of traditional keyword matching in capturing deep semantic relationships, ensuring accurate identification of target documents containing answer clues from noisy data. Using this high-confidence target document as a knowledge source, entity extraction and semantic filling are specifically performed on occluded key phrases in the current round question. This process essentially transforms the potential answers obtained from the previous round of retrieval into definite conditions for the next round of querying, achieving a logical leap from vague placeholders to specific referents. Therefore, the generated next round of questions not only eliminates the information uncertainty in the original questions, but also naturally carries verified contextual constraints. This allows the subsequent retrieval process to focus directly on deeper logical reasoning or attribute verification instead of blindly filtering through a large number of documents. This effectively reduces redundant rounds of multi-round dialogues, lowers the retrieval failure rate caused by intent drift, and ultimately achieves a dual improvement in question-answering accuracy and system response efficiency in complex task scenarios.
[0115] In some embodiments, the two-hop problem is taken as an example.
[0116] Assuming user problem The question is: "What is the name of the famous bridge in the birthplace of the composer of a certain musical work X?" This question contains a multi-condition link of "work - composer - birthplace - bridge".
[0117] In the first round, candidate phrases might contain "X," "composer," "birthplace," "bridge," etc. Masked phrases such as "bridge" or "birthplace" were detected. The search engine then... The occluded phrase search yields new documents containing "composer's birthplace". The LLM then generates the next round of queries based on these new documents. "Where was the composer born?" or "Which city was the composer born in?"
[0118] The second round of retrieval retrieves the birthplace city information. LLM is then regenerated. The system asks, "What is the name of the city's most famous bridge?" and classifies it as a single-hop question. After a final retrieval, the final answer is generated. In this process, the explicit introduction of masked phrases prevents the model from being influenced by relevant but irrelevant background information in the first round, thus reducing error accumulation.
[0119] This application is applicable to both open-domain retrieval (Web indexes, encyclopedias) and enterprise private domain knowledge bases (policy documents, work orders, R&D documents). In multimodal or structured data scenarios, the masked key phrases can also be structured field values (such as product models, clause numbers), and the retrieval module can be expanded into a combination of structured filtering and vector retrieval. For LLMs of different sizes and different search engines, the masking detection and retrieval-generation closed loop of this application can be deployed independently and can be adapted and optimized through the parameters required by this application.
[0120] The following describes an apparatus embodiment of this application, which can be used to perform the method embodiment of this application. For details not disclosed in the apparatus embodiment of this application, please refer to the method embodiment of this application.
[0121] Figure 4 A block diagram of a multi-hop inference device based on occlusion knowledge activation provided in an embodiment of this application. Figure 4 As shown, the multi-hop reasoning device 400 based on occlusion knowledge activation includes a phrase detection module 401, a document set retrieval module 402, a question generation module 403, and an answer generation module 404.
[0122] The phrase detection module 401 is used to determine the candidate key phrase set for the current round of query from the user's initial query information using a preset natural language processing library, and to detect the masked key phrases in the candidate key phrase set. The document set retrieval module 402 is used to retrieve a candidate document set from the retrieval database based on retrieval conditions and using a dense retrieval tool trained by fine-grained contrastive learning. The retrieval conditions include the current round question and the masked key phrases corresponding to the current round query. The question generation module 403 is used to determine the target document from the candidate document set, and generate the next round question corresponding to the next round query based on the occluded key phrases, the current round question and the target document using a large language model; The answer generation module 404 is used to determine the final answer based on the initial query information, the next round of questions, and the preset single-hop termination conditions.
[0123] Optionally, the language processing library includes the Spacy framework, which has pre-configured key phrase masking; wherein, the phrase detection module 401 is specifically used for: The initial query information is input into the Spacy framework to determine the clean key phrases obtained after removing stop words; Input clean key phrases into the Spacy framework to output a set of candidate key phrases; Detect masked key phrases in the candidate key phrase set.
[0124] Optionally, when detecting masked key phrases in the candidate key phrase set, the phrase detection module 401 is specifically used for: The Gaussian perturbation mechanism is used to measure the impact of each candidate key phrase in the candidate key phrase set on the output distribution of the large language model in order to determine the similarity. The candidate key phrase with the highest similarity was identified as the masked key phrase.
[0125] Optionally, the phrase detection module 401, in determining similarity by measuring the impact of each candidate key phrase in the candidate key phrase set on the output distribution of the large language model using a Gaussian perturbation mechanism, is specifically used for: Construct a binary mask corresponding to the candidate key phrase set. Gaussian noise is injected into the lexical embedding positions corresponding to the binary mask in the candidate key phrase set to determine the perturbed input embedding representation. The original input embedding representation and the perturbed input embedding representation are respectively input into the large language model to determine the original output distribution and the perturbed output distribution; The original output distribution and the perturbation output distribution are subjected to average pooling in the time dimension to determine the original vector and the perturbation vector; Calculate the cosine similarity between the original vector and the perturbation vector, and identify the candidate key phrase with the highest cosine similarity as the masked key phrase.
[0126] Optionally, the answer generation module 404 is specifically used for: Determine whether the next round of questions meets the single-jump termination condition; If the next round of questions does not meet the single-hop termination condition, the next round of questions will be used as the new current round of questions for inference iteration. If the single-hop termination condition is met in the next round of problems, the iteration will terminate after performing the last round of retrieval. The target document and initial query information are obtained during the iteration process, and then input into the large language model to generate the final answer.
[0127] Optionally, the answer generation module 404, when determining whether the next round of questions meets the single-hop termination condition, is specifically used for: The next round of questions is input into the large language model so that the large language model can determine whether the next round of questions is a single-hop query. If the result of the judgment is a single-hop query, then the single-hop termination condition is met. If the result is a non-single-hop query and the preset maximum number of iterations has not been reached, then the single-hop termination condition is not met. If the preset maximum number of iterations is reached, then the single-hop termination condition will be forcibly met.
[0128] Optionally, the multi-hop inference device 400 based on occlusion knowledge activation also includes a dense retrieval training module 405, used for: Construct a training sample set, which includes positive sample documents, semi-positive sample documents, and negative sample documents. Positive sample documents are related to both the question and the occluded key phrases. Semi-positive sample documents are related to the question but not directly related to the occluded key phrases. Negative sample documents are not related to either the question or the occluded key phrases. Based on the training sample set, the retrieval engine is trained using a fine-grained contrastive learning loss function to generate a trained dense retrieval engine. The fine-grained contrastive learning loss function includes a first loss term, a second loss term, and a total loss term. The first loss term is used to maximize the ratio of the retrieval score of positive sample documents to the sum of the retrieval scores of half-positive sample documents and negative sample documents. The second loss term is used to maximize the ratio of the sum of the retrieval scores of positive sample documents and half-positive sample documents to the sum of the retrieval scores of negative sample documents. The total loss term is the weighted sum of the first loss term and the second loss term.
[0129] Optionally, the document collection retrieval module 402 is specifically used for: The current round question is concatenated or merged with the obscured key phrases to generate a retrieval input vector; Based on the search criteria, a dense searcher is used to calculate the similarity between the search input vector and the document vectors in the search database, so as to determine the set of candidate documents with the highest similarity as a preset number of documents.
[0130] Optionally, the problem generation module 403 is specifically used for: The current round question is paired with each candidate document in the candidate document set and input into the large language model to output the relevance judgment result between each candidate document and the current round question, where the judgment result is a probability value of yes or no. The candidate document with the highest probability value is selected as the target document; Based on the target document and the hidden key phrases, the information in the current round of queries is completed to generate the next round of questions.
[0131] The device performs functions similar to those described above; other functions are described in the preceding descriptions and will not be repeated here.
[0132] Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 5 As shown, the electronic device 500 of this embodiment may include a memory 501 and a processor 502.
[0133] The memory 501 stores a computer program, which, when executed by the processor 502, causes the processor 502 to perform the method described in the above embodiments.
[0134] The processor 502 and the memory 501 are connected, for example, via a bus.
[0135] Optionally, the electronic device 500 may also include a transceiver. It should be noted that in practical applications, the transceiver is not limited to one, and the structure of the electronic device 500 does not constitute a limitation on the embodiments of this application.
[0136] Processor 502 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital 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 can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 502 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0137] A bus can include a pathway for transmitting information between the aforementioned components. The bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one thick line is used in the diagram, but this does not imply that there is only one bus or one type of bus.
[0138] The memory 501 can be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD. ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed discs, laser discs, optical discs, digital universal discs, Blu-ray discs, etc.), disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0139] The memory 501 is used to store application code that executes the solution of this application, and its execution is controlled by the processor 502. The processor 502 is used to execute the application code stored in the memory 501 to implement the content shown in the foregoing method embodiments.
[0140] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Servers can also be included. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0141] The electronic device in this embodiment can be used to execute the method of any of the above embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0142] This application also provides a non-transitory computer-readable storage medium storing computer-readable instructions thereon, which, when executed by a processor, cause the processor to perform the method as described in the above embodiments.
[0143] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a non-transitory computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0144] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. Furthermore, any changes or modifications made by those skilled in the art based on the ideas of this application, and on the specific implementation methods and application scope of this application, are all within the scope of protection of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A multi-hop reasoning method based on occlusion knowledge activation, characterized in that, include: Using a pre-defined natural language processing library, a set of candidate key phrases for the current round of query is determined from the user's initial query information, and masked key phrases in the set of candidate key phrases are detected. Based on the search criteria, a dense search engine trained with fine-grained contrastive learning is used to retrieve a set of candidate documents from the search database. The search criteria include the current round question corresponding to the current round query and the masked key phrase. The target document is determined from the candidate document set, and based on the occluded key phrase, the current round question, and the target document, the next round question corresponding to the next round query is generated using a large language model; Based on the initial query information, the next round of questions, and the preset single-hop termination condition, the final answer is determined.
2. The method according to claim 1, characterized in that, The natural language processing library includes the Spacy framework, which has pre-configured key phrase masking. The step of using a preset natural language processing library to determine the candidate key phrase set for the current round of query from the user's initial query information, and detecting masked key phrases in the candidate key phrase set, includes: The initial query information is input into the Spacy framework to determine the clean key phrases obtained after removing stop words; The clean key phrases are input into the Spacy framework to output the set of candidate key phrases; Detect the masked key phrases in the candidate key phrase set.
3. The method according to claim 2, characterized in that, The detection of the masked key phrases in the candidate key phrase set includes: The Gaussian perturbation mechanism is used to measure the influence of each candidate key phrase in the candidate key phrase set on the output distribution of the large language model in order to determine the similarity. The candidate key phrase with the highest similarity is identified as the masked key phrase.
4. The method according to claim 3, characterized in that, The method of using a Gaussian perturbation mechanism to measure the influence of each candidate key phrase in the candidate key phrase set on the output distribution of the large language model to determine similarity includes: Construct a binary mask corresponding to the candidate key phrase set. Gaussian noise is injected into the lexical embedding position corresponding to the binary mask in the candidate key phrase set to determine the perturbed input embedding representation; The original input embedding representation and the perturbed input embedding representation are respectively input into the large language model to determine the original output distribution and the perturbed output distribution; The original output distribution and the perturbation output distribution are subjected to average pooling in the time dimension to determine the original vector and the perturbation vector; Calculate the cosine similarity between the original vector and the perturbation vector, and determine the candidate key phrase with the highest cosine similarity as the masked key phrase.
5. The method according to claim 1, characterized in that, The process of determining the final answer based on the initial query information, the next round of questions, and the preset single-hop termination condition includes: Determine whether the next round of questions satisfies the single-hop termination condition; If the next round question does not meet the single-hop termination condition, the next round question is used as the new current round question for inference iteration. If the next round of questions satisfies the single-hop termination condition, the iteration terminates after performing the last round of retrieval; The target document and the initial query information are obtained during the iteration process, and the target document and the initial query information are input into the large language model to generate the final answer.
6. The method according to claim 5, characterized in that, The step of determining whether the next round of questions meets the single-hop termination condition includes: The next round question is input into the large language model so that the large language model can determine whether the next round question is a single-hop query. If the result is a single-hop query, then the single-hop termination condition is satisfied. If the result is a non-single-hop query and the preset maximum number of iterations has not been reached, then the single-hop termination condition is not met. If the preset maximum number of iterations is reached, then the single-hop termination condition will be forcibly satisfied.
7. The method according to claim 1, characterized in that, Also includes: Construct a training sample set, wherein the training sample set includes positive sample documents, semi-positive sample documents and negative sample documents, the positive sample documents are related to both the question and the occluded key phrases, the semi-positive sample documents are related to the question but not directly related to the occluded key phrases, and the negative sample documents are not related to either the question or the occluded key phrases. Based on the training sample set, the retrieval engine is trained using a fine-grained contrastive learning loss function to generate the dense retrieval engine. The fine-grained contrastive learning loss function includes a first loss term, a second loss term, and a total loss term. The first loss term is used to maximize the ratio of the retrieval score of positive sample documents to the sum of the retrieval scores of half-positive sample documents and negative sample documents. The second loss term is used to maximize the ratio of the sum of the retrieval scores of positive sample documents and half-positive sample documents to the sum of the retrieval scores of negative sample documents. The total loss term is the weighted sum of the first loss term and the second loss term.
8. The method according to claim 1, characterized in that, The process, based on search criteria, utilizes a dense search engine trained through fine-grained contrastive learning to retrieve a set of candidate documents from the search database, including: The current round question is concatenated or fused with the occluded key phrase to generate a retrieval input vector; Based on the search criteria, the dense searcher is used to calculate the similarity between the search input vector and each of the multiple document vectors in the search database, so as to determine the preset number of documents with the highest similarity as the candidate document set.
9. The method according to claim 1, characterized in that, The step of determining the target document from the candidate document set and generating the next round question for the next round query based on the occluded key phrase, the current round question, and the target document using a large language model includes: The current round question is paired with each candidate document in the candidate document set and input into the large language model to output the relevance judgment result between each candidate document and the current round question, wherein the judgment result is a probability value of yes or no; The candidate document with the highest probability value is determined as the target document; Based on the target document and the obscured key phrases, the information in the current round of queries is completed to generate the next round of questions.
10. A multi-hop reasoning device based on occlusion knowledge activation, characterized in that, include: The phrase detection module is used to determine the candidate key phrase set for the current round of query from the user's initial query information using a preset natural language processing library, and to detect the masked key phrases in the candidate key phrase set. The document set retrieval module is used to retrieve a candidate document set from the retrieval database based on retrieval conditions and using a dense retrieval tool trained through fine-grained contrastive learning. The retrieval conditions include the current round question corresponding to the current round query and the masked key phrase. The question generation module is used to determine the target document from the candidate document set, and generate the next round question corresponding to the next round query based on the occluded key phrase, the current round question and the target document using a large language model; The answer generation module is used to determine the final answer based on the initial query information, the next round of questions, and the preset single-hop termination condition.
Citation Information
Patent Citations
Intelligent question answering method, device and equipment based on multiple systems
CN114610845A
Text multi-hop reasoning question and answer method using two-stage retrieval
CN116383347A
Power grid equipment intelligent question and answer optimization method and system based on large language model
CN120197708A
Retrieval-augmented language model pre-training and fine-tuning
US11003865B1