Man-machine interaction method and system based on large language model
By constructing a hierarchical memory structure and a multi-layered Transformer architecture, the problem of emotional and contextual coherence in human-computer interaction systems was solved, achieving emotionally consistent and contextually coherent dialogue responses, thus improving the user experience.
Patent Information
- Application Number
- CN202512013952.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-21
AI Technical Summary
Existing human-computer interaction systems lack a deep understanding of user emotions and contextual atmosphere, making it difficult to maintain emotional consistency and contextual coherence in multi-turn dialogues, resulting in abrupt transitions and dialogue breaks.
By extracting the original semantic features of user input and the semantic representation of multi-turn dialogue history, a hierarchical memory structure is constructed, including semantic memory components and emotional memory components. The attention level is adjusted to generate emotionally coordinated and semantically coherent response sequences. A multi-layer Transformer architecture and sliding window mechanism are used to process long dialogues.
It achieves deep perception of user emotions and emotional consistency in multi-turn dialogues, avoiding the abrupt switching and dialogue breaks of traditional dialogue systems, and improving the user experience of human-computer interaction.
Smart Images

Figure CN121900620A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language models, and more particularly to a human-computer interaction method and system based on large language models. Background Technology
[0002] With the rapid development of large language model technology, AI-based dialogue systems have been widely used in various fields such as intelligent assistants, customer service systems, and educational tutoring.
[0003] While existing human-computer interaction systems can perform basic question-and-answer functions, they often lack a deep understanding of user emotions and the atmosphere of the scene, making it difficult to continuously convey a language style and emotional warmth that are appropriate for the context during dialogue.
[0004] CN119782490A discloses a generative dialogue system based on a large language model, which uses a Transformer architecture to capture long-distance contextual information. However, it still has shortcomings in emotion perception and multi-turn dialogue coherence. The system only encodes key information through a dialogue state tracking module and fails to update contextual memory in response to changes in the user's emotional state.
[0005] CN119884327A proposes a method for emotion perception and dynamic response in digital humans. Although it integrates multimodal emotion perception and scene knowledge graph, its emotion processing mechanism is mainly aimed at specific scenarios and does not solve the problems of coherence evaluation and skipping risk in multi-turn dialogues.
[0006] Solving this technical problem is a technical challenge that needs to be overcome by those skilled in the art. Summary of the Invention
[0007] This application provides a human-computer interaction method based on a large language model to at least partially solve the above-mentioned technical problems.
[0008] To achieve the above objectives, according to a first aspect of this application, a human-computer interaction method based on a large language model is provided, comprising: Extract raw semantic features from the user's current input and obtain semantic representations of the multi-turn dialogue history; The original semantic features and the semantic representation of the multi-turn dialogue history are input into the context encoding network to obtain the context representation of the current dialogue; Extract historical sentiment state sequences from the multi-turn dialogue history; the historical sentiment state sequences include sentiment intensity values and sentiment category labels for each turn of dialogue; Based on the contextual representation of the current dialogue and the historical emotional state sequence, a current user emotional representation vector with an emotional intensity dimension and a confidence index is generated. A hierarchical memory structure is constructed based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component; The degree of attention given to the historical dialogue content stored in the semantic memory component is adjusted according to the hierarchical memory structure. Based on the adjusted attention level, the hierarchical memory structure, and the contextual representation of the current dialogue, a response sequence is generated using a large language model and output to the user.
[0009] According to a second aspect of this application, a human-computer interaction system based on a large language model is provided, comprising: The first processing module is used to: extract raw semantic features from the user's current input and obtain semantic representations of multi-turn dialogue history. The second processing module is used to: input the original semantic features and the semantic representation of the multi-turn dialogue history into the context encoding network to obtain the context representation of the current dialogue; The third processing module is used to: extract a historical sentiment state sequence from the multi-turn dialogue history; the historical sentiment state sequence includes the sentiment intensity value and sentiment category label of each turn of dialogue; The fourth processing module is used to: generate a current user sentiment representation vector with sentiment intensity dimension and confidence index based on the context representation of the current dialogue and the historical sentiment state sequence; The fifth processing module is used to: construct a hierarchical memory structure based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component; The sixth processing module is used to: adjust the degree of attention paid to the historical dialogue content stored in the semantic memory component according to the hierarchical memory structure; The seventh processing module is used to: generate a response sequence based on the adjusted attention level, the hierarchical memory structure, and the contextual representation of the current dialogue using a large language model, and output the response sequence to the user.
[0010] In summary, the embodiments of this application, through the above technical solutions, avoid the problems of abrupt switching and dialogue breakage during emotional transitions in traditional dialogue systems.
[0011] Other features and advantages of this application will be described in detail in the following detailed description section. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating the steps of a human-computer interaction method based on a large language model provided in an exemplary embodiment of this application. Figure 2 This is a system diagram of a human-computer interaction system based on a large language model provided in an exemplary embodiment of this application; Explanation of reference numerals in the attached drawings: 01, First processing module; 202, Second processing module; 203, Third processing module; 204, Fourth processing module; 205, Fifth processing module; 206, Sixth processing module; 207, Seventh processing module. Detailed Implementation
[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the protection scope of this application.
[0015] This application provides a human-computer interaction method based on a large language model. Please refer to [link / reference]. Figure 1 The human-computer interaction method based on a large language model provided in this application includes the following steps: Step 101: Extract the original semantic features from the user's current input and obtain the semantic representation of the multi-turn dialogue history.
[0016] Specifically, the original semantic features refer to the semantic vectors extracted from the user's input text, which contain information at the lexical, grammatical, and semantic levels; the semantic representation of the multi-turn dialogue history refers to the vector sequence obtained by encoding the past N rounds of dialogue content stored in the system, arranged in chronological order.
[0017] Step 102: Input the original semantic features and the semantic representation of the multi-turn dialogue history into the context encoding network to obtain the context representation of the current dialogue.
[0018] Step 103: Extract the historical sentiment state sequence from the multi-turn dialogue history; the historical sentiment state sequence contains the sentiment intensity value and sentiment category label of each turn of dialogue.
[0019] Specifically, the historical emotional state sequence refers to the sequence of emotional feature vectors arranged in the order of dialogue rounds; the emotional intensity value refers to the numerical value that quantifies the intensity of the emotion, and the emotional intensity value usually ranges from 0 to 1; the emotional category label refers to the predefined emotional type identifier, such as basic emotional categories like joy, sadness, anger, surprise, fear, and neutrality.
[0020] Step 104: Generate a current user sentiment representation vector with sentiment intensity dimension and confidence index based on the context representation of the current dialogue and the historical sentiment state sequence.
[0021] Specifically, the current user sentiment representation vector includes the dominant sentiment category and sentiment intensity value, as well as the sentiment confidence index. The sentiment confidence index reflects the degree of certainty of the system's sentiment judgment result, and ranges between 0 and 1. The higher the value, the higher the confidence.
[0022] Step 105: Construct a hierarchical memory structure based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component.
[0023] Step 106: Adjust the level of attention paid to the historical dialogue content stored in the semantic memory component according to the hierarchical memory structure.
[0024] Step 107: Based on the adjusted attention level, hierarchical memory structure, and contextual representation of the current dialogue, generate a response sequence using a large language model and output the response sequence to the user.
[0025] This application extracts semantic features from user input and dialogue history to construct a contextual representation; it generates a user sentiment representation vector containing sentiment intensity and confidence by analyzing historical sentiment state sequences and the current context, thereby capturing user emotions; it constructs a hierarchical memory structure based on sentiment representation to distinguish and store semantic and sentiment information; it adjusts the degree of attention to historical content according to hierarchical memory, enabling the system to focus on memories consistent with the current sentiment; and it combines the adjusted degree of attention, hierarchical memory, and context to generate emotionally coordinated and semantically coherent responses through a large language model. This approach not only perceives changes in user emotions but also maintains consistency between topic and sentiment in multi-turn dialogues, avoiding the abrupt switching and dialogue breaks that occur in traditional dialogue systems during sentiment transitions, thus improving the user experience of human-computer interaction.
[0026] In some embodiments, the context encoding network employs a multi-layer Transformer architecture; the multi-layer Transformer architecture consists of N cascaded Transformer blocks; each Transformer block sequentially includes a position encoding layer, a multi-head self-attention layer, a residual connection layer, a normalization layer, and a feedforward neural network layer; The position encoding layer generates position vectors using sine and cosine functions; the position vectors are then added element-wise to the semantic representation of the multi-turn dialogue history to give the multi-turn dialogue history temporal position features. The multi-head self-attention layer contains several parallel self-attention heads. The outputs of these attention heads are concatenated and merged into a unified multi-head attention output through a linear transformation. Each attention head performs the following operations: linearly projects the original semantic features of the current user input into a query vector Q, and linearly projects the semantic representation of the multi-turn dialogue history into a key vector K and a value vector V; calculates the attention weight distribution between the query vector Q and the key vector K; and multiplies the attention weight distribution with the value vector V to obtain the output of the attention mechanism. The residual connection layer adds the multi-head attention output to the corresponding input element by element; The normalization layer standardizes the output after residual connection; The feedforward neural network layer consists of a first fully connected layer, a GELU non-linear activation function layer, and a second fully connected layer. The first fully connected layer maps the normalized attention output to the extended-dimensional feature space. The GELU non-linear activation function layer performs a non-linear transformation on the extended-dimensional features. The second fully connected layer maps the non-linearly transformed features back to the original dimension to enhance expressive power. The output of each Transformer block serves as the input to the next Transformer block; in the output of the Nth Transformer block, the hidden state corresponding to the current user input is selected as the context representation of the current dialogue. Among them, the allocation strategy of several attention heads is adjusted according to the complexity of the dialogue; when multiple topics or emotional shifts are detected in the dialogue, the number of attention heads used to capture emotional information is increased and the number of attention heads used to capture factual information is reduced to optimize the quality of contextual representation.
[0027] Specifically, the context encoding network adopts a multi-layer Transformer architecture; the multi-layer Transformer architecture is a deep neural network structure composed of N cascaded Transformer blocks, which can effectively capture long-range dependencies and complex semantic features in sequence data. Each Transformer block contains, in sequence, a position encoding layer, a multi-head self-attention layer, a residual connection layer, a normalization layer, and a feedforward neural network layer.
[0028] The positional encoding layer is used to add positional information to the input sequence. Specifically, this layer generates positional vectors using sine and cosine functions, and performs element-wise addition of the positional vectors with the semantic representation of the multi-turn dialogue history, giving the multi-turn dialogue history temporal positional features and solving the problem that the Transformer architecture itself does not have positional awareness.
[0029] The multi-head self-attention layer comprises several parallel self-attention heads. A self-attention head is a mechanism capable of calculating the correlation between elements within a sequence, allowing the model to focus on other relevant positions in the sequence while processing each position. The outputs of several attention heads are concatenated and merged into a unified multi-head attention output through a linear transformation, enhancing the model's ability to capture features from different subspaces. Within each attention head, the original semantic features of the current user input are linearly projected into a query vector Q, and the semantic representation of the multi-turn dialogue history is linearly projected into a key vector K and a value vector V. The attention weight distribution between the query vector Q and the key vector K is calculated, reflecting the degree of correlation between different positions.
[0030] The residual connection layer adds the multi-head attention output to the corresponding input element by element, which alleviates the gradient vanishing problem in deep network training and promotes the flow of information. The normalization layer standardizes the output after the residual connection, which accelerates the convergence of model training and improves stability.
[0031] The feedforward neural network layer consists of a first fully connected layer, a GELU non-linear activation function layer, and a second fully connected layer. GELU (Gaussian Error Linear Unit) is a smooth non-linear activation function with better gradient properties compared to the traditional ReLU. The first fully connected layer maps the normalized attention output to an extended-dimensional feature space, typically four times the input dimension. The GELU non-linear activation function layer performs a non-linear transformation on the extended-dimensional features, and the second fully connected layer maps the non-linearly transformed features back to the original dimension, enhancing the model's expressive power.
[0032] In the output of the Nth Transformer block, the hidden state corresponding to the current user input is selected as the context representation of the current dialogue. This context representation integrates the semantic information of the current input and all historical dialogues.
[0033] It is worth noting that the allocation strategy for several attention heads is adjusted according to the complexity of the dialogue. Specifically, when multiple topics or emotional shifts are detected in the dialogue, the number of attention heads used to capture emotional information is increased while the number of attention heads used to capture factual information is decreased, enabling the model to allocate computational resources according to the characteristics of the dialogue.
[0034] In this application, multi-layered cascaded Transformer blocks progressively construct rich contextual representations through hierarchical feature extraction; positional encoding layers ensure that the model can distinguish the temporal relationships of dialogue turns, avoiding confusion of historical content; multi-head self-attention mechanisms enable the model to simultaneously focus on multiple related segments in the dialogue; the design of residual connections and normalization layers solves the training difficulties of deep networks, enabling the model to stably learn long-term dependencies; feedforward neural network layers enhance the model's nonlinear expressive power; and the attention head allocation strategy enables the system to adaptively allocate computational resources according to the semantic complexity and emotional richness of the dialogue. When emotional transitions or multi-topic dialogues are detected, the system enhances the ability to capture emotional information, improves the quality of contextual representations, and effectively solves the problem of traditional dialogue systems losing key information in long dialogues.
[0035] In some embodiments, inputting the original semantic features and the semantic representation of the multi-turn dialogue history into a context encoding network to obtain the context representation of the current dialogue includes: The text corresponding to the user's current input is segmented into a sequence of lexical units; the sequence of lexical units is then mapped and transformed using a word embedding matrix to obtain the semantic vector sequence of the current input. Perform word segmentation and word embedding mapping transformation on the dialogue content of each round in the multi-turn dialogue history to obtain a set of semantic vector sequences of the historical dialogue; Insert a context aggregation marker vector at the beginning of the sequence; concatenate the semantic vector sequences of each round of historical dialogue, and insert a dialogue round separator after each round of historical dialogue; concatenate the semantic vector sequence of the current input at the end of the sequence and insert a dialogue round separator after it to form a complete dialogue sequence representation; the context aggregation marker vector is used to extract the global context representation; the dialogue round separator is used to identify the boundaries of different dialogue rounds; The complete dialogue sequence representation is input into the first layer of the Transformer block in the multi-layer Transformer architecture; Location information is added to the complete dialogue sequence representation through a location encoding layer to preserve the temporal characteristics of the dialogue; In the multi-head self-attention layer, the query vector Q corresponding to the current user input is interacted with the key vector K and value vector V corresponding to the semantic representation of the multi-turn dialogue history to obtain the attention distribution across the history dialogue; The process is performed layer by layer through N cascaded Transformer blocks; the feature representation output by each Transformer block is used as the input to the next Transformer block. In the output of the Nth Transformer block, the hidden state corresponding to the position of the context aggregation tag vector is selected as the global context representation, and the hidden state corresponding to the current user input part is retained as the local context representation; The global context representation and the local context representation are concatenated and linearly transformed to generate the final context representation vector of the current dialogue; Specifically, when a change in the dialogue topic is detected, the weights of the current input and historical dialogue content in the attention distribution calculation are adjusted.
[0036] Specifically, a lexical unit sequence refers to the sequence of basic language units obtained by segmenting the input text according to semantic boundaries, such as the word sequence after Chinese word segmentation or the token sequence in English; the lexical unit sequence is mapped and transformed through a word embedding matrix to obtain the semantic vector sequence of the current input; the word embedding matrix is a parameter matrix that maps discrete words to a continuous vector space, with each word corresponding to a semantic vector of a fixed dimension.
[0037] The same word segmentation and word embedding mapping transformation are performed on the dialogue content of each round of the multi-turn dialogue history to obtain a set of semantic vector sequences of historical dialogues. A context aggregation marker vector is inserted at the beginning of the sequence, which is usually represented as [CLS]. The semantic vector sequences of each round of historical dialogue are concatenated in sequence, and a dialogue round separator marker is inserted after each round of historical dialogue, which is usually represented as [SEP]. The semantic vector sequence of the current input is concatenated at the end of the sequence and a dialogue round separator marker is inserted after it to form a complete dialogue sequence representation. The hidden state of the context aggregation marker vector after Transformer encoding can aggregate the global information of the entire sequence. The dialogue round separator marker is a special marker used to identify the boundaries of different dialogue rounds, helping the model to distinguish different dialogue segments.
[0038] The complete dialogue sequence representation is input into the first layer of the multi-layer Transformer architecture. A positional encoding layer adds positional information to the complete dialogue sequence representation to preserve the temporal characteristics of the dialogue content, enabling the model to distinguish elements at different positions in the sequence. In the multi-head self-attention layer, the query vector Q corresponding to the current user input interacts with the key vector K and value vector V corresponding to the semantic representation of the multi-turn dialogue history. Attention weights are calculated and weighted, and historical content is aggregated to obtain the attention distribution across historical dialogues. This attention distribution reflects the relevance between the current input and various parts of the historical dialogue, guiding the model on how to extract relevant information from historical content.
[0039] The feature extraction process is performed layer by layer by N cascaded Transformer blocks. The feature representation output by each Transformer block is used as the input to the next Transformer block, forming a hierarchical feature extraction process. In the output of the Nth Transformer block, the hidden state corresponding to the context aggregation label vector is selected as the global context representation, and the hidden state corresponding to the current user input is retained as the local context representation. This local context representation focuses on the detailed semantic features of the current input. The hidden state refers to the feature vector encoded at each position in the Transformer network, which contains the semantic representation of the input content corresponding to that position in the context.
[0040] The global context representation and the local context representation are concatenated and linearly transformed to generate the final context representation vector of the current dialogue. This ensures that the context representation includes both the overall context of the dialogue and the detailed features of the current input. When a change in the dialogue topic is detected, the weights of the current input and historical dialogue content in the attention distribution calculation are adjusted. The weights of historical content related to the old topic are reduced, while the weights of content related to the new topic are increased, so that the context representation can adapt to changes in the dialogue topic.
[0041] To adapt to dialogue scenarios, a sliding window mechanism is adopted for long dialogue history processing. This mechanism retains the complete representation of the most recent M rounds of dialogue while summarizing earlier dialogue content to generate a fixed-length conversation summary vector. Weight balancing between the current input and historical content is achieved through a gating mechanism. Dialogue round boundary processing is implemented using a dialogue round separation marker, which explicitly identifies the boundaries between different rounds in the input sequence, enabling the model to distinguish semantic units from different rounds. To enhance dialogue coherence, a round-aware positional encoding is designed, combining absolute positional encoding with relative round positional encoding.
[0042] In some embodiments, extracting a sequence of historical emotional states from a multi-turn dialogue history includes: Retrieve the content of each round of dialogue from the history of multi-turn conversations; Fine-grained sentiment analysis was performed on each round of dialogue to identify explicit sentiment expressions and implicit sentiment cues; Based on the identified explicit emotional expression words and implicit emotional cues, each round of dialogue content is assigned an emotional category label; the emotional category label includes a first-level emotional category and a second-level emotional subcategory belonging to the first-level emotional category; The emotional intensity value for each round of dialogue is calculated based on the strength of the identified explicit emotional expression words and the salience of the implicit emotional cues. Detect emotional abrupt changes in the dialogue sequence; assign emotional importance weights based on the time distance between each dialogue turn and the nearest emotional abrupt change in the starting point; wherein, dialogue turns with smaller time distances are assigned higher emotional importance weights; The emotional category labels, emotional intensity values, and emotional importance weights of each round of dialogue are combined in chronological order to form a historical emotional state sequence.
[0043] Specifically, the content of each round of dialogue in the history of multi-turn conversations is obtained, and fine-grained sentiment analysis is performed on the content of each round of dialogue to identify explicit sentiment expression words and implicit sentiment cues. Explicit sentiment expression words refer to words that directly express emotions, such as words with clear emotional tendencies, such as happy, angry, and disappointed. Implicit sentiment cues refer to linguistic features that do not directly express emotions but imply emotional states, such as rhetorical devices, interjections, sentence structures, and descriptions of specific scenes, which require contextual understanding to infer emotional information.
[0044] Implicit sentiment cues can be obtained based on the following feature set: syntactic structure features, including negation word positions, interrogative sentence markers, and exclamatory sentence markers; contextual semantic features, determined by calculating the semantic similarity between the current word and sentiment seed words within the context window, based on the cosine similarity of pre-trained word vectors; modal particle features, constructing a sentiment polarity dictionary for modal particles; and rhetorical device features, identifying rhetorical devices such as rhetorical questions, metaphors, and hyperbole through rule matching. These features are fused using a multilayer perceptron, where explicit sentiment word vectors and the rest are implicit feature vectors. The fused representation is then input into the sentiment classification layer.
[0045] Based on the identified explicit emotional expressions and implicit emotional cues, emotional category labels are assigned to each round of dialogue. The emotional category labels adopt a two-level classification structure: the first level of emotional categories refers to basic emotional types, such as joy, sadness, anger, fear, surprise, and neutrality; the second level of emotional subcategories is a refinement of the first level of categories, such as satisfaction, excitement, and relief under the joy category, which can more accurately describe the emotional state.
[0046] Based on the strength of identified explicit emotional expressions and the salience of implicit emotional cues, the emotional intensity value for each round of dialogue is calculated. Emotional abrupt changes are detected in the dialogue sequence; these abrupt changes refer to the rounds in which the emotional state changes significantly, typically manifested as a shift in emotional category or a sharp change in emotional intensity. Emotional importance weights are assigned based on the time distance between each dialogue round and the most recent emotional abrupt change point; dialogue rounds with shorter time distances are assigned higher emotional importance weights, reflecting the time-sensitivity principle of emotional states, where recent emotional states have a greater impact on the current dialogue.
[0047] The emotional category labels, emotional intensity values, and emotional importance weights of each round of dialogue are combined in chronological order to form a historical emotional state sequence. The historical emotional state sequence is a structured data sequence, with each item containing emotional category, emotional intensity, and importance weight, arranged in chronological order of dialogue, recording the trajectory of emotional evolution during the dialogue process.
[0048] In some embodiments, generating a current user sentiment representation vector based on the context representation of the current dialogue and a sequence of historical sentiment states includes: Perform sentiment feature analysis on the current user-input dialogue content to identify explicit sentiment expression words and implicit sentiment cues, and generate preliminary sentiment category probability distribution and preliminary sentiment intensity prediction values for the current dialogue; The emotional inertia factor is calculated based on the emotional category and emotional intensity values of the most recent K rounds of dialogue in the historical emotional state sequence; the emotional inertia factor reflects the degree of continuous influence of the historical emotional state on the current emotion; The weight of historical sentiment is determined based on the position of the dialogue round and the stability of sentiment. When the dialogue round is earlier or the historical sentiment fluctuation is greater than the preset value, the weight of historical sentiment is reduced. When the dialogue round is later or the historical sentiment is more stable, the weight of historical sentiment is increased. The calibrated emotional intensity value is obtained by weighting and fusing the determined historical emotional weights, emotional inertia factors, and preliminary emotional intensity predictions. Calculate the semantic consistency score between the current dialogue content and the historical dialogue content, and assess the clarity of sentiment expression; calculate sentiment confidence based on the semantic consistency score and the clarity of sentiment expression. Construct the current user's sentiment representation vector; the current user's sentiment representation vector includes the dominant sentiment category, the calibrated sentiment intensity value, and the sentiment confidence.
[0049] Specifically, the system performs sentiment feature analysis on the current user-input dialogue content, identifying explicit sentiment expression words and implicit sentiment cues. Based on these identification results, it generates a preliminary sentiment category probability distribution and a preliminary sentiment intensity prediction value for the current dialogue. The system calculates an sentiment inertia factor based on the sentiment categories and intensity values of the most recent K rounds of dialogue in the historical sentiment state sequence. The sentiment inertia factor is a quantitative indicator that reflects the degree of continuous influence of historical sentiment states on current sentiment, simulating the continuous nature of human emotions rather than abrupt changes. For example, if the user has been in an anxious state for the past few rounds of dialogue, even if the current input does not explicitly express anxiety, the sentiment inertia factor will lead the system to believe that the user may still be in a state of some degree of anxiety.
[0050] Historical sentiment weights are determined based on the dialogue turn position and sentiment stability. Sentiment stability refers to the degree of change in sentiment state throughout the dialogue, which can be measured by calculating the standard deviation of historical sentiment intensity values or the frequency of change in sentiment categories. When the dialogue turn is relatively early, such as the first three turns, or when historical sentiment fluctuations exceed a preset value indicating sentiment instability, the system reduces the historical sentiment weight and relies primarily on the current input for sentiment judgment. When the dialogue turn is relatively late or historical sentiment is relatively stable, the historical sentiment weight is increased, placing greater emphasis on the continuity of sentiment.
[0051] The calibrated emotional intensity value is obtained by weighting and fusing the determined historical emotional weights, emotional inertia factors, and preliminary emotional intensity predictions. The calibrated emotional intensity value is a correction to the preliminary prediction value, which incorporates the continuous influence of historical emotions, making the emotional intensity estimation more accurate and stable.
[0052] The semantic consistency score between the current dialogue content and historical dialogue content is calculated. This score measures the coherence between the current input and historical topics; a higher score indicates greater coherence. The clarity of sentiment expression is also assessed, measuring the explicitness of the user's emotional expression based on sentiment lexical density and directness of expression. Based on these two metrics, sentiment confidence is calculated. Sentiment confidence is a value between 0 and 1, representing the system's certainty regarding the sentiment analysis results. Finally, a current user sentiment representation vector is constructed. This vector is a multi-dimensional structure containing three core dimensions: the dominant sentiment category, the calibrated sentiment intensity value, and the sentiment confidence.
[0053] In this application, the sentiment feature analysis considers both explicit and implicit sentiment cues, avoiding misjudgments caused by relying solely on surface sentiment vocabulary; the introduction of the sentiment inertia factor simulates the continuous characteristics of human emotions, enabling the system to understand the gradual changes in sentiment state rather than judging each round of dialogue in isolation; and the adjustment of historical sentiment weights based on the position of the dialogue round and the sentiment stability can intelligently balance the influence of current input and historical sentiment according to different dialogue stages and sentiment stability.
[0054] In some embodiments, a hierarchical memory structure is constructed based on the current user's emotion representation vector and the contextual representation of the current dialogue, including: Construct a semantic memory component; where key entities are extracted as nodes based on the context representation of the current dialogue, and semantic relationships between entities are identified as edges to construct a knowledge graph structure; each node contains an entity identifier, a semantic feature vector, and a recent access timestamp; each edge contains a relationship type identifier and a relationship strength weight; Construct an emotional memory component; wherein, the dominant emotional category, emotional intensity value, and emotional confidence in the current user's emotional representation vector are used as the latest emotional record and combined with the historical emotional state sequence to construct an emotional time series; set differentiated emotional decay coefficients for different emotional categories; For each entity node in the semantic memory component, the correlation between the entity and the current emotional state is calculated based on the temporal distance between the entity's location in the dialogue and the location of the emotional expression, as well as the correlation between the entity's co-occurrence frequency and the emotional intensity value. Adjust the retrieval priority of each node in the semantic memory component based on the dominant sentiment category in the current user sentiment representation vector; Based on the sentiment confidence in the current user sentiment representation vector, adjust the retention strength of historical sentiment records in the sentiment memory component; the higher the sentiment confidence, the slower the decay rate of historical sentiment records; the lower the sentiment confidence, the faster the decay rate of historical sentiment records.
[0055] Specifically, the hierarchical memory structure is a layered information system that simulates the human memory system, containing different types of memory modules. Semantic memory components are specifically used to store factual knowledge and conceptual relationships within a dialogue. During construction, key entities are extracted as nodes based on the contextual representation of the current dialogue. Key entities refer to important nouns, concepts, or objects mentioned in the dialogue, such as projects, teams, or holidays. Semantic relationships between entities are identified as edges to construct the knowledge graph structure. Each node contains three core attributes: entity identifier, semantic feature vector, and recent access timestamp. Each edge contains a relationship type identifier and a relationship strength weight.
[0056] The emotional memory component is specifically designed to store and manage emotional information in conversations. It uses the dominant emotional category, emotional intensity value, and emotional confidence score in the current user's emotional representation vector as the latest emotional record and combines them with historical emotional state sequences to construct an emotional time series. The emotional time series is a collection of emotional states arranged in chronological order, recording the evolution trajectory of emotions during the conversation. Different emotional decay coefficients are set for different emotional categories. The emotional decay coefficient is a parameter that controls the rate at which emotional memory weakens over time, and different emotional categories have different decay characteristics.
[0057] For each entity node in the semantic memory component, the system calculates the correlation between the entity and the current emotional state. The calculation is based on the following: the temporal distance between the location where the entity appears in the dialogue and the location of the emotional expression, i.e., the temporal distance refers to the time interval between the entity mention and the emotional expression, and the smaller the distance, the higher the correlation; and the correlation between the entity co-occurrence frequency and the emotional intensity value, i.e., the entity co-occurrence frequency refers to the number of times the entity appears together in the same context, and its correlation with the emotional intensity is determined through statistical analysis.
[0058] Based on the dominant sentiment category in the current user sentiment representation vector, the retrieval priority of each node in the semantic memory component is adjusted. The retrieval priority is a parameter that controls the order of memory retrieval. Nodes with higher priority are more likely to be referenced when generating responses. For example, when a user is in an anxious emotional state, entity nodes related to stress and solutions will be given higher retrieval priority.
[0059] Based on the sentiment confidence in the current user's sentiment representation vector, the retention strength of historical sentiment records in the sentiment memory component is adjusted; the retention strength controls the persistence of historical sentiment records in memory. Specifically, the higher the sentiment confidence, the slower the decay rate of historical sentiment records and the longer they are retained; the lower the sentiment confidence, the faster the decay rate of historical sentiment records and the faster they are replaced by new information.
[0060] In some embodiments, adjusting the level of attention given to historical dialogue content stored in the semantic memory component according to the hierarchical memory structure includes: The emotional guidance strength parameter is calculated based on the dominant emotional category and emotional intensity value in the current user's emotional representation vector; the emotional guidance strength parameter represents the degree of influence of the current emotional state on historical memory retrieval. Traverse each entity node in the semantic memory component and calculate the matching degree between the historical sentiment category associated with that node and the current dominant sentiment category; The timeliness weight is calculated based on the most recent access timestamp of the entity node; The overall attention weight of a node is calculated based on its basic importance weight, sentiment matching degree, and timeliness weight. The node's overall attention weight is mapped to the relevant historical dialogue content, and the weighted average attention of the associated nodes is calculated for each historical dialogue content.
[0061] Specifically, the emotional guidance strength parameter is calculated based on the dominant emotional category and emotional intensity value in the current user's emotional representation vector. The emotional guidance strength represents the degree of influence of the current emotional state on historical memory retrieval. When the emotional intensity value is high, the emotional guidance strength parameter also increases accordingly, indicating that the current emotional state has a stronger guiding effect on historical memory selection. When the emotional intensity value is low, the emotional guidance strength parameter decreases, and the system relies more on other factors rather than emotions to select historical content.
[0062] The system iterates through each entity node in the semantic memory component, calculating the matching degree between the historical sentiment category associated with that node and the current dominant sentiment category. The calculation method can use a predefined sentiment similarity matrix. For example, the matching degree between joy and relief may be 0.8, while the matching degree between joy and anger may be close to 0.1. For each entity node, the system retrieves the sentiment categories that accompany it when it is mentioned in the historical dialogue, calculates the average matching degree between these historical sentiment categories and the current dominant sentiment category, and uses it as the sentiment matching degree index of that node.
[0063] The timeliness weight reflects the degree to which the memory content decays over time. In other words, recently mentioned content should receive higher attention. It is usually calculated using an exponential decay function, which makes the system tend to focus on recent dialogue content and avoid contextual confusion caused by over-focusing on ancient dialogue.
[0064] The overall attention weight of a node is calculated based on its fundamental importance weight, sentiment matching degree, and timeliness weight. The fundamental importance weight is the inherent importance score of the node, determined according to entity type, frequency of occurrence, and functional role in the dialogue; the overall attention weight of a node is calculated through a weighted fusion: ,in, , , This is an adjustable coefficient.
[0065] The system maps the overall attention weight of nodes to relevant historical dialogue content, and calculates the weighted average attention of associated nodes for each historical dialogue content. Specifically, each historical dialogue content contains multiple entity nodes. The system collects the overall attention weight of these nodes and calculates the weighted average based on the importance of the nodes in the dialogue content to obtain the overall attention of the historical dialogue content.
[0066] Through the above steps, the introduction of the emotional guidance intensity parameter enables the system to dynamically adjust the influence of emotional factors in the selection of historical content based on the strength of the current emotional state, avoiding ignoring emotional consistency when the user's emotions are strong or overemphasizing emotional factors when the user's emotions are calm; the timeliness weight enables the system to naturally tend to focus on recent conversations, avoiding over-reliance on long-ago conversation content.
[0067] In some embodiments, generating response sequences using a large language model includes: The contextual representation of the current dialogue, the current user's sentiment vector, and the attention distribution of historical dialogue content are fused to serve as input for the large language model. Based on the sentiment category and sentiment intensity value in the current user sentiment representation vector, adjust the temperature parameters and sampling strategy of the large language model to make the sentiment expression of the generated content match the user's current sentiment state; Multiple candidate response sequences are generated using the decoder of a large language model; Analyze explicit sentiment expressions and implicit sentiment cues in candidate responses, and calculate the degree of matching between each candidate response and the current user's sentiment representation vector as the sentiment consistency score; The semantic quality score of each candidate response is calculated based on its semantic coherence, information completeness, and relevance to the dialogue history. The candidate responses are selected as the final output by weighting and sorting the responses based on their sentiment consistency score and semantic quality score.
[0068] Reference Figure 2 The second embodiment of the present invention provides a human-computer interaction system based on a large language model, comprising: The first processing module 201 is used to: extract the original semantic features from the user's current input and obtain the semantic representation of the multi-turn dialogue history; The second processing module 202 is used to: input the original semantic features and the semantic representation of the multi-turn dialogue history into the context encoding network to obtain the context representation of the current dialogue; The third processing module 203 is used to: extract historical sentiment state sequences from multi-turn dialogue history records; the historical sentiment state sequences contain sentiment intensity values and sentiment category labels for each turn of dialogue; The fourth processing module 204 is used to: generate a current user sentiment representation vector with sentiment intensity dimension and confidence index based on the context representation of the current dialogue and the historical sentiment state sequence; The fifth processing module 205 is used to: construct a hierarchical memory structure based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component; The sixth processing module 206 is used to: adjust the degree of attention paid to the historical dialogue content stored in the semantic memory component according to the hierarchical memory structure; The seventh processing module 207 is used to: generate a response sequence based on the adjusted attention level, hierarchical memory structure and contextual representation of the current dialogue through a large language model and output the response sequence to the user.
[0069] It should be noted that the human-computer interaction system based on a large language model provided in this embodiment of the invention is used to execute all the process steps of the human-computer interaction method based on a large language model in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0070] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0071] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0072] The embodiments, implementation methods, and related technical features of this application can be combined and substituted for each other without conflict.
[0073] The above are merely preferred embodiments of this application and are not intended to limit this application in any way. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of this application without departing from the scope of the technical solution of this application shall still fall within the scope of the technical solution of this application.
Claims
1. A human-computer interaction method based on a large language model, characterized in that, include: Extract raw semantic features from the user's current input and obtain semantic representations of multi-turn dialogue history; The original semantic features and the semantic representation of the multi-turn dialogue history are input into the context encoding network to obtain the context representation of the current dialogue; Extract historical sentiment state sequences from the multi-turn dialogue history; the historical sentiment state sequences include sentiment intensity values and sentiment category labels for each turn of dialogue; Based on the contextual representation of the current dialogue and the historical emotional state sequence, a current user emotional representation vector with an emotional intensity dimension and a confidence index is generated. A hierarchical memory structure is constructed based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component; The degree of attention given to the historical dialogue content stored in the semantic memory component is adjusted according to the hierarchical memory structure. Based on the adjusted attention level, the hierarchical memory structure, and the contextual representation of the current dialogue, a response sequence is generated using a large language model and output to the user.
2. The method according to claim 1, characterized in that, The context encoding network adopts a multi-layer Transformer architecture; the multi-layer Transformer architecture consists of N cascaded Transformer blocks; each Transformer block contains, in sequence, a position encoding layer, a multi-head self-attention layer, a residual connection layer, a normalization layer, and a feedforward neural network layer; The location encoding layer generates a location vector using sine and cosine functions; the location vector is then added element-wise to the semantic representation of the multi-turn dialogue history to give the multi-turn dialogue history temporal location features; The multi-head self-attention layer comprises several parallel self-attention heads; the outputs of these attention heads are concatenated and merged into a unified multi-head attention output through a linear transformation; each attention head performs the following operations: linearly projecting the original semantic features of the current user input into a query vector Q, and linearly projecting the semantic representation of the multi-turn dialogue history into a key vector K and a value vector V; calculating the attention weight distribution between the query vector Q and the key vector K; and multiplying the attention weight distribution by the value vector V to obtain the output of the attention mechanism. The residual connection layer adds the multi-head attention output to the corresponding input element by element; The normalization layer standardizes the output after residual connection. The feedforward neural network layer comprises a first fully connected layer, a GELU nonlinear activation function layer, and a second fully connected layer. The first fully connected layer maps the normalized attention output to an extended-dimensional feature space. The GELU nonlinear activation function layer performs a nonlinear transformation on the extended-dimensional features. The second fully connected layer maps the nonlinearly transformed features back to the original dimension to enhance expressive power. The output of each Transformer block serves as the input to the next Transformer block; in the output of the Nth Transformer block, the hidden state corresponding to the current user input is selected as the context representation of the current dialogue. The allocation strategy of the attention heads is adjusted according to the complexity of the dialogue; when multiple topics or emotional shifts are detected in the dialogue, the number of attention heads used to capture emotional information is increased and the number of attention heads used to capture factual information is reduced to optimize the quality of the context representation.
3. The method according to claim 2, characterized in that, The original semantic features and the semantic representation of the multi-turn dialogue history are input into a context encoding network to obtain the context representation of the current dialogue, including: The text corresponding to the user's current input is segmented into a sequence of lexical units; the sequence of lexical units is then mapped and transformed using a word embedding matrix to obtain the semantic vector sequence of the current input. Perform word segmentation and word embedding mapping transformation on the dialogue content of each round in the multi-turn dialogue history to obtain a set of semantic vector sequences of the historical dialogue; A context aggregation marker vector is inserted at the beginning of the sequence; the semantic vector sequences of each round of historical dialogue are concatenated sequentially, and a dialogue round separator is inserted after each round of historical dialogue; the semantic vector sequence of the current input is concatenated at the end of the sequence and a dialogue round separator is inserted thereafter to form a complete dialogue sequence representation; the context aggregation marker vector is used to extract the global context representation; the dialogue round separator is used to identify the boundaries of different dialogue rounds; The complete dialogue sequence is input into the first layer Transformer block of the multi-layer Transformer architecture; Location information is added to the complete dialogue sequence representation through a location encoding layer to preserve the temporal characteristics of the dialogue; In the multi-head self-attention layer, the query vector Q corresponding to the current user input is interacted with the key vector K and value vector V corresponding to the semantic representation of the multi-turn dialogue history to obtain the attention distribution across the history dialogue; The process is performed layer by layer through N cascaded Transformer blocks; the feature representation output by each Transformer block is used as the input to the next Transformer block. In the output of the Nth Transformer block, the hidden state corresponding to the position of the context aggregation tag vector is selected as the global context representation, and the hidden state corresponding to the current user input part is retained as the local context representation; The global context representation and the local context representation are concatenated and linearly transformed to generate the final context representation vector of the current dialogue; Specifically, when a change in the dialogue topic is detected, the weights of the current input and historical dialogue content in the attention distribution calculation are adjusted.
4. The method according to claim 3, characterized in that, Extract the historical sentiment state sequence from the multi-turn dialogue history, including: Retrieve the content of each round of dialogue from the history of multi-turn conversations; Fine-grained sentiment analysis was performed on each round of dialogue to identify explicit sentiment expressions and implicit sentiment cues; Based on the identified explicit emotional expression words and implicit emotional cues, each round of dialogue content is assigned an emotional category label; the emotional category label includes a first-level emotional category and a second-level emotional sub-category belonging to the first-level emotional category; The emotional intensity value for each round of dialogue is calculated based on the strength of the identified explicit emotional expression words and the salience of the implicit emotional cues. Detect emotional abrupt changes in the dialogue sequence; assign emotional importance weights based on the time distance between each dialogue turn and the nearest emotional abrupt change in the starting point; wherein, dialogue turns with smaller time distances are assigned higher emotional importance weights; The emotional category labels, emotional intensity values, and emotional importance weights of each round of dialogue are combined in chronological order to form a historical emotional state sequence.
5. The method according to claim 4, characterized in that, Generate the current user's sentiment representation vector based on the contextual representation of the current dialogue and the sequence of historical sentiment states, including: Perform sentiment feature analysis on the current user-input dialogue content to identify explicit sentiment expression words and implicit sentiment cues, and generate preliminary sentiment category probability distribution and preliminary sentiment intensity prediction values for the current dialogue; The emotional inertia factor is calculated based on the emotional category and emotional intensity values of the most recent K rounds of dialogue in the historical emotional state sequence; the emotional inertia factor reflects the degree of continuous influence of the historical emotional state on the current emotion; Historical sentiment weights are determined based on the position of the dialogue round and the stability of the sentiment. When the dialogue round is earlier or the historical sentiment fluctuation is greater than a preset value, the historical sentiment weight is reduced. When the dialogue round is later or the historical sentiment is more stable, the historical sentiment weight is increased. The calibrated emotional intensity value is obtained by weighting and fusing the determined historical emotional weights, emotional inertia factors, and preliminary emotional intensity predictions. Calculate the semantic consistency score between the current dialogue content and the historical dialogue content, and assess the clarity of sentiment expression; calculate sentiment confidence based on the semantic consistency score and the clarity of sentiment expression. Construct the current user's sentiment representation vector; the current user's sentiment representation vector includes the dominant sentiment category, the calibrated sentiment intensity value, and the sentiment confidence.
6. The method according to claim 5, characterized in that, A hierarchical memory structure is constructed based on the current user's sentiment representation vector and the context representation of the current dialogue, including: Construct a semantic memory component; where key entities are extracted as nodes based on the context representation of the current dialogue, and semantic relationships between entities are identified as edges to construct a knowledge graph structure; each node contains an entity identifier, a semantic feature vector, and a recent access timestamp; each edge contains a relationship type identifier and a relationship strength weight; Construct an emotional memory component; wherein, the dominant emotional category, emotional intensity value, and emotional confidence in the current user's emotional representation vector are used as the latest emotional record and combined with the historical emotional state sequence to construct an emotional time series; set differentiated emotional decay coefficients for different emotional categories; For each entity node in the semantic memory component, the correlation between the entity and the current emotional state is calculated based on the temporal distance between the entity's location in the dialogue and the location of the emotional expression, as well as the correlation between the entity's co-occurrence frequency and the emotional intensity value. Adjust the retrieval priority of each node in the semantic memory component based on the dominant sentiment category in the current user sentiment representation vector; Based on the sentiment confidence in the current user sentiment representation vector, adjust the retention strength of historical sentiment records in the sentiment memory component; the higher the sentiment confidence, the slower the decay rate of historical sentiment records; the lower the sentiment confidence, the faster the decay rate of historical sentiment records.
7. The method according to claim 6, characterized in that, Adjusting the level of attention given to historical dialogue content stored in the semantic memory component based on the hierarchical memory structure includes: The emotional guidance strength parameter is calculated based on the dominant emotional category and emotional intensity value in the current user's emotional representation vector; the emotional guidance strength parameter represents the degree of influence of the current emotional state on historical memory retrieval. Traverse each entity node in the semantic memory component and calculate the matching degree between the historical sentiment category associated with that node and the current dominant sentiment category; The timeliness weight is calculated based on the most recent access timestamp of the entity node; The overall attention weight of a node is calculated based on its basic importance weight, sentiment matching degree, and timeliness weight. The node's overall attention weight is mapped to the relevant historical dialogue content, and the weighted average attention of the associated nodes is calculated for each historical dialogue content.
8. The method according to claim 7, characterized in that, Response sequences are generated using a large language model, including: The contextual representation of the current dialogue, the current user's sentiment vector, and the attention distribution of historical dialogue content are fused to serve as input for the large language model. Based on the sentiment category and sentiment intensity value in the current user sentiment representation vector, adjust the temperature parameters and sampling strategy of the large language model to make the sentiment expression of the generated content match the user's current sentiment state; Multiple candidate response sequences are generated using the decoder of a large language model; Analyze explicit sentiment expressions and implicit sentiment cues in candidate responses, and calculate the degree of matching between each candidate response and the current user's sentiment representation vector as the sentiment consistency score; The semantic quality score of each candidate response is calculated based on its semantic coherence, information completeness, and relevance to the dialogue history. The candidate responses are selected as the final output by weighting and sorting the responses based on their sentiment consistency score and semantic quality score.
9. A human-computer interaction system based on a large language model, characterized in that, include: The first processing module is used to: extract raw semantic features from the user's current input and obtain semantic representations of multi-turn dialogue history. The second processing module is used to: input the original semantic features and the semantic representation of the multi-turn dialogue history into the context encoding network to obtain the context representation of the current dialogue; The third processing module is used to: extract a historical sentiment state sequence from the multi-turn dialogue history; the historical sentiment state sequence includes the sentiment intensity value and sentiment category label of each turn of dialogue; The fourth processing module is used to: generate a current user sentiment representation vector with sentiment intensity dimension and confidence index based on the context representation of the current dialogue and the historical sentiment state sequence; The fifth processing module is used to: construct a hierarchical memory structure based on the current user's emotion representation vector and the context representation of the current dialogue; the hierarchical memory structure includes a semantic memory component and an emotion memory component; The sixth processing module is used to: adjust the degree of attention paid to the historical dialogue content stored in the semantic memory component according to the hierarchical memory structure; The seventh processing module is used to: generate a response sequence based on the adjusted attention level, the hierarchical memory structure, and the contextual representation of the current dialogue using a large language model, and output the response sequence to the user.
Citation Information
Patent Citations
Generative dialogue system based on large language model
CN119782490A
Digital human emotion perception and dynamic response method, system and device and storage medium
CN119884327A
Cited By
AI active care intelligent interaction method based on long-term memory and multi-round dialogues
CN122113938A
Accompanying robot collaborative interaction system based on emotional state portrait and hierarchical memory
CN122116884A