A context generation method, a retrieval method, apparatuses, devices, and media

By decomposing the multi-hop problem and querying the state conditions, and dynamically adjusting the evidence selection, the problems of inaccurate evidence selection and computational delay in multi-hop question answering are solved, and more efficient evidence screening and answer generation are achieved.

CN123030723APending Publication Date: 2026-11-03HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611294606.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-25
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing multi-hop question-answering technology struggles to adjust subsequent evidence selection based on acquired information during the evidence selection process, resulting in relevant evidence not being effectively discovered, and the intermediate reasoning process increases computational latency.

Method used

By decomposing the multi-hop problem, generating state condition queries, evaluating the relevance of candidate paragraphs based on the queries, extracting original text evidence sentences, and sorting and constructing evidence trajectories according to reasoning dependencies, the evidence selection process is dynamically adjusted.

Benefits of technology

It improves the accuracy of evidence screening, reduces computational latency, and increases the efficiency of multi-hop question answering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123030723A_ABST
    Figure CN123030723A_ABST
Patent Text Reader

Abstract

The application discloses a context generation method, a retrieval method, devices, equipment and media, and is applied to the field of artificial intelligence and natural language processing, and comprises the following steps: obtaining a multi-hop question to be answered and a corresponding candidate paragraph set; decomposing the multi-hop question to obtain a sub-question sequence arranged according to reasoning dependency; the first reasoning hop takes a target sub-question as a state condition query, and the non-first reasoning hop generates a state condition query in combination with a previous sub-question, a previous original evidence state and the target sub-question; evaluating the candidate paragraph according to the state condition query, extracting an original evidence sentence to form a current original evidence state; sorting a target candidate paragraph according to the reasoning dependency and constructing an evidence track, and combining the target candidate paragraph with the multi-hop question to obtain a question and answer context. The application can dynamically adjust subsequent evidence selection based on previous original evidence, reduce repeated evidence and intermediate reasoning generation, and improve evidence effectiveness and context generation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and natural language processing, and in particular to a context generation method, a retrieval method, an apparatus, a device, and a medium. Background Technology

[0002] Multi-hop question answering requires extracting interdependent information from multiple candidate paragraphs to answer complex questions. Existing multi-hop question answering technologies typically evaluate candidate paragraphs based on the initial question during evidence selection, making it difficult to adjust subsequent evidence selection based on already acquired information. This results in some relevant evidence not being effectively discovered, or the evidentiary relationships between different reasoning steps not being fully reflected. Furthermore, when the number of candidate paragraphs is large, redundant information and the paragraph order can also affect the validity of the evidence. Some methods assist evidence selection by generating intermediate reasoning processes, but this adds extra computation, impacting system processing efficiency.

[0003] Therefore, how to improve the effectiveness of evidence selection and reduce latency to increase efficiency in multi-hop question answering is a technical problem that urgently needs to be solved. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a context generation method, a retrieval method, an apparatus, a device, and a medium to solve the problems in the prior art where the selection of evidence for multi-hop question answering is difficult to dynamically adjust with the reasoning state, the evidence validity is low, and the intermediate reasoning generation increases the processing latency.

[0005] To address the aforementioned technical problems, this invention provides a context generation method, comprising: Obtain the multi-hop questions to be answered and the set of candidate paragraphs corresponding to the multi-hop questions; The multi-hop problem is decomposed to obtain a sequence of sub-problems arranged according to reasoning dependencies, and the target sub-problem corresponding to the current reasoning hop is determined based on the sub-problem sequence. When the current inference jump is the first inference jump, the target subproblem is used as a state condition query. When the current inference jump is not the first inference jump, a state condition query is generated based on the sub-problem corresponding to the previous inference jump, the original evidence status corresponding to the previous inference jump, and the target sub-problem. Based on the state condition query, the relevance of the candidate paragraphs in the candidate paragraph set is evaluated, and the target candidate paragraph corresponding to the current inference jump is determined based on the evaluation results; Extract the original text evidence sentence from the target candidate paragraph, and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence; Based on the dependencies between the sub-problems corresponding to each inference jump, the target candidate paragraphs corresponding to each inference jump are sorted, and the evidence trajectory is constructed based on the original text evidence status corresponding to each inference jump. The sorted target candidate paragraphs, the evidence trajectory, and the multi-hop question are combined to obtain the question-answering context.

[0006] Optionally, the multi-hop problem is decomposed to obtain a sequence of sub-problems arranged according to reasoning dependencies, including: The multi-hop problem is input into the problem decomposition model, and the problem decomposition model is called to generate multiple sub-problems at once; The unrewritten multi-hop problem is identified as the last sub-problem in the sub-problem sequence, and the remaining sub-problems are identified as the intermediate information requirements for solving the multi-hop problem. Based on the relationship that the evidence corresponding to the previous subproblem can help solve the subsequent subproblem, the order of the subproblems is determined, and the subproblem sequence is obtained.

[0007] Optionally, the relevance evaluation of candidate paragraphs in the candidate paragraph set is performed based on the state condition query, including: Obtain the query word attention value of the state condition query for each word in each candidate paragraph; Under the same candidate paragraph and the same attention mask, obtain the baseline lexical attention value of the content-independent query for each lexical in each candidate paragraph, wherein the content-independent query does not contain information about the multi-hop problem; Based on the difference between the query word attention value and the corresponding baseline word attention value, the calibration attention value of each word is obtained; Based on the calibrated attention values ​​of each word in each candidate paragraph, determine the mean attention and standard deviation of attention for the corresponding candidate paragraph. A dynamic screening threshold is determined based on the mean attention value, the standard deviation of attention value, and a preset threshold coefficient. The calibrated attention values ​​that meet the dynamic screening threshold are aggregated to obtain the relevance score of the corresponding candidate paragraph. The candidate paragraphs are sorted according to the relevance score, and the target candidate paragraph is determined based on the sorting result.

[0008] Optionally, extract original text evidence sentences from the target candidate paragraphs, and generate the original text evidence state corresponding to the current inference jump based on the original text evidence sentences, including: Based on the character offset or word offset generated by the word segmentation process, each original sentence in the target candidate paragraph is mapped to the corresponding word position; Based on the word positions corresponding to each original sentence, the calibration attention values ​​that meet the dynamic screening threshold in the original sentences are aggregated to obtain the evidence relevance score of each original sentence. The original sentences are ranked according to the evidence relevance score, and the original sentences are selected from the ranking results; The selected original sentences are copied from the original text of the target candidate paragraphs, and the copied original sentences are combined according to the order of the relevance scores of each target candidate paragraph to obtain the original text evidence status.

[0009] Optionally, based on the dependencies between the sub-problems corresponding to each inference jump, the target candidate paragraphs corresponding to each inference jump are sorted, and an evidence trajectory is constructed based on the original text evidence status corresponding to each inference jump, including: For each intermediate inference jump, the corresponding target candidate paragraphs are arranged according to the relevance score to obtain the ordered paragraph batches corresponding to each intermediate inference jump. For the last inference jump, the candidate paragraphs that were not selected by each intermediate inference jump are arranged according to the relevance score to obtain the remaining paragraph sequence; The remaining paragraph sequence and each ordered paragraph batch are sorted in reverse order, and then combined according to the order of the remaining paragraph sequence and the ordered paragraph batch corresponding to the last intermediate reasoning jump to the first intermediate reasoning jump to obtain the sorted target candidate paragraphs. The sub-problems corresponding to each reasoning jump are paired with the original evidence state to obtain the corresponding evidence trajectory units; The evidence trajectory is obtained by combining the evidence trajectory units according to the order from the last reasoning jump to the first reasoning jump.

