Low-delay dialogue generation method and system based on hierarchical context engineering
By employing a parallel dual-path processing mechanism based on hierarchical context engineering, and utilizing lightweight and powerful language models for real-time sentiment analysis and deep emotion inference respectively, the problem of unnatural dialogue caused by the latency of large language models is solved. This achieves low-latency, high-quality dialogue generation, improving the naturalness and effectiveness of human-computer interaction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-11
- Publication Date
- 2026-04-07
AI Technical Summary
Existing large-scale language models introduce significant delays of hundreds of milliseconds to several seconds in voice dialogue systems due to their huge number of parameters and computational complexity. This causes users to experience unnatural silence after speaking, which seriously disrupts the rhythm and fluency of the dialogue and reduces the naturalness of human-computer interaction.
We employ a low-latency dialogue generation method based on hierarchical context engineering, using a parallel dual-path processing mechanism: the reflection layer uses a lightweight model to perform millisecond-level sentiment analysis to generate instant emotional transition responses, while the planning layer uses a powerful language model for deep sentiment inference and policy planning, combined with Monte Carlo tree search to optimize dialogue strategies, ensuring a seamless transition between instant responses and deep understanding.
It enables the generation of high-quality, emotionally resonant, and strategically-oriented dialogue responses with low latency, significantly improving the naturalness and effectiveness of human-computer interaction and solving the problem of balancing latency and quality.
Smart Images

