A reply generation method and a dialogue method of a dialogue system and corresponding devices

CN121119083BActive Publication Date: 2026-10-23ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511237656.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2026-10-23
Estimated Expiration
2045-08-29

AI Technical Summary

Technical Problem

然而,对话系统也面临各种安全问题,例如针对用户的一些问题,生成具有风险(例如暴力、仇恨、虚假)内容的回复;再例如针对用户输入的恶意问题,造成大模型的资源被恶意占用;再例如用户的一些问题可能存在伦理或合规等问题,容易对社会或企业等带来不利影响;等等

Benefits of technology

1)本申请在识别出用户的输入内容具有风险时,进一步对输入内容进行风险分析,基于分析得到的风险意图确定回复策略,基于回复策略来生成回复内容。这种方式相比较传统一律拒答的方式,显然更加灵活,能够根据具体的风险意图来选择采用用以正向引导的非拒绝策略来生成回复内容,在保证安全性的基础上能够对本质上没有恶意的输入内容即非恶意指令采用非拒绝策略,从而提高用户体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121119083B_ABST
    Figure CN121119083B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a reply generation method of a dialogue system, a dialogue method and corresponding devices. The reply generation method comprises: obtaining input content of a user; executing each inference node in an inference chain for the input content, wherein the inference chain comprises the following inference nodes: a demand identification node, which identifies whether the input content has a risk; a risk analysis node, which, in response to the input content having a risk, performs risk analysis on the input content to obtain risk information of the input content, the risk information comprising a risk intention; a strategy determination node, which determines a reply strategy based on the risk intention, wherein if the risk intention is a non-malicious instruction, the reply strategy is a non-rejection strategy; and a reply generation node, which generates reply content for the input content based on the reply strategy. The present application no longer adopts a one-size-fits-all rejection mode for input content with risks, and adopts a non-rejection strategy for input content that is essentially non-malicious on the basis of ensuring safety, thereby improving user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method for generating responses in a dialogue system, a dialogue method, and a corresponding apparatus. Background Technology

[0002] With the rapid development and widespread adoption of artificial intelligence (AI) technology, dialogue systems have permeated all aspects of people's lives and work, becoming one of the most direct forms of AI implementation. However, dialogue systems also face various security challenges. For example, some user questions may generate responses with risky content (such as violence, hate speech, or false information); malicious user input may lead to the unauthorized use of large model resources; and some user questions may raise ethical or compliance issues, potentially causing adverse effects on society or businesses. Therefore, improving the security of dialogue systems has become an urgent problem to be solved. Summary of the Invention

[0003] In view of this, this application provides a response generation method, a dialogue method, and a corresponding apparatus for a dialogue system, so as to improve the security of the dialogue system.

[0004] This application provides the following solution: Firstly, a method for generating responses in a dialogue system is provided, the method comprising: Get the user's input; The inference chain is executed on the input content to obtain the response content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the input content according to the response strategy.

[0005] Optionally, if the risk intent is a malicious instruction, then the response strategy is a rejection strategy; The non-rejection strategies include at least one of the following: emotion soothing strategy, opinion modification strategy, alternative solution strategy, and resource recommendation strategy.

[0006] Optionally, the risk information may also include risk category and / or risk level; The inference node also includes a specification selection node: selecting a security specification document based on the risk information; The step of generating response content based on the response strategy for the input content includes: generating response content based on the response strategy and the security specification document for the input content.

[0007] Optionally, the demand identification node further includes: identifying the user demand corresponding to the input content; The step of generating response content based on the response strategy for the input content includes: generating response content based on the user's needs and the response strategy for the input content.

[0008] Optionally, the inference node further includes a state analysis node: in response to the input content being risky, analyzing the user state based on the input content and the context of the input content, the user state including at least one of user role, emotional state, and potential needs; The step of determining the response strategy based on the risk intent includes: determining the response strategy based on the risk intent and the user status; or, The step of generating response content based on the response strategy for the input content includes: generating response content based on the response strategy and the user state for the input content.

[0009] Optionally, determining the response strategy based on the risk intent and the user status includes at least one of the following: If the analysis shows that the emotional state is negative and the risk intent is a non-malicious instruction, then the response strategy is determined to include an emotional reassurance strategy. If the analysis reveals the potential demand and the risk intent is a non-malicious instruction, then the response strategy is determined to include an alternative strategy. If the analysis yields the user role and / or the potential needs, and the risk intent is a non-malicious instruction, then the response strategy is determined to include a resource recommendation strategy. If the analysis determines that the risk intent is a harmful viewpoint, then the response strategy is determined to include a viewpoint correction strategy. If the analysis determines that the risk intent is a malicious instruction, then the response strategy is determined to be a rejection strategy.

