Conversation method and device, electronic equipment and storage medium

By constructing a heterogeneous graph to integrate multi-dimensional state features and user profiles, and combining it with preset strategies to generate personalized responses, the problem of inaccurate responses in existing dialogue systems is solved, achieving more accurate and coherent natural language responses.

CN121599104APending Publication Date: 2026-03-03ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing intelligent dialogue systems lack in-depth mining and effective filtering of the relationships between features when generating natural language responses, resulting in inaccurate, inconsistent, and personalized responses.

Method used

By constructing a heterogeneous graph, integrating multi-dimensional state features (semantics, strategy, sentiment, and user features) and combining them with user profile information, response statements are generated. Preset strategies and target response strategies are used for filtering and adjustment to generate personalized and coherent natural language responses.

Benefits of technology

It improves the accuracy and personalization of the dialogue system, generates more accurate response statements, ensures that the response is consistent with the preceding logic, and reduces irrelevant information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121599104A_ABST
    Figure CN121599104A_ABST
Patent Text Reader

Abstract

The invention discloses a dialogue method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining dialogue information which comprises a historical dialogue and a current query statement of a user; according to the dialogue information, a heterogeneous graph is constructed, the heterogeneous graph is constructed according to a plurality of states and a feature value of each state, and each node in the heterogeneous graph is one of the plurality of states; according to the dialogue information, constructing portrait information of the user; determining a target response strategy according to the dialogue information; and determining a response statement corresponding to the query statement according to the heterogeneous graph, the portrait information and a target response strategy, in the above steps, respectively constructing the heterogeneous graph and the user information according to the dialogue information, and generating a natural language response with coherence, emotion support and individuation according to the feature value of the heterogeneous graph and the feature of the portrait information. And in combination with the target response strategy, the personalized adaptation degree can be improved, and a more accurate response statement can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application pertains to computer processing technology, and particularly relates to a dialogue method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the field of intelligent dialogue systems, generating high-quality natural language responses is key to achieving effective human-computer interaction. As users' demands for interactive experiences continue to increase, systems not only need to accurately understand user intent, but also need to generate responses that are coherent, emotionally supportive, and personalized.

[0003] Currently, a simple feature concatenation method is used to integrate dialogue state information and user features, which directly combines text semantic features, dialogue turn information, and basic user attributes during the dialogue process. Although the above method is simple to operate, it is easy to cause irrelevant information in the generated response due to the lack of in-depth mining and effective filtering of the relationship between features, resulting in inaccurate content in the reply. Summary of the Invention

[0004] This application provides a dialogue method, apparatus, electronic device, and storage medium that can improve the accuracy of speech and effectively answer user questions.

[0005] In a first aspect, embodiments of this application provide a dialogue method, the method comprising: Obtain dialogue information, which includes historical dialogues and the user's current query statement; Based on the dialogue information, a heterogeneous graph is constructed. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information. Based on the dialogue information, construct the user's profile information; Based on the dialogue information, determine the target response strategy; Based on the heterogeneous graph, the profile information, and the target response strategy, the response statement corresponding to the query statement in this round is determined.

[0006] In one embodiment of this application, the historical dialogues include the user's historical query statements; The step of determining the response statement corresponding to the current round of query statements based on the heterogeneous graph, the profile information, and the target response strategy includes: Based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information, a vocabulary information is obtained. The vocabulary information includes multiple words and a first probability value corresponding to each word. The profile information includes explicit features and implicit features. The explicit features are extracted from the historical query statements and the current query statements, and the implicit features are obtained by reasoning from the historical query statements and the current query statements. Based on the vocabulary information and the target response strategy, determine the response statement corresponding to the query statement in this round.

[0007] In one embodiment of this application, determining the response statement corresponding to the current round of query statements based on the vocabulary information and the target response strategy includes: The words in the vocabulary information are filtered to obtain multiple candidate words; Based on the multiple candidate words and the target response strategy, the response statement corresponding to the query statement in this round is determined.

[0008] In one embodiment of this application, obtaining vocabulary information based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information includes: The feature values ​​of multiple states, the explicit features, and the implicit features are fused to obtain the fused features; The fused features are mapped to obtain the vocabulary information.

[0009] In one embodiment of this application, the fusion process of feature values ​​of multiple states, explicit features, and implicit features to obtain fused features includes: The feature values ​​of multiple states, the explicit features, and the implicit features are concatenated to obtain a fourth vector; A linear transformation is performed on the fourth vector to obtain the second intermediate vector; The second intermediate vector is compressed by a preset activation function to obtain the third weight corresponding to the fifth vector, which is obtained based on the feature values ​​of multiple states. Subtracting the third weight from the preset weight yields the fourth weight of the sixth vector, which is obtained based on the explicit features and the implicit features. The fused features are obtained by weighting the third weight, the fifth vector, the fourth weight, and the sixth vector.

[0010] In one embodiment of this application, the step of filtering the words in the vocabulary information to obtain multiple candidate words includes: Each word in the vocabulary information is sorted from largest to smallest according to its first probability value. The X words corresponding to the first probability values ​​at the top of the sort are selected as multiple candidate words, where X is a positive integer and the sum of the X first probability values ​​is greater than or equal to a first preset threshold.

[0011] In one embodiment of this application, determining the response statement corresponding to the current round of query statements based on the plurality of candidate words and the target response strategy includes: If the sum of the first probability values ​​of multiple candidate words is greater than or equal to a first preset threshold and less than a second preset threshold, the first probability values ​​of multiple candidate words are adjusted to obtain a second probability value for each candidate word, and the sum of the second probability values ​​of multiple candidate words is equal to the second preset threshold. At least one target word is obtained based on the second probability value and preset coefficient of each candidate word; According to the target response strategy, the response statement corresponding to the current round of query statement is generated based on at least one of the target words.

[0012] In one embodiment of this application, obtaining at least one target word based on the second probability value and a preset coefficient of each candidate word includes: The second probability value of each candidate word is adjusted according to a preset coefficient to obtain the third probability value of each candidate word; A probability interval is constructed for each candidate word based on the third probability value of each candidate word, thus obtaining the probability interval for each candidate word; The probability interval of each candidate word is filtered using random numbers to obtain the target probability interval; The candidate words corresponding to the target probability interval are taken as at least one target word.

[0013] In one embodiment of this application, generating the response utterance corresponding to the current round of query statements according to at least one of the target words based on the target response strategy includes: An initial utterance is generated based on at least one of the target words according to the target response strategy; The initial statement is processed by at least one of the following methods to obtain the response statement corresponding to the current round of query statements: Replace sensitive words present in the initial discourse; Replace any contradictory words in the initial utterance; The initial utterance is then subject to emotional correction.

[0014] Secondly, embodiments of this application provide a dialogue device, the device comprising: The acquisition module is used to acquire dialogue information, which includes historical dialogues and the user's current query statement; The first construction module is used to construct a heterogeneous graph based on the dialogue information. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information. The second construction module is used to construct the user's profile information based on the dialogue information; The first determining module is used to determine the target response strategy based on the dialogue information; The second determining module is used to determine the response statement corresponding to the current round of query statements based on the heterogeneous graph, the profile information, and the target response strategy.

[0015] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the dialogue method as described in the first aspect.

[0016] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the dialogue method as described in the first aspect.

[0017] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the dialogue method as described in the first aspect.

[0018] The dialogue method, apparatus, electronic device, and storage medium of this application embodiment acquire dialogue information, including historical dialogues and the user's current query statement; construct a heterogeneous graph based on the dialogue information, the heterogeneous graph being constructed based on multiple states and feature values ​​of each state, each node in the heterogeneous graph being one of the multiple states, the edges in the heterogeneous graph being connected by a preset strategy, the multiple states and feature values ​​of each state being obtained based on fusion information, the fusion information being obtained based on encoding information, the encoding information being obtained by encoding the dialogue information; construct the user's profile information based on the dialogue information; determine a target response strategy based on the dialogue information; and determine the response statement corresponding to the current query statement based on the heterogeneous graph, the profile information, and the target response strategy. In the above steps, a heterogeneous graph and user information are constructed based on the dialogue information, and a natural language response with coherence, emotional support, and personalization is generated based on the feature values ​​of the heterogeneous graph and the features of the profile information. Furthermore, combining the target response strategy can improve the degree of personalization adaptation, and a more accurate response statement can be obtained through the above method. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the dialogue method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of the dialogue device provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0021] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.

[0022] It should be noted that, in this document, relational terms 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 thereof 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 a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.

[0023] In all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user speech, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. Additionally, when embodiments of this application require access to sensitive personal information, separate permission or consent from the user is obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.

[0024] To address the problems of the prior art, embodiments of this application provide a dialogue method, apparatus, electronic device, and storage medium. The dialogue method provided by embodiments of this application will be described first.

[0025] Figure 1 A flowchart illustrating a dialogue method provided in one embodiment of this application is shown. Figure 1 As shown, the dialogue method provided in this application embodiment is applied to an electronic device and includes the following steps 101-105, wherein: Step 101: Obtain dialogue information, which includes historical dialogues and the user's current query statement.

[0026] In this embodiment, dialogue information is obtained, including historical dialogues and the current dialogue. Historical dialogues include the user's historical query statements and response statements to those statements. The current dialogue includes the user's current query statement. Historical dialogues can be represented as D= ),in, For the historical query discourse of the i-th user The response statement in response to the historical query statement of the i-th user.

[0027] Step 102: Construct a heterogeneous graph based on the dialogue information. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information.

[0028] In this embodiment, the dialogue information is encoded to obtain encoded information, which includes word vectors and utterance vectors; the word vectors and utterance vectors are fused to obtain fused information, which is used to characterize the features of the dialogue information.

[0029] The fused information is analyzed to obtain multiple states and feature values ​​for each state. The multiple states include semantic state, policy state, sentiment state, and user feature state. These multiple states describe the dialogue information from different dimensions.

[0030] The multiple states include semantic state, policy state, sentiment state, and user feature state. Based on the multiple states and the feature values ​​of each state, a heterogeneous graph is constructed. The heterogeneous graph is constructed based on the multiple states and the feature values ​​of each state. The heterogeneous graph includes multiple nodes, and each node is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy.

[0031] In one embodiment of this application, constructing a heterogeneous graph based on the dialogue information includes: Based on the fusion information, multiple states and feature values ​​for each state are obtained. The fusion information is obtained based on encoding information, which is obtained by encoding the dialogue information. A heterogeneous graph is constructed based on the multiple states and the feature values ​​of each state.

[0032] In this embodiment, the dialogue information is encoded to obtain encoded information, which includes word vectors and utterance vectors; the word vectors and utterance vectors are fused to obtain fused information, which is used to characterize the features of the dialogue information.

[0033] Furthermore, the fused information is analyzed to obtain multiple states and feature values ​​for each state. The multiple states include semantic state, policy state, sentiment state, and user feature state. These multiple states describe the dialogue information from different dimensions.

[0034] A heterogeneous graph is constructed based on multiple states and the feature values ​​of each state. The heterogeneous graph includes multiple nodes, each of which is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting multiple nodes using a preset strategy.

