Dialogue generation method, device and equipment and computer readable storage medium

By extracting quintuples from dialogues and generating dialogues using a progressive thought chain extension algorithm and a dual-channel verification mechanism, the problem of insufficient logical consistency in existing technologies is solved, and the adaptability and flexibility of dialogue generation are improved.

CN121615786APending Publication Date: 2026-03-06ZHEJIANG TONGHUASHUN INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511906971.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing dialogue generation technologies are insufficient in terms of logical consistency, adaptability, and flexibility, and are particularly difficult to adapt to the needs of multiple fields in specific scenarios such as medical consultation and legal counseling.

Method used

By extracting a quintuple from the current dialogue, including subject, relation, object, timestamp, and context, dynamic programming is performed using a progressive thought chain extension algorithm, combined with logical consistency constraints and a dual-channel verification mechanism to generate the output dialogue.

Benefits of technology

It improves the logical consistency and adaptability of dialogue generation, enabling it to adapt to different domain scenarios and multi-turn dialogues, and enhances the accuracy and flexibility of dialogue generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121615786A_ABST
    Figure CN121615786A_ABST
Patent Text Reader

Abstract

The invention discloses a dialogue generation method, device and equipment and a computer readable storage medium, and is applied to the technical field of computers, and the method comprises the steps: extracting a quintuple from the context of a current dialogue, and the quintuple comprises a subject, a relationship, an object, a timestamp and a context; the relationship can be dynamically adjusted; based on the logic consistency constraint, performing dynamic planning on the quintuple by using a progressive thinking chain extension algorithm to obtain a thinking chain; and inputting the thinking chain and the context of the current dialogue into the generative model to obtain an output dialogue. The context and the timestamp in the quintuple can accurately identify the scene of the current dialogue, and meanwhile, the weight of the relationship in the dialogue can be dynamically adjusted along with the content, so that the method can adapt to different field scenes and multiple rounds of dialogues, and the adaptivity and the flexibility for various professional scenes are improved; moreover, the thinking chain is generated based on the quintuple and the progressive thinking chain extension algorithm, the specific logic mode of the scene can be captured, and the accuracy and logic consistency of dialogue generation are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a dialogue generation method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] In recent years, significant progress has been made in the field of natural language processing, particularly in the application of dialogue systems, thanks to breakthroughs in large language models (LLMs). However, specific scenarios such as medical consultation and legal counseling place higher demands on the logical consistency of dialogue systems. Current technical solutions for improving logical consistency suffer from the following shortcomings: they are insufficient in terms of adaptability, flexibility, and the ability to adapt to different domains.

[0003] Therefore, how to improve logical consistency while ensuring adaptability and flexibility is a technical problem that urgently needs to be solved. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a dialogue generation method, apparatus, device and computer-readable storage medium, which solves the problems of poor consistency, insufficient flexibility and adaptability in dialogue generation logic in the prior art.

[0005] To address the aforementioned technical problems, this invention provides a dialogue generation method, comprising:

[0006] Extract a quintuple from the context of the current dialogue; the quintuple includes: subject, relation, object, timestamp, and context; the timestamp includes absolute time and relative time; the context includes context label and context vector; the relation can be dynamically adjusted;

[0007] Based on logical consistency constraints, the progressive thinking chain expansion algorithm is used to dynamically program the five-tuple to obtain the thinking chain; the progressive thinking chain expansion algorithm is a thinking chain generation algorithm that combines step-by-step expansion and dynamic programming optimization.

[0008] The thought chain and the context of the current dialogue are input into the generative model to obtain the output dialogue.

[0009] Optionally, extract the quintuple from the context of the current conversation, including:

[0010] Parse the context of the current dialogue to generate the context and the timestamp;

[0011] Based on the aforementioned context, a target domain-specific relation template library is invoked to define the scope of entities and relationships within the domain; the entities include the subject and the object.

[0012] The context of the current dialogue is encoded, the entity and the relationship are determined based on the entity scope and the relationship scope, and the weights of different relationships within the domain are dynamically adjusted.

[0013] Optionally, based on logical consistency constraints, a progressive thinking chain expansion algorithm is used to dynamically program the quintuple to obtain a thinking chain, including:

[0014] Word embedding processing is performed on the subject and object in the quintuple to obtain subject vector and object vector;

[0015] Obtain the logical consistency score calculation rule; the consistency score calculation rule is to calculate the correlation score between the subject vector of the first quintuple and the object vector of the second quintuple by cosine similarity for any adjacent first quintuple and second quintuple;

[0016] From a thought chain containing a quintuple Begin by progressively building the thought chain of the first k quintuples. And based on the logical consistency score calculation rules, each thought chain is obtained. The logical consistency score; k ranges from 2 to n, where n is the total number of the quintuples, k is the length of the current constructed thought chain, j is the length of the preceding thought chain, and j is less than k;

[0017] For each of the aforementioned thought chains From the thought chain containing the first j quintuples In the middle, the thought chain is... The target thought chain corresponding to the highest logical consistency score is taken as the thought chain. The optimal preceding thought chain; the thought chain For the chain of thought It forms a pair with the k-th quintuple;

[0018] When k=n, based on the optimal preceding thought chain, the thought chain is... The thought chain with the highest logical consistency score is designated as the thought chain.

[0019] Optionally, each thought chain is obtained based on the logical consistency score calculation rules. The logical consistency score includes:

[0020] ;

[0021] ;

[0022] in, This is the main body of the first quintuple; The object of the second quintuple; The correlation score; This is the principal vector of the first quintuple; Let be the object vector of the second quintuple; For the aforementioned thought chain Logical consistency score.

[0023] Optionally, the thought chain and the context of the current dialogue are input into the generative model to obtain the output dialogue, including:

[0024] The thought chain and the context of the current dialogue are input into the generative model to obtain the generated intermediate response fragment;

[0025] The intermediate response fragments are grammatically validated using a pre-defined grammar rule base, and their semantic coherence is validated using a semantic association graph.

[0026] When the verification passes, the intermediate fragments are generated based on the original strategy of the generation model, and the syntax verification and semantic coherence verification are performed until the complete output dialogue is obtained.

[0027] If the validation fails, the generation strategy of the generation model is dynamically adjusted, and the intermediate fragments are generated based on the adjusted generation strategy. The syntax validation and semantic coherence validation are then performed until the complete output dialogue is obtained.

[0028] Optionally, the thought chain and the context of the current dialogue are input into the generative model to obtain the output dialogue, including:

[0029] The thought chain and the context of the current dialogue are input into the generative model, and external knowledge results are obtained by querying the professional domain knowledge base;

[0030] The thought chain and the context of the current dialogue are input into the generative model, and the internal reasoning result is obtained through the internal reasoning capability of the generative model;