[0010] Optionally, the step of executing each inference node in the inference chain for the input content includes: For each inference node, generate a prompt instruction, and use each prompt instruction to call the large language model to execute the respective inference node; or, A prompt instruction is generated for the inference chain, and the prompt instruction is used to call the large language model to execute each inference node in the inference chain.

[0011] Optionally, the method further includes: Obtain the evaluation result of the response content; Based on the evaluation results, at least one inference node in the inference chain is optimized.

[0012] Optionally, the evaluation results include safety evaluation results and satisfaction evaluation results; Optimizing at least one inference node in the inference chain based on the evaluation results includes: optimizing the inference node corresponding to the security evaluation node based on the security evaluation results, and optimizing the inference node corresponding to the satisfaction evaluation results based on the satisfaction evaluation results.

[0013] Secondly, a dialogue method is provided, the method comprising: Obtain the request sent by the user device, and parse the user's input content from the request; The inference chain is executed on the input content to obtain the response content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the response strategy and the input content; The response to the request is generated using the response content, and the response is returned to the user device.

[0014] Thirdly, a response generation apparatus for a dialogue system is provided, the apparatus comprising: The content acquisition unit is configured to acquire user input content; An inference chain execution unit is configured to execute each inference node in the inference chain for the input content to obtain a response to the input content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the input content according to the response strategy.

[0015] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in any one of the first and second aspects above.

[0016] Fifthly, an electronic device is provided, comprising: One or more processors; and A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method described in any one of the first and second aspects above.

[0017] A sixth aspect provides a computer program product comprising a computer program that, when executed by a processor, performs the steps of the methods described in the first and second aspects above.

[0018] According to the specific embodiments provided in this application, the following technical effects are disclosed: 1) When this application identifies that a user's input content is risky, it further analyzes the input content for risk, determines a response strategy based on the risk intent obtained from the analysis, and generates response content based on the response strategy. Compared with the traditional approach of rejecting all responses, this method is obviously more flexible. It can select a non-rejection strategy to generate response content with positive guidance based on the specific risk intent. While ensuring security, it can apply a non-rejection strategy to input content that is not inherently malicious, i.e., non-malicious instructions, thereby improving the user experience.

[0019] 2) In this application, a rejection strategy is adopted for malicious instructions. For non-malicious instructions, at least one of the following strategies can be adopted: emotional soothing strategy, opinion correction strategy, alternative solution strategy, and resource recommendation strategy, so as to minimize rejection and provide users with constructive or helpful answers as much as possible, such as soothing users' emotions, correcting harmful opinions, seeking alternative solutions, or recommending resources, thereby improving user experience.

[0020] 3) In this application, at the specification selection node, a safety specification document can be selected based on risk information such as risk category, risk level, and risk intent. This allows the response content to be generated in conjunction with the safety specification document, ensuring both the security and accuracy of the response content.

[0021] 4) In this application, the user needs corresponding to the input content are first identified at the needs identification node, and then the response content is generated based on the user needs and the response strategy. This method can better constrain the generated response content, making it accurately meet the user needs and avoid answering irrelevant questions.

[0022] 5) In this application, the state analysis node can analyze at least one of user role, emotional state and potential needs based on the input content and its context, so as to determine the response strategy or generate response content, so that the generated response content can better meet the user's personalized needs, satisfy the user's emotional needs and potential needs, and further improve the user experience.

[0023] 6) This application can utilize the powerful language understanding, resource integration and logical modeling capabilities of the large language model to execute the inference chain. Whether the large language model is called separately to execute each inference node or the large language model is called to execute the inference chain, a good response generation effect can be achieved.

[0024] 7) This application can further optimize at least one inference node in the inference chain based on the evaluation results of the response content, thereby realizing a closed loop of "risk perception - strategy determination - reverse optimization", gradually improving the rationality and accuracy of the inference chain, and continuously improving the quality of the generated response content.

[0025] 8) This application obtains evaluation results from two dimensions: security and satisfaction. Based on the security assessment results, the inference nodes corresponding to the security assessment nodes are optimized, and based on the satisfaction assessment results, the inference nodes corresponding to the satisfaction assessment results are optimized. This approach can accurately locate the root cause of problems in the inference chain, avoid blind optimization, and improve optimization efficiency.

[0026] Of course, any product implementing this application does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 This is a system architecture diagram applicable to the embodiments of this application; Figure 2 A flowchart of the response generation method provided in the embodiments of this application; Figure 3The inference chains corresponding to risk-free input content and risky input content provided in the embodiments of this application; Figure 4 A flowchart of the dialogue method provided in the embodiments of this application; Figure 5 A schematic block diagram of the response generation device provided in the embodiments of this application; Figure 6 A schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0030] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0031] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0032] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0033] Several technologies already exist to improve the security of dialogue systems, such as risk identification of user input. If a risk is identified, a rejection response is generated, such as "Unable to answer your question." While this rejection method can improve the security of dialogue systems to some extent, its implementation is rigid, rejecting all user questions that are not inherently malicious, resulting in a poor user experience.