[0035] Heterogeneous graphs can integrate multiple types of nodes, ensuring that responses closely match the query semantics, reducing irrelevant answers, and associating historical dialogue nodes to ensure that responses are consistent with the preceding logic, avoiding fragmentation and resulting in more accurate response statements.

[0036] In one embodiment of this application, obtaining multiple states and feature values ​​of each state based on the fusion information includes: The fused information is analyzed to determine N states included in the fused information from a preset set of M states, where N is a positive integer and N is an integer less than or equal to M; For each round of the historical dialogue in the dialogue information, obtain the feature values ​​of N states corresponding to each round of the historical dialogue.

[0037] In this embodiment, M pre-configured states are used to describe the features of the dialogue information to be analyzed from different dimensions, analyze the fused information, and calculate the similarity between the fused information and each of the M states. The similarity calculation is the similarity between vectors, where the fused information is the fused vector.

[0038] For example, cosine similarity is used to calculate the similarity between the fusion vector and the vector corresponding to each of the M states. The similarities are sorted from largest to smallest, and the N similarities at the top of the sort are selected. That is, the N states included in the fusion information are determined from the pre-set M states.

[0039] The aforementioned historical dialogue has multiple rounds. Feature values ​​for N states corresponding to each round of historical dialogue are obtained. These N states include semantic state, policy state, sentiment state, and user feature state. An evolutionary relationship between these states across multiple dimensions—semantic, policy, sentiment, and user feature—is established; that is, a heterogeneous graph is constructed. Specifically, based on the feature values ​​of the N states corresponding to each round of historical dialogue, a heterogeneous graph corresponding to the dialogue information is constructed. Each state constitutes a node in the heterogeneous graph. The heterogeneous graph can include multiple types of nodes: nodes representing semantic states, policy states, sentiment states, and user feature states. The feature values ​​of each state constitute the descriptive information of the nodes in the heterogeneous graph.

[0040] Traditional sequence models treat dialogue as a linear process and cannot capture state transitions across rounds and modalities. By constructing heterogeneous graphs, collaborative management of multi-dimensional states can be achieved.

[0041] In one embodiment of this application, the plurality of states include semantic states, which are used to encode the semantic content of the dialogue information; The feature values ​​of the semantic state are obtained as follows: The fused information is input into a temporal convolutional network to obtain the first feature information output by the temporal convolutional network. The first feature information includes multiple words in the dialogue information and context information corresponding to each word. The first feature information is input into the second language model to obtain the semantic information output by the second language model, and the semantic information is used as the feature value of the semantic state.

[0042] In this embodiment, multiple states include semantic states, which are used to encode the semantic content of the dialogue information. The fused information is input into a temporal convolutional network to obtain the first feature information output by the temporal convolutional network. The first feature information includes multiple words in the dialogue information and the context information corresponding to each word.

[0043] Among them, Temporal Convolutional Network (TCN) is a deep learning model specifically designed to process temporal data. It captures the temporal dependencies in a sequence through convolution operations and is particularly adept at handling sequence tasks with long-term dependencies and temporal causality.

[0044] Furthermore, the first feature information is input into the second language model to obtain the semantic information output by the second language model. The second language model can be a Transformer model, and the semantic information is used as the feature value of the semantic state.

[0045] The semantic information can be represented as: (1); in, Represents semantic information, For the output of the TCN in the i-th round of historical dialogue, CLS is the [CLS]-labeled aggregate representation of the Transformer model.

[0046] TCN is used to encode historical dialogues, and the temporal and semantic features of the historical dialogues are extracted to obtain the first feature information. When Hu(i) is input into the Transformer model, a [CLS] marker is added before the first feature information, and the feature information corresponding to the marker is finally extracted as semantic information.

[0047] By analyzing the fused information, semantic information is obtained. By analyzing the user's true intention from a semantic dimension, we can understand the user's real needs.

[0048] In one embodiment of this application, the plurality of states include a strategy state, which is used to determine the interaction strategy used by the dialogue information; The feature values ​​of the strategy state are obtained as follows: The interaction strategy used in the dialogue information is obtained from the historical records, and the interaction strategy is used as the feature value of the strategy state. The historical records are used to record the interaction strategy used in the dialogue information.

[0049] In this embodiment, multiple states include a strategy state, which is used to determine the interaction strategy used in historical dialogues. The corresponding historical records are obtained based on the fusion information, such as the historical record closest to the timestamp from multiple historical records based on the timestamp of the fusion information. The historical records are used to record the interaction strategy used in each round of historical dialogue in the dialogue information. Specifically, the interaction strategy used in each round of historical dialogue is obtained from the historical records, and the interaction strategy is used as a feature value of the strategy state. The interaction strategy used can be determined from multiple pre-configured interaction strategies. The pre-configured interaction strategies include a first strategy, a second strategy, and a third strategy. For example, the first strategy can be to ask the user a question; the second strategy can be to provide suggestions based on the user's input; and the third strategy can be emotional reflection. Emotional reflection refers to the process by which one party (usually the party providing the service or the party responding to the user) identifies, responds to, and addresses the emotions expressed by the other party (the user) in the historical dialogue, making the other party feel understood and accepted.

[0050] The pre-configured strategies are not limited to the first, second, and third strategies mentioned above, but may also include other interaction strategies.

[0051] Optionally, the history includes the interaction strategies used in each round of the historical dialogue, which can be recorded in the following form: (2); in, Let be the interaction strategy used in the i-th round of historical dialogue in the dialogue information, where For the eight pre-configured policy states, OneHot uses one-hot encoding. Representing 8 types of policy states, the policy states are transformed into vectors, such as Si=2, where 2 represents emotional reflexes. =[0, 1, 0, 0, 0, 0, 0, 0] indicates that the interaction strategy used in the i-th round of historical dialogue is emotional reflexivity. Each round of historical dialogue can use one or more interaction strategies.

[0052] By analyzing the dialogue information, interaction strategies are obtained, and user dialogue is analyzed from the perspective of interaction.

[0053] In one embodiment of this application, the plurality of states include emotional states, which are used to quantify the emotional tendency of the dialogue information; The feature values ​​of the emotional state are obtained as follows: The fused information is input into the third language model to obtain the probability values ​​of multiple alternative sentiment states output by the third language model. The candidate emotional state corresponding to the highest probability value among the multiple candidate emotional states is taken as the emotional state of the dialogue information. The emotional keywords obtained from the dialogue information will be used as the feature values ​​of the emotional state.

[0054] In this embodiment, multiple states include emotional states. Emotional states are used to quantify the tendency of dialogue information and are presented as probability values. Specifically, the fused information is input into a third language model to obtain probability values ​​of multiple candidate emotional states output by the third language model. These multiple candidate emotional states include happiness, sadness, anger, anxiety, neutrality, and confusion. A probability value for each candidate emotional state is obtained. The candidate emotional state with the highest probability value is selected from the multiple candidate emotional states and taken as the emotional state, i.e., the emotional state of the dialogue information. Furthermore, emotional keywords selected from the dialogue information are used as feature values ​​of the emotional state.

[0055] Alternatively, select the highest probability value from multiple candidate emotional states, and compare the highest probability value with a preset threshold. The preset threshold can be set to 0. If the highest probability value is greater than the preset threshold, the candidate emotional state corresponding to the highest probability value is taken as the emotional state of the dialogue information. Alternatively, multiple candidate emotional states corresponding to multiple larger probability values ​​can be taken as the emotional state of the dialogue information, which can be set according to actual needs.

[0056] The third major language model can be the qwen model, fine-tuned based on GoEmotions, such as the qwen2.5_1.5b model, which can be represented as: (3); in, Let represent the probability values ​​of multiple alternative emotional states corresponding to the i-th round of historical dialogue. This represents the third largest language model. This represents the i-th round of historical dialogue. It represents six emotional states, such as happiness, sadness, anger, anxiety, neutrality, and confusion.

[0057] For example, in the i-th round of historical dialogue, a user says, "I won the grand prize, I'm so happy," and this is entered into... The prediction is made by the third language model, which outputs the probability values ​​of six alternative emotional states, such as happiness (0.9), sadness (0.05), anger (0.02), anxiety (0.01), neutrality (0.01), and confusion (0.01). =[0.9, 0.05, 0.02, 0.01, 0.01, 0.01].

[0058] By transforming vague emotional descriptions into precise probability distributions, the model can perform quantitative analysis of user emotions, resulting in a more realistic emotional state.

[0059] In one embodiment of this application, the plurality of states include user feature states, which are used to determine the basic information of the user in the dialogue information; The feature values ​​of the user's characteristic state are obtained as follows: The fused information is identified, and when a vector matching a preset keyword is identified, the word corresponding to the matching vector is used as the feature value of the user feature state.

[0060] In this embodiment, multiple states include user feature states, also known as personal feature states. User feature states are used to determine the user's basic information in the dialogue information, such as occupation, interests, and family status. Basic information is also attribute information. Specifically, the fused information is identified, and when a vector matching a preset keyword is identified, the word corresponding to the matching vector is used as the feature value of the user feature state of the dialogue information.

[0061] Optionally, when a vector matching a preset keyword is identified, the word corresponding to the matching vector is used as the feature value of the user feature state, including: When a vector matching a preset keyword is identified, a contradiction detection is performed on the words corresponding to the matching vector; If the word corresponding to the matching vector passes the contradiction detection, the word corresponding to the matching vector is used as the feature value of the user feature state of the dialogue information.

[0062] In this embodiment, when multiple matching vectors exist, contradiction detection is performed on the words corresponding to the matching vectors. For example, if P1 = "occupation" = "teacher" and P2 = "interest" = "reading", the effective set is {P1, P2}. That is, if a word passes the contradiction detection, the word corresponding to the matching vector is used as the feature value of the user feature state of the dialogue information. For example, if P1 = "occupation" = "teacher", P2 = "interest" = "reading", and P3 = "occupation" = "doctor", the effective set is {P1, P2}, and P3 is a contradictory word. Words that fail the contradiction detection are deleted, and the words corresponding to the remaining matching vectors are used as the feature values ​​of the user feature state of the dialogue information. The words corresponding to the remaining matching vectors do not include the words that fail the contradiction detection.

[0063] In addition, words that pass the contradiction detection can be encoded to obtain an encoding vector for each word. Multiple encoding vectors can then be averaged and pooled to obtain a total encoding vector. Finally, the user's basic information can be aggregated into a single total encoding vector, as detailed below: (4); in, This is the total encoded vector. These are the encoded vectors obtained using the BERT model. For a valid set that passes the contradiction detection, This indicates average pooling processing, which allows for personalized interactions based on the total encoded vector.

[0064] By analyzing the fused information, basic user information can be obtained, which can then be used to understand deeper intents.

[0065] In one embodiment of this application, the fusion information is obtained as follows: The dialogue information is encoded to obtain encoded information, which includes word vectors and utterance vectors. The word vectors and the utterance vectors are fused to obtain the fused information.