[0031] The output dialogue is obtained based on the external knowledge results and the internal reasoning results.

[0032] Optionally, the output dialogue is obtained based on the external knowledge results and the internal reasoning results, including:

[0033] The external knowledge results and the internal reasoning results are weighted and fused to obtain the output dialogue;

[0034] Alternatively, the output dialogue can be obtained by dynamically selecting and fusing the external knowledge results and the internal reasoning results using an attention mechanism.

[0035] The present invention also provides a dialogue generation apparatus, comprising:

[0036] The quintuple extraction module is used to extract quintuples from the context of the current dialogue; the quintuple includes: subject, relation, object, timestamp, and context; the timestamp includes absolute time and relative time; the context includes context label and context vector; the relation can be dynamically adjusted;

[0037] The thought chain construction module is used to dynamically program the five-tuple based on logical consistency constraints and using a progressive thought chain expansion algorithm to obtain the thought chain; the progressive thought chain expansion algorithm is a thought chain generation algorithm that combines step-by-step expansion and dynamic programming optimization.

[0038] The dialogue generation module is used to input the thought chain and the context of the current dialogue into the generation model to obtain the output dialogue.

[0039] The present invention also provides a dialogue generation device, comprising:

[0040] Memory, used to store computer programs;

[0041] A processor for executing the computer program to implement the dialogue generation method as described above.

[0042] The present invention also provides a computer-readable storage medium storing computer-executable instructions, which, when loaded and executed by a processor, implement the dialogue generation method described above.

[0043] As can be seen, this invention extracts a quintuple from the context of the current dialogue. The quintuple includes: subject, relation, object, timestamp, and context. The timestamp includes absolute and relative time; the context includes context tags and context vectors; and the relation can be dynamically adjusted. Based on logical consistency constraints, a progressive thought chain expansion algorithm is used to dynamically program the quintuple to obtain a thought chain. The progressive thought chain expansion algorithm is a thought chain generation algorithm that is progressively expanded and dynamically optimized. The thought chain and the context of the current dialogue are input into the generation model to obtain the output dialogue. This invention clarifies the core connections in the dialogue through structured quintuples. The context and timestamp in the quintuple can accurately identify the scene of the current dialogue, and the weight of the relation in the dialogue is dynamically adjusted with the content. This allows it to adapt to different domain scenarios and multi-turn dialogues, improving adaptability and flexibility for various professional scenarios. Furthermore, the thought chain generated based on the quintuple and the progressive thought chain expansion algorithm can capture the unique logical patterns of the scene, enhancing the accuracy and logical consistency of dialogue generation.

[0044] In addition, the present invention also provides a dialogue generation apparatus, device, and computer-readable storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description

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

[0046] Figure 1 A flowchart for dialogue generation is provided as an embodiment of the present invention;

[0047] Figure 2 This is a schematic diagram of the structure of a dialogue generation device provided in an embodiment of the present invention;

[0048] Figure 3 This is a schematic diagram of the structure of a dialogue generation device provided in an embodiment of the present invention. Detailed Implementation

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

[0050] First, let me explain some of the terms used in this application:

[0051] Large Language Models (MLMs): These are language models widely used in the field of artificial intelligence. Their main characteristic is their extremely large number of parameters, hence the name "large model." Large language models are trained on massive amounts of data to understand and generate natural language text. Their applications are very broad, including but not limited to automatic translation, text generation, dialogue systems, and information retrieval. Due to their large number of parameters and complex structure, large language models can capture complex patterns and semantic relationships in language, thus performing exceptionally well in various tasks.

[0052] Thought chains are a type of text-based reasoning logic, typically structured in a chain, used to simulate the human thought process. The basic idea behind thought chains is to break down complex problems into a series of simple steps, each building upon the result of the previous step, progressively leading to the final conclusion. This method not only improves the accuracy and transparency of reasoning but also helps systems better understand and handle complex problems. In the field of artificial intelligence, thought chains are widely used in question-answering systems, decision support systems, and intelligent assistants. By simulating human thought processes, they enable systems to interact more naturally with users and provide more accurate answers and suggestions.

[0053] In recent years, significant progress has been made in natural language processing, particularly in dialogue systems, thanks to breakthroughs in large language models (LLMs). Large models such as GPT-4 and Qwen, trained on massive amounts of data, have demonstrated powerful language generation capabilities. These models not only achieve near-human fluency and diversity in generated text but also demonstrate a deep understanding of context. However, in specific scenarios such as medical consultations and legal advice, dialogue systems require a high degree of logical consistency, posing challenges to existing technologies in these areas. To overcome these challenges, solutions have been proposed from different perspectives, such as explicit constraint methods based on knowledge graphs and implicit modeling methods based on attention mechanisms. Although existing technologies have made some progress in improving the logical consistency of dialogue generation, many shortcomings remain. For example, explicit constraint methods based on knowledge graphs, while improving the logical consistency of dialogue to some extent, are highly dependent on the completeness of the knowledge base. This dependence makes these methods inadequate when dealing with dynamically changing dialogue contexts. Furthermore, updating and maintaining the knowledge base requires significant human and time resources, which is particularly challenging in rapidly changing domains. While implicit modeling methods based on attention mechanisms enhance logical reasoning capabilities to some extent, their "black box" nature makes tracking logical deviations difficult. Due to the complexity of these models, developers struggle to understand or explain the internal logical flow, posing a challenge to identifying and correcting logical errors generated by the model. Moreover, these methods lack flexibility when handling multi-domain requirements and are ill-suited to adapting to different dialogue scenarios.

[0054] In summary, while existing technologies have made some progress in achieving logical consistency in dialogue generation, there is still significant room for improvement in terms of dynamic adaptability, flexibility, and the ability to adapt to different domains. This invention aims to address the problem of insufficient logical consistency in existing dialogue generation technologies, particularly in scenarios requiring high logical consistency, such as medical consultation and legal counseling. The main challenges faced by current technical solutions include: excessive reliance on knowledge bases, insufficient adaptability, and the black-box nature of implicit modeling methods.

[0055] Please refer to the details. Figure 1 , Figure 1 A flowchart for dialogue generation is provided as an embodiment of the present invention. The method may include:

[0056] S101: Extract a quintuple from the context of the current dialogue.

[0057] The execution subject in this embodiment is a terminal. This embodiment does not limit the type of terminal, as long as it can perform the dialogue generation method.

[0058] It should be noted that the quintuple in this embodiment includes subject, relation, object, timestamp, and context. This embodiment introduces time and context into the triple of subject, relation, and object, aiming to capture semantic information in the dialogue more comprehensively. That is: Quintuple = (Subject - S, Relation - R, Object - O, Timestamp - T, Context - C).