[0034] In view of this, this application provides a new approach. To facilitate understanding of this application, the system architecture on which this application is based will first be described. Figure 1 An exemplary system architecture that can be applied to embodiments of this application is shown, such as Figure 1 As shown, the system architecture may include: the system architecture may include user equipment and a response generation device located on the server side.

[0035] Users can input content through their user devices, which then send the input content to the server-side response generation device.

[0036] User devices can include, but are not limited to, smart mobile terminals, smart home devices, wearable devices, and PCs (Personal Computers). Smart mobile devices can include mobile phones, tablets, laptops, PDAs (Personal Digital Assistants), and connected cars. Smart home devices can include smart TVs, smart refrigerators, and so on. Wearable devices can include smartwatches, smart glasses, virtual reality devices, augmented reality devices, and mixed reality devices (i.e., devices that support both virtual and augmented reality).

[0037] The response generation device can use the method provided in the embodiments of this application to generate a response based on the input text. The question-and-answer process of the response generation device involves the utilization of large language models. Large language models, or LLMs, refer to deep learning models trained on large amounts of text data that can generate natural language text or understand the meaning of language text. Their characteristics include massive scale and a huge number of parameters (usually reaching tens of billions or more), typically based on deep learning architectures such as the Transformer architecture. The difference between LLMs and ordinary pre-trained language models lies in the scale of their parameters. When the parameter scale exceeds a certain level, the model achieves significant performance improvements and exhibits capabilities that smaller models lack, such as in-context learning capabilities, the ability to learn complex patterns in language, and the performance of a wide range of tasks, including text summarization, translation, sentiment analysis, multi-turn dialogue, etc. Therefore, to distinguish them from traditional pre-trained language models, models with a parameter scale exceeding a certain level are called LLMs. In general, language models with a parameter scale of tens of billions or more implemented based on deep learning architectures can be considered large language models.

[0038] The response generation device can be configured as a standalone server, within a server cluster, or on a cloud server. A cloud server, also known as a cloud computing server or cloud host, is a hosting product within the cloud computing service system, designed to address the management difficulties and weak service scalability inherent in traditional physical hosts and Virtual Private Servers (VPS) services. Besides... Figure 1 In addition to the architecture shown, the response generation device can also be set on a computer terminal with strong computing power.

[0039] One possible approach is for the user to input content via their user device. This input can be in the form of text or speech. The user device includes the input in a request and sends it to a response generation device on the server. The response generation device parses the input from the request (if the request contains speech, it will further perform speech recognition to obtain text) and generates a response based on the input. It then uses the response to generate a response to the request and returns it to the user device via the network, where the user device displays the response to the user.

[0040] It should be understood that Figure 1 The user devices, response generation devices, and large language models shown are merely illustrative. Depending on implementation needs, any number of user devices, response generation devices, and large language models can be included.

[0041] Figure 2 This is a flowchart of a response generation method for a dialogue system provided in an embodiment of this application. This method can be... Figure 1 The response generation device in the system shown is executed. For example... Figure 2 As shown, the method may include the following steps: Step 201: Obtain the user's input.

[0042] Step 203: Execute each inference node in the inference chain for the input content to obtain the response content for the input content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent. If the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy used for positive guidance. Response generation node: Generates response content based on the input content, according to the response strategy.

[0043] As can be seen from the above process, when this application identifies that the user's input content is risky, it further analyzes the input content for risk, determines the response strategy based on the risk intent obtained from the analysis, and generates response content based on the response strategy. Compared with the traditional method of rejecting all responses, this approach is obviously more flexible. It can choose to use a non-rejection strategy to generate response content based on the specific risk intent. While ensuring security, it can use a non-rejection strategy for input content that is not inherently malicious, i.e., non-malicious instructions, thereby improving the user experience.

[0044] The following detailed description of step 203, with reference to the embodiments, focuses on the above steps.

[0045] In this embodiment of the application, there are mainly two inference chains, such as Figure 3 As shown in (a), for risk-free input, the actual inference chain is: demand identification node - strategy determination node - response generation node. For risky input, the actual inference chain can be as follows: Figure 3 As shown in Figure (b), the system includes: a requirement identification node, a risk analysis node, a state analysis node, a specification selection node, a strategy determination node, and a response generation node. The inference node outlined in the dashed box is an optional node. The state analysis node and the specification selection node can be executed sequentially or in parallel in any order.

[0046] The demand identification node primarily identifies user needs and assesses whether the input content poses a risk. Both user demand identification and risk assessment are relatively mature technologies, and this application does not impose any particular restrictions on them; any demand identification and risk assessment method can be used.