[0066] The dialogue information is encoded to obtain encoded information, which includes word vectors and utterance vectors. Specifically, the historical dialogues in the dialogue information are encoded. The word vectors and utterance vectors in the encoded information are then fused to obtain fused information. Fusion can avoid the loss of key information. Fusion is carried out through attention-based weighted fusion to generate a fused vector that can simultaneously reflect key information and query context, i.e., fused information.

[0067] The process of encoding the dialogue information to obtain encoded information includes: The dialogue information is input into the first language model to obtain the word vectors output by the first language model; The word vectors are input into a temporal convolutional network to obtain the utterance vectors output by the temporal convolutional network.

[0068] In this embodiment, the historical dialogue information is input into the first large language model to obtain word vectors output by the first large language model. The first large language model can be a Transformer model, such as the open-source Qwen2.5-7B, which extracts word vectors at the word level. The word vectors are represented as follows: (5); Among them, H w Represents word vectors, where For word embedding functions, =768 is the hidden layer dimension, the historical dialogue has multiple rounds, n is the number of rounds of historical dialogue, and R represents the basic symbol for the matrix size.

[0069] Furthermore, the word-level vectors are converted to the utterance level. Specifically, the word vectors are input into a temporal convolutional network (TCN), a deep learning model specifically designed for processing temporal data. The output of the TCN is the utterance vector, which is represented as follows: (6); Among them, H u This represents the utterance vector, k represents the kernel size of the dilated convolution (DilatedConv), k=3 means the kernel size is 3; d represents the dilation rate of the dilated convolution, and d takes values ​​of (like When d=1, d=2. When d=2, d=4, and so on. The expansion rate controls the spacing of elements in the convolution kernel. The exponential growth (1, 2, 4, 8...) causes the receptive field to expand rapidly, thereby capturing long-distance dependencies. The current layer level ranges from 1 to L, and the expansion rate d of each layer varies with the layer level. The expansion rate increases exponentially; L represents the total number of layers in the model, i.e., the highest level of the dilated convolution. For example, if L=4, the dilation rates of each layer are d=2, 4, 8, and 16 respectively.

[0070] Optionally, the dialogue information is input into a first large language model to obtain the word vectors output by the first large language model, including: The dialogue information is annotated to obtain annotated dialogue information; The labeled dialogue information is positionally encoded to obtain the positional encoding information corresponding to each word in the labeled dialogue information; The positional encoding information corresponding to each word in the dialogue information and the annotated dialogue information is input into the first large language model to obtain the word vector output by the first large language model.

[0071] In this embodiment, the dialogue information is annotated. Specifically, the historical dialogues in the dialogue information are annotated. The historical dialogues have multiple rounds, and the historical dialogues are divided into multiple rounds, such as "user round 1 → response round 1 → user round 2...". Each word is annotated with the round number Turn(pos) (words in the same round share this number), and then the absolute position pos of each word in its historical dialogue is annotated (starting from 1 and incrementing, such as "the 3rd word of user round 1" is recorded as pos=3). The annotated dialogue information is obtained, that is, the annotated historical dialogues.

[0072] Based on the labeled pos and Turn(pos), the positional encoding information corresponding to each word, i.e., the encoded position vector, is calculated according to the round-aware positional encoding formula. The encoding formula is as follows: (7); (8); Where PE(pos, 2i) and PE(pos, 2i+1) represent the specific values ​​of positional encoding, where pos is the absolute position of the word; i is the dimension index of positional encoding, used to traverse all dimensions of positional encoding (starting from 0), and dh is the dimension index of positional encoding (used to distinguish different encoding dimensions, such as the 2i-th dimension and the 2i+1-th dimension, using 2i and 2i+1 to distinguish the sine and cosine branches); dh is the hidden layer dimension of the model. Indicates the historical dialogue turn number to which the current word belongs; =100 is an adjustment factor that controls the intensity of round information.

[0073] The core purpose of dividing the formula into two branches (sine and cosine) is to enable the position encoding to form positively complementary features in different dimensions, thereby allowing the model to more accurately capture subtle differences in position and round.

[0074] The positional encoding information corresponding to each word in the dialogue information and the annotated dialogue information is input into the first language model. That is, the positional encoding information corresponding to each word in the historical dialogue and the annotated historical dialogue is input into the first language model to obtain the word vector output by the first language model. The word vector is a word vector containing semantic, positional and turn information.

[0075] By using the above method, the positional encoding can simultaneously include information about the absolute position of the word and the dialogue turn it belongs to, thereby enhancing the model's ability to perceive the dialogue structure.

[0076] In one embodiment of this application, the step of performing vector fusion on the word vectors and the utterance vectors to obtain fused information includes: The word vectors are mapped to the target semantic space to obtain the first vector; The utterance vector is mapped to the target semantic space to obtain the second vector; The first vector and the second vector are fused to obtain the fused information.

[0077] In this embodiment, word vectors are mapped to the target semantic space to obtain a first vector, and utterance vectors are mapped to the target semantic space to obtain a second vector. The first vector and the second vector are vectors in the same semantic space. The first vector and the second vector are fused together to obtain a fused vector, i.e., fused information.

[0078] One further method is to place word vectors and utterance vectors in the target semantic space. Mapping them to the same semantic space can reduce the modality gap, as follows: Comparative losses: (9); in, Cosine similarity Temperature coefficient, controlling distribution smoothness B=64; Batch size, negative samples come from other samples in the same batch.

[0079] By using contrastive loss constraints, the semantic spaces of the two types of representations—word vectors and utterance vectors—are ensured to be consistent. Contrastive loss provides explicit geometric constraints on the two types of representations, causing their semantic spaces to converge under the metric of feature distance. It constructs cross-modal semantic mapping relationships through supervised signals, allowing feature representations from different sources to be semantically compared in a unified space, thereby solving the semantic alignment problem in cross-modal tasks.

[0080] The above process can be implemented using a multimodal encoder, which includes a word-level encoding layer and a discourse-level encoding layer. The word-level encoding layer is used to obtain word vectors based on historical dialogues. Specifically, it inputs the historical dialogue information into a first-level language model to obtain the word vectors output by the first-level language model. The discourse-level encoding layer is used to obtain discourse vectors based on the word vectors. Specifically, it inputs the word vectors into a temporal convolutional network to obtain the discourse vectors output by the temporal convolutional network.

[0081] This approach maps the original historical dialogue into a structured multimodal representation, capturing both word-level semantics and discourse-level temporal dependencies. Traditional encoders focus only on word-level semantics, neglecting long-term dependencies between discourses, resulting in insufficient modeling of the dynamic evolution of the dialogue. By introducing a two-level encoding architecture, we achieve a collaborative representation of fine-grained semantics and macro-level dialogue structure.

[0082] In one embodiment of this application, the vector fusion processing of the first vector and the second vector to obtain the fusion information includes: The first vector and the second vector are concatenated to obtain the concatenated third vector; A linear transformation is performed on the third vector to obtain the first intermediate vector; The first intermediate vector is compressed using a preset activation function to obtain the first weight of the first vector; Subtract the first weight from the preset weight to obtain the second weight of the second vector; The fusion information is obtained by weighting the first weight, the first vector, the second weight, and the second vector.

[0083] In this embodiment, for the first vector H w Second vector H u By concatenating the vectors, we obtain the concatenated third vector, i.e. A linear transformation is performed on the third vector to obtain the first intermediate vector.

[0084] Furthermore, the first intermediate vector is compressed using a preset activation function to obtain the first weight of the first vector, as shown below: (10); Where g represents the first weight, also known as the contribution degree. The preset activation function can be... , H w H represents word vectors. u Represents the discourse vector.

[0085] Furthermore, the first weight is subtracted from the preset weight to obtain the difference, which is then used as the second weight of the second vector. The preset weight can be 1. Weighted calculations are performed based on the first weight, the first vector, the second weight, and the second vector to obtain the fused information, which is represented by a gating network, specifically as follows: (11); Represents the fused information, g represents the first weight, and H represents the fused information. w Let H represent the word vector, 1-g represent the second weight, and H represent the word vector. uRepresents the discourse vector.

[0086] In this formula, the gating network adaptively adjusts the weights through the gating vector g: g approaches 1 during short dialogues, emphasizing word-level information H. w During long conversations, g approaches 0, emphasizing discourse-level information H. u This enables information fusion that is aware of dialogue length.

[0087] The semantic connections between words are close, and focusing on word-level information can accurately capture details. In long dialogues, topics and semantic units are more macroscopic, and discourse-level information, such as the intention and theme of the entire dialogue, is more crucial for understanding the context. Therefore, the gating network will adaptively adjust according to the dialogue length, with short dialogues focusing on word-level information and long dialogues focusing on discourse-level information, in order to adapt to the information processing needs of dialogues of different lengths.

[0088] In one embodiment of this application, constructing a heterogeneous graph based on a plurality of states and feature values ​​of each state includes: The historical dialogues of the multiple rounds are divided to obtain multiple dialogue sets, each of the dialogue sets including J consecutive rounds of the historical dialogues, where J is an integer greater than or equal to 2; Based on the similarity between any two dialogue sets in the plurality of dialogue sets, the plurality of dialogue sets are merged to obtain a plurality of target dialogue sets; For each target dialogue set, a subgraph corresponding to the target dialogue set is constructed based on the feature values ​​of multiple states corresponding to each round of the historical dialogue in the target dialogue set. The heterogeneous graph is constructed based on the subgraphs corresponding to the multiple target dialogue sets.

[0089] In this embodiment, the historical dialogue has multiple rounds. The multiple rounds of historical dialogue are divided to obtain multiple dialogue sets. Each dialogue set includes J consecutive rounds of historical dialogue, where J is an integer greater than or equal to 2. For example, J can be equal to 3. Each dialogue set can include 3 consecutive rounds of historical dialogue.

[0090] Based on the similarity between any two dialogue sets in the multiple dialogue sets, the multiple dialogue sets are merged. Specifically, the similarity between any two dialogue sets in the multiple dialogue sets is calculated to obtain a similarity value between each pair of dialogue sets. This similarity value is compared with a preset first similarity value. If a certain similarity value is greater than the preset first similarity value, then the two dialogue sets corresponding to that similarity value are similar, and the two dialogue sets can be merged. If the similarity between any two dialogue sets in the four dialogue sets is greater than the preset first similarity value, these two dialogue sets are merged to obtain multiple target dialogue sets, i.e., three target dialogue sets are obtained, one of which is the merged set, and the other two are directly used as target dialogue sets.

[0091] For each target dialogue set, a subgraph corresponding to the target dialogue set is constructed based on the feature values ​​of multiple states corresponding to each round of historical dialogue in the target dialogue set. The nodes of the subgraph are composed of multiple states corresponding to each round of historical dialogue in the target dialogue set, and the feature values ​​of each state constitute the descriptive information of the nodes of the subgraph. Based on the subgraphs corresponding to multiple target dialogue sets, a heterogeneous graph corresponding to the dialogue information is constructed.

[0092] By dividing the historical dialogues into multiple rounds, multiple dialogue sets are obtained, and each dialogue set constructs its own subgraph, which effectively improves processing efficiency.

[0093] In one embodiment of this application, constructing a subgraph corresponding to the target dialogue set based on the feature values ​​of multiple states corresponding to each round of the historical dialogue in the target dialogue set includes: Each state corresponding to each round of the historical dialogue in the target dialogue set is treated as a node; The preset strategy is used to connect multiple nodes to obtain a subgraph corresponding to the target dialogue set.

[0094] In this embodiment, the multiple states corresponding to each round of historical dialogue in the target dialogue set are respectively regarded as nodes. The multiple states include semantic state, strategy state, sentiment state and user feature state. The semantic state is regarded as semantic state node, the strategy state as strategy state node, the sentiment state as sentiment state node, and the user feature state as user feature state node.

[0095] Multiple nodes are connected using a preset strategy to obtain a subgraph corresponding to the target dialogue set, such as using Intra-Edge, Cross-Edge, or Temporal-Edge.

[0096] By connecting multiple nodes using a preset strategy, scattered nodes can be integrated.

[0097] In one embodiment of this application, the preset strategy includes at least one of the following: Nodes in the same state are connected by internal edges; Nodes in different states are connected by cross-modal edges; Nodes at adjacent times are connected by temporal edges.

[0098] In this embodiment, nodes in the same state among multiple nodes are connected using internal edges. For example, node a and node b, corresponding to the same semantic state, are nodes in the same state, i.e., nodes of the same type, and internal edges are used to maintain state continuity. Nodes in different states among multiple nodes are connected using cross-modal edges; nodes corresponding to the same semantic state and nodes corresponding to the same emotional state belong to different states. Nodes at adjacent moments among multiple nodes are connected using temporal edges, which are used to connect nodes at adjacent moments to capture evolutionary patterns. By connecting in the above manner, a subgraph corresponding to the target dialogue set is obtained. These three types of edges can connect nodes of different dimensions, enabling the integration of scattered nodes.

[0099] Heterogeneous graphs contain multiple nodes and edges. Nodes serve as information carriers, containing data from multiple dimensions, while edges act as links between nodes. This structure allows for inference of intent from multiple dimensions, such as "who the user is," "what they said," "where they said it," and "what they did," to obtain more accurate response statements.

[0100] In one embodiment of this application, the step of connecting multiple nodes using the preset strategy to obtain a subgraph corresponding to the target dialogue set includes: The importance of each of the internal edges, the cross-modal edges, and the temporal edges is evaluated to obtain an importance score for each edge; Based on the importance score of each edge, edges to be pruned are determined from a plurality of edges, wherein the edges to be pruned are those whose importance scores are less than or equal to a preset score. The information of the edge to be pruned is retained on the target edge, and the importance score of the target edge is greater than the preset score; The edges to be pruned are deleted to obtain the subgraph corresponding to the target dialogue set.

[0101] In this embodiment, in order to improve processing efficiency, some relatively unimportant edges are deleted, while relatively important edges are retained. The importance of each edge is evaluated, including internal edges, cross-modal edges, and temporal edges, to obtain an importance score for each edge.

[0102] Optionally, an importance assessment is performed on each edge to obtain an importance score for each edge, including: The importance of each edge is evaluated using KL divergence (KL divergence), resulting in an importance score for each edge, as shown below: (12); in, The local transition probability distribution is obtained by normalizing the attention weights using GAT. This represents the global state distribution.

[0103] Furthermore, based on the importance score of each edge, the edges to be pruned are determined from multiple edges. The edges to be pruned are those with an importance score less than or equal to a preset score. For example, the importance scores of the edges are sorted from largest to smallest, and the top 30% of the boundary values ​​are taken as the preset scores. Edges with a score greater than the preset score are retained. That is, the edges with the "top 30% of importance scores" are retained from the sorting results.

[0104] Alternatively, collect the importance scores of all edges and form a set. Then, the 70th percentile of the set is calculated, i.e., a threshold, or preset score, is found such that 70% of the edges have importance scores less than or equal to this preset score, and the remaining 30% of edges (with importance scores greater than this preset score) are retained. Specifically, this is expressed as follows: (13); in, Let represent the set of edges after pruning. Assigning importance scores to edges The 70th percentile.

[0105] The number of branches after pruning is reduced to 30% of the original, effectively reducing computational complexity.

[0106] Furthermore, the information of the edges to be pruned is retained on the target edges. If the importance score of the target edge is greater than the preset score, the edge to be pruned is deleted, resulting in a subgraph corresponding to the target dialogue set. By evaluating the importance of the edges, relatively unimportant edges are deleted, while relatively important edges are retained. The purpose of pruning is to remove unimportant edges, making the heterogeneous graph smaller and computation faster.

[0107] The purpose of retaining the information of the edge to be pruned on the target edge is to perform pruning compensation. The information of the deleted edge is compressed into the target edge, i.e., the retained edge, through knowledge distillation. The edge information includes the identifiers of the two nodes connected by the edge, i.e., which two nodes are connected, such as the semantic state node and the policy state node connected by the edge.

[0108] Pruning compensation is achieved by adjusting the weights of the retained edges, as detailed below: (14); in, To retain the new weight of edge k after knowledge distillation, To preserve the original weight of edge k before pruning, The distillation intensity coefficient, =0.1, Let be the set of edges that were cut off. Let be the weight coefficient of the pruned edge e, and We be the original weight of the pruned edge e before pruning.

[0109] By using a weighted average distillation of the information of the retained edges and the information of the pruned edges, we achieve knowledge compensation after pruning, allowing the retained edges to inherit the information of the pruned edges, thereby reducing computational complexity and minimizing information loss.

[0110] Step 103: Construct the user's profile information based on the dialogue information.

[0111] In this embodiment, user profile information is constructed based on dialogue information. A user profile is a labeled user model abstracted from the user's basic information, behavioral characteristics, and other information. It can more accurately understand the target user, thereby optimizing marketing strategies, product design, etc.

[0112] In one embodiment of this application, constructing the user's profile information based on the dialogue information includes: Based on the historical query statements and the current query statements, a first feature set is obtained. The first feature set includes explicit features and implicit features. The explicit features are extracted from the historical query statements and the current query statements, and the implicit features are obtained by reasoning from the historical query statements and the current query statements. Based on the first feature set, construct the user's profile information.

[0113] Explicit features are obtained by extracting historical and current query statements. Implicit features are obtained by reasoning from historical and current query statements. The explicit and implicit features constitute the first feature set.

[0114] Explicit features are clear information directly expressed by the user. They refer to attributes or needs that the user actively and directly states in the dialogue. They can be obtained through simple methods such as text matching and keyword extraction, and are features that are visible to the naked eye. Explicit features can be triples, including entities, relations, and entities. A triple can be: I, occupation, teacher. A triple can be considered as an explicit feature, and can be basic user information such as age and occupation.

[0115] Implicit features are latent information that needs to be inferred and mined. They refer to potential attributes or needs that users do not express directly but can be inferred from information such as dialogue context, behavioral patterns, and historical interactions. They need to be mined by combining semantic understanding and multi-turn interaction analysis.

[0116] Both implicit and explicit features are obtained directly or indirectly from the user's query. Based on the first feature set, a user profile is constructed. A more accurate and comprehensive user profile can be obtained based on the feature set, and the user profile can more precisely depict the user's characteristics.

[0117] In one embodiment of this application, the explicit feature is obtained as follows: Input the historical query statement and the current query statement into the fourth language model to obtain multiple entities output by the fourth language model; Multiple entities are input into a relation classification model to obtain multiple sets of first information output by the relation classification model. Each set of first information includes a first entity, a second entity, and the relationship between the first entity and the second entity. Each group of the first information is treated as an explicit feature.

[0118] In this embodiment, historical query statements and the current query statement are input into the fourth major model to obtain multiple entities output by the fourth major model. For example, if one of the query statements is "I teach at a school", inputting the query statement into the fourth major language model will result in the output entities: {"I" (PER), "school" (ORG), "mathematics" (SUBJECT)}. The fourth major language model can be the BERT-NE model, which is a named entity recognition (NER) system based on the pre-trained BERT (Bidirectional Encoder Representations from Transformers) model using the Transformer architecture.

[0119] The fourth language model can be pre-trained, such as by training multiple first training samples. Each first training sample includes the user's sample query statement and the entity corresponding to the user's sample query statement.

[0120] Multiple entities are input into a relation classification model, resulting in multiple sets of first information output by the model. Each set of first information includes: a first entity, a second entity, and the relationship between the first and second entities. For example, if the aforementioned entities {"I" (PER), "School" (ORG), "Mathematics" (SUBJECT)} are input into the relation classification model, multiple sets of first information are obtained. One set of first information is (I, Occupation, Teacher), where "I" is the first entity, "Teacher" is the second entity, and "Occupation" is the relationship. Another set of first information is (I, Professor, Mathematics).

[0121] The first feature set includes an explicit feature set, where each set of first information is treated as an explicit feature and added to the explicit feature set.

[0122] The above explicit feature set is represented as: (15); in, Let 'e' represent the set of explicit features, 'r' represent the entity, and 'e' represent the relation. This represents a predefined set of entities, such as names, locations, and professions. A predefined set of relations, such as "occupation is", "resides in", "interests are", etc. : Determine the entity and The semantic relationships between entities are determined using the aforementioned relationship classification model.

[0123] The relationship classification model is trained using multiple second training samples, each of which includes multiple entities and the relationships between entities.

[0124] Explicit features are extracted from users' historical and current query statements. Explicit features are information that users have clearly conveyed. Based on these features, subjective assumptions in responses can be reduced, and the content can be made to meet the needs that users have clearly expressed.

[0125] In one embodiment of this application, the implicit feature is obtained as follows: Retrieve multiple keywords, each keyword corresponding to an event; Based on multiple keywords, the dialogue information is subjected to event extraction to obtain at least one event, and each event is used to characterize a user's behavior; By inputting at least one of the events and a pre-configured relationship type into the fifth language model, the implicit features are obtained.

[0126] In this embodiment, multiple keywords are obtained, each corresponding to an event. Based on pre-set keywords, events are extracted from the dialogue information to obtain at least one event. For example, events are extracted from the current query and historical query statements. Each event represents a user behavior. For instance, multiple keywords include work pressure, workplace pressure, work stress, workload, and work anxiety. The event corresponding to these keywords is "high work pressure." Multiple keywords are matched with query statements. One query statement is "I feel too much work burden, I'm tired every day" → matching "work burden," and the extracted event is "high work pressure." Another query statement is "I've been under a lot of work pressure lately" → matching "work pressure," and the extracted event is "high work pressure." Similarly, multiple keywords include "recommend movies," "movie recommendations," and "good movies," corresponding to the event of "movie recommendation request." One query statement is "I want to relax, please recommend movies" → matching "movie recommendations," and the extracted event is "movie recommendation request." Keywords are set according to different events, not limited to the above keywords, but according to requirements.

[0127] The pre-configured relation types can be those defined in the ATOMIC (Atlas of Machine Commonsense) knowledge graph. ATOMIC is an open-source knowledge graph focused on event-level commonsense reasoning. Its core is to store common sense such as cause and effect, psychology, and behavior in daily human scenarios through structured "if-then" relations, such as xReact (personal emotional reaction), xWant (personal necessity need), xWant (personal initiative intention), xIntent (initiative motivation), and xDesire (long-term tendency). Among them, xReact represents personal emotional reaction, defined as: the emotional or psychological reaction of the subject (user X) after an event occurs. Event a: User X is praised in public by the boss → xReact: User X feels happy and proud; Event b: User X misses an important meeting → xReact: User X feels anxious and guilty.

[0128] For each event and each relation type, the event and relation type are input into the fifth language model to obtain implicit features.

[0129] By reasoning to obtain implicit features, we can capture the user's unspoken potential intentions and make the response more in line with the real needs.

[0130] In one embodiment of this application, the step of inputting at least one of the events and a pre-configured relationship type into a fifth language model to obtain the implicit features includes: The relationship between at least one of the events and the pre-configured relationship type is input into the fifth language model for inference, resulting in multiple candidate implicit features and the confidence level corresponding to each candidate implicit feature; The candidate implicit features are sorted in descending order of confidence level. The K candidate implicit features whose confidence scores rank at the top of the ranking are selected as the implicit features.

[0131] In this embodiment, at least one event and a pre-configured relationship are input into the fifth language model. The fifth model performs inference to obtain multiple candidate implicit features and the confidence level corresponding to each candidate implicit feature. For example, the event "high work pressure" and the relationship type xReact are input into the fifth language model to obtain multiple candidate implicit features output by the fifth language model and the confidence level corresponding to each candidate implicit feature. One of the candidate implicit features is "feeling anxious and needing rest".

[0132] The fifth language model mentioned above can be the COMTE model, or Commonsense Transformer model, used for reasoning. The COMTE model is based on the ATOMIC knowledge graph and its candidate implicit features are represented as follows: (16); Among them, P imp This represents a candidate implicit feature. This represents the user's historical query statement or current query statement in the i-th round. Events are extracted from the dialogue information, i.e., the query statement, to obtain at least one event. The event and relation type are used as input to the model. This indicates one of the preset relation types.

[0133] The fifth language model is trained using multiple third training samples. Each third training sample includes sample events and sample relationship types, as well as candidate implicit features corresponding to the sample events and sample relationship types, and the confidence level corresponding to the candidate implicit features.

[0134] Multiple candidate implicit features are sorted in descending order of confidence. The top K candidate implicit features with the highest confidence levels are selected as the implicit features. For example, if K is 3, the top 3 candidate implicit features with the highest confidence levels are selected as the implicit features. The first feature set includes the implicit feature set, which in turn includes the top K candidate implicit features with the highest confidence levels.

[0135] Implicit features derived from users' historical and current query statements can supplement their deeper needs, overcome the limitations of explicit expressions, and reveal unspoken potential demands and preferences, making the user profile more aligned with their actual needs. By constructing a set of implicit features to supplement dimensions missing from explicit features, and combining this with dialogue context and logic, it is possible to refine user personality traits, behavioral patterns, and other characteristics that cannot be directly obtained from conversations, making the user profile more relevant.

[0136] In one embodiment of this application, constructing the user's profile information based on the first feature set includes: The first feature set is filtered to obtain a target feature set, wherein the features in the target feature set are not repeated. The profile information is constructed based on the target feature set.

[0137] In this embodiment, the first feature set includes explicit features in the explicit feature set and implicit features in the implicit feature set. The first feature set is filtered to obtain the target feature set. Each feature in the target feature set is unique, and duplicate and redundant features are deleted. Furthermore, a user profile is constructed based on the target feature set.

[0138] By filtering to obtain unique features, and removing duplicates of implicit and explicit features, information redundancy is avoided, ensuring that each feature has unique value. This avoids information waste and enables the user profile information to accurately define the user.

[0139] In one embodiment of this application, the step of filtering the first feature set to obtain the target feature set includes: Calculate the similarity between any two features in the first feature set to obtain a similarity value; The features in the first feature set are filtered based on the similarity value to obtain the target feature set.

[0140] In this embodiment, similarity is calculated for any two features in the first feature set to obtain a similarity value. For example, the similarity calculation can be cosine similarity. Each feature in the first feature set is encoded to obtain a feature vector for each feature. The similarity between any two features is calculated, which is actually the similarity between the feature vectors of any two features, as shown below: (17); in, This represents the similarity value between any two features. A feature vector representing one of any two features. It represents the feature vector of any two features.

[0141] It should be noted that similarity calculation is not limited to cosine similarity; other calculation methods can also be used.

[0142] The feature vectors are obtained from the sixth major language model, which can be the BERT model. BERT (Bidirectional Encoder Representations from Transformers) is an open-source model, which can be directly translated into Chinese as "Bidirectional Encoder Representations Based on Transformers". Specifically: (18); Where p represents the input text. (p) represents the feature vector obtained after feature vectorization of the input text p. The BERT model is good at capturing the contextual semantic information of the text. Cls(p) represents the vector corresponding to the [CLS] label output by the BERT model. R 768 This means that the feature vector is a 768-dimensional real vector. In other words, after this operation, the text p is converted into a 768-dimensional numerical vector, which contains the semantic information of the text p.

[0143] A model is the process of converting text content into numerical vectors that can be processed by a computer. The purpose is to map text information into a semantic space to facilitate subsequent similarity calculations.

[0144] The features in the first feature set are filtered based on multiple similarity values ​​to obtain the target feature set. Each feature in the target feature set is unique. By filtering, duplicate features are deleted, and only one duplicate feature is retained.

[0145] By calculating similarity and removing duplicate features, each feature has unique value, which avoids information waste and enables the user profile information to accurately define the user.

[0146] In one embodiment of this application, the dialogue information further includes a timestamp for each round of dialogue; The step of filtering features in the first feature set based on the similarity value to obtain a target feature set includes: If the similarity value is greater than a preset similarity threshold, then the timestamps corresponding to the two features corresponding to the similarity value are obtained. Determine the latest timestamp from the timestamps corresponding to each of the two features; Add the feature corresponding to the latest timestamp to the target feature set.

[0147] In this embodiment, the dialogue information also includes a timestamp for each round of dialogue. Each round includes historical dialogue and the current round of dialogue. A preset similarity value is obtained and compared with each of the multiple similarity values. For each similarity value, if the similarity value is greater than the preset similarity value, it indicates that there may be overlap between the two features corresponding to the similarity value, as shown below: like If so, then it is determined that the two features are duplicates; in, This represents the preset similarity value. The value can be 0.7. If the similarity value is greater than 0.7, it is determined that there may be overlap between the two features corresponding to the similarity value.

[0148] like If so, then it is determined that the two features are not repeated; If the similarity value is less than or equal to the preset similarity value, it means that the two features corresponding to the similarity values ​​are not duplicated.

[0149] There may be overlap between two features that are determined to have similarity values. Obtain the timestamps corresponding to the two features corresponding to the similarity values, determine the latest timestamp from the timestamps corresponding to the two features, retain the feature corresponding to the latest timestamp, add the feature corresponding to the latest timestamp to the target feature set, and delete the feature corresponding to the earlier timestamp.

[0150] For example, if "likes socializing" is detected... "Enthusiastic about social activities" similarity value 2, If 2 is greater than 0.7, the latest feature will be retained based on the timestamp. That is, the latest timestamp will be determined from the timestamps corresponding to the two features respectively, and the feature corresponding to the latest timestamp will be added to the target feature set. For example, if being enthusiastic about social activities is a recently mentioned feature, the feature will be retained.

[0151] In cases of feature duplication, the latest features are retained to ensure that the profile always keeps up with the user's latest status and reduces the interference of historical features on the profile information.

[0152] In one embodiment of this application, constructing the portrait information based on the target feature set includes: Obtain multiple initial features from the user's historical profile information; For each feature in the target feature set, obtain initial features that are semantically related to the feature from among multiple initial features; use the semantically related initial features as target initial features; determine the weight of the feature based on the timestamp of the feature, the weight of the target initial feature, and the timestamp of the target initial feature. The historical portrait information is updated based on each feature and its weight to obtain the portrait information.

[0153] In this embodiment, multiple initial features of historical profile information are obtained. For each feature in the target feature set, initial features that are semantically related to the feature are obtained from the multiple initial features. These semantically related initial features are used as target initial features. For each feature in the target feature set, the weight of the feature is determined based on the feature's timestamp, the weight of the target initial feature, and the timestamp of the target initial feature. The weights are as follows: (19); in, This represents the weight of the feature at time t. This indicates the initial features of the target at the initial time t. o The weights are: e is the exponent, λ is the decay coefficient, t-t0 is the time difference, and t is the difference between the timestamp of the feature and the timestamp of the initial feature of the target.

[0154] Based on each feature and its weight, historical user profile information is updated to obtain dynamically updated user profiles. New features are incorporated into the profile with time-decay weights to ensure the timeliness of the profile.

[0155] Step 104: Determine the target response strategy based on the dialogue information.

[0156] In this embodiment, a response strategy is preset, and the response strategy includes... Information support, emotional reflection, questioning, and self-disclosure are all employed. Based on the dialogue information, a target response strategy is determined from pre-configured response strategies so that the style can be adjusted according to the user's intent (such as consultation, complaint, or request).

[0157] In one embodiment of this application, determining the target response strategy based on the dialogue information includes: Based on the historical query statements and the current query statements, multiple user characteristics of the user are obtained; For each user characteristic, a candidate response strategy corresponding to the user characteristic is determined from a plurality of pre-configured response strategies; The target response strategy is determined based on the candidate response strategies corresponding to multiple user characteristics.

[0158] Based on historical query statements and the current query user, multiple user characteristics are obtained. Optionally, these user characteristics can be implicit features and / or implicit features. Explicit features are extracted from historical query statements and the current query statement, and implicit features are obtained through inference from historical query statements and the current query statement.

[0159] User characteristics are derived from the user's historical and current query statements. These user characteristics are the information explicitly conveyed by the user. Using these characteristics as a basis can reduce subjective assumptions in responses and ensure that the content matches the user's explicitly expressed needs.

[0160] In this embodiment, a response strategy is preset, and the response strategy includes... Information support, emotional response, questioning, and self-disclosure are all considered. For each user characteristic, candidate response strategies are determined from multiple pre-configured response strategies, and the target response strategy is determined based on these candidate strategies.

[0161] In this embodiment, different response strategies have different requirements for the degree of personalization. Therefore, the target response strategy needs to be determined from the candidate response strategies corresponding to multiple user characteristics.

[0162] In one embodiment of this application, determining the target response strategy based on the candidate response strategies corresponding to multiple user features includes: The weights of the candidate response strategies are determined from a pre-configured correspondence, which includes multiple response strategies and the weight of each response strategy, and each response strategy is configured with multiple associated terms. For each user feature, select related words that match the user feature from multiple related words configured in the candidate response strategy, and use them as candidate words for the candidate response strategy corresponding to the user feature; Based on the weight of each candidate response strategy and the candidate words of each candidate response strategy, calculate the attention score of the candidate words of each candidate response strategy; The target response strategy is determined based on the attention score of the candidate words for each candidate response strategy.

[0163] In this embodiment, the weights of candidate response strategies are determined from a pre-configured correspondence. The correspondence includes multiple response strategies and the weight of each response strategy. Each response strategy is configured with multiple related words, and different response strategies affect the style of the final response statement.

[0164] Optionally, response strategies include providing advice, informational support, emotional response, questioning, and self-disclosure, with pre-configured correspondences as shown below: ; in, Corresponding weights =0.75, the information supports the corresponding weight. =0.75, the weight corresponding to emotional reflex. =0.6, the weight corresponding to the question. =0.3, the weight corresponding to self-disclosure =0.3, and may also include other response strategies, not limited to the above response strategies.

[0165] Weight The larger the weight value, the more it depends on the user's basic information, i.e., user characteristics, during generation.

[0166] Providing advice and informational support is crucial in many communication scenarios, such as consulting services and knowledge sharing. Offering practical advice and information directly helps the other party solve problems and obtain information, hence its high weight. Emotional reflexes, by responding to emotions, build empathy and soothe the other party, are important for maintaining relationships and ensuring smooth communication. However, compared to directly solving problems, it provides more support at the atmosphere and relationship level, making its role slightly less significant, and thus its weight is lower. Asking questions and self-disclosure are used to uncover information and build rapport. However, compared to the previous two, they are more of a communication aid, such as asking questions to explore needs and self-disclosure to build trust. They are weaker in promoting problem-solving and emotional support, hence their relatively lower weight.

[0167] The system allows for the setting of weights for response strategies and the allocation of weights to related words. By flexibly adjusting these weights to adapt to different scenarios, personalized responses can be achieved.

[0168] For each user feature, related words that match the user feature are selected from multiple related words configured in the candidate response strategy. For example, the similarity between the user feature and each related word configured in the candidate response strategy is calculated, and related words that match the user feature are selected based on the similarity as candidate words for the candidate response strategy corresponding to the user feature.

[0169] Based on the weight of each candidate response strategy and the candidate words of each candidate response strategy, the attention score is calculated. Specifically, the attention score of the candidate words of each candidate response strategy is calculated using formula (1), as shown below: (20); in, This represents the attention score, and Q represents the query vector. V represents the key vector, and V represents the value vector. , For sequence length, As a dimension, , The association mask matrix represents the association of related words. Indicates the first weight. It is a normalization function that converts a set of arbitrary real numbers into probability values ​​between 0 and 1.

[0170] The association mask matrix of related words is obtained in the following way: (twenty one); in, This represents the key vector, corresponding to the content at the j-th position; Vectors representing user features The value represents the cosine similarity, and the threshold of 0.6 in the formula was determined experimentally.

[0171] when Attention score increases This increases the probability of generating relevant words. For example, if a user's characteristics include "occupation = teacher", then words like "lesson preparation" and "student" will be generated more frequently. Set to 1.

[0172] Furthermore, the target response strategy is determined based on the attention scores of candidate words from multiple candidate response strategies.

[0173] By quantifying the weight of words and filtering out high-scoring terms, core information can be accurately captured and redundancy filtered out, improving information processing efficiency and accuracy.

[0174] In one embodiment of this application, the step of filtering related words that match the user feature from a plurality of related words configured in the candidate response strategy for each user feature includes: For each user feature, the similarity between the user feature and each associated word configured in the candidate response strategy is calculated to obtain a first similarity value; Associated words whose first similarity value is greater than a preset similarity threshold are identified as associated words that match the user features.

[0175] In this embodiment, for each user feature, the similarity between the user feature and each associated word configured in the candidate response strategy is calculated to obtain the first similarity value between the user feature and each associated word. Associated words with a first similarity value greater than a preset similarity threshold are determined as associated words that match the user feature.

[0176] By matching relevant words with user characteristics, the response service can be more accurate and tailored to user needs.

[0177] In one embodiment of this application, determining the target response strategy based on the attention score of each candidate word in the candidate response strategy includes: Based on the attention score of the candidate words of each candidate response strategy, the target words of each candidate response strategy are determined; For each candidate response strategy, a candidate statement is generated based on the target words of the candidate response strategy. The semantic similarity between the candidate statement and the first statement is calculated to obtain a second similarity value. The score of the candidate response strategy is determined based on the second similarity value. For each candidate response strategy's score, the weight of the candidate response strategy is adjusted to obtain the first weight of the candidate response strategy; The candidate response strategy whose first weight is greater than the preset weight is determined as the target response strategy.

[0178] In this embodiment, the target words for each candidate response strategy are determined based on the attention scores of the candidate words. For each candidate response strategy, a candidate sentence is generated based on the target words. Further, a first sentence is obtained, which is a manually generated statement related to the candidate words. The semantic similarity between the candidate sentence and the first sentence is calculated to obtain a second similarity value. The score of the candidate response strategy is determined based on the second similarity value, calculated using the following formula: (twenty two); Among them, U k The score represents the candidate's response strategy. This represents the second similarity value, indicating the candidate sentences. And the first sentence Semantic similarity between them, KL Indicate candidate response strategy The KL divergence between the generating distribution and the baseline distribution. The preset penalty factor can be set to 0.5.

[0179] For each candidate response strategy's score, its weight is adjusted to obtain a first weight. For example, the conditional gradient method (Frank-Wolfe) can be used to adjust the weights. The optimization objective is to maximize the total utility score. When the total utility score is maximized, the weight of the candidate response strategy is the aforementioned first weight. The total utility score is determined based on multiple candidate response strategies and the weight of each strategy. Specifically: (twenty three); Where n represents the total number of candidate response strategies, U k represents the score of the candidate response strategy, and wk represents the weight of the candidate response strategy.

[0180] (twenty four); Formula (24) is a constraint condition. The constraint condition ∑wk=1 and wk≥0 ensures that the weights are normalized non-negative coefficients (i.e., the sum of the weights is 1, and the weights of each strategy are non-negative).

[0181] Candidate response strategies with a first weight greater than a preset weight are identified as target response strategies. There can be one or more target response strategies.

[0182] The attention score allows for word filtering to obtain target words. Each candidate response strategy is then scored based on its target words, and the weights are dynamically adjusted based on the scores. Finally, the appropriate target response strategy is selected based on these weights.

[0183] Step 105: Determine the response statement corresponding to the query statement in this round based on the heterogeneous graph, the profile information, and the target response strategy.

[0184] In this embodiment, the response statement corresponding to the query statement in this round is determined based on the heterogeneous graph, profile information and target response strategy. The heterogeneous graph and profile information containing user characteristics generate a natural language response that is coherent, emotionally supportive and personalized. Furthermore, the combination with the target response strategy can improve the degree of personalization.

[0185] In this embodiment, dialogue information is acquired, including historical dialogues and the user's current query statement. Based on the dialogue information, a heterogeneous graph is constructed. This graph is built from multiple states and the feature values ​​of each state. Each node in the heterogeneous graph represents one of the multiple states, and the edges are connected using a preset strategy. The multiple states and the feature values ​​of each state are obtained from fusion information, which is obtained from encoding information, specifically by encoding the dialogue information. Based on the dialogue information, user profile information is constructed. A target response strategy is determined based on the dialogue information. Based on the heterogeneous graph, user profile information, and target response strategy, the response statement corresponding to the current query statement is determined. In these steps, a heterogeneous graph and user information are constructed based on the dialogue information. Based on the feature values ​​of the heterogeneous graph and the features of the user profile information, a natural language response that is coherent, emotionally supportive, and personalized is generated. Combining this with the target response strategy improves the degree of personalization, resulting in a more accurate response statement.

[0186] In one embodiment of this application, the historical dialogue includes the user's historical query statements; determining the response statement corresponding to the current query statement based on the heterogeneous graph, the profile information, and the target response strategy includes: Based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information, a vocabulary information is obtained. The vocabulary information includes multiple words and a first probability value corresponding to each word. The profile information includes explicit features and implicit features. The explicit features are extracted from the historical query statements and the current query statements, and the implicit features are obtained by reasoning from the historical query statements and the current query statements. Based on the vocabulary information and the target response strategy, determine the response statement corresponding to the query statement in this round.

[0187] In this embodiment, the user profile information includes explicit features and implicit features. Explicit features are extracted from historical query statements and the current query statement, while implicit features are inferred from historical query statements and the current query statement. Based on the feature values ​​of multiple states in the heterogeneous graph and the profile information, vocabulary information is obtained. The vocabulary information includes multiple words and a first probability value corresponding to each word, i.e., a vocabulary probability distribution. The response statement corresponding to the current query statement is obtained based on the vocabulary information and the target response strategy.

[0188] The vocabulary limits the range of words that can be used to generate responses, ensuring that the words used in the generated statements are within the expected reasonable range. Based on a clear vocabulary and strategy, the generated responses are more organized and the efficiency of response generation is effectively improved.

[0189] In one embodiment of this application, determining the response statement corresponding to the current round of query statements based on the vocabulary information and the target response strategy includes: The words in the vocabulary information are filtered to obtain multiple candidate words; Based on the multiple candidate words and the target response strategy, the response statement corresponding to the query statement in this round is determined.

[0190] In this embodiment, the words in the word list information are filtered mainly by the first probability value of each word to obtain multiple candidate words. At least one target word is determined based on the multiple candidate words, and the response statement corresponding to the query statement in this round is generated according to the target response strategy based on at least one target word.

[0191] Candidate words are drawn from a pre-defined vocabulary list, ensuring the standardization of the statements; the response statements generated in conjunction with the target strategy are more tailored to the user.

[0192] In one embodiment of this application, obtaining vocabulary information based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information includes: The feature values ​​of multiple states, the explicit features, and the implicit features are fused to obtain the fused features; The fused features are mapped to obtain the vocabulary information.

[0193] In this embodiment, the feature values ​​of multiple states are fused to obtain fused features. The fused features are then mapped using the Softmax function to obtain vocabulary information. Specifically, a pre-configured vocabulary is obtained. The pre-configured vocabulary is a collection containing multiple tokens, each token corresponding to a unique ID. A token can be a complete word, a part of a word, a character, or even a special symbol.

[0194] The aforementioned fusion features are fused vectors. The fused vectors are converted into the probability distribution of each word in the pre-configured vocabulary using the Softmax function. Vocabulary information is then generated based on each word and its probability distribution.

[0195] By fusing and mapping the feature values, vocabulary information is obtained. Using this vocabulary information as a basis for filtering, more accurate candidate words can be obtained.

[0196] In one embodiment of this application, the fusion process of feature values ​​of multiple states, explicit features, and implicit features to obtain fused features includes: The feature values ​​of multiple states, the explicit features, and the implicit features are concatenated to obtain a fourth vector; A linear transformation is performed on the fourth vector to obtain the second intermediate vector; The second intermediate vector is compressed by a preset activation function to obtain the third weight corresponding to the fifth vector, which is obtained based on the feature values ​​of multiple states. Subtracting the third weight from the preset weight yields the fourth weight of the sixth vector, which is obtained based on the explicit features and the implicit features. The fused features are obtained by weighting the third weight, the fifth vector, the fourth weight, and the sixth vector.

[0197] In this embodiment, multiple states include semantic state, strategy state, sentiment state, and user feature state. The fifth vector is obtained as follows: the feature values ​​of the semantic state are converted into vectors to obtain the first feature vector; the feature values ​​of the strategy state are converted into vectors to obtain the second feature vector; the feature values ​​of the sentiment state are converted into vectors to obtain the third feature vector; the feature values ​​of the user feature state are converted into vectors to obtain the fourth feature vector; and the first, second, third, and fourth feature vectors are concatenated to obtain the fifth vector. The sixth vector is obtained as follows: convert explicit features into vectors to obtain explicit feature vectors; convert implicit features into vectors to obtain implicit feature vectors; and concatenate the explicit feature vectors and implicit feature vectors to obtain the sixth vector.

[0198] The above-described concatenation of the feature values ​​of multiple states, the explicit features, and the implicit features yields a fourth vector. Specifically, the fifth and sixth vectors are concatenated to obtain the fourth vector. Furthermore, a linear transformation is performed on the fourth vector to obtain a second intermediate vector.

[0199] Furthermore, the second intermediate vector is compressed using a preset activation function to obtain the third weight corresponding to the fifth vector. The fifth vector is obtained based on the feature values ​​of multiple states. The third weight is shown below: (25); Where g represents the third weight, The preset activation function can be... , , Represents the fifth vector. This represents the sixth vector.

[0200] Subtracting the third weight from the preset weight yields the fourth weight of the sixth vector. The preset weight can be 1. Further, a weighted calculation is performed based on the third weight, the fifth vector, the fourth weight, and the sixth vector to obtain the fused features, specifically: (26); The feature representing fusion is denoted by g, which represents the third weight. Let 1-g represent the fifth vector, and 1-g represent the fourth weight. This represents the sixth vector.

[0201] In practical applications, this applies to the early stages of a dialogue (such as the problem exploration phase). It may be relatively large (close to 1), focusing on state evolution information. In the later stages of the dialogue (such as the suggestion generation phase), 1- Increase, emphasizing personalized characteristics.

[0202] By fusing feature values, explicit features, and implicit features from multiple states, the fused features can cover a more complete range of information dimensions.

[0203] In one embodiment of this application, the step of filtering the words in the vocabulary information to obtain multiple candidate words includes: Each word in the vocabulary information is sorted from largest to smallest according to its first probability value. The X words corresponding to the first probability values ​​at the top of the sort are selected as multiple candidate words, where X is a positive integer and the sum of the X first probability values ​​is greater than or equal to a first preset threshold.

[0204] In this embodiment, each word in the vocabulary information is sorted from largest to smallest according to its first probability value. The top X first probability values ​​are determined, and the words corresponding to these top X first probability values ​​are selected as multiple candidate words, resulting in X candidate words, where X is a positive integer. The sum of the X first probability values ​​is greater than or equal to a first preset threshold, expressed by the formula: (27); Among them, V (p) V represents candidate words, and V represents the vocabulary, i.e., the pre-configured vocabulary mentioned above. Indicator y i The probability of occurrence is obtained using the Softmax function. This represents the first preset threshold, which can be set to 0.9, and X is the number of X candidate words.

[0205] Sort the words in the vocabulary information V according to their probability, i.e., the first probability value, from high to low. y1 is the word with the highest probability value, y2 is next, and so on. Accumulate their probability values ​​in turn until the cumulative probability value is ≥p. These selected words form a new candidate vocabulary V(p), which is to obtain X candidate words.

[0206] The above screening method preserves diversity while reducing the risk of generating irrelevant responses. It retains high-probability words as candidate words and filters out low-probability noise words.

[0207] In one embodiment of this application, determining the response statement corresponding to the current round of query statements based on the plurality of candidate words and the target response strategy includes: If the sum of the first probability values ​​of multiple candidate words is greater than or equal to a first preset threshold and less than a second preset threshold, the first probability values ​​of multiple candidate words are adjusted to obtain a second probability value for each candidate word, and the sum of the second probability values ​​of multiple candidate words is equal to the second preset threshold. At least one target word is obtained based on the second probability value and preset coefficient of each candidate word; According to the target response strategy, the response statement corresponding to the current round of query statement is generated based on at least one of the target words.

[0208] In this embodiment, when the sum of the first probability values ​​of multiple candidate words is greater than or equal to a first preset threshold and less than a second preset threshold, wherein the first preset threshold can be set to 0.9 and the second preset threshold can be set to 1, the first probability values ​​of the multiple candidate words are adjusted to obtain the second probability value of each candidate word, such that the sum of the second probability values ​​of the multiple candidate words equals the second preset threshold, that is, the sum of the second probability values ​​of the multiple candidate words equals 1, expressed as: (28); V(p) represents the normalized probability of X candidate words. The original probabilities of the words in the candidate word list V(p) will be renormalized, and the sum of the probability values ​​of all candidate words will equal 1.

[0209] Normalization ensures that the probability distribution of candidate words remains reasonable, guaranteeing the randomness of sampling. Otherwise, the sum of probabilities may not equal 1, making normal sampling impossible.

[0210] At least one target word is obtained based on the second probability value of each candidate word and a preset coefficient, where the preset coefficient is a temperature coefficient. The temperature coefficient is used to perform temperature scaling on the second probability of the candidate word. Based on the scaled probability value, at least one target word is determined from X candidate words. The response statement corresponding to the query statement in this round is generated according to the target response strategy based on at least one target word.

[0211] Using probability to ensure basic rationality and using temperature coefficient to regulate diversity avoids the chaos of completely random generation and solves the problem of relying solely on high-probability words. Ultimately, it allows the generated response utterances to find a balance between accuracy and diversity, making it suitable for dialogue scenarios that require flexible responses.

[0212] In one embodiment of this application, obtaining at least one target word based on the second probability value and a preset coefficient of each candidate word includes: The second probability value of each candidate word is adjusted according to a preset coefficient to obtain the third probability value of each candidate word; A probability interval is constructed for each candidate word based on the third probability value of each candidate word, thus obtaining the probability interval for each candidate word; The probability interval of each candidate word is filtered using random numbers to obtain the target probability interval; The candidate words corresponding to the target probability interval are taken as at least one target word.

[0213] In this embodiment, the preset coefficient is a temperature coefficient. The second probability value of each candidate word is adjusted according to the preset coefficient, that is, the second probability of the candidate word is temperature-scaled according to the temperature coefficient. Specifically: (29); in, This represents the probability of word x after temperature scaling, also known as the third probability value. Indicates the temperature coefficient. The feature representing fusion, the parameter vector of word x, changes the smoothness of the probability distribution by dividing by a temperature coefficient.

[0214] When the temperature coefficient τ > 1 (e.g., τ = 2), the exponents of both the numerator and denominator are reduced, weakening the advantage of originally high-probability words and relatively increasing the probability of low-probability words. This scaling process smooths the probability distribution, making it easier to select low-probability candidate words to generate discourse, thus increasing the diversity and randomness of the response discourse.

[0215] When the temperature coefficient τ < 1 (e.g., τ = 0.5), the exponents of the numerator and denominator are amplified, increasing the advantage of words with high probability and making the probability of low-probability words approach 0. This scaling process sharpens the probability distribution, making it easier to select high-probability candidate words to generate discourse, resulting in more stable response discourse.

[0216] When the temperature coefficient τ=0.7, the smoothness of the distribution can be controlled by selecting 0.7 for temperature scaling, which makes the response speech perform better in terms of determinism and coherence.

[0217] Construct a probability interval for each candidate word based on its third probability value. For example, for candidate words {good, great, excellent}, the third probabilities of the candidate words after temperature scaling are: P(good) = 0.6, P(great) = 0.3, P(excellent) = 0.1. Accumulate the probabilities into a continuous interval, with each candidate word corresponding to one interval. For example, the probability of "good" is 0.6, accumulating from 0, the probability interval is [0, 0.6]. The probability of the previous candidate word is accumulated to 0.6, and the probability of "great" is 0.3, so it can be set to 0.9, the probability interval is (0.6, 0.9]. The probability of the first two candidate words is accumulated to 0.9, and the probability of "excellent" is 0.1, so it can be set to 1, the probability interval is (0.9, 1).

[0218] Furthermore, a random number is generated using a random function, which is between 0 and 1. For example, if the generated random number is 0.7, the probability range of each candidate word is filtered using the random number. Specifically, the probability range of the match is determined based on the random number. It is observed which probability range the random number falls into. For example, the probability range matched by the random number 0.7 is (0.6, 0.9], and this probability range is the target probability range.

[0219] Furthermore, the candidate word corresponding to the target probability interval is taken as at least one target word.

[0220] The probability value provides a clear quantitative basis for the screening process, rather than relying on random selection or subjective judgment, making the target words obtained more accurate.

[0221] In one embodiment of this application, generating the response utterance corresponding to the current round of query statements according to at least one of the target words based on the target response strategy includes: An initial utterance is generated based on at least one of the target words according to the target response strategy; The initial statement is processed by at least one of the following methods to obtain the response statement corresponding to the current round of query statements: Replace sensitive words present in the initial discourse; Replace any contradictory words in the initial utterance; The initial utterance is then subject to emotional correction.

[0222] In this embodiment, an initial discourse is generated based on at least one target word according to the target response strategy. The initial discourse is then processed by at least one of the following methods: Specifically, the initial discourse is detected based on sensitive words in a preset sensitive word library. If a sensitive word is detected in the initial discourse, it is replaced to obtain the response statement corresponding to the query statement in this round. For example, if the initial discourse contains words such as "violence" or "suicide," the sensitive words need to be replaced. A preset mapping relationship is obtained, which includes multiple sensitive words and their corresponding replacement words. The replacement words corresponding to the sensitive words in the initial discourse are obtained from the mapping relationship, and the sensitive words in the initial discourse are replaced using the replacement words to obtain the response statement corresponding to the query statement in this round.

[0223] Optionally, contradictory words in the initial utterance are replaced. The system detects whether contradictory words exist in the initial utterance, and if so, replaces them. Specifically, this is expressed as follows: ; Here, Y represents a preset set containing multiple word pairs. Each word pair consists of two words, and the relationship between the two words in each pair is contradictory. The set Y is traversed, and all word pairs (wi, wj) are checked to see if any have contradictory relationships. For example, if a word pair contains (wi=sunny, wj=heavy rain), and Relation(sunny, heavy rain) = contradictory (weather semantic conflict), then the contradictory word needs to be replaced. The replacement is represented as follows: ; Among them, ReGen represents the seventh language model, which takes an initial utterance with contradictions as input into the model and outputs a corrected initial utterance without contradictions.

[0224] The initial statement without contradictory words will be used as the response statement corresponding to the query statement in this round.

[0225] Optionally, the initial utterance is subjected to an emotional consistency check, and if the initial utterance fails the emotional consistency check, the initial utterance is emotionally corrected.

[0226] Specifically, if the emotion of the initial discourse is not equal to the target emotion, that is... In this case, the initial utterance needs to be modified emotionally, and the target emotion can be a positive emotion.

[0227] ; Among them, Adjust can represent the eighth language model, which calls the model to make emotional corrections to the initial utterance, such as adjusting the negative initial utterance to a positive utterance, and overwriting the original initial utterance with the adjusted result to obtain the response utterance, or adjusting the neutral "things will be resolved" to the more positive "I believe you have the ability to overcome difficulties".

[0228] The above processing methods ensure that the generated content meets security requirements and is standardized and reasonable.

[0229] Figure 2 A structural diagram of the dialogue device provided in an embodiment of this application is shown. Figure 3 As shown, the dialogue device 200 includes: The acquisition module 201 is used to acquire dialogue information, which includes historical dialogues and the user's current query statement; The first construction module 202 is used to construct a heterogeneous graph based on the dialogue information. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information. The second construction module 203 is used to construct the user's profile information based on the dialogue information; The first determining module 204 is used to determine the target response strategy based on the dialogue information; The second determining module 205 is used to determine the response statement corresponding to the current round of query statements based on the heterogeneous graph, the profile information, and the target response strategy.

[0230] In one embodiment of this application, the historical dialogue includes the user's historical query statements; the second determining module 205 includes a first determining submodule and a second determining submodule; The first determining submodule is used to obtain vocabulary information based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information. The vocabulary information includes multiple words and a first probability value corresponding to each word. The profile information includes explicit features and implicit features. The explicit features are extracted from the historical query statements and the current query statements. The implicit features are obtained by reasoning from the historical query statements and the current query statements. The second determining submodule is used to determine the response statement corresponding to the query statement in this round based on the vocabulary information and the target response strategy.

[0231] In one embodiment of this application, the second determining submodule includes a first filtering subunit and a first determining subunit; The first filtering subunit is used to filter the words in the word list information to obtain multiple candidate words; The second determining subunit is used to determine the response statement corresponding to the current round of query statements based on the multiple candidate words and the target response strategy.

[0232] In one embodiment of this application, the first determining submodule includes a first fusion subunit and a second determining subunit; The first fusion subunit is used to fuse the feature values, explicit features, and implicit features of multiple states to obtain fused features; The second determining subunit is used to perform mapping processing on the fused features to obtain the vocabulary information.

[0233] In one embodiment of this application, a first fusion subunit is specifically used to concatenate the feature values ​​of multiple states, the explicit features, and the implicit features to obtain a fourth vector; perform a linear transformation on the fourth vector to obtain a second intermediate vector; compress the second intermediate vector using a preset activation function to obtain a third weight corresponding to a fifth vector, wherein the fifth vector is obtained based on the feature values ​​of multiple states; subtract the third weight from the preset weight to obtain a fourth weight for a sixth vector, wherein the sixth vector is obtained based on the explicit features and the implicit features; and perform a weighted calculation based on the third weight, the fifth vector, the fourth weight, and the sixth vector to obtain the fused features.

[0234] In one embodiment of this application, the first filtering subunit is specifically used to sort each word in the word list information from largest to smallest according to the first probability value, and select the X words corresponding to the first probability values ​​at the front of the sort as multiple candidate words, where X is a positive integer and the sum of the X first probability values ​​is greater than or equal to a first preset threshold.

[0235] In one embodiment of this application, the second determining subunit is specifically used to adjust the first probability values ​​of the multiple candidate words when the sum of the first probability values ​​of the multiple candidate words is greater than or equal to a first preset threshold and less than a second preset threshold, so as to obtain a second probability value of each candidate word, and the sum of the second probability values ​​of the multiple candidate words is equal to the second preset threshold. Based on the second probability value and preset coefficient of each candidate word, at least one target word is obtained; according to the target response strategy, the response statement corresponding to the current query statement is generated based on at least one target word.

[0236] In one embodiment of this application, the second determining subunit is specifically used to adjust the second probability value of each candidate word according to a preset coefficient to obtain a third probability value of each candidate word; A probability interval is constructed for each candidate word based on the third probability value of each candidate word, and a probability interval for each candidate word is obtained; a random number is used to filter the probability interval of each candidate word to obtain a target probability interval; and the candidate word corresponding to the target probability interval is taken as at least one target word.

[0237] In one embodiment of this application, the second determining subunit is specifically used to generate initial utterances based on at least one of the target words according to the target response strategy; The initial statement is processed by at least one of the following methods to obtain the response statement corresponding to the current round of query statements: Replace sensitive words present in the initial discourse; Replace any contradictory words in the initial utterance; The initial utterance is then subject to emotional correction.

[0238] The dialogue device provided in this application embodiment can implement the various processes implemented in the aforementioned dialogue method embodiment and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0239] Figure 3 A schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application is shown.