[0010] Optional, also includes: Lexicalization and encoding are performed on the candidate paragraphs in the candidate paragraph set to obtain the key-value representations corresponding to each candidate paragraph; The key-value representations corresponding to each candidate paragraph are written into key-value cache blocks with fixed positions, and the key-value cache blocks are reused in different inference jumps; Candidate state identifiers and block-level attention masks are set based on the candidate paragraphs participating in the current inference jump, so that the state condition query accesses the corresponding key-value cache block; The candidate state identifier and the block-level attention mask are updated according to the target candidate paragraph corresponding to the current inference jump, so as to exclude the key-value cache block corresponding to the target candidate paragraph in other inference jumps, while keeping the position of each key-value cache block unchanged.

[0011] The present invention also provides a retrieval method, comprising: Obtain the user-inputted question and the corresponding set of candidate information; Using the aforementioned context generation method, a question-answering context is generated based on the question and the candidate information set; The search results corresponding to the question are obtained based on the question-and-answer context.

[0012] The present invention also provides a context generation apparatus, comprising: The acquisition module is used to acquire the multi-hop questions to be answered and the candidate paragraph set corresponding to the multi-hop questions; The decomposition module is used to decompose the multi-hop problem into a sequence of sub-problems arranged according to reasoning dependencies, and to determine the target sub-problem corresponding to the current reasoning hop based on the sub-problem sequence. The state condition query generation module is used to use the target sub-problem as the state condition query when the current inference jump is the first inference jump; and to generate the state condition query based on the sub-problem corresponding to the previous inference jump, the original evidence state corresponding to the previous inference jump, and the target sub-problem when the current inference jump is not the first inference jump. The target paragraph determination module is used to perform relevance evaluation on candidate paragraphs in the candidate paragraph set according to the state conditions, and determine the target candidate paragraph corresponding to the current inference jump based on the evaluation results; The original text evidence state generation module is used to extract the original text evidence sentence from the target candidate paragraph and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence; The evidence trajectory construction module is used to sort the target candidate paragraphs corresponding to each inference jump according to the dependency relationship between the sub-problems corresponding to each inference jump, and construct the evidence trajectory according to the original text evidence status corresponding to each inference jump. The combination module is used to combine the sorted target candidate paragraphs, the evidence trajectory, and the multi-hop question to obtain the question-answering context.

[0013] The present invention also provides a retrieval device, comprising: The information acquisition module is used to acquire the question input by the user and a set of candidate information corresponding to the question; The generation module is used to generate a question-answering context based on the question and the candidate information set using the context generation method described above. The retrieval module is used to obtain retrieval results corresponding to the question based on the question-and-answer context.

[0014] The present invention also provides an electronic device, comprising: Memory, used to store computer programs; A processor for implementing the context generation method and / or retrieval method as described above when executing the computer program.

[0015] The present invention also provides a computer-readable storage medium storing computer-executable instructions, which, when loaded and executed by a processor, implement the context generation method and / or retrieval method as described above.

[0016] The present invention also provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the context generation method and / or retrieval method steps as described above.

[0017] As can be seen from the above technical solution, the present invention obtains the multi-hop question to be answered and the candidate paragraph set corresponding to the multi-hop question; decomposes the multi-hop question to obtain a sequence of sub-questions arranged according to reasoning dependencies, and determines the target sub-question corresponding to the current reasoning hop based on the sub-question sequence; when the current reasoning hop is the first reasoning hop, the target sub-question is used as a state condition query; when the current reasoning hop is not the first reasoning hop, a state condition query is generated based on the sub-question corresponding to the previous reasoning hop, the original text evidence state corresponding to the previous reasoning hop, and the target sub-question; the relevance of the candidate paragraphs in the candidate paragraph set is evaluated based on the state condition query, and the target candidate paragraph corresponding to the current reasoning hop is determined based on the evaluation result; the original text evidence sentence is extracted from the target candidate paragraph, and the original text evidence state corresponding to the current reasoning hop is generated based on the original text evidence sentence; the target candidate paragraphs corresponding to each reasoning hop are sorted according to the dependencies between the sub-questions corresponding to each reasoning hop, and an evidence trajectory is constructed based on the original text evidence state corresponding to each reasoning hop; the sorted target candidate paragraphs, evidence trajectory, and multi-hop question are combined to obtain the question-answering context.

[0018] The beneficial effects of this invention are as follows: By integrating the original text evidence state corresponding to the previous reasoning jump into the construction process of the current state condition query, the relevance evaluation of candidate paragraphs can be dynamically adjusted according to the obtained information state, thereby identifying complementary paragraphs connected with the preceding evidence in subsequent reasoning jumps, avoiding the omission or repeated selection of valid evidence caused by static evaluation methods, and improving the accuracy of evidence screening in multi-hop question answering; the original text evidence sentences are directly extracted from the target candidate paragraphs as reasoning states, and the target candidate paragraphs are sorted and evidence trajectories are constructed according to the dependency relationship between each reasoning jump, so that the evidence information obtained at different reasoning stages can be combined according to the correlation relationship; since the information transmission in the reasoning process is realized by using the original text evidence state, there is no need to generate intermediate reasoning text in each reasoning jump, reducing the additional calculation process and improving the efficiency of context generation.

[0019] In addition, the present invention also provides a retrieval method, a context generation device, a retrieval device, an apparatus, and a medium, which also have the above-mentioned beneficial effects. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0021] Figure 1 A flowchart of a context generation method provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a problem decomposition method provided in an embodiment of the present invention; Figure 3 A flowchart illustrating a progressive conditional evidence highlighting process provided in an embodiment of the present invention; Figure 4 A flowchart illustrating the process of relying on alignment evidence sorting and evidence trajectory injection is provided in this embodiment of the invention. Figure 5 A flowchart illustrating a context generation method provided in an embodiment of the present invention; Figure 6 A flowchart of a retrieval method provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of the structure of a context generation device provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of a retrieval device provided in an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] Multi-hop question answering requires computers to find interdependent facts from multiple candidate paragraphs. For example, the first paragraph provides an intermediate entity, the second paragraph describes the entity's attributes, and subsequent paragraphs provide the information needed to form the final answer. Even if all supporting evidence is contained in the input context, large language models may still fail to connect these facts correctly due to scattered evidence, numerous interfering paragraphs, or paragraph order that is unfavorable to reasoning. Existing multi-hop question answering techniques struggle to balance the adaptability of evidence selection with system efficiency. For example, static reordering always uses the original question to evaluate candidate paragraphs and cannot utilize the obtained bridging entities or intermediate facts to adjust subsequent evidence selection, easily leading to repeated selection of similar paragraphs or omission of complementary evidence; while direct long-context question answering, although containing all supporting evidence, may still result in large language models failing to correctly utilize and combine evidence due to positional bias, interfering information, and unreasonable paragraph order; although generative intermediate reasoning can dynamically update retrieval requirements, it requires multiple rounds of autoregressive decoding, significantly increasing end-to-end latency and computational overhead. Therefore, to address the problems in long-context multi-hop question answering such as the inability of evidence scores to dynamically update with the reasoning state, the high computational overhead caused by repeatedly generating intermediate reasoning, the repeated selection of the same paragraphs across hops, and unreasonable evidence combination order. This invention provides a multi-hop question-and-answer evidence combination method that is training-independent and does not require hop-by-hop generation of intermediate inference text. It uses key sentences from the original text in the selected paragraph as traceable dynamic evidence states to guide the selection of subsequent complementary evidence, and collaboratively combines complete paragraphs and fine-grained evidence according to inference dependencies. This improves evidence utilization, answer accuracy, and the rationality of evidence order while reducing end-to-end inference latency.