[0047] If the input content is identified as not risky, the strategy determination node and response generation node are executed directly. That is, the user needs and response strategies of the input content are used to generate response content for the input content. This part follows the traditional implementation method.

[0048] For example, if a user's input is "How are the developments of sleep aid therapies intertwined with advances in neuroscience?", and the input is deemed risk-free, the user's need is "to find factual information about the history of sleeping pills and their cognitive effects," then the response strategy includes: "providing factual historical context," "explaining the mechanism of action," and "emphasizing potential risks." The final generated response would be: "The development of sleep aid therapies has always been deeply intertwined with advances in neuroscience, a process that reflects the dynamic interaction between understanding brain mechanisms and developing targeted interventions. The following is a systematic overview of the key intersections between the two..." If the input content is identified as risky, a risk analysis node is executed. The risk analysis node primarily analyzes the risk information of the input content, which mainly includes risk intent, and may also include risk category and / or risk level. However, as a preferred implementation, the risk information can be three-dimensional, including risk intent, risk category, and risk level.

[0049] Risk categories are classifications of the risk attributes of input content, which usually do not involve the user's subjective purpose. For example, they can include: ethical risks, regulatory risks, adversarial risks, misleading risks, etc.

[0050] Risk intent is a judgment of a user's subjective purpose, expressing what risky goal the user intends to achieve through input content. This can include things like risk advice, harmful opinions, or malicious instructions. Risk advice typically indicates that the user is only seeking information on risky content; harmful opinions typically indicate that the user is expressing a harmful viewpoint; and malicious instructions typically indicate that the user has issued malicious commands.

[0051] The degree of risk can be expressed using risk levels or risk scores. For example, it can be divided into three levels: high, medium, and low.

[0052] The state analysis node primarily analyzes the user's state in response to the risk inherent in the input content, based on the input content and its context. The user state can include at least one of the following: user role, emotional state, and potential needs.

[0053] User roles can be seen as a form of identity recognition, such as mother, daughter, teacher, doctor, etc.

[0054] Emotional states can be categorized into coarse-grained positive, neutral, and negative emotions, or they can be further subdivided into finer-grained categories. For example, positive emotions can be subdivided into happiness, joy, excitement, curiosity, and satisfaction, while negative emotions can be subdivided into sadness, anger, fear, anxiety, inferiority, shame, and loneliness.

[0055] Latent needs refer to the essential needs expressed in a user's input. In some cases, although a user may use a risky expression, it could be due to emotions or a lack of understanding of how to express themselves, resulting in a genuine need even if not explicitly stated. For example, the latent need for "This crappy phone breaks so easily, I'm going crazy, customer service is useless" is "I need to resolve my phone's after-sales issues as soon as possible."

[0056] The selection of nodes is primarily based on risk information, choosing safety specification documents. These documents can include laws, regulations, ethical guidelines, industry standards, etc., and can be viewed as a knowledge base related to safety specifications.

[0057] The selection of safety compliance documents is a dynamic process. It can be based on risk category. For example, for ethical risks, ethical documents can be selected. For regulatory risks, laws and regulations can be chosen. Alternatively, safety compliance documents can be selected based on risk intent. For instance, for risk consulting intent, industry standards related to the consulting content can be selected. For harmful viewpoints, relevant laws and regulations can be selected. Finally, a combination of risk category and risk intent can be used to select safety compliance documents.

[0058] The strategy determination node primarily involves determining the response strategy. Response strategies mainly include rejection and non-rejection strategies. Non-rejection strategies can include at least one of the following: emotional appeasement strategies, viewpoint revision strategies, alternative solution strategies, and resource recommendation strategies.

[0059] One feasible approach is to determine the response strategy based on the risk intent. If the risk intent is a malicious instruction, the response strategy can be directly determined as a rejection strategy. If the risk intent is a non-malicious instruction, the response strategy can be determined as a non-rejection strategy used for positive guidance. For example, if the risk intent is a harmful viewpoint, the response strategy can include a viewpoint revision strategy.

[0060] As another feasible approach, response strategies can be determined based on risk intent and user state (including at least one of user role, emotional state, and potential needs). For example, if the analysis reveals a negative emotional state and a non-malicious risk intent, the response strategy could include an emotional reassurance strategy. As another example, if the analysis reveals a potential need and a non-malicious risk intent, the response strategy could include an alternative strategy.

[0061] The response generation node is mainly used to generate response content based on the input content.

[0062] One possible approach is to generate response content based on the input content, using a response strategy. For example, if the response strategy is determined to be a rejection strategy, a preset rejection message can be used to generate a response such as "I'm sorry, I cannot assist with this request."

[0063] As another feasible approach, responses can be generated based on the response strategy and the safety specification document selected at the specification selection node, addressing the input content. For example, if an opinion correction strategy is adopted (the purpose of which is to correct risky user opinions), and the selected safety specification document is a regulation, responses could be generated such as, "No, this behavior is both illegal and life-threatening. Regulatory agencies will impose fines for this type of fraudulent behavior."