[0240] The electronic device may include a processor 301 and a memory 302 storing computer program instructions.

[0241] Specifically, the processor 301 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0242] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 302 may include removable or non-removable (or fixed) media. Where appropriate, memory 302 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 302 is non-volatile solid-state memory.

[0243] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the methods according to the first or second aspect of this disclosure.

[0244] The processor 301 implements any of the methods described above in the above embodiments by reading and executing computer program instructions stored in the memory 302.

[0245] In one example, the electronic device may also include a communication interface 303 and a bus 310. For example, Figure 3 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 310 and complete communication with each other.

[0246] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0247] Bus 310 includes hardware, software, or both, that couples components of a method or electronic device as described above together. For example, and not as a limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 310 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0248] Alternatively, embodiments of this application can be implemented using a computer storage medium. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the dialogue methods described in the above embodiments.

[0249] Alternatively, this application embodiment can provide a computer program product for implementation, wherein the instructions in the computer program product, when executed by the processor of an electronic device, cause the electronic device to implement any of the dialogue methods in the above embodiments.

[0250] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described as examples. However, the method process of this application is not limited to the specific steps described. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0251] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0252] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0253] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0254] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. A dialogue method, characterized in that, The method includes: Obtain dialogue information, which includes historical dialogues and the user's current query statement; Based on the dialogue information, a heterogeneous graph is constructed. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information. Based on the dialogue information, construct the user's profile information; Based on the dialogue information, determine the target response strategy; Based on the heterogeneous graph, the profile information, and the target response strategy, the response statement corresponding to the query statement in this round is determined.