[0024] Please refer to the details. Figure 1 , Figure 1 A flowchart illustrating a context generation method provided in an embodiment of the present invention. The method may include: S101, obtain the multi-hop questions to be answered and the set of candidate paragraphs corresponding to the multi-hop questions.

[0025] The context generation method in this embodiment can be executed by a server, personal computer, or other electronic devices with data processing capabilities. This method can be used in retrieval-enhanced generation systems and complex reasoning systems. By dynamically adjusting the selection of subsequent evidence using prior evidence, combining the order of evidence dependencies, and reducing repetitive intermediate reasoning generation, it improves the reasoning accuracy, evidence utilization efficiency, and response speed of large language models. It can also be applied to agent memory modules, performing step-by-step retrieval, relevance reordering, key memory extraction, and structured injection of the agent's long-term memory, task records, historical interactions, and external knowledge. This provides the agent with a memory context that matches its current state for task planning, continuous decision-making, tool invocation, and multi-turn interactions.

[0026] Multi-hop problems are those that require combining multiple interdependent facts to arrive at an answer. For example, a preceding candidate paragraph is used to identify an intermediate entity, while a subsequent candidate paragraph is used to determine the attributes or relationships of that intermediate entity. The set of candidate paragraphs provides candidate evidence information relevant to the multi-hop problem. Let the multi-hop problem to be answered be q, and the set of candidate paragraphs corresponding to this problem can be represented as... Among them, d i Let represent the i-th candidate paragraph, which can come from multiple candidate documents; N represents the number of candidate paragraphs. Each candidate paragraph can retain its corresponding document identifier, paragraph identifier, original text content, and position in the original document, so that the subsequently extracted original text evidence can be traced back to the original document. In one implementation, the multi-hop problem, candidate paragraphs, sub-problems, original text evidence sentences, paragraph ranking results, and attention scores can be stored in computer memory in the form of text data, terminology data, index data, attention weight data, or cached data, respectively.

[0027] S102, decompose the multi-hop problem to obtain a sequence of sub-problems arranged according to reasoning dependencies, and determine the target sub-problem corresponding to the current reasoning hop based on the sub-problem sequence.

[0028] This step is used to predetermine the reasoning dependency structure of multi-hop problems, enabling subsequent evidence selection to be performed hop-by-hop according to the needs of each intermediate information. Specifically, the multi-hop problem is decomposed once, and then the target sub-problems corresponding to each reasoning hop are determined sequentially according to the order of the sub-problem sequence. The problem decomposition process is used to obtain sub-problems and their execution order, but does not generate sub-problem answers, hop-by-hop thought chains, or other intermediate reasoning text.

[0029] Furthermore, the above-mentioned decomposition of the multi-hop problem into a sequence of sub-problems arranged according to reasoning dependencies can specifically include: inputting the multi-hop problem into a problem decomposition model, calling the problem decomposition model to generate multiple sub-problems at once; identifying the unrewritten multi-hop problem as the last sub-problem in the sub-problem sequence, and identifying the remaining sub-problems as the intermediate information requirements for solving the multi-hop problem; determining the order of each sub-problem based on the relationship that the evidence corresponding to the previous sub-problem can help solve the subsequent sub-problem, thus obtaining the sub-problem sequence.

[0030] Please refer to Figure 2 In one implementation, after inputting the multi-hop problem q into the problem decomposition model, the problem decomposition model generates a sequence of sub-problems arranged according to reasoning dependencies. Where Q represents the result of problem decomposition, i.e., the sequence of subproblems; q i Let q represent the subproblem corresponding to the i-th reasoning hop, H represent the number of reasoning hops required to complete the multi-hop problem, and q represent the last subproblem in the subproblem sequence. HKeep it as an unrewritten multi-hop problem q. q1 to q H-1 This section describes the intermediate information requirements for solving the multi-hop problem, arranged in order that the evidence corresponding to the previous sub-problem can help solve the subsequent sub-problem. It should be noted that the sub-problem sequence is not limited to a chain structure; it may also have a parallel tree structure. Each sub-problem can be a semantically complete natural language question. Using this problem decomposition method, only one problem decomposition is needed to obtain the processing framework required for subsequent hop-by-hop evidence selection, avoiding the repeated generation of new intermediate inference text at each inference hop. In one example, the number of inference hops H does not exceed 5; in other examples, H can be determined based on problem complexity, the number of candidate paragraphs, the maximum context length of the model, or computational resource limitations.

[0031] S103, when the current inference jump is the first inference jump, the target sub-problem is used as the state condition query; when the current inference jump is not the first inference jump, the state condition query is generated based on the sub-problem corresponding to the previous inference jump, the original evidence state corresponding to the previous inference jump, and the target sub-problem.

[0032] State condition queries are used to characterize the evidence requirements of the current reasoning jump. For the first reasoning jump q1, the first target subproblem can be directly used as the state condition query, i.e. For the i-th non-first reasoning jump (2≤i≤H), the previous subproblem q can be processed according to the preset field format. i-1 The original evidence state S of the previous reasoning jump i-1 and the current target subproblem q i By splicing them together, we get Among them, r i This represents the query text actually used for candidate paragraph evaluation in the i-th inference jump, i.e., the state condition query; Concat represents the text field concatenation operation. The original text evidence state S of the previous inference jump. i-1 This can include factual information such as intermediate entities, time, location, quantity, attributes, or relationships. After adding the original evidence status to the current status condition query, the evaluation of candidate paragraphs for the current reasoning jump can change according to the facts already obtained, thereby prioritizing the search for complementary candidate paragraphs that connect with the preceding evidence.

[0033] S104, evaluate the relevance of candidate paragraphs in the candidate paragraph set based on the state condition query, and determine the target candidate paragraph corresponding to the current inference jump based on the evaluation result.

[0034] This step queries the relevance between the candidate paragraphs and the current evidence requirement based on the state conditions of the current inference jump. Relevance evaluation can be achieved using attention signals in the language model, and the target candidate paragraphs for the current inference jump are determined according to the relevance score after evaluation. For intermediate inference jumps, higher-scoring candidate paragraphs can be selected from those not yet chosen by preceding inference jumps; for the last inference jump, the remaining candidate paragraphs can be scored and ranked as a whole.

[0035] Furthermore, the aforementioned relevance evaluation of candidate paragraphs in the candidate paragraph set based on state condition queries can specifically include: obtaining the query term attention value of each term in each candidate paragraph for the state condition query; obtaining the baseline term attention value of each term in each candidate paragraph for the content-independent query under the same candidate paragraph and the same attention mask conditions, wherein the content-independent query does not contain information about multi-hop issues; obtaining the calibration attention value of each term based on the difference between the query term attention value and the corresponding baseline term attention value; determining the mean attention and standard deviation of the attention for the corresponding candidate paragraph based on the calibration attention value of each term in each candidate paragraph; determining a dynamic filtering threshold based on the mean attention, standard deviation attention, and a preset threshold coefficient; aggregating the calibration attention values ​​that meet the dynamic filtering threshold to obtain the relevance score of the corresponding candidate paragraph; sorting each candidate paragraph according to the relevance score; and determining the target candidate paragraph based on the sorting result.