Figure CN121807995A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language model technology, and in particular to a low-latency dialogue generation method and system based on hierarchical context engineering. Background Technology
[0002] With the maturation of large-scale language model technology, intelligent dialogue systems are increasingly being applied in scenarios such as customer service, consultation, and emotional support. Users not only expect the system to generate accurate and logically coherent responses, but also seek an interactive experience that is as real as human communication, instantaneous, fluent, and emotionally resonant. However, the inherent contradiction between system response latency and the naturalness of interaction has become a key bottleneck restricting its development to higher levels, especially in voice dialogue scenarios with strict real-time requirements.
[0003] Currently, a typical existing technology employs a serial processing flow: the system needs to receive the user's complete speech, convert it into text via a speech recognition module, then combine it with a lengthy dialogue history, and finally feed it into a large language model for complex semantic understanding and response generation. The text is then output via a text-to-speech module. In this process, the large language model, due to its massive number of parameters and computational complexity, often introduces significant delays of hundreds of milliseconds to several seconds into its inference process. This cumulative delay causes users to experience an unnatural silence after speaking, severely disrupting the rhythm and fluency of the dialogue and making the interaction feel very "machine-like."
[0004] Based on this, this application provides a low-latency dialogue generation method and system based on hierarchical context engineering. Summary of the Invention
[0005] To address the issue that large language models, due to their massive number of parameters and computational complexity, often introduce significant delays of hundreds of milliseconds to several seconds into their inference processes, this cumulative delay causes users to experience unnatural silences after speaking, severely disrupting the rhythm and fluency of the dialogue and making the interaction feel robotic. This application provides a low-latency dialogue generation method and system based on hierarchical context engineering.
[0006] Firstly, this application provides a low-latency dialogue generation method based on hierarchical context engineering, employing the following technical solution: including: Initialize a structured dialogue state summary for dynamically recording and updating dialogue state information, which includes at least the user's emotional state, the current dialogue stage, and the user's intent; Based on the initial text input and the current dialogue state summary, the reflection layer path and the planning layer path are executed in parallel. The reflection layer path is used to generate and output an immediate emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to call the second language model in parallel to perform deep emotion reasoning based on the complete text input and dialogue history while the reflection layer path is running, and generate the core text response. After the first synthesized speech has finished playing, the core text response is immediately synthesized into speech, and the second synthesized speech is played next. After the planning layer path is completed, the dialogue state summary is updated based on the content of the core text response for use in the next round of dialogue.
[0007] Preferably, the reflection layer path and the planning layer path, executed in parallel based on the initial text input and the current dialogue state summary, wherein the reflection layer path is used to generate and output an immediate emotional transition, and to generate a transition text response by calling the first language model to generate the first synthesized speech, includes: In the initial stage of receiving user voice input, the preliminary text input converted from the initial voice segment is obtained; Based on the initial text input and the current dialogue state summary, the first language model is invoked to generate an emotional transition text response. The first language model is a lightweight model optimized to achieve millisecond-level inference latency. The emotional transition text is converted into the first synthesized speech and then played back.
[0008] Preferably, the planning layer path is used to, while the reflection layer path is running, in parallel invoke a second language model to perform deep sentiment inference based on complete text input and dialogue history, generating core text responses, including: Obtain complete text input converted from the user's complete voice input; Based on the complete text input and dialogue history, the second language model is invoked to execute the emotion inference chain and output fine-grained user emotion state. The second language model is superior to the first language model in terms of logical processing and context understanding. Based on the fine-grained user emotional state, dialogue history, and current dialogue state summary, dialogue strategy planning is performed, and the optimal dialogue strategy is output. Based on the optimal dialogue strategy, the fine-grained user emotional state, and the dialogue context, the second language model is invoked to generate the core text response.
[0009] Preferably, based on the initial text input and the current dialogue state summary, a first language model is invoked to generate an emotional transition text response. The first language model is a lightweight model optimized to achieve millisecond-level inference latency, comprising: The initial text input is analyzed to quickly identify its implicit dominant sentiment category and immediate conversational intent; The identified dominant sentiment category, immediate dialogue intent, and current dialogue stage in the dialogue state summary are fused to form a rapid contextual representation; The fast context representation is input into the first language model, and the first language model is instructed to generate an emotional transition text response within a preset length and adapted to the dominant sentiment category based on a preset non-committal phrase library.
[0010] Preferably, the step of invoking the second language model to execute the emotion inference chain based on the complete text input and dialogue history, and outputting fine-grained user emotion states, includes: Based on the complete text input, multiple common-sense inferences related to the current discourse are automatically generated from an external common-sense knowledge base, and filtered based on their relevance to the dialogue context to form a refined knowledge set; Construct an emotion reasoning chain prompt, and guide the second language model to follow a chain-like logical path from the user's situation to the user's emotion, and then from the user's emotion to the user's intention. The complete text input, dialogue history, refined knowledge set, and emotion reasoning chain prompts are input into the second language model. The second language model executes the chain logic path and outputs a structured, fine-grained user emotional state. The fine-grained user emotional state includes at least an analysis of the user's objective situation, subjective emotional experience, and potential needs.
[0011] Preferably, the step of constructing the emotion reasoning chain prompt guides the second language model to follow a chain-like logical path from the user's situation to the user's emotion, and then from the user's emotion to the user's intention, including: The second language model is guided to identify and structurally describe the core events and background environment that cause the user's current emotional fluctuations based on the complete text input and dialogue history, as an objective basis for reasoning; Based on the core events and background environment, the second language model is guided to infer the user's subjective emotional experience, which includes at least one dominant emotion category and its corresponding intensity tendency. Based on the aforementioned subjective emotional experience, the second language model is guided to further analyze the user's expectations and demands, that is, the dialogue goals that the user hopes to achieve by expressing the core events and emotions; Based on the core events, background environment, subjective emotional experiences, and user expectations, the fine-grained user emotional state is ultimately constituted.
[0012] Preferably, the step of planning the dialogue strategy based on the fine-grained user emotional state, dialogue history, and current dialogue state summary, and outputting the optimal dialogue strategy, includes: The current dialogue state is modeled as the root node. Based on the fine-grained user emotional state, the second language model is invoked, and the Monte Carlo tree search algorithm is used to simulate future multi-turn dialogues. The current dialogue state includes dialogue history, the fine-grained user emotional state, and target state information. During the simulation of Monte Carlo tree search, based on a preset multi-objective reward mechanism, the contribution of each candidate dialogue strategy to the three long-term objectives of exploring user problems, providing emotional comfort, and guiding actual actions is comprehensively evaluated. Based on the current dialogue round or the dialogue stage in the dialogue status summary, the weight coefficients of the three long-term goals in the multi-objective reward mechanism are dynamically adjusted so that exploration is emphasized in the early stage of the dialogue, comfort is emphasized in the middle stage, and action is emphasized in the later stage. Based on the simulation and evaluation results of Monte Carlo tree search, the dialogue strategy that can obtain the maximum long-term cumulative reward is selected, and the optimal dialogue strategy is obtained.
[0013] Secondly, this application provides a low-latency dialogue generation device based on hierarchical context engineering, which adopts the following technical solution, including: The information processing module is used to initialize a structured dialogue state summary and to dynamically record and update dialogue state information, which includes at least the user's emotional state, the current dialogue stage, and the user's intent. The text generation module is used to execute the reflection layer path and the planning layer path in parallel based on the initial text input and the current dialogue state summary. The reflection layer path is used to generate and output an instant emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to call the second language model in parallel to perform deep emotion reasoning based on the complete text input and dialogue history while the reflection layer path is running, and generate the core text response. The voice broadcast module is used to immediately synthesize the core text response into speech after detecting that the first synthesized speech has finished playing, and then continue playing the second synthesized speech. The dialogue update module is used to update the dialogue state summary based on the content of the core text response after the planning layer path is completed, for use in the next round of dialogue.
[0014] Thirdly, this application also provides a control device, the device comprising: It includes a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executed, such as the low-latency dialogue generation method based on hierarchical context engineering described above.
[0015] Fourthly, this application also provides a computer-readable storage medium storing a computer program that can be loaded by a processor and executed as described above in a low-latency dialogue generation method based on hierarchical context engineering.
[0016] In summary, the system in this application first initializes and dynamically maintains a structured dialogue state summary to capture key contextual information such as user emotions, dialogue stages, and intentions. A parallel dual-path processing mechanism is employed: the reflection layer uses a lightweight model to perform rapid sentiment analysis on user speech segments, instantly generating and playing emotional transition responses, effectively hiding the latency of subsequent system processing; simultaneously, the planning layer invokes a more powerful large language model to perform chain-like deep reasoning on complete user input, accurately inferring emotions from the context, then deriving intentions from emotions, and potentially performing forward-looking strategy planning through a multi-objective Monte Carlo tree search. This planning simulates the long-term impact of different dialogue strategies and comprehensively evaluates multiple objectives such as exploration, comfort, and action based on dynamically adjusted weights, thereby selecting the globally optimal strategy to generate a high-quality core response. Finally, the system uses intelligent scheduling to seamlessly continue playing the core response speech after the transition response ends. Thus, through clever parallel processing and resource scheduling, the system quickly responds to users while ensuring that the response content has profound empathy and strategic depth, reducing the inherent contradiction of difficulty in balancing response latency and dialogue quality in existing technologies, and significantly improving the naturalness and effectiveness of human-computer interaction. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating a low-latency dialogue generation method based on hierarchical context engineering.
[0018] Figure 2 This is a block diagram of a low-latency dialogue generation device based on hierarchical context engineering. Detailed Implementation
[0019] The following combination Figure 1 - Figure 2 This application will be described in further detail.
[0020] Reference Figure 1 The embodiments of this application include at least steps S10 to S40.
[0021] S10: Initialize a structured dialogue state summary for dynamically recording and updating dialogue state information. The state information includes at least the user's emotional state, the current dialogue stage, and the user's intent.
[0022] S20, based on the initial text input and the current dialogue state summary, executes the reflection layer path and the planning layer path in parallel. The reflection layer path is used to generate and output an immediate emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to perform deep emotion reasoning based on the complete text input and dialogue history in parallel while the reflection layer path is running, and to generate the core text response by calling the second language model.
[0023] After detecting the end of the first synthesized speech playback, S30 immediately synthesizes the core text response into speech and then plays the second synthesized speech.
[0024] S40: After the planning layer path is completed, update the dialogue state summary based on the content of the core text response for use in the next round of dialogue.
[0025] Specifically, a structured dialogue state summary is initialized and dynamically maintained to capture key contextual information such as user emotions, dialogue stages, and intentions. A parallel dual-path processing mechanism is employed: the reflection layer uses a lightweight model to quickly analyze user speech segments, instantly generating and playing emotional transition responses, effectively filling the latency gap in the system's deep processing; simultaneously, the planning layer invokes a more powerful large language model to perform deep emotion inference and strategy planning on the complete user input to generate high-quality core responses. Through intelligent scheduling, the system seamlessly continues playing the core response after the transition response playback ends, ultimately updating the dialogue state based on the content of this round of interaction, forming a continuously evolving interactive system with both rapid response and deep empathy capabilities.
[0026] In some embodiments, step S20 specifically includes the following steps: In the initial stage of receiving user voice input, obtaining preliminary text input converted from the initial voice segment; based on the preliminary text input and the current dialogue state summary, calling a first language model to generate an emotional transition text response, wherein the first language model is a lightweight model optimized to achieve millisecond-level inference latency; converting the emotional transition text into first synthesized speech and playing the speech. Obtaining complete text input converted from the user's complete voice input; based on the complete text input and dialogue history, calling a second language model to execute the emotion inference chain and outputting a fine-grained user emotion state, wherein the second language model is superior to the first language model in logical processing and contextual understanding; based on the fine-grained user emotion state, dialogue history, and the current dialogue state summary, performing dialogue strategy planning and outputting the optimal dialogue strategy; based on the optimal dialogue strategy, the fine-grained user emotion state, and the dialogue context, calling the second language model to generate the core text response.
[0027] Specifically, the reflection layer, based on the initial speech fragment and dialogue state, utilizes a lightweight model to generate emotional transition responses in milliseconds and play them instantly, effectively masking system latency. Simultaneously, the planning layer performs in-depth processing of the complete speech input, accurately analyzing the user's situation, emotions, and intentions through an emotion inference chain. It then combines multi-objective strategy planning to select the optimal dialogue strategy, ultimately generating a core response rich in empathy and intelligence. These two paths work together to ensure a seamless interactive experience where users receive an emotional response immediately after speaking, quickly gaining in-depth answers.
[0028] In practice, the first language model and the second language model are two core components working collaboratively within the system. They have a clear division of labor and complementarity in terms of model capabilities, design goals, and system roles. The first language model is a lightweight model optimized for low latency and high speed. Its core design goal is to complete reasoning within milliseconds, ensuring the rapid generation of emotional transitional responses based on incomplete speech fragments, acting as the system's "fast reflex arc." In contrast, the second language model is a larger model with greater power in logical reasoning, contextual understanding, and generation quality. It is responsible for performing complex deep sentiment analysis, strategy planning, and high-quality response generation, serving as the system's "deliberate brain." The two do not operate in isolation but form an asynchronous processing pipeline under a unified system schedule: the first model maintains the fluency of the dialogue through immediate feedback, while simultaneously buying valuable time for the second model's deep computation; the second model then uses this time for fine-tuning, and its high-quality output and state information, in turn, guide the first model's rapid decision-making in the next round, achieving the architectural cornerstone of low latency and high intelligence coexisting.
[0029] In this embodiment, the first language model can be a Qwen-7B model with 4-bit quantization, which is specifically responsible for generating immediate emotional transition responses; while the second language model can be a powerful GPT-4 or open-source Qwen-72B model, which has deep logical reasoning and contextual understanding capabilities, and is specifically responsible for executing fine-grained emotional reasoning chains and multi-objective strategy planning. The two together constitute the intelligent core of the system through a fast and slow complementary cooperation mechanism.
[0030] Furthermore, based on the initial text input and the current dialogue state summary, a first language model is invoked to generate an emotional transition text response. The first language model is a lightweight model optimized to achieve millisecond-level inference latency. Specifically, it includes: analyzing the initial text input to quickly identify its implicit dominant sentiment category and immediate dialogue intent; fusing the identified dominant sentiment category, immediate dialogue intent, and the current dialogue stage in the dialogue state summary to form a rapid contextual representation; inputting the rapid contextual representation into the first language model, and instructing the first language model to generate an emotional transition text response within a preset length and adapted to the dominant sentiment category based on a preset non-committal phrase library.
[0031] Specifically, the initial text is first analyzed in real time to extract its dominant emotion and immediate intent; then, this emotion and intent are dynamically integrated with the current stage of the dialogue to form a condensed contextual representation; finally, a lightweight first language model is guided to generate a transition text with a limited length that matches the user's emotional tone based on a preset safe phrase library, thereby quickly completing the conversion from emotional perception to appropriate language expression.
[0032] Furthermore, based on the complete text input and dialogue history, the second language model is invoked to execute the emotion reasoning chain and output a fine-grained user emotion state. Specifically, this includes: automatically generating multiple common-sense inferences related to the current discourse from an external common-sense knowledge base based on the complete text input, and filtering them based on their relevance to the dialogue context to form a refined knowledge set; constructing an emotion reasoning chain prompt, which guides the second language model to follow a chain-like logical path from the user's situation to the user's emotion, and then from the user's emotion to the user's intention; inputting the complete text input, dialogue history, refined knowledge set, and emotion reasoning chain prompt into the second language model, which then executes the chain-like logical path and outputs a structured fine-grained user emotion state. The fine-grained user emotion state includes at least an analysis of the user's objective situation, subjective emotional experience, and potential demands.
[0033] Specifically, the system first generates and filters refined knowledge highly relevant to the current dialogue from an external common sense knowledge base as supplementary context; then it constructs a progressive reasoning chain of situation → emotion → intention, guiding the second language model to analyze the user's objective situation, infer subjective emotional experience and analyze potential demands based on the complete dialogue history and refined knowledge; finally, it outputs a structured, fine-grained emotional state, completing the deepening from semantic understanding to emotional understanding.
[0034] Furthermore, an emotion reasoning chain prompt is constructed to guide the second language model along a chain-like logical path from inferring the user's situation to their emotions, and then from their emotions to their intentions. Specifically, this includes: guiding the second language model to identify and structurally describe the core events and background environment that cause the user's current emotional fluctuations based on complete text input and dialogue history, serving as the objective basis for reasoning; based on the core events and background environment, guiding the second language model to infer the user's subjective emotional experience, which includes at least one dominant emotion category and its corresponding intensity; based on the subjective emotional experience, guiding the second language model to further analyze the user's expectations and demands, i.e., the dialogue goals the user hopes to achieve by expressing the core events and emotions; and finally, based on the core events, background environment, subjective emotional experience, and the user's expectations and demands, a fine-grained user emotional state is formed.
[0035] Specifically, the model is first guided to identify the core events and environmental context that trigger emotions, establishing an objective factual basis; then, based on this, the user's subjective emotional experience is inferred, including the type and intensity of emotions; finally, the deep-seated demands that the user hopes to achieve through expression are analyzed, forming a complete cognitive map from objective situation to subjective feelings to behavioral intentions. These three reasoning steps together constitute a refined model of the user's psychological state.
[0036] In some embodiments, considering the output of the optimal dialogue strategy, the corresponding processing steps are as follows: The current dialogue state is modeled as the root node. Based on fine-grained user emotional states, a second language model is invoked, and a Monte Carlo tree search algorithm is used to simulate future multi-turn dialogues. The current dialogue state includes dialogue history, fine-grained user emotional states, and target state information. During the Monte Carlo tree search simulation, according to a preset multi-objective reward mechanism, the contribution of each candidate dialogue strategy to the three long-term objectives of exploring user problems, providing emotional comfort, and guiding actual action is comprehensively evaluated. Based on the dialogue stage in the current dialogue round or dialogue state summary, the weight coefficients of the three long-term objectives in the multi-objective reward mechanism are dynamically adjusted, so that exploration is emphasized in the early stage of the dialogue, comfort is emphasized in the middle stage, and action is emphasized in the later stage. Based on the simulation and evaluation results of the Monte Carlo tree search, the dialogue strategy that can obtain the maximum long-term cumulative reward is selected, thus obtaining the optimal dialogue strategy.
[0037] Specifically, the Monte Carlo tree search algorithm is used to realize long-term planning of dialogue strategies: taking the current dialogue state as the root node, the development of future multi-turn dialogues is simulated based on fine-grained emotional states; during the simulation, a multi-objective reward mechanism is used to evaluate the contribution of each strategy to the three major objectives of exploration, comfort, and action, and the weight of each objective is dynamically adjusted according to the progress of the dialogue to realize the shift of focus from exploration to comfort and then to action; finally, the optimal strategy that can obtain the maximum long-term cumulative reward is selected through comprehensive evaluation to ensure that the dialogue system has the ability to provide continuous support for goal orientation.
[0038] The implementation principle of a low-latency dialogue generation method based on hierarchical context engineering in this application is as follows: The system first initializes and dynamically maintains a structured dialogue state summary to capture key contexts such as user emotions, dialogue stages, and intentions. A parallel dual-path processing mechanism is adopted: the reflection layer uses a lightweight model to perform rapid sentiment analysis on user speech segments, instantly generating and playing emotional transition responses, effectively hiding the latency of subsequent system processing; simultaneously, the planning layer calls a stronger large language model to perform chain-like deep reasoning on complete user input, accurately inferring emotions from the context, then deriving intentions from emotions, and possibly performing forward-looking strategy planning through a multi-objective Monte Carlo tree search. This planning simulates the long-term impact of different dialogue strategies and comprehensively evaluates multiple objectives such as exploration, comfort, and action based on dynamically adjusted weights, thereby selecting the globally optimal strategy to generate a high-quality core response. Finally, the system uses intelligent scheduling to seamlessly continue playing the core response speech after the transition response ends. Through clever parallel processing and resource scheduling, it can quickly respond to users while ensuring that the response content is deeply empathetic and strategic. This reduces the inherent contradiction between response latency and dialogue quality in existing technologies, and significantly improves the naturalness and effectiveness of human-computer interaction.
[0039] Figure 1 This is a flowchart illustrating a low-latency dialogue generation method based on hierarchical context engineering in one embodiment. It should be understood that, although... Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows; unless explicitly stated otherwise, there is no strict order requirement for the execution of these steps, and they can be executed in other orders; and Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0040] Based on the same technical concept, referring to Figure 2 This application also provides a low-latency dialogue generation device based on hierarchical context engineering, which adopts the following technical solution: The device includes: The information processing module is used to initialize a structured dialogue state summary, and to dynamically record and update dialogue state information. The state information includes at least the user's emotional state, the current dialogue stage, and the user's intent. The text generation module is used to execute the reflection layer path and the planning layer path in parallel based on the initial text input and the current dialogue state summary. The reflection layer path is used to generate and output an instant emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to perform deep emotion reasoning in parallel based on the complete text input and dialogue history while the reflection layer path is running, and to generate the core text response by calling the second language model. The voice broadcast module is used to immediately synthesize the core text response into speech after the first synthesized speech has finished playing, and then continue playing the second synthesized speech. The dialogue update module is used to update the dialogue state summary based on the content of the core text response after the planning layer path is completed, so that it can be used in the next round of dialogue.
[0041] In some embodiments, the text generation module is specifically used to obtain preliminary text input converted from an initial speech segment at the initial stage of receiving user voice input; Based on the initial text input and the current dialogue state summary, the first language model is invoked to generate emotional transition text responses. The first language model is a lightweight model optimized to achieve millisecond-level inference latency. The emotional transitional text is converted into the first synthesized speech and then played back.
[0042] In some embodiments, the text generation module is specifically used to obtain complete text input converted from the user's complete voice input; Based on complete text input and dialogue history, the second language model is invoked to execute the emotion inference chain and output fine-grained user emotion state. The second language model is superior to the first language model in terms of logical processing and context understanding. Based on fine-grained user emotional state, dialogue history, and current dialogue state summary, dialogue strategy planning is performed, and the optimal dialogue strategy is output. Based on the optimal dialogue strategy, fine-grained user emotional state, and dialogue context, a second language model is invoked to generate the core text response.
[0043] In some embodiments, the text generation module is specifically used to analyze the initial text input to quickly identify its implicit dominant sentiment category and immediate conversational intent. The identified dominant sentiment category, immediate dialogue intent, and current dialogue stage in the dialogue state summary are fused to form a rapid contextual representation; The fast contextual representation is input into the first language model, which is then instructed to generate an emotional transition text response that is within a preset length and matches the dominant sentiment category, based on a preset non-committal phrase library.
[0044] In some embodiments, the text generation module is specifically used to automatically generate multiple common-sense inferences related to the current discourse from an external common-sense knowledge base based on complete text input, and filter them based on their relevance to the dialogue context to form a refined knowledge set; Construct an emotion reasoning chain prompt, and guide the second language model to follow a chain-like logical path from the user's situation to the user's emotion, and then from the user's emotion to the user's intention. The complete text input, dialogue history, refined knowledge set, and emotion reasoning chain prompts are input into the second language model. The second language model executes a chain-like logical path and outputs a structured, fine-grained user emotional state. The fine-grained user emotional state includes at least an analysis of the user's objective situation, subjective emotional experience, and potential needs.
[0045] In some embodiments, the text generation module is specifically used to guide the second language model to identify and structurally describe the core events and background environment that cause the user's current emotional fluctuations based on complete text input and dialogue history, as an objective basis for reasoning; Based on the core events and background environment, the second language model is guided to infer the user's subjective emotional experience, which includes at least one dominant emotion category and its corresponding intensity tendency. Based on subjective emotional experience, the second language model is guided to further analyze the user's expectations and demands, that is, the dialogue goals that the user hopes to achieve by expressing core events and emotions; Based on the core events, background environment, subjective emotional experience, and user expectations, the fine-grained user emotional state is ultimately formed.
[0046] In some embodiments, the text generation module is specifically used to model the current dialogue state as the root node, and based on the fine-grained user emotional state, call the second language model and simulate future multi-turn dialogues through the Monte Carlo tree search algorithm. The current dialogue state includes dialogue history, fine-grained user emotional state and target state information. During the simulation of Monte Carlo tree search, based on a preset multi-objective reward mechanism, the contribution of each candidate dialogue strategy to the three long-term objectives of exploring user problems, providing emotional comfort, and guiding actual actions is comprehensively evaluated. Based on the current dialogue round or the dialogue stage in the dialogue status summary, the weight coefficients of the three long-term goals in the multi-objective reward mechanism are dynamically adjusted so that the focus is on exploration in the early stage of the dialogue, comfort in the middle stage, and action in the later stage. Based on the simulation and evaluation results of Monte Carlo tree search, the dialogue strategy that can obtain the maximum long-term cumulative reward is selected, thus obtaining the optimal dialogue strategy.
[0047] This application also discloses a control device.
[0048] Specifically, the control device includes a memory and a processor, the memory storing a computer program that can be loaded and executed by the processor to perform the aforementioned low-latency dialogue generation method based on hierarchical context engineering.
[0049] This application also discloses a computer-readable storage medium.
[0050] Specifically, the computer-readable storage medium stores a computer program that can be loaded by a processor and executed, such as the low-latency dialogue generation method based on hierarchical context engineering described above. The computer-readable storage medium includes, for example, various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0051] The above are all preferred embodiments of this application, and are not intended to limit the scope of protection of this application. Therefore, all equivalent changes made in accordance with the structure, shape and principle of this application should be covered within the scope of protection of this application.
Claims
1. A low-latency dialogue generation method based on hierarchical context engineering, characterized in that, include: Initialize a structured dialogue state summary for dynamically recording and updating dialogue state information, which includes at least the user's emotional state, the current dialogue stage, and the user's intent; Based on the initial text input and the current dialogue state summary, the reflection layer path and the planning layer path are executed in parallel. The reflection layer path is used to generate and output an immediate emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to call the second language model in parallel to perform deep emotion reasoning based on the complete text input and dialogue history while the reflection layer path is running, and generate the core text response. After the first synthesized speech has finished playing, the core text response is immediately synthesized into speech, and the second synthesized speech is played next. After the planning layer path is completed, the dialogue state summary is updated based on the content of the core text response for use in the next round of dialogue.
2. The low-latency dialogue generation method based on hierarchical context engineering according to claim 1, characterized in that, The parallel execution of the reflection layer path and planning layer path based on the initial text input and the current dialogue state summary, wherein the reflection layer path is used to generate and output an immediate emotional transition, generates a transition text response by calling the first language model, and generates the first synthesized speech, including: In the initial stage of receiving user voice input, the preliminary text input converted from the initial voice segment is obtained; Based on the initial text input and the current dialogue state summary, the first language model is invoked to generate an emotional transition text response. The first language model is a lightweight model optimized to achieve millisecond-level inference latency. The emotional transition text is converted into the first synthesized speech and then played back.
3. The low-latency dialogue generation method based on hierarchical context engineering according to claim 2, characterized in that, The planning layer path is used to, while the reflection layer path is running, in parallel invoke a second language model to perform deep sentiment inference based on complete text input and dialogue history, generating core text responses, including: Obtain complete text input converted from the user's complete voice input; Based on the complete text input and dialogue history, the second language model is invoked to execute the emotion inference chain and output fine-grained user emotion state. The second language model is superior to the first language model in terms of logical processing and context understanding. Based on the fine-grained user emotional state, dialogue history, and current dialogue state summary, dialogue strategy planning is performed, and the optimal dialogue strategy is output. Based on the optimal dialogue strategy, the fine-grained user emotional state, and the dialogue context, the second language model is invoked to generate the core text response.
4. The low-latency dialogue generation method based on hierarchical context engineering according to claim 3, characterized in that, Based on the initial text input and the current dialogue state summary, a first language model is invoked to generate an emotional transition text response. The first language model is a lightweight model optimized to achieve millisecond-level inference latency, including: The initial text input is analyzed to quickly identify its implicit dominant sentiment category and immediate conversational intent; The identified dominant sentiment category, immediate dialogue intent, and current dialogue stage in the dialogue state summary are fused to form a rapid contextual representation; The fast context representation is input into the first language model, and the first language model is instructed to generate an emotional transition text response within a preset length and adapted to the dominant sentiment category based on a preset non-committal phrase library.
5. A low-latency dialogue generation method based on hierarchical context engineering according to claim 3, characterized in that, Based on the complete text input and dialogue history, the second language model is invoked to execute the emotion inference chain and output fine-grained user emotion state, including: Based on the complete text input, multiple common-sense inferences related to the current discourse are automatically generated from an external common-sense knowledge base, and filtered based on their relevance to the dialogue context to form a refined knowledge set; Construct an emotion reasoning chain prompt, and guide the second language model to follow a chain-like logical path from the user's situation to the user's emotion, and then from the user's emotion to the user's intention. The complete text input, dialogue history, refined knowledge set, and emotion reasoning chain prompts are input into the second language model. The second language model executes the chain logic path and outputs a structured, fine-grained user emotional state. The fine-grained user emotional state includes at least an analysis of the user's objective situation, subjective emotional experience, and potential needs.
6. The low-latency dialogue generation method based on hierarchical context engineering according to claim 5, characterized in that, The construction of the emotion reasoning chain prompt guides the second language model to follow a chain-like logical path from user situation to user emotion, and then from user emotion to user intention, including: The second language model is guided to identify and structurally describe the core events and background environment that cause the user's current emotional fluctuations based on the complete text input and dialogue history, as an objective basis for reasoning; Based on the core events and background environment, the second language model is guided to infer the user's subjective emotional experience, which includes at least one dominant emotion category and its corresponding intensity tendency. Based on the aforementioned subjective emotional experience, the second language model is guided to further analyze the user's expectations and demands, that is, the dialogue goals that the user hopes to achieve by expressing the core events and emotions; Based on the core events, background environment, subjective emotional experiences, and user expectations, the fine-grained user emotional state is ultimately constituted.
7. A low-latency dialogue generation method based on hierarchical context engineering according to claim 5, characterized in that, The process of planning dialogue strategies based on the fine-grained user emotional state, dialogue history, and current dialogue state summary, and outputting the optimal dialogue strategy, includes: The current dialogue state is modeled as the root node. Based on the fine-grained user emotional state, the second language model is invoked, and the Monte Carlo tree search algorithm is used to simulate future multi-turn dialogues. The current dialogue state includes dialogue history, the fine-grained user emotional state, and target state information. During the simulation of Monte Carlo tree search, based on a preset multi-objective reward mechanism, the contribution of each candidate dialogue strategy to the three long-term objectives of exploring user problems, providing emotional comfort, and guiding actual actions is comprehensively evaluated. Based on the current dialogue round or the dialogue stage in the dialogue status summary, the weight coefficients of the three long-term goals in the multi-objective reward mechanism are dynamically adjusted so that exploration is emphasized in the early stage of the dialogue, comfort is emphasized in the middle stage, and action is emphasized in the later stage. Based on the simulation and evaluation results of Monte Carlo tree search, the dialogue strategy that can obtain the maximum long-term cumulative reward is selected, and the optimal dialogue strategy is obtained.
8. A low-latency dialogue generation apparatus based on hierarchical context engineering, characterized in that, The device includes: The information processing module is used to initialize a structured dialogue state summary and to dynamically record and update dialogue state information, which includes at least the user's emotional state, the current dialogue stage, and the user's intent. The text generation module is used to execute the reflection layer path and the planning layer path in parallel based on the initial text input and the current dialogue state summary. The reflection layer path is used to generate and output an instant emotional transition by calling the first language model to generate a transition text response and generate the first synthesized speech. The planning layer path is used to call the second language model in parallel to perform deep emotion reasoning based on the complete text input and dialogue history while the reflection layer path is running, and generate the core text response. The voice broadcast module is used to immediately synthesize the core text response into speech after detecting that the first synthesized speech has finished playing, and then continue playing the second synthesized speech. The dialogue update module is used to update the dialogue state summary based on the content of the core text response after the planning layer path is completed, for use in the next round of dialogue.
9. A control device, characterized in that, The device includes: A memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executed as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer program is stored that can be loaded by a processor and executed as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Incremental coding dialogue emotion recognition method fusing knowledge
CN115169363A
Text reply method, electronic equipment and computer readable storage medium
CN118674039A
User incoming call intention recognition method and device and readable storage medium
CN118899006A
Digital human emotion perception and dynamic response method, system and device and storage medium
CN119884327A
Situation simulation method and system based on vehicle-mounted large language model
CN120296197A