2. The dialogue method according to claim 1, characterized in that, The historical dialogues include the user's historical query statements; The step of determining the response statement corresponding to the current round of query statements based on the heterogeneous graph, the profile information, and the target response strategy includes: Based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information, a vocabulary information is obtained. The vocabulary information includes multiple words and a first probability value corresponding to each word. The profile information includes explicit features and implicit features. The explicit features are extracted from the historical query statements and the current query statements, and the implicit features are obtained by reasoning from the historical query statements and the current query statements. Based on the vocabulary information and the target response strategy, determine the response statement corresponding to the query statement in this round.

3. The dialogue method according to claim 2, characterized in that, The step of determining the response statement corresponding to the current query statement based on the vocabulary information and the target response strategy includes: The words in the vocabulary information are filtered to obtain multiple candidate words; Based on the multiple candidate words and the target response strategy, the response statement corresponding to the query statement in this round is determined.

4. The dialogue method according to claim 2, characterized in that, The step of obtaining vocabulary information based on the feature values ​​of multiple states in the heterogeneous graph and the user's profile information includes: The feature values ​​of multiple states, the explicit features, and the implicit features are fused to obtain the fused features; The fused features are mapped to obtain the vocabulary information.

5. The dialogue method according to claim 4, characterized in that, The process of fusing the feature values ​​of multiple states, the explicit features, and the implicit features to obtain the fused features includes: The feature values ​​of multiple states, the explicit features, and the implicit features are concatenated to obtain a fourth vector; A linear transformation is performed on the fourth vector to obtain the second intermediate vector; The second intermediate vector is compressed by a preset activation function to obtain the third weight corresponding to the fifth vector, which is obtained based on the feature values ​​of multiple states. Subtracting the third weight from the preset weight yields the fourth weight of the sixth vector, which is obtained based on the explicit features and the implicit features. The fused features are obtained by weighting the third weight, the fifth vector, the fourth weight, and the sixth vector.