[0059] It's further important to note that the timestamp T in the quintuple expands the time dimension, encompassing both absolute and relative time. Absolute time provides the precise moment the dialogue occurred, such as "2023-10-05 14:30:25," crucial for recording the exact time of an event. Meanwhile, relative time marks logical dependencies within the dialogue by calculating dialogue turn offsets, for example: Where 'a' represents the number of time intervals from the starting point (starting dialogue) to the current point (current dialogue); Δt represents the standard time unit for each interval; Indicates relative time; This represents a baseline value. This two-layer time annotation method not only helps in understanding the sequential structure of a conversation but also effectively identifies the changing trends of certain key information over time. Especially in the legal field, revisions to legal provisions may lead to differences in interpretation between different periods; the addition of the time dimension can more accurately capture these changes in timeliness.

[0060] It's worth noting that the context C in the quintuple enhances the understanding and processing of context. Context includes two aspects: context labels and context vectors. Context labels are primarily used to identify the domain of the dialogue (e.g., medical, legal, financial) and the specific scenario type (e.g., diagnosis, compensation, investment), which helps in quickly locating and classifying information. Meanwhile, the context vectors... The context vector is generated by encoding the content of nearly N rounds of dialogue using BERT (a pre-trained language model): Here, D represents the entire round of dialogue; b represents the current round of dialogue. Context can capture subtle changes in context during a dialogue. For example, the term "margin" has drastically different meanings in the financial and legal fields. By combining context labels and context vectors, the precise meaning of words in a specific context can be analyzed more accurately, thereby resolving cross-domain ambiguities. In this way, the quintuple not only enhances the accuracy of information extraction but also provides a solid foundation for subsequent knowledge reasoning and application.

[0061] It should be further explained that the relationship can be dynamically adjusted; here, the relationship refers to the relationship between an object and a subject. To more accurately reflect the complex dynamics of relationships in the real world, this embodiment also introduces dynamic relationship weights, meaning that relationships can be dynamically adjusted by setting weights. The weight range is [0,1], initially set to 0.5. This allows for automatic adjustment of the importance of relationships based on context, thus more flexibly adapting to the needs of different scenarios. For example, in medical consultations, the strength of the association between the symptoms mentioned by the patient and the disease may vary depending on the duration and severity of the symptoms; dynamic relationship weights can better reflect this change. For instance, in medical consultations, the strength of the "symptom-disease" association can be dynamically updated as the duration and severity of the patient's symptoms change, accurately modeling the dynamic evolution of semantic associations in the dialogue and eliminating reliance on static knowledge bases.

[0062] This embodiment can extract quintuples from the context of the current dialogue using an extraction algorithm / model. To improve the generalization ability and semantic accuracy of structural quintuples in cross-domain scenarios, this embodiment further constructs a context-aware domain-adaptive mechanism. Specifically, the extraction of quintuples from the context of the current dialogue can include: parsing the context of the current dialogue to generate context and timestamps; calling a target domain-specific relation template library based on the context, and defining the scope of entities and relations within the domain using the target domain-specific relation template library; entities include subjects and objects; encoding the context of the current dialogue, and determining entities and relations based on the entity and relation scopes.

[0063] Specifically, the context-aware domain-adaptive mechanism aims to enhance the robustness of the model in multi-domain tasks by introducing a domain-specific relation template library and a context-driven relation mapping strategy to dynamically adapt semantic expressions in different professional domains (such as medicine, law, and finance). First, a structured domain-specific relation template library is pre-designed to address the semantic characteristics of different domains. This template library can be organized in the form of a knowledge graph, containing typical five-tuple patterns and their relation definitions from multiple vertical domains. For example, in the medical field, "symptom-disease" and "drug-contraindication" are common relations; while in the legal field, logical associations such as "subject-rights and obligations" and "clause-scope of application" are more important. Through the predefined domain-specific relation templates, the system can prioritize matching structures that conform to the semantics of the current domain when extracting five-tuples, avoiding semantic ambiguity caused by generalized modeling. Second, to achieve efficient transfer from a general domain to a specific domain, this embodiment adopts a context-based dynamic relation mapping strategy. Specifically, by identifying contextual tags (such as domain identifiers and scene types) in real time and combining them with context vectors (i.e., context vectors) generated by BERT, the output distribution when generating relational words is dynamically adjusted. For example, when the current dialogue is detected to belong to the financial domain and involve the scenario of "investment consulting," the model will automatically enhance its sensitivity to keywords such as "return," "risk level," and "product type," thereby improving the domain fit and semantic consistency of the extraction results. This mechanism not only improves the accuracy of five-tuple extraction but also significantly enhances the system's adaptability when facing new domains or mixed context dialogues. The domain adaptation mechanism in this embodiment effectively solves the problems of semantic drift and logical inconsistency in cross-domain information extraction, providing key support for building a dialogue understanding system with strong generalization ability and high semantic accuracy.

[0064] S102: Based on logical consistency constraints, the progressive thinking chain expansion algorithm is used to perform dynamic programming on the quintuple to obtain the thinking chain.

[0065] It's important to clarify that mind chain construction involves organizing extracted quintuples into a coherent logical chain to reflect the main logical thread of the dialogue and user needs. A mind chain is represented as an ordered sequence of quintuples. Each quintuple represents a key interaction point in the dialogue. By arranging these quintuples in a logical order, a mind chain reflecting the dialogue's logic can be formed. This mind chain not only captures the main logical thread of the dialogue but also reflects subtle differences in user needs and background information, providing crucial guidance for subsequent dialogue generation.

[0066] In this embodiment, the construction of the thought chain does not rely on manually designed prompt templates, as such reliance makes it difficult to automatically capture scene-specific logical patterns, thus limiting their versatility in diverse applications. Therefore, this embodiment employs a progressive thought chain expansion algorithm using dynamic programming to construct the thought chain. The progressive thought chain expansion algorithm is a thought chain generation algorithm that gradually expands and is optimized by dynamic programming. Progressive expansion is the core path of thought chain construction. Instead of directly performing full permutation filtering on all quintuples, it starts with a single quintuple and successively adds new quintuples, gradually expanding the length of the thought chain like building blocks (from a short chain containing one quintuple to a long chain containing n quintuples), avoiding redundant calculations.

[0067] Furthermore, based on logical consistency constraints, the above-mentioned progressive thinking chain expansion algorithm is used to dynamically program the quintuple to obtain the thinking chain, which can specifically include:

[0068] Step 1: Perform word embedding processing on the subject and object in the quintuple to obtain the subject vector and object vector.

[0069] Step 2: Obtain the logical consistency score calculation rules; the consistency score calculation rules are as follows: for any adjacent first quintuple and second quintuple, calculate the relevance score of the subject vector of the first quintuple and the object vector of the second quintuple using cosine similarity.