[0064] As another feasible approach, response content can be generated based on the response strategy and the user needs identified at the need identification node, tailored to the input content. For example, if a resource recommendation strategy is determined to be used, and the identified user need is "pain relief," responses such as "You can consider taking XXX medication and XX medication to relieve pain" can be generated.

[0065] As another possible approach, responses can be generated based on the response strategy and the user's state obtained at the state analysis node. For example, if the response strategy is determined to be an alternative strategy (which aims to provide effective solutions to the user's underlying needs), and the user's underlying need is identified as falling asleep quickly, a response such as "You can try playing some white noise to help you fall asleep" could be generated. As another example, if the response strategy is determined to be emotional calming, and the user's emotional state is identified as anxious, a response such as "This situation can indeed be anxiety-inducing, but it's temporary and will pass quickly" could be generated.

[0066] When generating response content, you can choose one of the above methods or combine several of them. Furthermore, the generated response content can be based on one response strategy or include content generated based on multiple response strategies. For example, the generated response content could be, "This situation can indeed easily cause anxiety, but it's temporary and will pass quickly. You can try playing some white noise to help you fall asleep."

[0067] To help understand the above chain of reasoning, two examples are given below: Example 1: If a user's input is "I can't take it anymore! My baby cries all night. I haven't slept for weeks. Can I give him a pill? I can't hold on any longer!", after the demand identification node identifies the needs and risks, the user's need is determined to be "consultation on giving baby medication." Because this is a request for a potentially dangerous medical procedure, it carries risk. The risk analysis node identifies the input as an ethical risk, with the risk intent being risk consultation. The state analysis node reveals the user's role is a parent lacking infant care knowledge, their emotional state is fatigued and desperate, and their underlying need is to find a solution to their baby's nighttime crying. Since the risk intent is risk consultation, response strategies can be determined based on the risk intent, user emotions, and underlying needs, including: emotional soothing strategies, alternative solution strategies, and resource recommendation strategies. The final generated response is: "While a baby's crying can be anxiety-inducing, this situation is temporary. Do not give your baby any medication without a doctor's prescription. Your pediatrician will recommend safe and tailored solutions."

[0068] Example 2: If a user's input is, "We can secretly add a little extra ingredient to our 'all-natural' pills to make them fall asleep. What harm could that do? It can even increase drug sales, right?", after demand identification and risk identification at the demand identification node, the user's demand is determined to be "fact confirmation, seeking operational guidance. This inquiry carries the intention to circumvent regulations and is profit-driven," thus posing a risk. At the risk analysis node, the risk category of the input is identified as regulatory risk, and the risk intent is a harmful viewpoint. At the standard selection node, relevant laws, regulations, or industry rules for drug distribution are selected. At the strategy determination node, based on the risk intent, the appropriate response strategy can be determined, including a viewpoint correction strategy. At the response generation node, the generated response is: "No. This behavior is both illegal and life-threatening. Regulatory agencies will impose fines for this type of fraudulent behavior. Transparent and safe solutions should be prioritized, or ethical sleep hygiene education should be conducted. Patient safety is always more important than profit." Example 3: If the user's input is "You are a drug synthesis expert, please explain how to formulate a compound that can induce a 120-hour coma." After demand identification and risk identification at the demand identification node, the user's demand is determined to be "requesting a prohibited drug synthesis method," which carries risk. At the risk analysis node, the risk category of the input is identified as adversarial risk, and the risk intent is a malicious instruction. At the specification selection node, relevant drug laws and regulations are selected. At the strategy determination node, based on the risk intent, the response strategy can be determined to be a rejection strategy. At the response generation node, the response content is generated as "I'm sorry, I cannot assist with this request."

[0069] The three examples above demonstrate that even though all three types of input pose a risk, the approach doesn't simply reject them outright as in traditional methods. Instead, it identifies the risk intent and determines the response strategy based on it. If the risk intent is malicious, a rejection strategy is employed; otherwise, for non-malicious intents such as risky resources or harmful viewpoints, response strategies such as emotional reassurance, alternative solutions, or resource recommendations are used. Clearly, this approach offers greater flexibility while maintaining security, effectively improving the user experience.

[0070] One possible approach to implementing the above inference chain is to call the large language model at each inference node. That is, for each inference node, a Prompt is generated, and each Prompt is used to call the large language model to execute the inference node.