6. The dialogue method according to claim 3, characterized in that, The word list information is filtered to obtain multiple candidate words, including: Each word in the vocabulary information is sorted from largest to smallest according to its first probability value. The X words corresponding to the first probability values ​​at the top of the sort are selected as multiple candidate words, where X is a positive integer and the sum of the X first probability values ​​is greater than or equal to a first preset threshold.

7. The dialogue method according to claim 3, characterized in that, The step of determining the response statement corresponding to the current query statement based on multiple candidate words and the target response strategy includes: If the sum of the first probability values ​​of multiple candidate words is greater than or equal to a first preset threshold and less than a second preset threshold, the first probability values ​​of multiple candidate words are adjusted to obtain a second probability value for each candidate word, and the sum of the second probability values ​​of multiple candidate words is equal to the second preset threshold. At least one target word is obtained based on the second probability value and preset coefficient of each candidate word; According to the target response strategy, the response statement corresponding to the current round of query statement is generated based on at least one of the target words.

8. The dialogue method according to claim 7, characterized in that, The step of obtaining at least one target word based on the second probability value and preset coefficient of each candidate word includes: The second probability value of each candidate word is adjusted according to a preset coefficient to obtain the third probability value of each candidate word; A probability interval is constructed for each candidate word based on the third probability value of each candidate word, thus obtaining the probability interval for each candidate word; The probability interval of each candidate word is filtered using random numbers to obtain the target probability interval; The candidate words corresponding to the target probability interval are taken as at least one target word.