[0036] Please refer to Figure 3 In the i-th inference hop, the state condition query r can be made easier through a block-level attention mask. i Access only the current remaining candidate paragraph pool R i The corresponding key-value cache block. For term t in candidate paragraph d, retrieve the state condition query r. i The corresponding query term attention value a i,t This attention value represents the degree of attention the current query pays to the corresponding paragraph's tokens. It can be used to average or weight and aggregate query tokens, model layers, or attention heads in the language model according to preset methods. Meanwhile, to reduce query irrelevant bias caused by paragraph position, common words, and the inherent attention distribution of the language model, a content-irrelevant query q that does not contain actual question information is set. In one embodiment, q Use fixed text such as "N / A" that does not contain information about the actual problem. Under the same candidate paragraphs and the same attention mask, calculate the content-irrelevant query q. The corresponding attention value, i.e., the baseline lexical attention value Then the calibrated attention value can be expressed as . ã i,t This indicates a query based on the current state conditions for r. ithe actual induced token attention increment, that is, the calibrated attention value. For a candidate paragraph d, the attention mean μ of its calibrated attention values can be calculated i,d and the attention standard deviation σ i,d , and μ i,d -λσ i,d is used as the dynamic filtering threshold, where λ is a preset threshold coefficient or a threshold coefficient determined based on validation data; for example, λ can be 2. That is, the expression of the relevance scoring formula for the candidate paragraph is: . Wherein, s i (d) represents the relevance score of the candidate paragraph d in the i-th reasoning hop; T(d) represents the set of token positions included in the candidate paragraph d; 1[ ] represents a conditional indication operation, which takes the value 1 when the condition is satisfied, and takes the value 0 otherwise. For the intermediate reasoning hop i<H, the K with the highest relevance score can be selected from the current remaining candidate paragraph pool R i candidate paragraphs to form an ordered paragraph batch B d i , and the formula expression is: ; and stored in descending order of the relevance score to obtain , and satisfy . Wherein, K d represents the number of paragraphs selected for each reasoning hop, which can be set according to the total number of candidate paragraphs, the expected number of evidences, or the maximum context length of the model. For the last reasoning hop i=H, the last state condition query can be used to score all candidate paragraphs in the remaining candidate paragraph pool R H , to form a remaining paragraph sequence π arranged according to the relevance score H ; wherein the K candidate paragraphs with the highest score d are used to extract the original text evidence state of the last reasoning hop, but are still retained in π H and will not be removed from the final remaining paragraph sequence. It should be noted that B i and S i are both chain structures. In this embodiment, the attention signal is calibrated by using a content-agnostic query, and the dynamic filtering threshold is determined in combination with the attention distribution of the candidate paragraph itself, which can reduce the attention deviation irrelevant to the actual problem, make the relevance score better reflect the attention change caused by the current state condition query, thereby improving the effectiveness of target candidate paragraph selection.

[0037] ​Furthermore, the above method may further include: lexicalizing and encoding the candidate paragraphs in the candidate paragraph set to obtain the key-value representations corresponding to each candidate paragraph; writing the key-value representations corresponding to each candidate paragraph into key-value cache blocks with fixed positions, and reusing the key-value cache blocks in different inference jumps; setting candidate state identifiers and block-level attention masks according to the candidate paragraphs participating in the current inference jump, so that state condition queries can access the corresponding key-value cache blocks; updating the candidate state identifiers and block-level attention masks according to the target candidate paragraph corresponding to the current inference jump, so as to exclude the key-value cache blocks corresponding to the target candidate paragraphs in other inference jumps, while keeping the positions of each key-value cache block unchanged.

[0038] It should be noted that before hop-by-hop evidence selection, all candidate paragraphs in the candidate paragraph set D are lexicalized and encoded. Specifically, all candidate paragraphs in the candidate paragraph set D can be input into the document encoding part of the language model encoder or the decoding language model, so that each candidate paragraph corresponds to a fixed-position key-value cache block, i.e., a KV cache block, and the remaining candidate paragraph pool R1=D of the first inference hop is initialized. Subsequent inference hops do not actually delete, move, or re-encode the selected candidate paragraphs, but rather update the candidate state flags and block-level attention masks to logically exclude the cache blocks corresponding to the target candidate paragraphs selected by the previous inference hop. For example, in the intermediate inference hop i, an ordered paragraph batch B is selected. i Then, the logic for the remaining candidate paragraph pool can be updated to... And exclude B in the block-level attention mask of the next inference hop. i The corresponding KV cache blocks prevent the same candidate paragraph from appearing repeatedly in the Top-K selection results of multiple inference hops. Selected candidate paragraphs can still be retained in their original positions in the KV cache, ensuring that the positions of each cache block remain unchanged and that the aforementioned encoding results are reused. This embodiment uses fixed-position KV caches, candidate state identifiers, and block-level attention masks to avoid repeatedly encoding long text in different inference hops and to reduce the recurrence of the same candidate paragraph in target candidate paragraphs across multiple inference hops. This reduces the overhead of redundant document computation and improves the utilization rate of evidence within a limited context space.

[0039] S105, extract the original text evidence sentence from the target candidate paragraph, and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence.

[0040] This step is used to extract fine-grained original text evidence from the target candidate paragraph of the current inference jump, which can directly represent the facts that have been obtained. Unlike generative intermediate inference, the original text evidence sentences are directly derived from the original text of the target candidate paragraph, and the corresponding document identifier, paragraph identifier, and sentence position can be retained to form a traceable original text evidence state.

[0041] Further, the step of extracting the original text evidence sentences from the target candidate paragraphs and generating the original text evidence state corresponding to the current reasoning hop according to the original text evidence sentences may specifically include: mapping each original sentence in the target candidate paragraphs to the corresponding token position according to the character offset or token offset generated by word segmentation processing; aggregating the calibrated attention values that meet the dynamic filtering threshold in the original sentences according to the token positions corresponding to each original sentence, to obtain the evidence relevance score of each original sentence; sorting each original sentence according to the evidence relevance scores, and selecting original sentences from the sorting result; copying the selected original sentences from the original text of the target candidate paragraphs, and combining the copied original sentences according to the arrangement order of the relevance scores of each target candidate paragraph, to obtain the original text evidence state.

[0042] Specifically, for the target candidate paragraph d, each natural language sentence u in the paragraph may be mapped to the corresponding token position set T(u) according to the character offset or token offset generated by the tokenizer, and the calibrated attention signal identical to the candidate paragraph score is used to calculate the evidence relevance score of the sentence, and the expression of the evidence relevance score formula of sentence u in the i-th reasoning hop is: . The original sentence with the highest sentence score is extracted from each selected paragraph, that is, the formula expression of the original text evidence sentence selected from the target candidate paragraph d is: . Wherein, Sent(d) represents all sentences contained in the target candidate paragraph d. According to the order of the target candidate paragraph d in B i , the corresponding original sentences are combined into an ordered original text evidence state S i , and the formula expression is: . In a preferred example, one original sentence is extracted from each target candidate paragraph, that is, the number of extracted sentences Ks=1; in other examples, a plurality of original sentences with the highest scores may also be extracted according to the evidence granularity requirement. For i<H, the current sub-question q i , the current original text evidence state S i and the next sub-question q i+1 are serialized according to a fixed field format, so as to construct the state condition query of the next reasoning hop. In this embodiment, the original text evidence state is formed by directly copying the original sentences in the candidate paragraphs, which can highlight the key facts already obtained in the current reasoning hop while retaining the original evidence source, and avoid the additional decoding overhead and the risk of generating false facts caused by generating sub-question answers or thought chains hop by hop.

[0043] S106, sorting the target candidate paragraphs corresponding to each reasoning hop according to the dependency relationship between the sub-questions corresponding to each reasoning hop, and constructing an evidence track according to the original text evidence state corresponding to each reasoning hop.

[0044] This step combines complete candidate paragraphs and fine-grained original text evidence after the evidence selection for each inference jump. The ranking of complete candidate paragraphs is used to adapt their position to the inference dependencies between sub-questions; the evidence trajectory is used to explicitly present the sub-questions and their original text evidence status corresponding to each inference jump, so that the subsequent model can quickly locate key facts.