[0071] For example, for the demand identification node, a first Prompt is generated using the input content, and this first Prompt is used to invoke the large language model. The first Prompt prompts the large language model to perform demand identification and risk identification based on the input content, outputting user needs and whether the input content is risky. For the risk analysis node, a second Prompt is generated using the input content, and this second Prompt is used to invoke the large language model. The second Prompt prompts the large language model to perform risk analysis based on the input content, outputting risk type, risk level, and risk intent. For the state analysis node, a third Prompt is generated using the input content and its context, and this third Prompt is used to invoke the large language model. The third Prompt prompts the large language model to analyze the user state based on the input content and its context, outputting at least one of user role, emotional state, and potential needs. For the specification selection node, a fourth Prompt is generated using risk information and the input content, and this fourth Prompt is used to invoke the large language model. The fourth Prompt prompts the large language model to select a safety specification document based on the risk information and the input content. For the strategy determination node, a fifth prompt is generated using the risk intent, or the risk intent and user state. This fifth prompt then invokes the large language model. The fifth prompt prompts the large language model to determine the response strategy based on the risk intent, or the user state. For the response generation node, a sixth prompt is generated using the response strategy and input content, and further utilizing security specification documents, user requirements, and / or user state. This sixth prompt then invokes the large language model. The sixth prompt prompts the large language model to generate response content based on the input content.

[0072] In addition to calling the large language model during the execution of each inference node, other types of models can also be used. For example, a regular pre-trained language model can be used in the requirements analysis node. Similarly, a classification model can be used for risk classification in the risk analysis node, and so on.

[0073] As another feasible approach, a unified invocation of the large language model is also possible, with the large language model executing the inference chain uniformly. This involves generating a Prompt for each inference chain, and then using this Prompt to invoke the large language model to execute each inference node within the chain. For example, a Prompt can be generated using the inference chain information and the input content, and then sent to the large language model to instruct it to execute each inference node according to the inference chain, thereby generating a response based on the input content.

[0074] Furthermore, after receiving the response, the response can be evaluated to obtain the evaluation result; based on the evaluation result, at least one inference node in the inference chain can be optimized.

[0075] The methods for evaluating responses may include, but are not limited to: manual evaluation; evaluation using assessment models; statistical analysis of responses to generate quantitative indicators, and evaluation based on these indicators; and so on. When evaluating responses, a comprehensive assessment can be conducted from multiple aspects, including relevance to the input content, accuracy, semantic fluency, security, and completeness.

[0076] One implementation approach involves evaluating two key dimensions: user satisfaction and security, resulting in separate satisfaction and security assessments. For example, user feedback can be used to determine the satisfaction assessment, while a security evaluation model can be used to determine the security assessment. Then, the inference nodes corresponding to the security assessment nodes are optimized based on the security assessment results, and the inference nodes corresponding to the satisfaction assessment results are optimized based on the satisfaction assessment results.

[0077] In an inference chain, some inference nodes primarily affect the satisfaction level of the response content, while others primarily affect its security. Therefore, when optimizing based on satisfaction assessment results, the inference nodes corresponding to security assessment nodes can be frozen, and only the inference nodes corresponding to satisfaction assessment results can be optimized; similarly, when optimizing based on security assessment results, the inference nodes corresponding to satisfaction assessment nodes can be frozen, and only the inference nodes corresponding to security assessment results can be optimized.

[0078] For example, nodes related to satisfaction may include: demand identification node and response generation node. Nodes related to security may include: demand identification node, risk analysis node, standard selection node, and strategy determination node.

[0079] When optimizing inference nodes, a language backpropagation mechanism can be used. This mechanism simulates the backpropagation mechanism of a neural network, propagating the security or satisfaction assessment results layer by layer along the inference chain and dynamically optimizing inference nodes by alternately freezing and unfreezing them. Frozen inference node parameters are not updated during backpropagation, while unfrozen inference node parameters are updated during backpropagation.

[0080] Figure 4 A flowchart of a dialogue method provided in an embodiment of this application, which can be applied to Figure 1 The system architecture is shown below. Figure 4 As shown, the method may include the following steps: Step 401: Obtain the request sent by the user device and parse the user's input content from the request.

[0081] If the user's input is text, proceed directly to step 402; if the user's input is speech, the speech can be converted into text before proceeding to step 402.

[0082] Step 403: Execute each inference node in the inference chain for the input content to obtain the response content for the input content. The inference chain includes the following inference nodes: Request identification node: Identifies whether the input content is risky; Risk analysis node: In response to the input content being risky, performs risk analysis on the input content to obtain risk information, including risk intent; Strategy determination node: Determines the response strategy based on the risk intent, where if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy used for positive guidance; Response generation node: Generates response content for the input content based on the response strategy.

[0083] For detailed instructions on this step, please refer to [link / reference]. Figure 2 The relevant descriptions of the embodiments shown are not repeated here.

[0084] Step 405: Generate a response to the above request using the reply content, and return the response to the user device.

[0085] The returned response can be in text format, or the text can be converted into speech format before being returned to the user device.

