A large language model multi-round question and answer optimization method, system, device and medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XI AN JIAOTONG UNIV
- Filing Date
- 2026-05-21
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]基于上述现有技术存在的缺陷,本发明提供了一种大语言模型多轮问答优化方法、系统、设备及介质,解决了现有的问题
本发明通过将多轮语义输入数据输入至大语言模型,基于预设推理策略自动生成包含推理路径和回答的推理文本,并将推理文本中的语义单元转换为语义节点、按逻辑顺序连接生成原始思维链。上述过程无需人工设计思维链模板或示例,实现了思维链的自动化构建,显著降低了构建成本,提高了思维链生成的效率。本发明通过对原始思维链进行多种质量检测,生成质量评分,并基于评分与阈值的比较结果对原始思维链进行语义节点修复,随后通过节点贡献度评分进行路径重构,得到优化思维链。上述质量检测与修复机制能够有效提升思维链的逻辑一致性、完整性及紧凑性,避免了推理冗余或错误累积。同时,多个优化思维链构成思维链样本库,为后续不同任务提供可复用的高质量推理基础,从而显著提升思维链的泛化能力。
Smart Images

Figure CN122529093A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and natural language processing technology, and in particular to a method, system, device and medium for optimizing multi-turn question answering of large language models. Background Technology
[0002] With the rapid development of artificial intelligence and natural language processing technologies, large language models, due to their large parameter scale and strong semantic modeling capabilities, are widely used in scenarios such as intelligent question answering, multi-turn dialogue, and knowledge reasoning. Especially in multi-turn question answering tasks, large language models need to understand, remember, and reason about historical context during continuous interactions to generate logically consistent and semantically coherent answers. However, limited by the model's context window length and end-to-end generation mechanism, existing large language models are prone to problems such as context forgetting, broken reasoning chains, and answer deviations in multi-turn dialogues, thus affecting dialogue quality and user experience.
[0003] To enhance the reasoning ability of multi-turn question answering, existing technologies have proposed methods based on implicit or explicit reasoning. Implicit reasoning mainly relies on the model's internal parameters to complete inferences, lacking constraints on the reasoning process and prone to factual errors or illusion problems. Explicit reasoning methods, on the other hand, introduce a thought chain structure to break down complex problems into multi-step reasoning processes, which helps improve the interpretability of the reasoning.
[0004] However, existing thought chains mostly rely on manual design or static examples, which are costly to build and have limited generalization capabilities. Summary of the Invention
[0005] Based on the shortcomings of the existing technology, the present invention provides a method, system, device and medium for optimizing multi-turn question answering of large language models, which solves the existing problems.
[0006] The present invention adopts the following technical solution: In a first aspect, the present invention provides a multi-turn question-answering optimization method for large language models, comprising the following steps: Semantic analysis is performed on multi-text data input by different users and contextual dialogue event data of responses from large language models in historical conversations to generate different multi-turn semantic input data. Each multi-round semantic input data is fed into a large language model, and inference text containing inference paths and answers is generated based on a preset inference strategy. Semantic units in the inference text are converted into corresponding semantic nodes, and different semantic nodes are connected in a logical order to generate the corresponding original thought chain. Multiple quality checks are performed on each original thought chain to generate a corresponding quality score. The original thought chain is repaired by comparing the quality scores of different semantic nodes with the corresponding set thresholds. Based on the semantic weights of each semantic node in the repaired original thought chain, a corresponding node contribution score is generated. The path of the repaired original thought chain is reconstructed by multiple node contribution scores to obtain an optimized thought chain. Multiple optimized thought chains constitute a thought chain sample library. The question to be answered is semantically matched with multiple optimized thought chains in the thought chain sample library to obtain the target thought chain; the question to be optimized and the target thought chain are input into the large language model to generate an optimized answer with reasoning path.
[0007] Preferably, the semantic analysis of multi-text data input by different users and contextual dialogue event data from large language model responses in historical conversations specifically includes the following steps: Syntactic structure analysis, semantic segmentation, and entity annotation are performed on multi-text data to obtain semantic text. The contextual dialogue event data is extracted, roles are identified, pronoun references are parsed, and semantic dependencies are resolved to obtain a structured context. Semantic text and structured context are mapped uniformly based on time series and semantic relevance to obtain multi-round semantic input data.
[0008] Preferably, the reasoning strategy includes chained prompt templates, task decomposition rules, and structured output constraints.
[0009] Preferably, the semantic node types include fact nodes, reasoning nodes, and conclusion nodes. Fact nodes are used to represent objective factual information in multi-round semantic input data, reasoning nodes are used to represent the logical deduction process formed based on objective factual information, and conclusion nodes are used to represent the stage reasoning results or the final output results.
[0010] Preferably, the quality inspection includes reasoning logic consistency inspection, reasoning step integrity inspection, and node redundancy inspection; the quality score includes logical conflict score, integrity score, and redundancy score; the semantic node repair of the original thought chain by comparing the quality scores of different semantic nodes with the corresponding set thresholds specifically includes the following steps: When the logical conflict score is higher than the corresponding preset conflict threshold, the corresponding semantic node or path is marked as a conflict structure; for conflict structures, node replacement is performed by combining the semantics of adjacent contexts. When the integrity score is lower than the corresponding preset integrity threshold, the corresponding position is marked as a missing structure; for missing structures, intermediate inference nodes are supplemented based on the semantic dependency relationship between adjacent nodes. When the redundancy score is higher than the corresponding preset redundancy threshold, the corresponding node or sub-path is marked as a redundant structure; for redundant structures, semantically duplicated nodes are deleted.
[0011] Preferably, the node contribution score is as follows: ; In the formula, Indicates the first i The node contribution score of each semantic node Indicates positional weight. Indicates the degree of relevance. Indicates semantic coverage. α , β , γ These are the corresponding weighting coefficients.
[0012] Preferably, the step of inputting the question to be optimized and the target thought chain into the large language model to generate an optimized answer with a reasoning path specifically includes the following steps: The problem to be optimized is semantically encoded to obtain the target feature vector; The semantic nodes in the target thought chain sample are vectorized to obtain the node feature sequence. The target feature vector and node feature sequence are concatenated and then input into a pre-trained LSTM model to obtain the activation scores of each semantic node. When the activation score is less than the preset threshold of a node, the corresponding semantic node is determined as a suppressed node; otherwise, the corresponding semantic node is determined as an activated node. By extracting the corresponding node feature sequences from the activated nodes of the target thinking chain and concatenating them, a key reasoning feature representation is constructed. Based on the key reasoning feature representation, the key reasoning feature representation is decoded, and an optimized answer with a reasoning path is generated as the output.
[0013] Secondly, this invention provides a multi-turn question-answering optimization system for large language models, comprising: The acquisition module is used to perform semantic analysis on multi-text data input by different users and contextual dialogue event data of responses from large language models in historical conversations, and generate different multi-turn semantic input data. The generation module is used to input each multi-turn semantic input data into the large language model, generate reasoning text containing reasoning paths and answers based on the preset reasoning strategy, convert the semantic units in the reasoning text into corresponding semantic nodes, connect different semantic nodes in a logical order, and generate the corresponding original thought chain. The optimization module performs multiple quality checks on each original thought chain and generates corresponding quality scores. It repairs the semantic nodes of the original thought chain by comparing the quality scores of different semantic nodes with the corresponding set thresholds. Based on the semantic weights of each semantic node in the repaired original thought chain, it generates corresponding node contribution scores. It reconstructs the path of the repaired original thought chain by using multiple node contribution scores to obtain optimized thought chains. Multiple optimized thought chains constitute a thought chain sample library. The question-answering module is used to semantically match the question to be answered with multiple optimized thought chains in the thought chain sample library to obtain the target thought chain; the question to be optimized and the target thought chain are input into the large language model to generate an optimized answer with reasoning path.
[0014] Thirdly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described large language model multi-turn question answering optimization method.
[0015] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described large language model multi-turn question-answering optimization method.
[0016] Compared with the prior art, the above-mentioned at least one technical solution adopted by the present invention can achieve the following beneficial effects: This invention automatically generates reasoning text containing reasoning paths and responses by inputting multi-round semantic input data into a large language model based on a preset reasoning strategy. Semantic units in the reasoning text are then converted into semantic nodes and connected logically to generate an original thought chain. This process eliminates the need for manually designing thought chain templates or examples, achieving automated thought chain construction, significantly reducing construction costs and improving the efficiency of thought chain generation. Furthermore, this invention performs various quality checks on the original thought chain, generating a quality score. Based on the comparison between the score and a threshold, semantic nodes in the original thought chain are repaired. Subsequently, path reconstruction is performed using node contribution scores to obtain an optimized thought chain. These quality checks and repair mechanisms effectively improve the logical consistency, completeness, and compactness of the thought chain, avoiding reasoning redundancy or error accumulation. Simultaneously, multiple optimized thought chains constitute a thought chain sample library, providing a reusable high-quality reasoning foundation for subsequent tasks, thereby significantly improving the generalization ability of the thought chain. Attached Figure Description
[0017] 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 some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of a multi-turn question-answering optimization method for a large language model according to the present invention; Figure 2 This is a flowchart of the preprocessing process of the present invention; Figure 3 This is a flowchart illustrating the thought chain construction process of the present invention. Figure 4 This is a flowchart of the optimized thought process of the present invention; Figure 5 The flowchart of the thought chain sample library of the present invention; Figure 6 This is a flowchart illustrating the response process of the present invention; Figure 7 This is an optimized flowchart of the present invention. Detailed Implementation
[0019] 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.
[0020] Existing thought chains mostly rely on manual design or static examples, resulting in high construction costs, limited generalization capabilities, and difficulties in dynamic maintenance and optimization in multi-turn interaction scenarios, easily leading to inference redundancy or error accumulation. There is an urgent need for a technical solution that can automatically build, optimize, and continuously evolve thought chains during multi-turn question-and-answer processes to improve the inference stability, contextual consistency, and response reliability of large language models in complex dialogue scenarios.
[0021] This invention provides a method for optimizing multi-turn question answering using a large language model, specifically a method based on thought chain technology, applicable to multi-turn dialogue interaction scenarios. In multi-turn dialogue interaction scenarios, users can ask questions around the same or related topics in multiple consecutive dialogue rounds. The large language model integrates the current input with historical conversation content to generate logically consistent responses. In this implementation, the system first uniformly collects and manages the data generated during the multi-turn dialogue process, providing basic data support for subsequent thought chain construction and reasoning optimization. The data includes not only the user's input text in the current round, but also the user's input text in previous rounds, the system-generated response text, and the corresponding contextual state information, thereby ensuring that the reasoning process can fully reflect the semantic evolution of the multi-turn dialogue. See also... Figures 1-7 The method includes the following steps:
[0022] S1: The system acquires multi-text data input by the user and contextual dialogue event data corresponding to the responses of the large language model in historical conversations; it preprocesses the multi-text data and contextual dialogue event data respectively, and then performs correlation and fusion to obtain multi-turn semantic input data for reasoning in the current task.
[0023] In this embodiment, the system is an automatic thought chain construction system that can be deployed on servers, terminal devices, or cloud computing platforms. In its specific implementation, the system is built on a large language model and a retrieval enhancement generation architecture. Specifically, it uses a text embedding model and a vector database to perform multi-text data processing and historical conversation context extraction. It completes multi-dimensional semantic fusion through the Transformer attention mechanism and combines model fine-tuning technology or prompt word engineering to achieve dynamic generation of inference chains and other operations.
[0024] The system first performs semantic parsing on the multi-text data input by the user, specifically including syntactic structure analysis, semantic segmentation, and entity annotation. Through in-depth analysis of the internal structure of the text, the system can identify declarative and interrogative content in the user input and extract key technical terms and domain concepts as semantic anchors, providing the necessary information foundation for subsequently constructing explicit reasoning paths.
[0025] The system extracts contextual information, identifies roles, parses pronoun references, and analyzes semantic dependencies from historical dialogue data. This process aims to identify implicit referential relationships and ellipsis in users' multi-turn questions, effectively solve the semantic reuse problem in cross-turn dialogues by clarifying the semantic roles of different speakers, and ensure that historical dialogue information can be accurately transformed into a logically connected structured context.
[0026] After completing the above analysis, the system performs unified mapping and structured integration of multi-source data based on time series and semantic relevance. This step, by fusing preprocessed user input with historical dialogue event data, preserves the temporal evolution and semantic dependencies of the dialogue. Through this fusion method, the system eliminates the differences in format and expression between data from different sources, transforming fragmented dialogue information into a highly consistent structured representation.
[0027] The system outputs structured multi-turn semantic input data. This output data not only includes the original natural language text but also integrates hierarchical feature information generated during the semantic analysis stage. This hierarchical feature information includes word-level keywords and entity annotations, sentence-level semantic relationships and intent information, turn-level core question information, and multi-turn-level historical context association information. These features are used to represent the core question of the current turn, supporting historical context information, and background information. This structured data serves as input for subsequent reasoning stages, providing a stable and semantically consistent data foundation for the generation of thought chains and the optimization of reasoning paths.
[0028] Step S2: Based on the multi-turn semantic input data, generate the original multi-turn question thinking chain using the preset large language model reasoning strategy, process the original multi-turn question thinking chain and iteratively optimize it through the reinforcement learning mechanism to obtain the optimized thinking chain sample, and store it in the thinking chain sample library.
[0029] In this embodiment, the large language model reasoning strategy is implemented through a pre-defined chained prompt template, task decomposition rules, and a structured output constraint mechanism. This guides the large language model to explicitly output reasoning steps during the generation process, rather than simply generating the final answer. Intermediate reasoning steps include sub-question analysis, contextual association, conditional judgment, and generation of interim conclusions. In this way, the system can decompose complex multi-turn question-answering tasks into multiple continuous and interpretable reasoning steps, thus providing a foundational structure for subsequent optimization and reuse of the thought chain.
[0030] The thought process chain of the original multi-turn problem is initially generated in the form of reasoning text, which includes input fact analysis, intermediate reasoning process, and interim conclusions. The system performs semantic parsing on the reasoning text, converting different semantic units into corresponding semantic nodes to achieve a structured representation of the original reasoning process; whereby each semantic node is used to represent factual conditions, logical derivation relationships, or intermediate judgment results.
[0031] Furthermore, based on the semantic attributes of each semantic node, the system categorizes semantic nodes into fact nodes, inference nodes, and conclusion nodes. Fact nodes represent objective factual information in multi-round semantic input data, inference nodes represent the logical deduction process based on objective factual information, and conclusion nodes represent the staged inference results or the final output result. This node categorization enables the thought chain structure to form clear hierarchical and logical relationships.
[0032] Based on the causal, conditional, and sequential relationships implicit in the reasoning text, the system connects various reasoning nodes in a logical order to form an original multi-turn question-and-answer chain. This chain reflects the model's reasoning path in the multi-turn question-and-answer task, enabling the complete tracking and backtracking of the solution process for complex problems, thereby improving the transparency and interpretability of the reasoning process.
[0033] S3: After generating the original thought chain, the system performs a preliminary quality check on the original thought chain and performs local repair and path reconstruction based on the check results.
[0034] S31: Quality inspection operations include inference logic consistency detection, inference step integrity detection, and node redundancy detection. In its implementation, the system calculates the semantic mutual exclusion probability between inference nodes using a natural language inference model, using this probability as the logical conflict score for the original thought chain. It quantifies the degree of logical jumps by measuring the semantic Euclidean distance or information entropy difference between feature vectors of adjacent inference steps to obtain an integrity score. Simultaneously, it calculates the cosine similarity between feature vectors of each node, using the ratio of highly overlapping features as the redundancy score. Finally, based on these scores, the system identifies low-quality nodes, abnormal edge relationships, and broken inference paths, providing a quantitative basis for subsequent chain optimization.
[0035] The system employs several key performance indicators (KPIs). The logical conflict score characterizes whether there are factual contradictions, temporal conflicts, causal conflicts, or inconsistent conclusions between nodes. The completeness score characterizes the coverage of key facts, necessary intermediate steps, and conclusion-generating steps within the current thought chain. The redundancy score characterizes whether there are semantically repetitive nodes, repeated reasoning steps, or nodes with low information gain within the thought chain. When the logical conflict score exceeds a preset conflict threshold, the system marks the corresponding node or path as a conflicting structure. When the completeness score is below a preset completeness threshold, the system marks the corresponding position as a missing structure. When the redundancy score exceeds a preset redundancy threshold, the system marks the corresponding node or sub-path as a redundant structure.
[0036] S32: Based on the quality inspection results, the system performs node-level repair operations on the original thought chain. The node-level repair operations include redundant node pruning, abnormal node replacement, and missing node completion.
[0037] Specifically, for redundant structures, the system deletes semantically repetitive nodes, repeated reasoning steps, or nodes with low information gain; for conflicting structures, the system performs node replacement by combining adjacent contextual semantics, historical high-quality thought chain samples, or newly generated candidate nodes to eliminate logical conflicts; for missing structures, the system supplements intermediate reasoning nodes based on the semantic dependencies between adjacent nodes to restore the continuity of the reasoning chain.
[0038] S33: After completing node-level repair, the system enters the path reconstruction phase. Based on the low-quality nodes, abnormal edge relationships, and broken paths marked in the quality inspection stage, the system performs path-level structural optimization on the thought chain. The system calculates the node contribution score based on the positional weight of each semantic node in the thought chain, its correlation with the conclusion node, and its semantic coverage. The node contribution score can be expressed as:
[0039] ; in, Indicates the first i The node contribution score of each semantic node Represents the position weight, used to characterize the position weight. i The topological position of a semantic node in the main reasoning path or the path distance between the semantic node and the conclusion node; Represents the degree of correlation, used to characterize the first... i The semantic similarity or dependency strength between each semantic node and the conclusion node; Represents semantic coverage, used to characterize the first... i The extent to which each semantic node covers the key facts, constraints, or entity slots of the current task; α , β , γ These correspond to the weighting coefficients. The node contribution score is used to measure the importance of a single semantic node in the overall reasoning process, providing a quantitative basis for node pruning, node merging, edge reconnection, and node ranking.
[0040] Based on node contribution scores, the system performs structural optimization operations on the thought chain. For semantic nodes whose contribution scores are below a preset threshold and whose semantic repetition with other semantic nodes exceeds a repetition threshold, pruning operations are performed. For semantically similar and logically merging semantic nodes, node merging and edge reconnection operations are performed. For paths with misaligned order or branch offsets, node order adjustment and branch path redirection operations are performed, thereby generating an optimized thought chain. Path reconstruction aims to give the optimized thought chain a more compact structure, higher logical coherence, and better semantic consistency.
[0041] Furthermore, after path reconstruction, the system can perform a utility evaluation on the optimized thought chain. Utility evaluation quantifies and scores the optimized thought chain by constructing a utility function, which can be expressed as:
[0042] ; in, U This represents the utility score of the optimized thought chain. Conf Indicates the confidence level of the conclusion. Dcontrib Indicators representing the distribution of node contributions Lnorm Indicates the normalized inference length. , , These are the weighting coefficients.
[0043] Among them, the confidence level of the conclusion Conf It can be obtained based on at least one of the following: the average output probability when the large language model generates conclusions, the consistency score between the conclusion node and the input facts and historical context, and the consistency score between the results generated from multiple samplings. Node contribution distribution index Dcontrib The utility score can be obtained from the normalized entropy value, inverse variance, or proportion of high-contribution nodes after the contribution score of each semantic node, and is used to characterize the rationality of the distribution of key semantic nodes in the optimized thought chain. The normalized inference length Lnorm is used to characterize the ratio of the current thought chain length to the preset maximum length. If the utility score is lower than the preset threshold, the system can re-trigger the quality check and path reconstruction operation until the optimized thought chain meets the preset utility requirements.
[0044] In this embodiment, the system introduces a reinforcement learning mechanism to optimize the inference strategy of the large language model offline. The reinforcement learning mechanism evaluates the quality of the generated thought chain by constructing a reward function, which can be expressed as:
[0045] ; in, R Indicates the reward value. Acc Indicates the accuracy rate of the answer. Ctx Indicates the context consistency score. Sta This represents the stability score of generating thought chains multiple times. Feed This represents the score based on historical user feedback. Confli This indicates a logical conflict penalty term. Red Indicates a redundancy penalty term. to These are the corresponding weighting coefficients.
[0046] Based on the reward value, the system uses a strategy optimization algorithm to update the inference strategy parameters, prompt template parameters, or candidate path selection weights, and stores the optimized thought chain as a high-quality sample in the thought chain sample library.
[0047] Furthermore, the system also performs a thought chain sample library retrieval operation. This operation includes: based on the multi-round semantic input data of the current task, retrieving historical high-quality thought chain samples from the thought chain sample library that are semantically similar to the current task, and using these historical high-quality thought chain samples to assist in the generation of the original thought chain, node repair, and path reconstruction; for optimized thought chains that meet preset quality requirements after quality testing, path reconstruction, and utility evaluation, the system writes them, along with their corresponding task tags, semantic node structures, path topology relationships, quality score information, and feedback information, into the thought chain sample library to achieve continuous updates. Through the above retrieval and writing mechanisms, the reasoning chains stored in the thought chain sample library can gradually acquire higher logical reliability and generalization ability, thereby providing a stable and reusable reasoning foundation for subsequent multi-round question-answering tasks.
[0048] S4: Based on the thought chain sample library, combined with the preset intelligent agent model LSTM, the system assists in generating answers for subsequent user inputs, making the answer generation process explicitly dependent on the historical reasoning chain and logical context.
[0049] In this embodiment, when the system receives new user input, it no longer relies solely on the current input text or limited historical context, but instead introduces a thought chain sample library as an explicit reasoning support mechanism. By calling upon high-quality historical thought chain samples, the system provides structured reasoning references for the current round of question answering, thereby enhancing the logical stability and consistency of the answer generation process.
[0050] In the multi-round question-answering assisted generation stage, the automatic thought chain construction system first uses a pre-trained text embedding model to semantically parse the current user input to extract high-dimensional feature vectors. These feature vectors are then matched with existing thought chain samples stored in a vector database. This matching process is based on a comprehensive calculation of multiple indicators, including cosine similarity between vectors, entity overlap extracted using named entity recognition technology, and consistency of reasoning objectives. Through this underlying retrieval technology, the system can accurately recall multiple candidate thought chain samples related to the current question from the thought chain sample library, forming a candidate sample set, thereby avoiding interference from irrelevant reasoning paths in answer generation.
[0051] After obtaining the candidate sample set, the system further sorts the candidate thought chain samples based on a preset priority strategy and determines the target thought chain sample from them. The priority strategy may include the historical success rate of the thought chain, the frequency of invocation, the node stability score, and the degree of matching with the current semantic input. By introducing a sorting mechanism, the system can prioritize the thought chain samples with higher reasoning reliability and better matching with the semantics of the current task as auxiliary reasoning basis.
[0052] After identifying the target thought chain samples, the multi-turn question-answering auxiliary generation system based on the thought chain sample library inputs the thought chain samples as explicit reasoning conditions into the large language model. Unlike the traditional approach that relies solely on contextual concatenation, the large language model explicitly references the order and logical relationships of reasoning nodes in the thought chain when generating answers. This ensures that the answer generation process is constrained by the historical reasoning structure, avoiding logical jumps or self-contradictory conclusions.
[0053] The system can analyze and schedule thought chain samples using a pre-defined agent model. The agent model is used to selectively activate or suppress different semantic nodes in the thought chain samples based on the current task objective. In this embodiment, the agent model is implemented using a Long Short-Term Memory (LSTM) network. Specifically, the system first performs semantic encoding on the current task objective to obtain a task objective feature vector; simultaneously, it vectorizes each semantic node in the target thought chain sample to obtain a node feature sequence. Node features may include node semantic representation, node type, node position in the thought chain, and logical relationship information with adjacent nodes. Subsequently, the system concatenates or fuses the task objective feature vector with the node features of each semantic node, and inputs them into the LSTM model in the order of nodes in the thought chain, so that the LSTM model learns the temporal dependency and correlation between the current task objective and each semantic node. The LSTM model outputs the corresponding hidden state for each semantic node and further calculates the node activation score through a scoring layer. The node activation score can be expressed as:
[0054] ; in, Indicates the first i The activation score of each semantic node. Indicates that LSTM is applied to the first... i The hidden states output by each semantic node are given, where W and b represent the weight and bias parameters of the scoring layer, respectively. The system schedules and controls the semantic nodes based on the comparison between their activation scores and a preset threshold θ; when... When ≥θ, the corresponding semantic node is determined as the active node and included in the current round's response generation process; when When the value is less than θ, the corresponding semantic node is identified as a suppressed node, and its participation weight is reduced or it is temporarily not invoked during the current round of answer generation. Through this method, the system can selectively activate or ignore different semantic nodes in the thought chain sample based on the current task objective, thereby improving inference efficiency and enhancing the relevance between the generated answer and the current question. The agent model can prioritize activating inference nodes highly relevant to the current question while temporarily ignoring background nodes with lower relevance, thus improving inference efficiency.
[0055] During the answer generation process, the system utilizes validated reasoning paths from the thought chain samples to guide the large language model in gradually generating the response. The generated response not only includes the final conclusion but also implicitly follows the intermediate reasoning logic within the thought chain, ensuring semantic consistency between the response and the historical reasoning conclusions. In this way, the system can significantly reduce inconsistencies in responses or repeated changes in conclusions during multiple rounds of question answering.
[0056] The system can also dynamically detect the consistency between the generated answer and the thought chain sample. If a significant deviation is detected between the generated content and the referenced thought chain nodes, the system can trigger a correction mechanism to adjust or regenerate the answer, thereby further ensuring the quality of the answer.
[0057] While generating the answer, the system records the usage of the thought chain samples, forming inference citation data. This inference citation data may include the identifier of the invoked thought chain sample, the sequence of activated inference nodes, and the level of participation of each node during the generation process. By recording this inference citation data, the system can provide data support for the subsequent evaluation and updating of thought chain samples.
[0058] The system can also perform correlation analysis between the answers generated in the current round and subsequent user feedback to evaluate the effectiveness of the thought chain samples used in actual question-and-answer tasks. If a thought chain sample performs well in multiple rounds of question-and-answer, the system can increase its weight in the sample library; otherwise, it will reduce its priority or mark it as a sample to be optimized.
[0059] By using the multi-turn question-and-answer assisted generation method based on the thought chain sample library, this embodiment realizes the explicit dependence of the answer generation process on the historical reasoning chain, enabling the large language model to stably inherit the existing reasoning logic in multi-turn dialogues, thereby effectively improving the consistency, interpretability and overall reliability of answers in multi-turn question-and-answer scenarios.
[0060] S5: While generating the answer content, record the reasoning chain auxiliary data, and feed the above reasoning chain auxiliary data back to the thinking chain sample library for continuous optimization and reinforcement learning of subsequent reasoning strategies.
[0061] In this embodiment, while generating the answer content, the system systematically records the reasoning information involved in the answer generation process to construct complete reasoning chain auxiliary data. This reasoning chain auxiliary data reflects the usage and performance of the thought chain samples in actual multi-round question-and-answer tasks and is an important basis for continuous optimization of the thought chain.
[0062] The auxiliary data for the inference chain includes, but is not limited to: the identifier of the invoked thought chain sample, the activation order of the inference nodes, the degree of participation of each inference node in the answer generation, whether the answer generation was successful, and whether there was any inference interruption or deviation. By recording the above data in a fine-grained manner, the system can accurately evaluate the actual reasoning ability of a single thought chain sample in different question-and-answer scenarios.
[0063] The system feeds back the reasoning chain auxiliary data to the thinking chain sample library, and dynamically updates the thinking chain samples in the sample library based on the feedback data. The system can set dynamic weights for thinking chain samples according to reasoning success rate, answer consistency and user feedback results. Thinking chain samples with higher weights have higher priority in subsequent retrieval and retrieval, thereby realizing the enhanced utilization of high-quality reasoning paths.
[0064] For thought chain samples that frequently exhibit reasoning errors or answer deviations in multi-round question-and-answer sessions, the system can perform weight reduction processing based on feedback data, or mark them as samples to be optimized. The system can also reintroduce reinforcement learning or structural optimization processes into such samples to attempt to repair their reasoning structure, thereby preventing erroneous reasoning paths from accumulating in the sample library over a long period of time.
[0065] Through the aforementioned dynamic feedback and weight adjustment mechanism, the thought chain sample library can continuously evolve during actual operation. The thought chain sample library is not a static storage structure, but rather continuously introduces new, high-quality reasoning chain samples as multiple rounds of question-and-answer tasks proceed, while eliminating or weakening low-quality samples, thereby forming an adaptive reasoning knowledge base.
[0066] The system can also periodically perform offline cleanup operations on the thought chain sample library in the background. Offline cleanup operations may include merging similar thought chain samples, compressing redundant inference paths, and cleaning up low-usage samples. Through offline cleanup, the storage efficiency and retrieval efficiency of the sample library can be further improved, while reducing the impact of inference chain redundancy on system performance.
[0067] By combining the inference chain feedback mechanism with the reinforcement learning mechanism, the system forms a complete continuous reinforcement learning loop. This loop enables the inference strategy of the large language model to be continuously corrected and optimized in real multi-turn question-answering scenarios, thereby gradually improving the model's inference stability, generalization ability and long-term consistency in complex dialogue environments.
[0068] The method of this embodiment can be executed by an electronic device, which includes a processor and a memory. The memory stores a computer program for implementing the above method. When executed by the processor, the computer program can perform operations such as multi-round semantic processing, thought chain generation, sample library retrieval, and inference chain feedback.
[0069] In specific deployment, this embodiment does not limit the deployment form of the electronic devices. The method can be deployed on local terminal devices, servers, or cloud computing platforms, and can adopt a centralized or distributed architecture according to actual application needs. Through flexible deployment methods, this invention can adapt to multi-round query-answering application scenarios of different scales.
[0070] Through the above embodiments, the present invention realizes a complete technical closed loop from multi-turn semantic input, thought chain generation, sample library-driven reasoning to feedback evolution, enabling large language models to explicitly rely on historical reasoning structures and continuously optimize their reasoning strategies in the multi-turn question answering process, thereby significantly improving the logical consistency, interpretability and overall reliability of the multi-turn question answering system.
[0071] Based on the same concept, the present invention also provides a multi-turn question-answering optimization system for a large language model, including an acquisition module, a generation module, an optimization module and a question-answering module.
[0072] The acquisition module is used to perform semantic analysis on multi-text data input by different users and contextual dialogue event data of large language model responses in historical sessions, and generate different multi-turn semantic input data.
[0073] The generation module is used to input each multi-round semantic input data into the large language model, generate reasoning text containing reasoning paths and answers based on the preset reasoning strategy, convert the semantic units in the reasoning text into corresponding semantic nodes, connect different semantic nodes in a logical order, and generate the corresponding original thought chain.
[0074] The optimization module performs multiple quality checks on each original thought chain and generates corresponding quality scores. It repairs semantic nodes in the original thought chain by comparing the quality scores of different semantic nodes with the corresponding set thresholds. Based on the semantic weights of each semantic node in the repaired original thought chain, it generates corresponding node contribution scores. It then reconstructs the path of the repaired original thought chain using multiple node contribution scores to obtain optimized thought chains. Multiple optimized thought chains constitute a thought chain sample library.
[0075] The question-answering module is used to semantically match the question to be answered with multiple optimized thought chains in the thought chain sample library to obtain the target thought chain; the question to be optimized and the target thought chain are input into the large language model to generate an optimized answer with reasoning path.
[0076] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described large language model multi-turn question answering optimization method.
[0077] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described large language model multi-turn question-answering optimization method.
[0078] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0079] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A multi-turn question-answering optimization method for large language models, characterized in that, Includes the following steps: Semantic analysis is performed on multi-text data input by different users and contextual dialogue event data of responses from large language models in historical conversations to generate different multi-turn semantic input data. Each multi-round semantic input data is fed into a large language model, and inference text containing inference paths and answers is generated based on a preset inference strategy. Semantic units in the inference text are converted into corresponding semantic nodes, and different semantic nodes are connected in a logical order to generate the corresponding original thought chain. Perform multiple quality checks on each original thought chain to generate a corresponding quality score; The original thought chain is repaired by comparing the quality scores of different semantic nodes with the corresponding set thresholds. Based on the semantic weights of each semantic node in the repaired original thought chain, a corresponding node contribution score is generated. The path of the repaired original thought chain is reconstructed by multiple node contribution scores to obtain an optimized thought chain. Multiple optimized thought chains constitute a thought chain sample library. The question to be answered is semantically matched with multiple optimized thought chains in the thought chain sample library to obtain the target thought chain; the question to be optimized and the target thought chain are input into the large language model to generate an optimized answer with reasoning path.
2. The multi-turn question-answering optimization method for a large language model as described in claim 1, characterized in that, The semantic analysis of multi-text data input by different users and contextual dialogue event data from large language model responses in historical conversations specifically includes the following steps: Syntactic structure analysis, semantic segmentation, and entity annotation are performed on multi-text data to obtain semantic text. The contextual dialogue event data is extracted, roles are identified, pronoun references are parsed, and semantic dependencies are resolved to obtain a structured context. Semantic text and structured context are mapped uniformly based on time series and semantic relevance to obtain multi-round semantic input data.
3. The multi-turn question-answering optimization method for a large language model as described in claim 1, characterized in that, The reasoning strategy includes chained prompt templates, task decomposition rules, and structured output constraints.
4. The multi-turn question-answering optimization method for a large language model as described in claim 1, characterized in that, The semantic node types include fact nodes, reasoning nodes, and conclusion nodes. Fact nodes are used to represent objective factual information in multi-round semantic input data, reasoning nodes are used to represent the logical deduction process formed based on objective factual information, and conclusion nodes are used to represent the stage reasoning results or the final output results.
5. The multi-turn question-answering optimization method for a large language model as described in claim 4, characterized in that, The quality inspection includes reasoning logic consistency detection, reasoning step integrity detection, and node redundancy detection. The quality score includes logical conflict score, integrity score, and redundancy score. The semantic node repair of the original thought chain by comparing the quality scores of different semantic nodes with the corresponding set thresholds specifically includes the following steps: When the logical conflict score is higher than the corresponding preset conflict threshold, the corresponding semantic node or path is marked as a conflict structure; for conflict structures, node replacement is performed by combining the semantics of adjacent contexts. When the integrity score is lower than the corresponding preset integrity threshold, the corresponding position is marked as a missing structure; for missing structures, intermediate inference nodes are supplemented based on the semantic dependency relationship between adjacent nodes. When the redundancy score is higher than the corresponding preset redundancy threshold, the corresponding node or sub-path is marked as a redundant structure; for redundant structures, semantically duplicated nodes are deleted.
6. The multi-turn question-answering optimization method for a large language model as described in claim 1, characterized in that, The specific node contribution score is shown below: ; In the formula, Indicates the first i The node contribution score of each semantic node Indicates positional weight. Indicates the degree of relevance. Indicates semantic coverage. α , β , γ These are the corresponding weighting coefficients.
7. The multi-turn question-answering optimization method for a large language model as described in claim 1, characterized in that, The process of inputting the problem to be optimized and the target thought chain into the large language model to generate an optimized answer with a reasoning path includes the following steps: The problem to be optimized is semantically encoded to obtain the target feature vector; The semantic nodes in the target thought chain sample are vectorized to obtain the node feature sequence. The target feature vector and node feature sequence are concatenated and then input into a pre-trained LSTM model to obtain the activation scores of each semantic node. When the activation score is less than the preset threshold of a node, the corresponding semantic node is determined as a suppressed node; otherwise, the corresponding semantic node is determined as an activated node. By extracting the corresponding node feature sequences from the activated nodes of the target thinking chain and concatenating them, a key reasoning feature representation is constructed. Based on the key reasoning feature representation, the key reasoning feature representation is decoded, and an optimized answer with a reasoning path is generated as the output.
8. A multi-turn question-answering optimization system for a large language model, characterized in that, include: The acquisition module is used to perform semantic analysis on multi-text data input by different users and contextual dialogue event data of responses from large language models in historical conversations, and generate different multi-turn semantic input data. The generation module is used to input each multi-turn semantic input data into the large language model, generate reasoning text containing reasoning paths and answers based on the preset reasoning strategy, convert the semantic units in the reasoning text into corresponding semantic nodes, connect different semantic nodes in a logical order, and generate the corresponding original thought chain. The optimization module is used to perform multiple quality checks on each original thought chain and generate a corresponding quality score. The original thought chain is repaired by comparing the quality scores of different semantic nodes with the corresponding set thresholds. Based on the semantic weights of each semantic node in the repaired original thought chain, a corresponding node contribution score is generated. The path of the repaired original thought chain is reconstructed by multiple node contribution scores to obtain an optimized thought chain. Multiple optimized thought chains constitute a thought chain sample library. The question-answering module is used to semantically match the question to be answered with multiple optimized thought chains in the thought chain sample library to obtain the target thought chain; the question to be optimized and the target thought chain are input into the large language model to generate an optimized answer with reasoning path.
9. A computer device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the large language model multi-turn question answering optimization method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the large language model multi-turn question answering optimization method according to any one of claims 1-7.