[0045] Furthermore, the above-mentioned sorting of target candidate paragraphs corresponding to each inference jump based on the dependencies between the sub-problems corresponding to each inference jump, and constructing evidence trajectories based on the original text evidence states corresponding to each inference jump, specifically includes: for each intermediate inference jump, sorting the corresponding target candidate paragraphs according to the relevance score to obtain the ordered paragraph batches corresponding to each intermediate inference jump; for the last inference jump, sorting the candidate paragraphs not selected by each intermediate inference jump according to the relevance score to obtain the remaining paragraph sequence; reversing the order of the remaining paragraph sequence and each ordered paragraph batch, and combining them according to the order of the remaining paragraph sequence, the last intermediate inference jump to the first intermediate inference jump to obtain the sorted target candidate paragraphs; pairing the sub-problems corresponding to each inference jump with the original text evidence states to obtain the corresponding evidence trajectory units; and combining the evidence trajectory units according to the order of the last inference jump to the first inference jump to obtain the evidence trajectory.

[0046] Please refer to Figure 4 Let the ordered paragraph batches corresponding to each intermediate reasoning jump be B1, B2, ..., B H-1 The remaining paragraph sequence formed by the last reasoning jump is π. H For any ordered sequence of paragraphs Define the reverse operation You can follow Construct the complete paragraph block D after dependency alignment ,in This represents a concatenation operation of text or paragraph sequences. In this way, complete paragraphs belonging to different reasoning jumps are grouped according to sub-question dependencies, and their positions within each group are determined based on the paragraph scores within each reasoning jump. Compared to directly using the original order of candidate paragraphs or only sorting for the original questions, this arrangement allows the positional relationships of complete paragraphs to be adapted to the evidentiary dependencies of multi-hop questions.

[0047] Furthermore, complete paragraphs may contain a significant amount of content unrelated to the current question. To enable the answer generation model to directly locate the key facts at each reasoning jump, the evidence trajectory injection unit pairs and serializes each sub-question and its corresponding original text evidence state. Firstly, each sub-question q can be... i Corresponding original evidence state S i Pairing forms evidence trajectory units [q] i Si The evidence trajectory is obtained by combining the evidence in the order of the last reasoning jump to the first reasoning jump. Each evidence trajectory unit includes at least a sub-question field and a source text evidence field, and may also include source document identifiers, paragraph identifiers, and sentence position fields. Since each source text evidence state is composed of source text sentences from candidate paragraphs, the evidence trajectory is used to present the factual evidence that has already been obtained, without needing to include intermediate inference content generated by the language model. Complete paragraph blocks are used to provide complete context, while evidence trajectories are used to highlight fine-grained key facts. The combination of the two can balance contextual completeness, evidence salience, and traceability of evidence sources. This embodiment uses dependency-aligned paragraph sorting, which can avoid unreasonable evidence order caused by only following the original paragraph order or only performing a global sorting for the original question; at the same time, combining sub-questions and source text evidence states into evidence trajectories allows the answer generation model to obtain key facts according to inference dependencies, improving the adaptability of the evidence combination results to the multi-hop inference process.

[0048] S107 combines the sorted target candidate paragraphs, evidence trajectories, and multi-hop questions to obtain the question-answering context.

[0049] In one implementation, the complete paragraph block D formed by sorting the target candidate paragraphs can be... The evidence trajectory τ and the unrewritten multi-hop question q are concatenated sequentially to obtain the question-answering context. Among them, the complete paragraph block D The original paragraph context is provided, the evidence trajectory τ highlights the fine-grained original text evidence corresponding to each reasoning jump, and the multi-hop question q remains unchanged as the final question-and-answer instruction to avoid changing the user's original information needs due to question decomposition. The generated question-and-answer context can be directly input into the answer generation model, which combines the complete paragraph, the original text evidence trajectory, and the multi-hop question to generate the final answer. Except for the one-time sub-question generation in the question decomposition stage and the final answer generation, the above-mentioned jump-by-hop evidence selection process may not generate sub-question answers, thought chains, or other intermediate reasoning text. Candidate paragraph scoring, original text evidence sentence extraction, candidate paragraph pool updating, candidate paragraph sorting, and evidence trajectory construction can be completed through computer operations such as attention data reading, cache access, logical masking, index updating, numerical aggregation, and text concatenation.

[0050] In one deployment approach, the aforementioned context generation process does not require modification of the underlying language model parameters and can be integrated as an independent evidence reordering and context building component into a retrieval enhancement generation system or a complex inference system. The number of inference hops H and the number of candidate paragraphs K selected per inference hop can be configured based on the model's maximum context length and computational budget. d The number of original text evidence sentences extracted from each candidate paragraph, K sIn addition to the dynamic filtering threshold coefficient λ, this scheme also allows for the selection of one or more processing methods, such as dependency alignment evidence ranking and evidence trajectory injection, depending on the specific application. Therefore, this scheme can adapt to different base models, candidate paragraph sizes, and context budgets without requiring additional training models.

[0051] Applying a context generation method provided in this embodiment of the invention, in step S101, a multi-hop question to be answered and a set of candidate paragraphs corresponding to the multi-hop question are obtained; in step S102, the multi-hop question is decomposed to obtain a sequence of sub-questions arranged according to reasoning dependencies, and the target sub-question corresponding to the current reasoning hop is determined based on the sub-question sequence; in step S103, when the current reasoning hop is the first reasoning hop, the target sub-question is used as a state condition query; when the current reasoning hop is not the first reasoning hop, a state condition query is generated based on the sub-question corresponding to the previous reasoning hop, the original text evidence state corresponding to the previous reasoning hop, and the target sub-question; 104. Evaluate the relevance of candidate paragraphs in the candidate paragraph set based on the state condition query, and determine the target candidate paragraph corresponding to the current inference jump based on the evaluation results; S105. Extract the original text evidence sentence from the target candidate paragraph, and generate the original text evidence state corresponding to the current inference jump based on the original text evidence sentence; S106. Sort the target candidate paragraphs corresponding to each inference jump according to the dependency relationship between the sub-questions corresponding to each inference jump, and construct the evidence trajectory based on the original text evidence state corresponding to each inference jump; S107. Combine the sorted target candidate paragraphs, evidence trajectory, and multi-hop questions to obtain the question-answering context. This method integrates the original text evidence state corresponding to the previous reasoning jump into the construction process of the current state condition query, enabling the relevance evaluation of candidate paragraphs to be dynamically adjusted according to the information state obtained. This allows for the identification of complementary paragraphs that connect with previous evidence in subsequent reasoning jumps, avoiding the omission or duplicate selection of valid evidence caused by static evaluation methods, and improving the accuracy of evidence screening in multi-hop question answering. The original text evidence sentences are directly extracted from the target candidate paragraphs as reasoning states, and the target candidate paragraphs are sorted and evidence trajectories are constructed according to the dependencies between each reasoning jump, so that the evidence information obtained at different reasoning stages can be combined according to the correlation. Since the original text evidence state is used to realize the information transmission in the reasoning process, there is no need to generate intermediate reasoning text in each reasoning jump, reducing the additional calculation process and improving the efficiency of context generation.