[0070] Step 3: From a thought chain containing a quintuple Begin by progressively building the thought chain of the first k quintuples. And based on the logical consistency score calculation rules, each thought chain is obtained. The logical consistency score; k ranges from 2 to n, where n is the total number of quintuples, k is the length of the current constructed thought chain, j is the length of the preceding thought chain, and j is less than k.

[0071] Step 4: Analyze each thought chain From the thought chain containing the first j quintuples In the middle, the chain of thought The target thought chain corresponding to the highest logical consistency score is used as the thought chain. The optimal preceding thought chain; thought chain For the chain of thought It forms a pair with the kth quintuple.

[0072] Step 5: When k=n, based on the optimal preceding thought chain, the thought chain is... The thought chain with the highest logical consistency score is considered the thought chain.

[0073] Specifically, (1) The relevance score is the main component of the first quintuple. With the object of the second quintuple The correlation score between them is calculated using cosine similarity, with the specific formula as follows:

[0074] .

[0075] in, The principal vector of the first quintuple, i.e., the principal. Word embedding representation; The object vector of the second quintuple, i.e., the object Word embedding representation.

[0076] (2) Set up a chain of thought This represents the thought chain formed by the first k quintuples. Logical consistency score Defined as:

[0077] .

[0078] (3) The goal of constructing the thought chain is to maximize the logical consistency score:

[0079] .

[0080] In this way, the most logically ordered sequence can be selected from the extracted quintuples to form a coherent chain of thought. This chain of thought not only reflects the main logical thread of the dialogue but also provides important guidance for the generation of subsequent dialogues.

[0081] The specific steps of the progressive thinking chain expansion algorithm are as follows:

[0082] Initialization: Set This indicates that the logical consistency score of the first quintet is 0, because there is only one quintet, so there is no subject-object correlation with the adjacent quintets.

[0083] Recursion: For each k from 2 to n, calculate :

[0084] .

[0085] In this step, by comparing all possible thought chains... (i.e., the preceding thought chain) to find the The largest preceding thought chain is the optimal preceding thought chain.

[0086] Termination: The final thought chain is the one with the highest logical consistency score. That is, when k=n, The logical consistency score is determined by the preceding steps. to The optimal preceding thought chain is selected sequentially and gradually accumulated, thus filtering out the Consistency at this point. The largest thought chain serves as the final thought chain.

[0087] Furthermore, in order to improve the efficiency of the incremental thinking chain expansion algorithm, the following optimization strategies can also be adopted: (1) Pruning: During the recursive process, if a certain thinking chain The logical consistency score of this path is significantly lower than other paths, so it can be pruned earlier to reduce computation. Specifically, if If the score is below a certain threshold, the subsequent calculation of the path can be skipped. It should be noted that this pruning strategy does not guarantee finding the global optimum, because some paths with low current scores may significantly improve their scores in subsequent steps by introducing highly relevant quintuples. However, in practical applications, since the number of quintuples is large and most low-scoring paths do not have potential value, the pruning strategy significantly improves the running efficiency while sacrificing a small amount of accuracy, and has good practicality. (2) Parallel computing: Using multi-threaded or distributed computing, different k are computed in parallel to accelerate the construction process of the thought chain. For example, different k are assigned to different computing nodes and computed simultaneously. Through these optimization strategies, the efficiency of thought chain construction can be significantly improved, ensuring efficient operation on large-scale dialogue data. By constructing the thought chain, the patient's symptoms and related conditions can be clearly seen, providing logical support for subsequent dialogue generation. This thought chain can not only reflect the main logical clues of the dialogue, but also provide important diagnostic basis for doctors.

[0088] S103: Input the thought chain and the context of the current dialogue into the generative model to obtain the output dialogue.

[0089] In this embodiment, the generative model can be a Transformer-based model. The thought chain constructed in step 102, along with the original context of the current dialogue, is input into the generative model to obtain the output dialogue. This embodiment utilizes the constructed thought chain to guide the dialogue generation process, ensuring that the generated responses are both logically sound and closely aligned with the user's actual needs.

[0090] Furthermore, the above-mentioned input of the thought chain and the context of the current dialogue into the generative model to obtain the output dialogue can specifically include: inputting the thought chain and the context of the current dialogue into the generative model to obtain generated intermediate response fragments; performing grammatical verification on the intermediate response fragments using a preset grammar rule base, and performing semantic coherence verification on the intermediate response fragments using a semantic association graph; when the verification passes, continuing to generate intermediate fragments based on the original strategy of the generative model, and performing grammatical verification and the aforementioned semantic coherence verification, until the complete output dialogue is obtained; when the verification fails, dynamically adjusting the generation strategy of the generative model, continuing to generate the intermediate fragments based on the adjusted generation strategy, and performing grammatical verification and semantic coherence verification, until the complete output dialogue is obtained.

[0091] Specifically, in order to improve the accuracy of logical verification and the dynamic adaptability of the model, a dual-channel verification mechanism is introduced. Through the collaborative operation of the grammar rule verification channel and the semantic constraint verification channel, real-time logical verification of the dialogue generation process is achieved. This mechanism breaks through the limitations of the traditional single verification method and can provide more comprehensive logical support for the model in complex and dynamically changing scenarios, significantly improving the robustness of the system. The specific operation process of the dual-channel verification mechanism is as follows: (1) Grammar rule verification channel: Based on the preset grammar rule library (covering basic grammar norms such as sentence structure, punctuation usage, and part-of-speech collocation), the intermediate response fragments generated by the model are analyzed sentence by sentence. For example, when generating a response containing a compound sentence, this channel will automatically detect grammatical elements such as subject-verb agreement and tense correspondence. If problems such as "subject and predicate tense mismatch" are found, a correction signal is immediately triggered. (2) Semantic constraint verification channel: Combined with the semantic association graph constructed by the dialogue context, the semantic coherence of the generated content is verified. The channel calculates the semantic similarity between the currently generated fragment and the key information in the preceding text (such as entities, events, and sentiments mentioned by the user) in real time. If semantic contradictions such as "disconnection between topics" or "incorrect entity reference" occur, semantic correction suggestions are generated immediately.