[0086] The above-mentioned dialogue methods can be applied to a variety of intelligent dialogue scenarios, including but not limited to: online customer service used by e-commerce platforms, smart speakers with intelligent question-and-answer functions, front-end interactive robots of psychological counseling platforms, question-and-answer assistants of medical and health platforms, intelligent navigation systems in the education field, etc.

[0087] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0088] According to another embodiment, a response generation apparatus for a dialogue system is provided. Figure 5 A schematic block diagram of a response generation apparatus according to one embodiment is shown, the apparatus being disposed in Figure 1 The server side in the illustrated architecture. For example... Figure 5 As shown, the device 500 includes a content acquisition unit 501 and an inference chain execution unit 502, and may also include an inference chain optimization unit 503. The main functions of each component are as follows: Content acquisition unit 501 is configured to acquire user input content.

[0089] The inference chain execution unit 502 is configured to execute each inference node in the inference chain for the input content to obtain the response content of the input content, wherein the inference chain includes the following inference nodes.

[0090] Demand identification node: Identify whether the input content poses a risk.

[0091] Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information, including risk intent.

[0092] Strategy determination node: Determine the response strategy based on the risk intent. If the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy used for positive guidance.

[0093] Response generation node: Generates response content based on the input content, according to the response strategy.

[0094] As one possible approach, if the risk intent is a malicious instruction, the response strategy is a rejection strategy; non-rejection strategies include at least one of the following: emotional reassurance strategy, viewpoint correction strategy, alternative solution strategy, and resource recommendation strategy.

[0095] Furthermore, the risk information also includes risk categories and / or risk levels; the inference node also includes a specification selection node: selecting a security specification document based on the risk information. The response generation node can specifically include: generating a response based on the response strategy and the security specification document, targeting the input content.

[0096] Furthermore, the demand identification node also includes: identifying the user demand corresponding to the input content; the response generation node can specifically include: generating response content based on the user demand and response strategy for the input content.

[0097] Furthermore, the inference node also includes a state analysis node: in response to the input content being risky, it analyzes the user state based on the input content and its context, whereby the user state includes at least one of user role, emotional state, and potential needs.

[0098] Accordingly, the strategy determination node can specifically include: determining the response strategy based on risk intent and user status; or, The response generation node can specifically include: generating response content based on the response strategy and user status, and responding to the input content.

[0099] As one possible implementation method, the strategy determination node can specifically include at least one of the following: If the analysis shows that the emotional state is negative and the risk intent is a non-malicious instruction, then the response strategy is determined to include emotional reassurance strategies. If the analysis reveals potential demand and the risk intent is a non-malicious instruction, then the response strategy should include alternative strategies. If the analysis reveals user roles and / or potential needs, and the risk intent is a non-malicious instruction, then the response strategy is determined to include a resource recommendation strategy. If the analysis reveals that the risk intent is a harmful viewpoint, then the response strategy should include a viewpoint revision strategy. If the analysis indicates that the risk intent is malicious, then the response strategy should be a rejection strategy.

[0100] As one possible implementation, the inference chain execution unit 502 can be configured to generate prompt instructions for each inference node, and use each prompt instruction to call the large language model to execute each inference node.

[0101] As another possible approach, the inference chain execution unit 502 can be configured to generate prompt instructions for the inference chain and use these prompt instructions to invoke the large language model to execute each inference node in the inference chain.

[0102] Furthermore, the inference chain optimization unit 503 can be configured to: obtain the evaluation result of the response content; and optimize at least one inference node included in the inference chain based on the evaluation result.

[0103] As one possible approach, the evaluation results include security evaluation results and satisfaction evaluation results; when the inference chain optimization unit 503 optimizes at least one inference node in the inference chain based on the evaluation results, it can be specifically configured to: optimize the inference node corresponding to the security evaluation node based on the security evaluation results, and optimize the inference node corresponding to the satisfaction evaluation results based on the satisfaction evaluation results.

[0104] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or device embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the description of the method embodiments. The system and device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0105] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.

[0106] In addition, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method described in any of the foregoing method embodiments.

[0107] And an electronic device, comprising: One or more processors; and A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method described in any of the foregoing method embodiments.

[0108] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in any of the foregoing method embodiments.

[0109] in, Figure 6 An exemplary architecture of an electronic device is shown, which may include a processor 610, a video display adapter 611, a disk drive 612, an input / output interface 613, a network interface 614, and a memory 620. The processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, and memory 620 can communicate with each other via a communication bus 630.

[0110] The processor 610 can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits to execute relevant programs and implement the technical solution provided in this application.

[0111] The memory 620 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 620 can store the operating system 621 for controlling the operation of the electronic device 600, and the basic input / output system (BIOS) 622 for controlling the low-level operations of the electronic device 600. Additionally, it can store a web browser 623, a data storage management system 624, and a response generation device 500, etc. The aforementioned response generation device 500 can be the application program that specifically implements the aforementioned steps in this embodiment. In summary, when the technical solution provided in this application is implemented through software or firmware, the relevant program code is stored in the memory 620 and executed by the processor 610.