[0052] For a clearer understanding of this invention, please refer to the following details. Figure 5 , Figure 5 This invention provides an example diagram of a data processing flow for a context generation method, which may specifically include: First, the problem decomposition module takes a multi-hop problem q as input and outputs an ordered sequence of sub-problems in one go. Secondly, the progressive conditional evidence highlighting module takes the sub-problem sequence Q and the candidate paragraph set D as input, encodes the candidate paragraphs once, and establishes a KV cache at a fixed position. In the i-th inference jump, it utilizes the original text evidence state S output by the previous inference jump. i-1 Construct state condition query r i Evaluate the remaining candidate paragraphs and output the ordered paragraph batch B. i and the current state of the original evidence S i and S i Feedback is then passed to the next inference jump. After each inference jump is completed, the progressive conditional evidence highlighting module can output the ordered paragraph batches B1 to B1 corresponding to the intermediate inference jumps. H-1 All reasoning jumps correspond to the original text evidence states S1 to S2. H The remaining paragraph sequence π formed by the last reasoning jump H The output includes the correspondence between sub-problems, target candidate paragraphs, and original text evidence sentences. The dependency alignment evidence sorting and evidence trajectory injection module receives the above output, where B1 to B... H-1 and π H Used to construct a complete paragraph block D S1 to S H After being paired with the subproblem sequence Q, it is used to construct the evidence trajectory τ, and finally D is... τ and the unrewritten multi-hop question q are concatenated into a question-answering context C. Therefore, the state of the original evidence in the previous inference jump can change the evaluation result of the candidate paragraph in the subsequent inference jump, and the final complete paragraph order and evidence trajectory in the context correspond to the inference dependencies between sub-problems. Therefore, this invention has the following beneficial effects: By adding the original text evidence state extracted from the previous inference jump to the query of the next inference jump, the evidence score can be dynamically updated with the entities, facts, and relationships already obtained, thereby discovering complementary evidence that is only relevant after the preceding facts are clear; the inference state is represented by the original text evidence sentence in the candidate paragraph, eliminating the need to call the language model to generate sub-question answers or thought chains in each inference jump, thus reducing the computational latency caused by multiple rounds of autoregressive decoding and reducing the risk of generating erroneous facts in generative intermediate inference; after selecting a paragraph in each intermediate inference jump, the remaining candidate paragraph pool is updated, and the selected paragraphs are excluded by block-level attention masking to prevent the same paragraph from repeatedly occupying limited evidence positions in multiple inference jumps; all candidate paragraphs are encoded only once, and the fixed-position KV cache is reused in subsequent inference jumps, and the changes in the candidate paragraph pool are implemented through logical identifiers and attention masks, avoiding re-encoding long documents in each inference jump; complete paragraphs are sorted by dependency alignment, while highlighting the original text evidence sentences corresponding to each sub-question, taking into account the contextual information of the complete paragraph and the salience of fine-grained evidence, and ensuring that relevant evidence can be traced back to the original document.

[0053] Please refer to Figure 6 , Figure 6 A flowchart illustrating a retrieval method provided in an embodiment of the present invention. The method may include: S201, Obtain the user-inputted question and the set of candidate information corresponding to the question; S202, using the context generation method described above, generate a question-answering context based on the question and the candidate information set; S203, obtain the search results corresponding to the question based on the question-answer context.

[0054] In this embodiment, the candidate information set may include candidate paragraphs, candidate document fragments, knowledge base entries, or other information that can be used to answer the user's input question. The user's input question can be treated as the aforementioned multi-hop question, and the candidate information in the candidate information set can be treated as candidate paragraphs or their corresponding data units. A question-and-answer context is constructed according to the aforementioned context generation method. Subsequently, the question-and-answer context can be input into the retrieval result generation module or the answer generation model to obtain retrieval results corresponding to the user's input question. The retrieval results may include selected and sorted evidence information, or question answers generated based on that evidence information.

[0055] The retrieval method provided in this embodiment of the invention involves the following steps: S201, obtaining the user-inputted question and a set of candidate information corresponding to the question; S202, generating a question-and-answer context based on the question and the set of candidate information using the aforementioned context generation method; and S203, obtaining the retrieval result corresponding to the question based on the question-and-answer context. Since the candidate information in the question-and-answer context can be dynamically selected based on preceding original text evidence and combined according to inference dependencies, the efficiency of utilizing relevant evidence in the retrieval process of complex questions can be improved, and the processing overhead caused by repeated retrieval and intermediate inference generation can be reduced.

[0056] The context generation apparatus provided in the embodiments of the present invention will be described below. The context generation apparatus described below and the context generation method described above can be referred to in correspondence.

[0057] Please refer to the details. Figure 7 , Figure 7 A schematic diagram of a context generation device provided in an embodiment of the present invention may include: The acquisition module 100 is used to acquire the multi-hop question to be answered and the candidate paragraph set corresponding to the multi-hop question; The decomposition module 200 is used to decompose the multi-hop problem to obtain a sequence of sub-problems arranged according to reasoning dependencies, and to determine the target sub-problem corresponding to the current reasoning hop based on the sub-problem sequence. The state condition query generation module 300 is used to use the target sub-problem as the state condition query when the current inference jump is the first inference jump, and to generate the state condition query based on the sub-problem corresponding to the previous inference jump, the original evidence state corresponding to the previous inference jump, and the target sub-problem when the current inference jump is not the first inference jump. The target paragraph determination module 400 is used to perform relevance evaluation on the candidate paragraphs in the candidate paragraph set according to the state condition query, and determine the target candidate paragraph corresponding to the current inference jump according to the evaluation result; The original text evidence state generation module 500 is used to extract the original text evidence sentence from the target candidate paragraph and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence; The evidence trajectory construction module 600 is used to sort the target candidate paragraphs corresponding to each inference jump according to the dependency relationship between the sub-problems corresponding to each inference jump, and construct the evidence trajectory according to the original text evidence status corresponding to each inference jump. The combination module 700 is used to combine the sorted target candidate paragraphs, the evidence trajectory, and the multi-hop question to obtain the question-answering context.

[0058] Furthermore, based on any of the above embodiments, the decomposition module 200 may include: The decomposition unit is used to input the multi-hop problem into the problem decomposition model and call the problem decomposition model to generate multiple sub-problems at one time. The sub-problem determination unit is used to determine the unrewritten multi-hop problem as the last sub-problem in the sub-problem sequence, and to determine the remaining sub-problems as the intermediate information requirements needed to solve the multi-hop problem. The subproblem sequence acquisition unit is used to determine the order of each subproblem based on the relationship that the evidence corresponding to the previous subproblem can help solve the subsequent subproblem, and thus obtain the subproblem sequence.

[0059] Furthermore, based on any of the above embodiments, the target paragraph determination module 400 may include: The query lexical attention value acquisition unit is used to acquire the query lexical attention value of each lexical in each candidate paragraph for the state condition query; The baseline lexical attention value acquisition unit is used to acquire the baseline lexical attention value of each lexical in each candidate paragraph under the same candidate paragraph and the same attention mask, wherein the content-independent query does not contain information about the multi-hop problem; The calibration attention value acquisition unit is used to obtain the calibration attention value of each word based on the difference between the query word attention value and the corresponding benchmark word attention value. The mean and standard deviation determination unit is used to determine the attention mean and attention standard deviation of the corresponding candidate paragraph based on the calibrated attention value of each word in each candidate paragraph; The paragraph scoring unit is used to determine a dynamic screening threshold based on the mean attention, the standard deviation of attention, and a preset threshold coefficient, and to aggregate the calibrated attention values ​​that meet the dynamic screening threshold to obtain the relevance score of the corresponding candidate paragraph. The paragraph sorting unit is used to sort each candidate paragraph according to the relevance score, and to determine the target candidate paragraph based on the sorting result.

[0060] Furthermore, based on any of the above embodiments, the original evidence state generation module 500 may include: The mapping unit is used to map each original sentence in the target candidate paragraph to the corresponding word position based on the character offset or word offset generated by the word segmentation process. The sentence scoring unit is used to aggregate the calibration attention values ​​that meet the dynamic screening threshold in the original sentences according to the word positions corresponding to each original sentence, so as to obtain the evidence relevance score of each original sentence; The sentence sorting unit is used to sort each original sentence according to the evidence relevance score and select original sentences from the sorting results; The combination unit is used to copy selected original sentences from the original text of the target candidate paragraphs, and combine the copied original sentences according to the order of the relevance scores of each target candidate paragraph to obtain the original text evidence state.