[0092] During dialogue generation, the two channels can operate in parallel and form a dynamic feedback loop: for each sentence unit (such as a phrase or clause) generated by the model, both channels simultaneously output verification results. If both channels determine that there are no logical problems, the model continues generation according to the original strategy; if either channel detects an anomaly, the system dynamically adjusts the generation strategy based on the problem type: for example, when the grammar channel finds an error, the model will prioritize calling the "grammar correction template library" to adjust the sentence structure; when the semantic channel indicates a contradiction, the model will backtrack to the relevant nodes in the thought chain and replan the response logic. This dynamic adjustment capability ensures both logical consistency and reliability of the output content, especially in multi-turn dialogues, effectively avoiding logical deviations caused by contextual accumulation. In this way, the system can not only dynamically adjust the strategy in real time when generating dialogues (such as switching from a rapid generation mode to a precise verification mode), but also adaptively optimize the verification weights according to the characteristics of different domains: for example, in professional medical dialogue scenarios, the weight of the semantic constraint channel will automatically increase to prioritize the accuracy of medical terminology; in everyday casual conversation scenarios, the weight of the grammar rule channel will be appropriately reduced to retain more natural colloquial expressions. This significantly improves the model's applicability across multiple domains and complex scenarios, enabling it to better adapt to different user needs and contextual changes.

[0093] Furthermore, to improve the quality of generated responses, the following generation strategies can be adopted: (1) BeamSearch: During the generation process, multiple candidate sequences are maintained, and the i-th sequence with the highest probability is selected to continue generation. Finally, the sequence with the highest probability is selected as the generation result. Specifically, at each generation step, the i-th candidate sequence with the highest probability is retained, and the next step is generated until a complete response is generated. (2) Deduplication strategy: During the generation process, duplicate quintuples or intermediate response fragments are avoided to ensure the diversity and novelty of the generated content. Specifically, the generated quintuples are recorded during the generation process. If duplicate quintuples are found, the generation path is skipped, and other candidate paths are selected to continue generation. Through these generation strategies, the quality of generated responses can be significantly improved, ensuring that the generated responses are both logical and close to the actual needs of users. The combination of the thought chain and the dual-channel verification mechanism further strengthens the logical depth and scenario adaptability of the responses, ultimately improving the accuracy of the dialogue system and the user experience.

[0094] Furthermore, the above-mentioned input of the thought chain and the context of the current dialogue into the generative model to obtain the output dialogue can specifically include: inputting the thought chain and the context of the current dialogue into the generative model to obtain external knowledge results by querying a professional domain knowledge base; inputting the thought chain and the context of the current dialogue into the generative model to obtain internal reasoning results through the internal reasoning ability of the generative model; and obtaining the output dialogue based on the external knowledge results and the internal reasoning results.

[0095] Specifically, in order to further enhance the generative model's ability to understand and respond to complex dialogue situations, external knowledge (such as databases of professional fields) and internal reasoning ability (such as context-based understanding) are further integrated. (1) External knowledge integration: Knowledge related to the current dialogue is obtained by querying databases of professional fields. Let the external professional field knowledge base be K and the external knowledge result be r, then the probability of considering external knowledge when generating a response (outputting the dialogue) is as follows. for:

[0096] .

[0097] Where P(r|X,C) represents the probability that the result of querying external knowledge is r, given the context and thought chain of the current dialogue; This represents the probability of generating a response Y given a dialogue context X, a thought chain C, and a specific knowledge result r. It indicates how the model utilizes external knowledge to generate accurate and relevant responses. Specifically, this probability can be estimated by calculating the similarity between the context and the query result. By integrating external knowledge, the model can acquire more background information and generate more accurate and relevant responses.

[0098] (2) Internal reasoning ability enhances the reasoning ability of the generative model through context-based understanding. Let the context representation (i.e., the internal reasoning result) be h, then the probability of considering internal reasoning when generating a response is... for:

[0099] .

[0100] Where P(h|X,C) represents the probability of generating an internal reasoning result h given the context and thought chain of the current dialogue. This represents the probability of generating a response Y given the dialogue context X, the thought chain C, and the internal inference result h. It is a marginal probability calculated by summing over all possible internal inference results h. Specifically, the internal inference result h is calculated using an attention mechanism, thereby enhancing the model's reasoning ability. Through internal inference, the model can better understand the contextual information of the dialogue and generate more logical responses.

[0101] Furthermore, the above-mentioned output dialogue based on external knowledge results and internal reasoning results can specifically include: weighted fusion of external knowledge results and internal reasoning results to obtain the output dialogue; or, dynamically selecting and fusing external knowledge results and internal reasoning results using an attention mechanism to obtain the output dialogue.

[0102] Specifically, to better integrate external knowledge and internal reasoning ability, the following methods can be adopted: (1) Weighted fusion: The results of external knowledge and internal reasoning are weighted and fused, and the weights can be learned through training data. Specifically, an optimal weight parameter can be learned by training a fusion model, making the generated response more accurate and relevant. (2) Attention mechanism: The attention mechanism is used to dynamically select and fuse the results of external knowledge and internal reasoning, thereby improving the relevance and accuracy of the generated response. Specifically, the attention weight can be calculated to dynamically select and fuse the results of external knowledge and internal reasoning, thereby generating a more accurate and relevant response. Through these methods, the model's ability to understand and respond to complex dialogue situations can be significantly improved, generating a more accurate and relevant response.

[0103] The dialogue generation method provided in this invention extracts a quintuple from the context of the current dialogue. The quintuple includes: subject, relation, object, timestamp, and context. The timestamp includes absolute and relative time; the context includes context tags and context vectors; and the relation can be dynamically adjusted. Based on logical consistency constraints, a progressive thought chain expansion algorithm is used to dynamically program the quintuple to obtain a thought chain. The progressive thought chain expansion algorithm is a thought chain generation algorithm that is progressively expanded and dynamically optimized. The thought chain and the context of the current dialogue are input into the generation model to obtain the output dialogue. This invention clarifies the core connections in the dialogue through structured quintuples. The context and timestamp in the quintuple can accurately identify the scene of the current dialogue, and the weight of the relation in the dialogue is dynamically adjusted according to the content. This allows it to adapt to different domain scenarios and multi-turn dialogues, improving adaptability and flexibility for various professional scenarios. Furthermore, generating a thought chain based on quintuples and the progressive thought chain expansion algorithm can capture the unique logical patterns of the scene, enhancing the accuracy and logical consistency of dialogue generation.

[0104] As can be seen, this invention first constructs a scenario-oriented dynamic graph network of quintuples (i.e., quintuples whose relations can be dynamically adjusted, which can be understood as a dynamic quintuple network), using the (subject-S, relation-R, object-O, timestamp-T, context label-C)> quintuple structure to simulate dialogue logic units, reducing reliance on static knowledge bases. Secondly, a dual-check verification mechanism is designed, combining grammatical rules and semantic constraints for logical verification, improving the model's adaptability and reliability in dynamic scenarios. Finally, a progressive thought chain expansion algorithm is proposed, achieving end-to-end optimization of logical consistency through dynamic optimization of the reasoning path. This method not only automatically captures scenario-specific logical patterns but also effectively reduces the need for manually designing prompt templates, thereby improving the model's applicability and accuracy in multiple domains and complex scenarios. This gives this invention significant advantages in generating logically consistent dialogues, better meeting the diverse needs of practical applications.