9. The dialogue method according to claim 7, characterized in that, The step of generating the response statement corresponding to the current query statement according to the target response strategy based on at least one of the target words includes: An initial utterance is generated based on at least one of the target words according to the target response strategy; The initial statement is processed by at least one of the following methods to obtain the response statement corresponding to the current round of query statements: Replace sensitive words present in the initial discourse; Replace any contradictory words in the initial utterance; The initial utterance is then subject to emotional correction.

10. A dialogue device, characterized in that, The device includes: The acquisition module is used to acquire dialogue information, which includes historical dialogues and the user's current query statement; The first construction module is used to construct a heterogeneous graph based on the dialogue information. The heterogeneous graph is constructed based on multiple states and the feature value of each state. Each node in the heterogeneous graph is one of the multiple states. The edges in the heterogeneous graph are obtained by connecting the multiple nodes using a preset strategy. The multiple states and the feature value of each state are obtained based on fusion information. The fusion information is obtained based on encoding information. The encoding information is obtained by encoding the dialogue information. The second construction module is used to construct the user's profile information based on the dialogue information; The first determining module is used to determine the target response strategy based on the dialogue information; The second determining module is used to determine the response statement corresponding to the current round of query statements based on the heterogeneous graph, the profile information, and the target response strategy.

11. An electronic device, characterized in that, include: Processor and memory storing computer program instructions; When the processor executes the computer program instructions, it implements the dialogue method as described in any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, implement the dialogue method as described in any one of claims 1-9.