[0061] Furthermore, based on any of the above embodiments, the evidence trajectory construction module 600 may include: The paragraph batch acquisition unit is used to sort the corresponding target candidate paragraphs according to the relevance score for each intermediate inference jump, and obtain the ordered paragraph batches corresponding to each intermediate inference jump. The remaining paragraph sequence acquisition unit is used to sort the candidate paragraphs that were not selected by each intermediate inference jump according to the relevance score for the last inference jump, and obtain the remaining paragraph sequence. The sorting unit is used to sort the remaining paragraph sequence and each ordered paragraph batch in reverse order, and to combine them according to the order of the remaining paragraph sequence and the ordered paragraph batch corresponding to the last intermediate reasoning jump to the first intermediate reasoning jump, so as to obtain the sorted target candidate paragraphs. The evidence trajectory unit acquisition unit is used to pair the sub-problems corresponding to each reasoning jump with the original text evidence state to obtain the corresponding evidence trajectory unit; The evidence trajectory acquisition unit is used to combine the evidence trajectory units according to the order from the last reasoning jump to the first reasoning jump to obtain the evidence trajectory.

[0062] Furthermore, based on any of the above embodiments, the context generation apparatus may further include: The lexicalization and encoding module is used to perform lexicalization and encoding on the candidate paragraphs in the candidate paragraph set to obtain the key-value representations corresponding to each candidate paragraph. The writing module is used to write the key-value representations corresponding to each candidate paragraph into a key-value cache block with a fixed position, and reuse the key-value cache block in different inference jumps; The access module is used to set candidate state identifiers and block-level attention masks based on the candidate paragraphs participating in the current inference jump, so that the state condition query accesses the corresponding key-value cache block; The update module is used to update the candidate state identifier and the block-level attention mask according to the target candidate paragraph corresponding to the current inference jump, so as to exclude the key-value cache block corresponding to the target candidate paragraph in other inference jumps, and keep the position of each key-value cache block unchanged.

[0063] It should be noted that the order of the modules and units in the above context generation device can be changed without affecting the logic.

[0064] The present invention provides a context generation device, comprising: an acquisition module 100 for acquiring a multi-hop question to be answered and a set of candidate paragraphs corresponding to the multi-hop question; a decomposition module 200 for decomposing the multi-hop question into a sequence of sub-questions arranged according to reasoning dependencies, and determining the target sub-question corresponding to the current reasoning hop based on the sub-question sequence; a state condition query generation module 300 for using the target sub-question as a state condition query when the current reasoning hop is the first reasoning hop, and generating a state condition query based on the sub-question corresponding to the previous reasoning hop, the original text evidence state corresponding to the previous reasoning hop, and the target sub-question when the current reasoning hop is not the first reasoning hop; and a target paragraph determination module. Block 400 is used to evaluate the relevance of candidate paragraphs in the candidate paragraph set according to the state condition query, and determine the target candidate paragraph corresponding to the current inference jump based on the evaluation result; the original text evidence state generation module 500 is used to extract original text evidence sentences from the target candidate paragraphs, and generate the original text evidence state corresponding to the current inference jump based on the original text evidence sentences; the evidence trajectory construction module 600 is used to sort the target candidate paragraphs corresponding to each inference jump according to the dependency relationship between the sub-questions corresponding to each inference jump, and construct the evidence trajectory based on the original text evidence state corresponding to each inference jump; the combination module 700 is used to combine the sorted target candidate paragraphs, the evidence trajectory, and the multi-hop questions to obtain the question-answering context. This device can dynamically adjust the evaluation of subsequent candidate paragraphs using the preceding original text evidence state, and combine multi-hop evidence through dependency-aligned paragraph sorting and evidence trajectory, while reusing candidate paragraph encoding results, thereby improving the effectiveness of evidence selection and combination and reducing the context generation processing overhead.

[0065] The retrieval device provided in the embodiments of the present invention will be described below. The retrieval device described below can be referred to in correspondence with the retrieval method described above.

[0066] Please refer to the details. Figure 8 , Figure 8 A schematic diagram of a retrieval device provided in an embodiment of the present invention may include: The information acquisition module 800 is used to acquire the question input by the user and a set of candidate information corresponding to the question; The generation module 900 is used to generate a question-answering context based on the question and the candidate information set using the context generation method described above. The retrieval module 1000 is used to obtain retrieval results corresponding to the question based on the question-and-answer context.

[0067] It should be noted that the order of the modules and units in the above context generation device can be changed without affecting the logic.

[0068] An embodiment of the present invention provides a context generation device, comprising an information acquisition module 800 for acquiring a user-input question and a set of candidate information corresponding to the question; a generation module 900 for generating a question-and-answer context based on the question and the set of candidate information using the aforementioned context generation method; and a retrieval module 1000 for obtaining retrieval results corresponding to the question based on the question-and-answer context. This device generates retrieval results based on a question-and-answer context obtained through dynamic evidence selection and dependency combination, which helps improve the efficiency of utilizing complementary evidence in complex question retrieval and reduces the latency caused by repeated retrieval and intermediate inference generation.

[0069] The electronic device provided in the embodiments of the present invention is described below. The electronic device described below can be referred to in correspondence with the context generation method and / or retrieval method described above.

[0070] Please refer to Figure 9 , Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention may include: Memory 10 is used to store computer programs; Processor 20 is used to execute computer programs to implement the above-described context generation method and / or retrieval method.

[0071] The memory 10, processor 20, and communication interface 31 all communicate with each other through the communication bus 32.

[0072] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions: The process involves: acquiring the multi-hop question to be answered and the corresponding candidate paragraph set; decomposing the multi-hop question to obtain a sequence of sub-questions arranged according to reasoning dependencies, and determining the target sub-question corresponding to the current reasoning hop based on the sub-question sequence; using the target sub-question as a state condition query when the current reasoning hop is the first reasoning hop; generating a state condition query based on the sub-question corresponding to the previous reasoning hop, the original text evidence state corresponding to the previous reasoning hop, and the target sub-question when the current reasoning hop is not the first reasoning hop; evaluating the relevance of candidate paragraphs in the candidate paragraph set based on the state condition query, and determining the target candidate paragraph corresponding to the current reasoning hop based on the evaluation results; extracting original text evidence sentences from the target candidate paragraphs, and generating the original text evidence state corresponding to the current reasoning hop based on the original text evidence sentences; sorting the target candidate paragraphs corresponding to each reasoning hop according to the dependencies between the sub-questions corresponding to each reasoning hop, and constructing an evidence trajectory based on the original text evidence state corresponding to each reasoning hop; and combining the sorted target candidate paragraphs, evidence trajectory, and multi-hop question to obtain the question-answering context. And / or, Obtain the user-input question and the corresponding candidate information set; use the aforementioned context generation method to generate a question-answering context based on the question and the candidate information set; obtain the search results corresponding to the question based on the question-answering context.

[0073] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0074] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.

[0075] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.

[0076] Communication interface 31 can be an interface for the communication module, used to connect with other devices or systems.

[0077] Of course, it should be noted that, Figure 9 The structure shown does not constitute a limitation on the electronic device in the embodiments of the present invention. In practical applications, the electronic device may include more than Figure 9 More or fewer components as shown, or combinations of certain components.

[0078] It is understood that if the context generation method and / or retrieval method in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk, or optical disk, and other media capable of storing program code.