[0105] Specifically, the present invention has the following beneficial effects:

[0106] (1) A five-tuple structure is established by incorporating the concepts of time and context, and dynamic relational weights are added to the core structure of the five-tuple. Combining absolute and relative time, the temporal logic of the dialogue is accurately captured, which is especially suitable for reasoning needs in time-sensitive scenarios such as revision of legal clauses. A composite form of context labels and context vectors is adopted. Context labels identify the domain and scenario type, and context vectors are generated by encoding nearly N rounds of dialogue through BERT. This can resolve ambiguities of terms such as margin in cross-domain contexts and significantly improve the ability to support contextualized decision-making.

[0107] (2) Domain-Adaptive Mechanism Based on Context Awareness: A domain-specific relation template library integrates typical five-tuple patterns of the vertical domain in the form of a knowledge graph, ensuring that the extraction results conform to the semantic characteristics of the domain and avoiding semantic ambiguity caused by general modeling. Context-Driven Relation Mapping Strategy: Combining context labels and context vectors, the sensitivity of the model to domain keywords is dynamically adjusted to achieve efficient transfer from general models to specific domains, significantly improving the semantic accuracy in cross-domain and mixed-context dialogues.

[0108] (3) The progressive thinking chain expansion algorithm achieves end-to-end optimization of logical consistency by dynamically optimizing the reasoning path. Using dynamic programming, the extracted quintuples are organized into a logically coherent thinking chain, reflecting the main logical clues of the dialogue and user needs. Through this process, the system can effectively capture the unique logical patterns of the scene, reduce reliance on manual prompt templates, improve the accuracy and logical consistency of dialogue generation, and enhance the system's performance in complex multi-domain scenarios.

[0109] (4) The dual-channel verification mechanism combines grammatical rules and semantic constraints for logical verification, improving the accuracy of logical verification and the dynamic adaptability of the model, making the model more robust in complex and dynamically changing scenarios. The system can dynamically adjust its strategy when generating dialogues to ensure the logical consistency and reliability of the output. This significantly improves the applicability of the model in multiple domains and complex scenarios, enabling it to better adapt to different user needs and contextual changes.

[0110] (5) Integration of external knowledge and internal reasoning ability: During the dialogue generation process, by weightedly fusing external knowledge and context-based internal reasoning results, the system can generate more accurate and relevant responses. The attention mechanism is used to dynamically select and fuse the results of external knowledge and internal reasoning, further improving the relevance and accuracy of the generated responses. This integration enhances the model's ability to handle complex dialogue scenarios, enabling it to provide logically clear and practical dialogue content in various contexts.

[0111] The following section will verify this method through experiments.

[0112] First, experimental data.

[0113] A large amount of dialogue data was collected in the legal field to ensure the comprehensiveness and diversity of the experiment. 3000 real legal consultation dialogue samples were compiled, covering various legal issues such as contract disputes, labor law, and family law. This data comes from professional legal consultation platforms, possessing high professionalism and authority. After data collection, the data underwent preprocessing to ensure its quality and consistency. Specific steps included: text cleaning: removing irrelevant information from the dialogues, such as advertisements and duplicate content; and five-tuple annotation: using a large language model to annotate the dialogue text and extract five-tuple information. To ensure the accuracy and consistency of the five-tuples, domain experts manually annotated a small portion of the dialogue data. This manual annotation ensured the accuracy and professionalism of the five-tuples, providing high-quality training data for the model.

[0114] Second, evaluation criteria.

[0115] The generated results were initially scored using the GPT-4o model. This step relies on a pre-trained model to identify and quantify the quality features of the text, such as logical consistency and information accuracy. Specifically, this study used the following indicators: (1) Information accuracy: assessing whether the information in the generated text is accurate. (2) Logical consistency: assessing whether the generated text conforms to the logical flow of the dialogue. (3) Relevance: assessing whether the generated text is highly relevant to user needs and background information. In addition, the generated results were manually scored by a team of experts in the field. The scoring criteria are as follows:

[0116] 1 point (very poor): The generated results do not meet the expectations or task requirements at all, contain a lot of error information or are completely irrelevant.

[0117] 2 stars (Poor): Although some relevant information is provided, the overall quality is low, with many errors or inaccuracies that may mislead users.

[0118] 3 points (average): The generated content basically meets the requirements, but there may be some minor errors or inaccuracies in the details.

[0119] 4 points (Good): High-quality generated results with only minor shortcomings in a few non-critical aspects; overall performance is excellent.

[0120] 5 points (Excellent): Impeccable generated results that not only fully meet expectations but may also exceed them, providing additional value or insights.

[0121] To further improve the reliability of the scoring system, cross-validation was used for evaluation. This means dividing the dataset into several parts and using one part as the test set in turn to test the consistency and stability of the scoring system.

[0122] Third, discussion of results.

[0123] Two sets of control experiments are provided to evaluate the information accuracy of the text generated by the large model (generative model) after incorporating the thought chain constructed by this method, as well as the logical consistency and relevance of the text generated by the large model.

[0124] First, regarding the accuracy of text generated by large models, we evaluated the text information accuracy before and after the introduction of the thought chain (+Cot, referring to the thought chain constructed by this method) using LLaMa3-80B (3rd generation of AI large language model), Qwen2-70B (2nd generation of Tongyi Qianwen), and GPT4o (4th generation of generative pre-trained Transformer). The evaluation results are shown in Table 1. Table 1 shows that after introducing the thought chain, the pass rate and average score of each model in both human evaluation and automatic scoring showed a significant improvement trend: taking the LLaMa3-80B model as an example, before introducing Cot, the human evaluation pass rate was 79%, and the average score was 3.33; after adding the thought chain, the human evaluation pass rate increased to 87%, and the average score also increased significantly to 4.23. The same was true for automatic scoring; before introducing Cot, the pass rate was 82%, and the average score was 3.63; after introducing Cot, the pass rate reached 89%, and the average score became 3.68. Other models, such as Qwen2-70B and GPT4o, also exhibited similar positive changes.

[0125] Table 1. Comparison of Evaluation Results of Information Generation Accuracy Before and After Introducing Cot

[0126]

[0127] To explore the role of Chain-of-Thought (CoT) in assisted text generation, an experiment was designed to evaluate its impact on text relevance and logical consistency. The experiment employed three different large-scale language models: LLaMa3-80B, Qwen2-70B, and GPT4o, and compared the performance changes of these models before and after the introduction of CoT. Using prompt-guided CoT technology, CoT was integrated into dialogues to observe whether this adjustment improved the model's output quality. Extensive data was collected and analyzed through both human evaluation and automatic scoring. Table 2 presents the evaluation results of the relevance and logical consistency of the generated text before and after the addition of CoT by different models. The table details the average human evaluation score and the average automatic scoring score for each model.