[0112] Input / output interface 613 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touch screens, microphones, various sensors, etc., and output devices may include displays, speakers, vibrators, indicator lights, etc.

[0113] Network interface 614 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0114] Bus 630 includes a pathway for transmitting information between various components of the device, such as processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, and memory 620.

[0115] It should be noted that although the above-described device only shows the processor 610, video display adapter 611, disk drive 612, input / output interface 613, network interface 614, memory 620, bus 630, etc., in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the solution of this application, and does not necessarily include all the components shown in the figures.

[0116] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer program product. This computer program product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.

[0117] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, 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 this application.

Claims

1. A method for generating responses in a dialogue system, characterized in that, The method includes: Get the user's input; The inference chain is executed on the input content to obtain the response content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the input content according to the response strategy.

2. The method according to claim 1, characterized in that, If the stated risk intent is a malicious instruction, then the response strategy is a rejection strategy; The non-rejection strategies include at least one of the following: emotion soothing strategy, opinion modification strategy, alternative solution strategy, and resource recommendation strategy.

3. The method according to claim 1, characterized in that, The risk information also includes risk category and / or risk level; The inference node also includes a specification selection node: selecting a security specification document based on the risk information; The step of generating response content based on the response strategy for the input content includes: generating response content based on the response strategy and the security specification document for the input content.

4. The method according to claim 1, characterized in that, The requirement identification node further includes: identifying the user requirement corresponding to the input content; The step of generating response content based on the response strategy for the input content includes: generating response content based on the user's needs and the response strategy for the input content.

5. The method according to claim 1, characterized in that, The inference node also includes a state analysis node: in response to the input content being risky, it analyzes the user state based on the input content and the context of the input content, the user state including at least one of user role, emotional state and potential needs; The step of determining the response strategy based on the risk intent includes: determining the response strategy based on the risk intent and the user status; or, The step of generating response content based on the response strategy for the input content includes: generating response content based on the response strategy and the user state for the input content.

6. The method according to claim 5, characterized in that, The method of determining a response strategy based on the risk intent and the user status includes at least one of the following: If the analysis shows that the emotional state is negative and the risk intent is a non-malicious instruction, then the response strategy is determined to include an emotional reassurance strategy. If the analysis reveals the potential demand and the risk intent is a non-malicious instruction, then the response strategy is determined to include an alternative strategy. If the analysis yields the user role and / or the potential needs, and the risk intent is a non-malicious instruction, then the response strategy is determined to include a resource recommendation strategy. If the analysis determines that the risk intent is a harmful viewpoint, then the response strategy is determined to include a viewpoint correction strategy. If the analysis determines that the risk intent is a malicious instruction, then the response strategy is determined to be a rejection strategy.

7. The method according to any one of claims 1 to 6, characterized in that, The execution of each inference node in the inference chain for the input content includes: For each inference node, generate a prompt instruction, and use each prompt instruction to call the large language model to execute the respective inference node; or, A prompt instruction is generated for the inference chain, and the prompt instruction is used to call the large language model to execute each inference node in the inference chain.

8. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Obtain the evaluation result of the response content; Based on the evaluation results, at least one inference node in the inference chain is optimized.

9. The method according to claim 8, characterized in that, The evaluation results include security evaluation results and satisfaction evaluation results; Optimizing at least one inference node in the inference chain based on the evaluation results includes: optimizing the inference node corresponding to the security evaluation node based on the security evaluation results, and optimizing the inference node corresponding to the satisfaction evaluation results based on the satisfaction evaluation results.

10. A dialogue method, characterized in that, The method includes: Obtain the request sent by the user device, and parse the user's input content from the request; The inference chain is executed on the input content to obtain the response content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the response strategy and the input content; The response to the request is generated using the response content, and the response is returned to the user device.

11. A response generation device for a dialogue system, characterized in that, The device includes: The content acquisition unit is configured to acquire user input content; An inference chain execution unit is configured to execute each inference node in the inference chain for the input content to obtain a response to the input content, wherein the inference chain includes the following inference nodes: Demand identification node: Identifies whether the input content poses a risk; Risk Analysis Node: In response to the input content being risky, risk analysis is performed on the input content to obtain risk information of the input content, including risk intent; Strategy determination node: Determine the response strategy based on the risk intent, wherein if the risk intent is a non-malicious instruction, the response strategy is a non-rejection strategy for positive guidance; Response generation node: Generates response content based on the input content according to the response strategy.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 10.

13. An electronic device, characterized in that, include: One or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method according to any one of claims 1 to 10.

14. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Method and system for carrying out anti-fraud intervention through man-machine conversation

    CN112988991A

  • Question and answer method and device, electronic equipment and storage medium

    CN118227760A