[0079] Based on this, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the context generation method and / or retrieval method described above.

[0080] The following describes a computer program product provided by an embodiment of this application. The computer program product described below can be referred to in conjunction with other embodiments described herein.

[0081] A computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the aforementioned disclosed context generation method and / or retrieval method.

[0082] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0083] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0084] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0085] The foregoing has provided a detailed description of the context generation method, retrieval method, apparatus, device, and computer-readable storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A context generation method, characterized in that, include: Obtain the multi-hop questions to be answered and the set of candidate paragraphs corresponding to the multi-hop questions; The multi-hop problem is decomposed to obtain a sequence of sub-problems arranged according to reasoning dependencies, and the target sub-problem corresponding to the current reasoning hop is determined based on the sub-problem sequence. When the current inference jump is the first inference jump, the target sub-problem is used as the state condition query. When the current inference jump is not the first inference jump, the state condition query is generated based on the sub-problem corresponding to the previous inference jump, the original evidence state corresponding to the previous inference jump, and the target sub-problem. Based on the state condition query, the relevance of the candidate paragraphs in the candidate paragraph set is evaluated, and the target candidate paragraph corresponding to the current inference jump is determined based on the evaluation results; Extract the original text evidence sentence from the target candidate paragraph, and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence; Based on the dependencies between the sub-problems corresponding to each inference jump, the target candidate paragraphs corresponding to each inference jump are sorted, and the evidence trajectory is constructed based on the original text evidence status corresponding to each inference jump. The sorted target candidate paragraphs, the evidence trajectory, and the multi-hop question are combined to obtain the question-answering context.

2. The context generation method according to claim 1, characterized in that, The multi-hop problem is decomposed into a sequence of subproblems arranged according to reasoning dependencies, including: The multi-hop problem is input into the problem decomposition model, and the problem decomposition model is called to generate multiple sub-problems at once; The unrewritten multi-hop problem is identified as the last sub-problem in the sub-problem sequence, and the remaining sub-problems are identified as the intermediate information requirements for solving the multi-hop problem. Based on the relationship that the evidence corresponding to the previous subproblem can help solve the subsequent subproblem, the order of the subproblems is determined, and the subproblem sequence is obtained.

3. The context generation method according to claim 1, characterized in that, Based on the state condition query, the relevance of candidate paragraphs in the candidate paragraph set is evaluated, including: Obtain the query word attention value of the state condition query for each word in each candidate paragraph; Under the same candidate paragraph and the same attention mask, obtain the baseline lexical attention value of the content-independent query for each lexical in each candidate paragraph; wherein, the content-independent query does not contain information about the multi-hop problem; Based on the difference between the query word attention value and the corresponding baseline word attention value, the calibration attention value of each word is obtained; Based on the calibrated attention values ​​of each word in each candidate paragraph, determine the mean attention and standard deviation of attention for the corresponding candidate paragraph. A dynamic screening threshold is determined based on the mean attention value, the standard deviation of attention value, and a preset threshold coefficient. The calibrated attention values ​​that meet the dynamic screening threshold are aggregated to obtain the relevance score of the corresponding candidate paragraph. The candidate paragraphs are sorted according to the relevance score, and the target candidate paragraph is determined based on the sorting result.

4. The context generation method according to claim 1, characterized in that, Extracting original text evidence sentences from the target candidate paragraphs, and generating the original text evidence state corresponding to the current inference jump based on the original text evidence sentences, including: Based on the character offset or word offset generated by the word segmentation process, each original sentence in the target candidate paragraph is mapped to the corresponding word position; Based on the word positions corresponding to each original sentence, the calibration attention values ​​that meet the dynamic screening threshold in the original sentences are aggregated to obtain the evidence relevance score of each original sentence. The original sentences are ranked according to the evidence relevance score, and the original sentences are selected from the ranking results; The selected original sentences are copied from the original text of the target candidate paragraphs, and the copied original sentences are combined according to the order of the relevance scores of each target candidate paragraph to obtain the original text evidence status.

5. The context generation method according to claim 1, characterized in that, Based on the dependencies between the sub-problems corresponding to each inference jump, the target candidate paragraphs corresponding to each inference jump are sorted, and an evidence trajectory is constructed based on the original text evidence status corresponding to each inference jump, including: For each intermediate inference jump, the corresponding target candidate paragraphs are arranged according to the relevance score to obtain the ordered paragraph batches corresponding to each intermediate inference jump; For the last inference jump, the candidate paragraphs that were not selected by each intermediate inference jump are arranged according to the relevance score to obtain the remaining paragraph sequence; The remaining paragraph sequence and each ordered paragraph batch are sorted in reverse order, and then combined according to the order of the remaining paragraph sequence and the ordered paragraph batch corresponding to the last intermediate reasoning jump to the first intermediate reasoning jump to obtain the sorted target candidate paragraphs. Each reasoning jump is paired with the sub-problem corresponding to the original text evidence state to obtain the corresponding evidence trajectory unit; The evidence trajectory is obtained by combining the evidence trajectory units according to the order from the last reasoning jump to the first reasoning jump.

6. The context generation method according to claim 1, characterized in that, Also includes: Lexicalization and encoding are performed on the candidate paragraphs in the candidate paragraph set to obtain the key-value representations corresponding to each candidate paragraph; The key-value representations corresponding to each candidate paragraph are written into key-value cache blocks with fixed positions, and the key-value cache blocks are reused in different inference jumps; Candidate state identifiers and block-level attention masks are set based on the candidate paragraphs participating in the current inference jump, so that the state condition query accesses the corresponding key-value cache block; The candidate state identifier and the block-level attention mask are updated according to the target candidate paragraph corresponding to the current inference jump, so as to exclude the key-value cache block corresponding to the target candidate paragraph in other inference jumps, while keeping the position of each key-value cache block unchanged.

7. A retrieval method, characterized in that, include: Obtain the user-inputted question and the corresponding set of candidate information; Using the context generation method according to any one of claims 1 to 6, a question-answering context is generated based on the question and the candidate information set; The search results corresponding to the question are obtained based on the question-and-answer context.

8. A context generation apparatus, characterized in that, include: The acquisition module is used to acquire the multi-hop questions to be answered and the candidate paragraph set corresponding to the multi-hop questions; The decomposition module is used to decompose the multi-hop problem into a sequence of sub-problems arranged according to reasoning dependencies, and to determine the target sub-problem corresponding to the current reasoning hop based on the sub-problem sequence. The state condition query generation module is used to query the target sub-problem as a state condition when the current inference jump is the first inference jump; When the current inference jump is not the first inference jump, a state condition query is generated based on the sub-problem corresponding to the previous inference jump, the original evidence status corresponding to the previous inference jump, and the target sub-problem. The target paragraph determination module is used to perform relevance evaluation on candidate paragraphs in the candidate paragraph set according to the state conditions, and determine the target candidate paragraph corresponding to the current inference jump based on the evaluation results; The original text evidence state generation module is used to extract the original text evidence sentence from the target candidate paragraph and generate the original text evidence state corresponding to the current reasoning jump based on the original text evidence sentence; The evidence trajectory construction module is used to sort the target candidate paragraphs corresponding to each inference jump according to the dependency relationship between the sub-problems corresponding to each inference jump, and construct the evidence trajectory according to the original text evidence status corresponding to each inference jump. The combination module is used to combine the sorted target candidate paragraphs, the evidence trajectory, and the multi-hop question to obtain the question-answering context.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the context generation method as described in any one of claims 1 to 6 and / or the retrieval method as described in claim 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the context generation method as described in any one of claims 1 to 6 and / or the retrieval method as described in claim 7.