[0128] Table 2. Comparison of Evaluation Results of Text Relevance and Logical Consistency Before and After Introducing Cot

[0129]

[0130] As shown in Table 2, the average scores of all tested models significantly improved after incorporating the thought chain, regardless of whether they were assessed manually or automatically. For example, in the LLaMa3-80B model, the manual assessment score increased from 3.53 to 4.24 after adding the thought chain, and the automatic score also improved from 3.51 to 4.22. The GPT4o model showed a similar trend, with the manual assessment score increasing from 3.79 to 4.29 and the automatic score increasing from 3.67 to 4.43. This indicates that the thought chain can effectively enhance the quality and coherence of text generation, especially showing a clear advantage in improving logical consistency and text relevance.

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

[0132] Please refer to the details. Figure 2 , Figure 2 A schematic diagram of a dialogue generation device provided in an embodiment of the present invention may include:

[0133] The quintuple extraction module 100 is used to extract quintuples from the context of the current dialogue; the quintuple includes: subject, relation, object, timestamp, and context; the timestamp includes absolute time and relative time; the context includes context label and context vector; the relation can be dynamically adjusted;

[0134] The thought chain construction module 200 is used to perform dynamic programming on the five-tuple based on logical consistency constraints and using a progressive thought chain expansion algorithm to obtain a thought chain; the progressive thought chain expansion algorithm is a thought chain generation algorithm that combines step-by-step expansion and dynamic programming optimization.

[0135] The dialogue generation module 300 is used to input the thought chain and the context of the current dialogue into the generation model to obtain the output dialogue.

[0136] Based on the above implementation, the quintuple extraction module 100 may include:

[0137] The parsing unit is used to parse the context of the current dialogue to generate the context and the timestamp;

[0138] The scope determination unit is used to call a target domain-specific relation template library based on the context, and to define the scope of entities and relations within the domain through the target domain-specific relation template library; the entities include the subject and the object;

[0139] The extraction unit can encode the context of the current dialogue, determine the entity and the relationship based on the entity scope and the relationship scope, and dynamically adjust the weights of different relationships within the domain.

[0140] Based on the above embodiments, the thought chain construction module 200 may include:

[0141] A word embedding processing unit is used to perform word embedding processing on the subject and object in the quintuple to obtain subject vector and object vector;

[0142] The rule acquisition unit is used to acquire the logical consistency score calculation rule; the consistency score calculation rule is to calculate the correlation score between the subject vector of the first quintuple and the object vector of the second quintuple by cosine similarity for any adjacent first quintuple and second quintuple.

[0143] Initialization unit, used to start from a thought chain containing a quintuple. Begin by progressively building the thought chain of the first k quintuples. And based on the logical consistency score calculation rules, each thought chain is obtained. The logical consistency score; k ranges from 2 to n, where n is the total number of the quintuples, k is the length of the current constructed thought chain, j is the length of the preceding thought chain, and j is less than k;

[0144] The first building unit is used to construct each of the aforementioned thought chains. From the thought chain containing the first j quintuples In the middle, the thought chain is... The target thought chain corresponding to the highest logical consistency score is taken as the thought chain. The optimal preceding thought chain; the thought chain For the chain of thought It forms a pair with the k-th quintuple;

[0145] The second building unit is used to, when k=n, based on the optimal preceding thought chain, construct the thought chain... The thought chain with the highest logical consistency score is designated as the thought chain.

[0146] Based on the above embodiments, the initialization unit may specifically include:

[0147] ;

[0148] ;

[0149] in, This is the main body of the first quintuple; The object of the second quintuple; The correlation score; This is the principal vector of the first quintuple; Let be the object vector of the second quintuple; For the aforementioned thought chain Logical consistency score.

[0150] Based on the above embodiments, the dialogue generation module 300 may include:

[0151] The intermediate response fragment generation unit is used to input the thought chain and the context of the current dialogue into the generation model to obtain the generated intermediate response fragment;

[0152] A two-layer verification unit is used to perform grammatical verification on the intermediate response fragment using a preset grammar rule base and semantic coherence verification on the intermediate response fragment using a semantic association graph.

[0153] The first verification result unit is used to continue generating the intermediate fragment based on the original strategy of the generation model when the verification passes, and to perform the syntax verification and the semantic coherence verification until the complete output dialogue is obtained.

[0154] The second verification result unit is used to dynamically adjust the generation strategy of the generation model when the verification fails, continue to generate the intermediate fragment based on the adjusted generation strategy, and perform the syntax verification and semantic coherence verification until the complete output dialogue is obtained.

[0155] Based on the above embodiments, the dialogue generation module 300 may include:

[0156] An external query unit is used to input the thought chain and the context of the current dialogue into the generative model, and obtain external knowledge results by querying a professional domain knowledge base;

[0157] An internal reasoning unit is used to input the thought chain and the context of the current dialogue into the generative model, and obtain the internal reasoning result through the internal reasoning capability of the generative model;

[0158] The fusion unit is used to obtain the output dialogue based on the external knowledge results and the internal reasoning results.

[0159] Based on the above embodiments, the fusion unit may include:

[0160] The first fusion subunit is used to weightedly fuse the external knowledge results and the internal reasoning results to obtain the output dialogue;

[0161] Alternatively, the second fusion subunit is used to dynamically select and fuse the external knowledge results and the internal reasoning results using an attention mechanism to obtain the output dialogue.

[0162] It should be noted that the order of the modules and units in the above-mentioned dialogue generation device can be changed without affecting the logic.

[0163] The dialogue generation device provided in this embodiment of the invention uses a quintuple extraction module 100 to extract quintuples from the context of the current dialogue. The quintuples include: subject, relation, object, timestamp, and context. The timestamp includes absolute and relative time. The context includes context tags and context vectors. The relation can be dynamically adjusted. A thought chain construction module 200 dynamically plans the quintuples based on logical consistency constraints using a progressive thought chain expansion algorithm to obtain a thought chain. The progressive thought chain expansion algorithm is a thought chain generation algorithm that combines step-by-step expansion and dynamic programming optimization. A dialogue generation module 300 inputs the thought chain and the context of the current dialogue into a generation model to obtain an output dialogue. This device clarifies the core connections in dialogue through structured quintuples. The context and timestamps in the quintuples can accurately identify the current dialogue scenario, and the weight of the relationships in the dialogue will be dynamically adjusted according to the content. This allows it to adapt to different domain scenarios and multi-turn dialogues, improving its adaptability and flexibility for various professional scenarios. Furthermore, the thought chain generated based on the quintuple and progressive thought chain extension algorithm can capture the unique logical patterns of the scenario, enhancing the accuracy and logical consistency of dialogue generation.

[0164] The dialogue generation device provided in the embodiments of the present invention will be described below. The dialogue generation device described below and the dialogue generation method described above can be referred to in correspondence.

[0165] Please refer to Figure 3 , Figure 3 A schematic diagram of a dialogue generation device provided in an embodiment of the present invention may include:

[0166] Memory 10 is used to store computer programs;

[0167] Processor 20 is used to execute computer programs to implement the dialogue generation method described above.

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

[0169] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions:

[0170] Extract the quintuple from the context of the current dialogue; the quintuple includes: subject, relation, object, timestamp, and context; the timestamp includes absolute time and relative time; the context includes context label and context vector; the relation can be dynamically adjusted;

[0171] Based on logical consistency constraints, a progressive thinking chain expansion algorithm is used to dynamically program the quintuple to obtain the thinking chain; the progressive thinking chain expansion algorithm is a thinking chain generation algorithm that is progressively expanded and dynamically optimized.

[0172] The thought chain and the context of the current dialogue are input into the generative model to obtain the output dialogue.

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

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

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

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

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

[0178] The following describes the computer-readable storage medium provided in the embodiments of the present invention. The computer-readable storage medium described below can be referred to in correspondence with the dialogue generation method described above.

[0179] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described dialogue generation method.

[0180] The computer-readable storage medium may include 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.

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

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

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

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

Claims

1. A dialogue generation method, characterized by, The method comprises the following steps: extracting a five-tuple from the context of the current dialogue; the five-tuple comprises: subject, relationship, object, timestamp and context; the timestamp comprises absolute time and relative time; the context comprises context label and context vector; the relationship can be dynamically adjusted; based on the logical consistency constraint, the five-tuple is dynamically planned by using the progressive thought chain expansion algorithm to obtain a thought chain; the progressive thought chain expansion algorithm is a thought chain generation algorithm of step-by-step expansion and dynamic planning optimization; input the thought chain and the context of the current dialogue into a generation model to obtain an output dialogue.

2. The dialogue generation method of claim 1, wherein, extracting a five-tuple from the context of the current dialogue, comprising: parsing the context of the current dialogue to generate the context and the timestamp; calling a target domain-specific relationship template library based on the context, and defining the entity range and relationship range within the domain through the target domain-specific relationship template library; the entity includes the subject and the object; encoding the context of the current dialogue, determining the entity and the relationship based on the entity range and relationship range, and dynamically adjusting the weight of different relationships within the domain.

3. The dialogue generation method of claim 1, wherein, based on the logical consistency constraint, the five-tuple is dynamically planned by using the progressive thought chain expansion algorithm to obtain a thought chain, comprising: word embedding processing the subject and the object in the five-tuple to obtain subject vector and object vector; obtaining a logical consistency score calculation rule; the consistency score calculation rule is that for any adjacent first five-tuple and second five-tuple, the correlation score of the subject vector of the first five-tuple and the object vector of the second five-tuple is calculated by cosine similarity; From a thought chain containing a quintuple Begin by progressively building the thought chain of the first k quintuples. And based on the logical consistency score calculation rules, each thought chain is obtained. The logical consistency score; k ranges from 2 to n, where n is the total number of the quintuples, k is the length of the current constructed thought chain, j is the length of the preceding thought chain, and j is less than k; for each of the thought chains from the thought chains containing the first j five-tuples the target thought chain corresponding to the maximum logical consistency score of the thought chains is the optimal previous thought chain of the thought chain is a thought chain formed with the kth five-tuple When k = n, based on the optimal preceding thought chain, a thought chain is selected The thought chain with the highest score of logical consistency is selected as the thought chain.

4. The dialogue generation method of claim 3, wherein, Each thought chain is obtained based on the aforementioned logical consistency score calculation rules. The logical consistency score includes: ; ; in, This is the main body of the first quintuple; The object of the second quintuple; The correlation score; This is the principal vector of the first quintuple; Let be the object vector of the second quintuple; For the aforementioned thought chain Logical consistency score.

5. The dialogue generation method of claim 1, wherein, input the thought chain and the context of the current dialogue into a generation model to obtain an output dialogue, comprising: input the thought chain and the context of the current dialogue into the generation model to obtain a generated intermediate reply segment; using a pre-set grammar rule library to perform grammar checking on the intermediate reply segment, and using a semantic association graph to perform semantic coherence checking on the intermediate reply segment; when the checking passes, the intermediate segment is continuously generated based on the original strategy of the generation model, and the grammar checking and the semantic coherence checking are performed, until a complete output dialogue is obtained; when the checking fails, the generation strategy of the generation model is dynamically adjusted, the intermediate segment is continuously generated based on the adjusted generation strategy, and the grammar checking and the semantic coherence checking are performed, until a complete output dialogue is obtained.

6. The dialogue generation method of claim 1, wherein, input the thought chain and the context of the current dialogue into a generation model to obtain an output dialogue, comprising: input the thought chain and the context of the current dialogue into the generation model to obtain external knowledge results by querying a professional domain knowledge base; input the thought chain and the context of the current dialogue into the generation model to obtain internal reasoning results by using the internal reasoning ability of the generation model; based on the external knowledge results and the internal reasoning results, the output dialogue is obtained.

7. The dialogue generation method of claim 6, wherein, The output dialogue is obtained based on the external knowledge result and the internal reasoning result, including: The external knowledge result and the internal reasoning result are weighted and fused to obtain the output dialogue; Or, the external knowledge result and the internal reasoning result are dynamically selected and fused by using an attention mechanism to obtain the output dialogue.

8. A dialogue generation apparatus characterized by comprising: Including: A five-tuple extraction module is configured to extract five-tuples from the context of the current dialogue; The five-tuples include a subject, a relationship, an object, a timestamp, and a context; the timestamp includes an absolute time and a relative time; the context includes a context label and a context vector; and the relationship can be dynamically adjusted; A thought chain construction module is configured to dynamically plan the five-tuples based on a logical consistency constraint and by using a progressive thought chain expansion algorithm to obtain a thought chain; the progressive thought chain expansion algorithm is a thought chain generation algorithm that is gradually expanded and dynamically planned and optimized; A dialogue generation module is configured to input the thought chain and the context of the current dialogue into a generation model to obtain an output dialogue.

9. A dialogue generation device, characterized by, Including: A memory is configured to store a computer program; A processor is configured to implement the dialogue generation method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by a processor, the dialogue generation method according to any one of claims 1 to 7 is implemented.