Large model similarities enhancement method based on activation subspace guidance
By using orthogonal basis matrix splitting and enhanced sentiment-color sub-vectors in a large language model, the problems of high resource consumption and difficulty in balancing specialization and versatility are solved, and stable and efficient empathy generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-01
AI Technical Summary
Existing large language models suffer from high computational resource consumption and high deployment costs when improving empathy levels, and they also struggle to balance specialization and generality, easily leading to the problem of 'catastrophic forgetting'.
By obtaining the orthogonal basis matrix, the original activation vector is split into a first sub-vector representing emotional color and a second sub-vector representing semantic information. The first sub-vector is then enhanced in a fine-grained intervention subspace and fused with the second sub-vector to form a fused vector to determine the target response.
It reduces the amount of computational data and deployment costs, improves the stability and professionalism of model empathy generation, avoids 'catastrophic forgetting', and balances professionalism and versatility.
Smart Images

Figure CN121959005A_ABST
Abstract
Description
A method for enhancing empathy in large models based on activation subspace guidance Technical Field
[0001] This application belongs to the field of artificial intelligence technology, and more specifically, relates to a method for enhancing empathy in large models based on activation subspace guidance. Background Technology
[0002] With the widespread application of large language models in scenarios such as dialogue, psychological counseling, and emotional support, improving the model's empathy level in interaction has become a core requirement for enhancing user experience. Currently, mainstream technical solutions primarily optimize both model input and model parameters.
[0003] At the model input level, the In-Context Learning (ICL) method is used to attach highly empathetic dialogue examples as prompts before user input. Although this method is simple and flexible, its effectiveness depends heavily on the quality of the examples and the capacity of the context window. Moreover, its guiding role is limited to the current single dialogue and cannot sustainably and stably shape the model's empathy generation pattern.
[0004] At the model parameter level, supervised fine-tuning (SFT) is used to fine-tune the model using high-quality, manually labeled empathic dialogue data; and direct preference optimization (DPO) is used to construct human preference data to optimize the model's alignment strategy. However, both methods involve high computational data and deployment costs, requiring significant GPU resources for full-parameter or large-scale parameter training, resulting in long cycles that hinder rapid iteration and application deployment. Furthermore, they are prone to "catastrophic forgetting," where while optimizing empathy specifically, the model's performance often degrades on general tasks such as logical reasoning and fact-finding, making it difficult to balance specialization and general applicability. Summary of the Invention
[0005] The purpose of this application is to provide a large model empathy enhancement method based on activation subspace guidance, so as to reduce resource consumption and improve the stability and professionalism of model empathy generation.
[0006] A first aspect of this application provides a large-scale empathy enhancement method based on activation subspace guidance, comprising: obtaining an original activation vector based on a user's query instruction and a pre-trained large language model, wherein the original activation vector is used to represent the tendency of an initial response with inherent semantic and emotional information; obtaining an orthogonal basis matrix, and projecting the original activation vector onto a corresponding empathy subspace based on the orthogonal basis matrix to split the original activation vector into a first sub-vector and a second sub-vector, wherein the first sub-vector is used to represent the emotional color of the initial response and the second sub-vector is used to represent the semantic information of the initial response; enhancing the first sub-vector to obtain an enhanced first sub-vector, and fusing the enhanced first sub-vector with the second sub-vector to obtain a fused vector; and determining the target response of the query instruction based on the fused vector.
[0007] A second aspect of this application provides a large-scale empathy enhancement device based on activation subspace guidance, comprising: an original activation vector determination module, configured to obtain an original activation vector based on a user's query instruction and a pre-trained large language model, wherein the original activation vector is used to characterize the tendency of an initial response with inherent semantic and emotional information; an original activation vector splitting module, configured to obtain an orthogonal basis matrix and, based on the orthogonal basis matrix, project the original activation vector onto a corresponding empathy subspace to split the original activation vector into a first sub-vector and a second sub-vector, wherein the first sub-vector is used to characterize the emotional color of the initial response and the second sub-vector is used to characterize the semantic information of the initial response; a sub-vector enhancement module, configured to enhance the first sub-vector to obtain an enhanced first sub-vector, and fuse the enhanced first sub-vector with the second sub-vector to obtain a fused vector; and a target response instruction determination module, configured to determine the target response of the query instruction based on the fused vector.
[0008] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the steps of the above-described large model empathy enhancement method based on activation subspace guidance.
[0009] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described large model empathy enhancement method based on activation subspace guidance.
[0010] The beneficial effects of the large-scale empathy enhancement method based on activation subspace guidance provided in this application are as follows: This application projection method projects the original activation vector using an orthogonal basis matrix, splitting it into a first sub-vector representing emotional color and a second sub-vector representing semantic information. The first sub-vector is enhanced and then fused with the second sub-vector to obtain a fused vector, which is then used to determine the target response. This embodiment processes emotional and semantic information at the vector level, which can more persistently and stably influence the empathy performance of the model when generating responses. Furthermore, this embodiment does not require large-scale parameter training, greatly reducing the amount of computational data and deployment costs, which is conducive to rapid iteration and application deployment. Based on the original activation vector, this embodiment separates the vector expressing emotion from the vector expressing semantic information and enhances the vector expressing emotion (the part of the vector related to empathy) without changing the semantic information, thus obtaining a target response with enhanced empathy and unchanged semantic information. This does not excessively interfere with the original general capabilities of the model and can also avoid the problem of "catastrophic forgetting" while improving empathy, thus balancing specialization and versatility. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 is a flowchart illustrating a large model empathy enhancement method based on activation subspace guidance according to an embodiment of this application; Figure 2 is a flowchart illustrating another large model empathy enhancement method based on activation subspace guidance according to an embodiment of this application; Figure 3 is a structural block diagram illustrating a large model empathy enhancement device based on activation subspace guidance according to an embodiment of this application; Figure 4 is a schematic block diagram illustrating an electronic device according to an embodiment of this application. Detailed Implementation
[0013] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0014] It should be noted that the terms "first," "second," etc., used in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those illustrated or described herein.
[0015] To make the objectives, technical solutions, and advantages of this application clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.
[0016] Please refer to Figure 1. Figure 1 is a flowchart of a large model empathy enhancement method based on activation subspace guidance provided in an embodiment of this application. The method may include: S101: Obtaining the original activation vector according to the user's query instruction and through a pre-trained large language model.
[0017] In this embodiment, the original activation vector is used to characterize the tendency of the initial response with inherent semantic and emotional information.
[0018] In this embodiment, the user's query command is input into a pre-trained large language model, and an original activation vector is generated according to the inference stage of the large model. The original activation vector encodes the model's tendency to generate an initial response.
[0019] S102: Obtain the orthogonal basis matrix, and based on the orthogonal basis matrix, project the original activation vector onto the corresponding empathic subspace to split the original activation vector into a first subvector and a second subvector.
[0020] In this embodiment, a k-dimensional linear empathy center subspace can be spanned by the column vectors of the orthogonal basis matrix. This empathy center subspace is used as a fine-grained intervention subspace S. This fine-grained intervention subspace S is used to project the real-time activation vector into this subspace, separating the projection components directly related to the empathy center. The orthogonal basis matrix can be spanned by the eigenvectors of the sensitive layer and the principal component vectors.
[0021] In this embodiment, after generating the original activation vector, the original activation vector is projected onto the fine-grained intervention subspace S to perform real-time activation vector intervention. The real-time activation vector intervention can be performed by: projecting the original activation vector onto the fine-grained intervention subspace S based on the orthogonal basis matrix to obtain a first sub-vector (projection vector) and a second sub-vector (general semantic orthogonal complement component) to enhance the components related to emotion (projection vector) and suppress irrelevant components.
[0022] In this embodiment, the activation vector refers to the key intermediate representation generated by the large language model during the forward propagation process. Specifically, when a query command is input into the model, the query command data flows sequentially through each layer of the model (e.g., each layer of the Transformer); after processing its input, each layer outputs a vector with a fixed dimension, which is the "activation vector" corresponding to that layer.
[0023] After a query instruction (e.g., first-type instruction information or second-type instruction information) is input into the large model, each layer of the large model will obtain an activation vector. This activation vector carries the model's understanding of the input query instruction sample and its internal state. This activation vector is used as the basis for calculating the input of the next layer and the final output, until the final layer outputs an enhanced activation vector. This enhanced activation vector is then mapped to a text vocabulary to obtain the target response of the query instruction.
[0024] The process of determining the orthogonal basis matrix is as follows: For each query instruction sample, an orthogonal basis matrix determination operation is performed to obtain the orthogonal basis matrix corresponding to the query instruction; the orthogonal basis matrix determination operation includes: obtaining the first type of instruction information and the second type of instruction information corresponding to the query instruction sample; the sentiment matching degree between the first type of instruction information and the query instruction sample is greater than a preset threshold, and the sentiment matching degree between the second type of instruction information and the query instruction sample is not greater than a preset threshold; based on the query instruction sample and the first type of instruction information, and through the large language model to be enhanced, the first empathy average activation vector corresponding to each layer in the model is obtained; based on the first empathy average activation vector, the first empathy average activation vector is obtained... Obtain the first set of activation values; based on the query instruction sample and the second type of instruction information, and through the large language model to be enhanced, obtain the second empathy average activation vector corresponding to each layer in the model; obtain the second set of activation values based on the second empathy average activation vector; determine the sensitive layer and the guiding vector set based on the first and second sets of activation values; extract the sensitive layer feature vector based on the sensitive layer; the sensitive layer is determined based on the cosine similarity between the first and second empathy average activation vectors; perform principal component analysis on the guiding vector set to extract the principal component vectors; determine the orthogonal basis matrix corresponding to the query instruction based on the sensitive layer feature vector and the principal component vector.
[0025] In this embodiment, the first empathy average activation vector can be obtained in the following way: input the first type of instruction information into the large language model to be enhanced (the large language model without intervention by the orthogonal basis matrix). When the model processes the input first type of instruction information, for each layer of the model, obtain the activation vector corresponding to that layer, and calculate the average value of each activation vector to obtain the first empathy average activation vector of that layer.
[0026] The first empathy average activation vector can characterize the central trend of the activation pattern of this layer when the model processes the first type of instruction information (instructions with high emotional matching degree). It can also be understood as the common emotional features or general emotional representations triggered by the query instruction samples.
[0027] In this embodiment, the second empathy average activation vector can be obtained in the following way: the second type of instruction information is input into the large language model to be enhanced. When the model processes the input second type of instruction information, for each layer of the model, the activation vector corresponding to that layer is obtained, and the average value of each activation vector is calculated to obtain the second empathy average activation vector of that layer.
[0028] The second empathy average activation vector can characterize the central trend of the activation pattern of this layer when the model processes the second type of instruction information (low emotional matching instruction). It can also be understood as the common emotional features or general emotional representations triggered by the query instruction samples.
[0029] In this embodiment, the first activation value set is used to characterize the set of first empathic average activation vectors of each layer in the model, and the second activation value set is used to characterize the set of second empathic average activation vectors of each layer in the model.
[0030] In this embodiment, the first empathy average activation vector and the second empathy average activation vector are calculated once at each layer of the model. Based on the cosine similarity between the first and second empathy average activation vectors, the minimum cosine similarity is selected from all cosine similarities, and the layer corresponding to the minimum cosine similarity is determined as the sensitive layer n. In this embodiment, a representative vector can be extracted from the average activation vector of the sensitive layer (for example, the average activation vector can be the first empathy average activation vector, the second empathy average activation vector, or a combination of both) as the sensitive layer feature vector.
[0031] In this embodiment, the large language model to be enhanced can be understood as a model without injected intervention vectors (orthogonal basis matrices).
[0032] This embodiment obtains various types of instruction information in the following way: Referring to Figure 2, in this embodiment, the differences in the representation of the concept of "empathy" within the model are first captured. Based on each query instruction, two sets of instruction information that are semantically corresponding but have completely different emotional polarities are pre-constructed. The instruction information sets may include a first type of instruction information and a second type of instruction information. The first type of instruction information includes N instruction information D with a strong empathic tone and an emotional matching degree greater than a preset threshold. high (Instruction information corresponding to high empathy), the second type of instruction information includes N semantically identical but emotionally matched instructions D with a cold tone or merely stating facts and an emotional matching degree not greater than a preset threshold. low(Instruction information corresponding to low empathy).
[0033] In this embodiment, two types of instruction information (first type and second type) are input into the large model to be enhanced (e.g., a Transformer architecture model) for forward computation. To eliminate random noise caused by specific query instruction samples, this embodiment extracts the high-dimensional vectors (e.g., 4096-dimensional vectors) of all query instruction samples in each layer l (l∈{1,2,...,L}, where L represents the total number of layers in the model) of the model, and performs an arithmetic mean on all the high-dimensional vectors in the layer to obtain the first empathy average activation vector corresponding to that layer. And the second empathy average activation vector corresponding to this layer. The average activation vector of the first empathy center is: , i represents the i-th instruction of type I. This represents the activation vector of the l-th layer after the i-th first-type instruction is input into the model. The average activation vector of the second empathy center is: , i represents the i-th type II instruction information, This represents the activation vector of the l-th layer after the i-th second-type instruction is input into the model.
[0034] In this embodiment, all first empathy average activation vectors are set together to obtain the first activation value set H. high Set all the average activation vectors of the second empathy to obtain the set of second activation values H. low .
[0035] In one implementation, determining the guide vector set based on the first activation value set and the second activation value set includes: for each layer of the large language model to be enhanced, determining the initial guide vector for that layer based on the difference between the first empathy average activation vector and the second empathy average activation vector corresponding to that layer; and aggregating all the initial guide vectors to obtain the guide vector set.
[0036] This embodiment calculates the difference vector between the first empathy mean activation vector and the second empathy mean activation vector for each layer of the large language model to be enhanced. (Also known as: initial guiding vector), the difference vectors corresponding to each layer are collected to obtain the full layer guiding vector set V.
[0037] In the l-th layer, the difference vector between the first empathy average activation vector and the second empathy average activation vector is calculated as follows: .
[0038] In one implementation, determining the sensitive layer based on the first set of activation values and the second set of activation values includes: for each layer of the large language model to be enhanced, calculating the cosine similarity corresponding to the layer based on the first average activation vector of empathy and the second average activation vector of empathy, and using the cosine similarity calculation formula; selecting the layer corresponding to the smallest cosine similarity among all cosine similarities, and taking that layer as the sensitive layer.
[0039] In this embodiment, the cosine similarity between the first and second empathy center average activation vectors is calculated once at each layer of the model. The layer with the smallest cosine similarity is selected from all cosine similarities and designated as the sensitive layer n. The cosine similarity calculation formula in this embodiment is: .
[0040] In this embodiment, the cosine similarity is used to measure the directional difference between the first empathy average activation vector and the second empathy average activation vector in each layer of the model. The lower the difference value, the greater the difference in the activation patterns of the first empathy average activation vector and the second empathy average activation vector in that layer, which means that the layer is better able to distinguish the representation of empathy.
[0041] This embodiment extracts the difference vector of the sensitive layer n. Using this difference vector as the first basis vector of the subspace can reflect the core representation law of empathy in the sensitive layer of the model, and provide a precise local anchor point for the subsequent determination of the fine-grained intervention subspace S.
[0042] In this embodiment, the layer with the lowest cosine similarity is extracted as the sensitive layer. This can accurately locate the layer in the model that is most sensitive to the feature of empathy, providing a basis for subsequent intervention on the original activation vector based on the orthogonal basis matrix.
[0043] This embodiment can avoid interference from irrelevant levels, achieve low-resource, high-efficiency empathy enhancement, and at the same time ensure the accuracy and stability of the intervention.
[0044] In one implementation, principal component analysis is performed on the set of guiding vectors to extract principal component vectors, including: centering the set of guiding vectors to obtain a centered guiding vector matrix; performing singular value decomposition on the centered guiding vector matrix to obtain singular values and eigenvectors; wherein the square of the singular value is used to characterize the strength of the variability of the data represented by the corresponding eigenvector; calculating the explanatory variance contribution rate of each eigenvector based on the singular values; sorting all eigenvectors in descending order according to their corresponding explanatory variance contribution rates, and selecting the first preset number of eigenvectors as principal component vectors.
[0045] In this embodiment, the set of guiding vectors is centered to obtain a centered guiding vector matrix. For example, if the set of guiding vectors contains c guiding vectors, each of which is n-dimensional, all guiding vectors are arranged by rows to obtain the original matrix. The mean value of each column (each feature dimension) in the original matrix is obtained, resulting in a mean vector μ. This mean vector is then subtracted from each row of the original matrix to obtain the centered guiding vector matrix, which has a dimension of c×n.
[0046] In this embodiment, the offset in each dimension is eliminated by centering, so that the mean of the data is zero, which makes it easier to extract the main direction of variation.
[0047] This embodiment performs singular value decomposition on the centered guiding vector matrix. The singular value decomposition can be performed in the following way: ,in, Let U denote the centered guiding vector matrix, and let U denote a c×c left singular matrix whose column vectors are left singular vectors. Let represent a c×n singular value matrix, and W represent an n×n right singular matrix whose column vectors are eigenvectors.
[0048] In this embodiment, the eigenvalues (variances) corresponding to the singular values are calculated according to the eigenvalue calculation formula, the total variance is determined according to the eigenvalues, and the explanatory variance contribution rate of each eigenvector is determined according to the ratio of the eigenvalues to the total variance.
[0049] The formula for calculating eigenvalues can be: ,in, This represents the eigenvalue of the k-th principal component. Let represent the k-th singular value, k=1,2,...,r, where r represents the rank of the matrix and c represents the number of guiding vectors.
[0050] In this embodiment, all feature vectors are sorted in descending order according to their corresponding explanatory variance contribution rates, the number of principal components to be retained m (i.e., the preset number) is determined, and the first m feature vectors after sorting are selected to form a set of principal component vectors.
[0051] For example, principal component analysis is performed on the entire set of guided vectors to construct a guided vector matrix, and singular value decomposition is performed to extract the top m principal component vectors p1, p2, ... p with the largest explained variance. m .
[0052] In one implementation, determining the orthogonal basis matrix corresponding to the query instruction based on the sensitive layer feature vector and the principal component vector includes: concatenating the sensitive layer feature vector and the principal component vector to obtain a concatenated vector group; performing Schmitt orthogonalization on the concatenated vector group to obtain an orthogonalized vector group; and using the orthogonalized vector group as column vectors to form an orthogonal basis matrix.
[0053] In this embodiment, the difference vector of the sensitive layer is... Concatenate the vectors with the m principal components to obtain a concatenated vector group. Perform Schmitt orthogonalization on the concatenated vector group to construct an orthogonal basis matrix of dimension (m+1). The space spanned by this orthogonal basis matrix is taken as the fine-grained intervention subspace S in this embodiment.
[0054] This embodiment utilizes the cosine similarity minimization algorithm to automatically locate the layer in the model that is most sensitive to empathy features, and extracts the local difference vector of that layer (the difference vector of the sensitive layer). Furthermore, principal component analysis (PCA) was used to extract global common features p1, p2, ... p from the activation differences across all layers. m The global principal component vector is constructed based on the extracted m global common features. This global principal component vector represents the global common pattern of empathy features in each layer of the model. In this embodiment, the difference vector of the above sensitive layer and the global principal component vector are orthogonalized by Schmitt to form an orthogonal basis matrix. Based on this orthogonal basis matrix, a dedicated intervention subspace of dimension (m+1) is constructed, namely the fine-grained intervention subspace. The construction method of the fine-grained intervention subspace in this embodiment captures the most significant local features, takes into account the global semantic flow, and ensures that each dimension within the subspace is independent, which can accurately and stably separate activation features related to empathy.
[0055] In this embodiment, when the model processes the user's input query command and calculates it to the sensitive layer, it obtains the current original activation vector. Based on the above orthogonal basis matrix and according to the projection component calculation formula, the projection components are calculated, and the original activation vector is projected onto the fine-grained intervention subspace S; the projection component calculation formula can be: ,in, Denotes the first subvector. This represents a fine-grained intervention subspace. This represents the original activation vector. Based on this first sub-vector (projected component) and the original activation vector, and using the orthogonal complement component calculation formula, the second sub-vector (orthogonal complement component) is calculated; the orthogonal complement component calculation formula can be: ,in, This represents the second subvector (orthogonal complement), which is a general semantic orthogonal complement independent of empathy.
[0056] S103: Enhance the first sub-vector to obtain the enhanced first sub-vector, and then merge the enhanced first sub-vector with the second sub-vector to obtain the merged vector.
[0057] In one implementation, the enhanced first sub-vector and the second sub-vector are fused to obtain a fused vector, including: obtaining the fused vector based on the first sub-vector and the second sub-vector using a preset first fusion formula, wherein the preset first fusion formula is: ,in, This represents the fused vector. Denotes the second subvector. Indicates the enhancement coefficient. Denotes the first subvector. This represents the first subvector after enhancement.
[0058] This embodiment can also obtain a fused vector based on the enhanced first sub-vector and the original activation vector, using a preset second fusion formula. The preset second fusion formula is as follows: ,in, This represents the original activation vector.
[0059] In this embodiment, the first sub-vector can be a projection component, which reflects the emotional tone of the initial response; the second sub-vector can be an orthogonal complement component, which reflects the semantic information of the initial response.
[0060] This embodiment can apply an enhancement coefficient to the projection component to obtain the enhanced first sub-vector; or superimpose guiding energy to obtain the enhanced first sub-vector.
[0061] In this embodiment, an enhanced first sub-vector is obtained by applying an enhancement coefficient to the projection component, and then the enhanced first sub-vector is fused with a second sub-vector to obtain a fused activation vector. The fused activation vector can be obtained in the following way: , This represents the fused vector. This represents the second subvector (orthogonal complement component). This represents the enhancement factor, which can be dynamically adjusted based on the emotional intensity of the query command. This represents the first subvector (projected component). This represents the first subvector after enhancement.
[0062] The method for obtaining the fused activation vector by superimposing guiding energy can be as follows: ,in, This represents the original activation vector.
[0063] In this embodiment, the method of obtaining the fused activation vector by superimposing guiding energy can also be expressed as: ,in, , , Let S denote the projection, and let S denote the fine-grained intervention subspace. This represents the difference vector.
[0064] In this embodiment, the fused vector The calculation continues in the next layer of the model.
[0065] This embodiment explicitly decomposes the real-time activation vector into a first sub-vector (projection component) and a second sub-vector (orthogonal complement component). This embodiment only enhances or adjusts the projection component that falls within the aforementioned (m+1)-dimensional empathy subspace (fine-grained intervention subspace), while strictly maintaining the orthogonal complement component representing general semantics (e.g., grammatical structure, factual knowledge). This mechanism achieves mathematical decoupling between empathy enhancement and general capabilities, fundamentally solving the technical challenge of balancing "high emotional intelligence" and "high intellectual intelligence" in traditional methods.
[0066] In this embodiment, the fine-grained intervention subspace serves as a dedicated control channel within the model related to "empathy." By projecting the real-time activation vector onto this subspace, the projection component directly related to empathy can be isolated. Only this projection component is enhanced or adjusted, avoiding interference with the model's ability to process general semantics such as facts and logic. Since this subspace is strictly orthogonal (mathematically independent) to the orthogonal complement representing general semantics, only the projection component within the subspace is adjusted during intervention, while the orthogonal complement carrying grammatical structure and factual knowledge remains unchanged. This solves the "catastrophic forgetting" problem caused by traditional fine-tuning, ensuring that the model improves empathy without sacrificing its original general task performance.
[0067] Since the orthogonal complementary components carrying facts and logic remain unchanged in this embodiment, this embodiment ensures that the model does not lose its original general semantic processing capabilities while generating highly empathetic responses.
[0068] S104: Based on the fused vector, determine the target response for the query command.
[0069] In this embodiment, the fused vector is activated on the sensitive layer of the model, so that the model outputs a target response that conforms to the first type of instruction information (high empathy) feature corresponding to the fused vector.
[0070] This embodiment employs a non-parametric method guided by activation values during inference, abandoning backpropagation and weight update processes. Unlike traditional Prompt engineering, this embodiment operates on the semantic representation layer within the model, resulting in more persistent effects and freedom from context window limitations. The method provided in this embodiment offers a low-resource implementation architecture that requires no training, is plug-and-play, and extracts features with only a few instruction pairs, enabling its deployment at extremely low cost in various computationally constrained scenarios.
[0071] As can be seen from the above, this embodiment obtains the original activation vectors that represent the inherent semantic and emotional information of the query command through a pre-trained large language model, then obtains the orthogonal basis matrix, spans the orthogonal basis matrix to form a fine-grained intervention subspace, and projects the original activation vectors onto this fine-grained intervention subspace, accurately splitting them into a first sub-vector representing emotional color and a second sub-vector representing semantic information. This embodiment accurately splits the original activation vectors within the fine-grained intervention subspace, enabling specialized enhancement of the emotional color of empathy, avoiding excessive interference with semantic information, and thus improving the accuracy of empathy representation.
[0072] This embodiment constructs a stable processing flow by manipulating vector levels, starting from the intrinsic characteristics of query commands. Compared to single-vector intervention, multi-dimensional subspaces can capture rich details of empathy (e.g., different aspects such as emotion recognition and soothing strategies). Each time a query command is processed, vector splitting, enhancement, and fusion are performed according to the same steps, unaffected by random factors such as the context of a single dialogue. This makes the model-generated responses more natural and emotionally resonant, and can persistently and stably influence the empathy performance of the model's generated responses, avoiding templated and rigid responses and providing users with a more consistent and reliable interactive experience.
[0073] This embodiment does not rely on large-scale labeled data. Instead, it utilizes the pre-stored correspondence between various sentiments and orthogonal basis matrices in the orthogonal basis matrix library, as well as the information of the original activation vectors themselves, to perform processing. This reduces the dependence on external data and further reduces the cost of data acquisition and processing.
[0074] This embodiment can accurately process emotional and semantic information and does not rely on specific data or large-scale parameter training, thus exhibiting better adaptability and flexibility. It can be applied to various scenarios such as dialogue, psychological counseling, and emotional companionship. In different scenarios, it can generate a target response with an appropriate level of empathy based on the inherent emotional and semantic features of the query command, meeting diverse user needs.
[0075] The method provided in this embodiment is widely applicable to various human-computer dialogue systems requiring high emotional intelligence interaction, significantly enhancing the practical application value of large models in the field of affective computing. For example, in intelligent psychological counseling and guidance systems, it can serve as a core dialogue engine, helping counselors accurately capture users' negative emotions (e.g., anxiety, depression) and generate empathetic, accepting, and guiding responses, establishing a deeper counselor-client relationship and assisting human counselors in initial intervention. In emotionally-oriented intelligent customer service scenarios, it can be applied to enterprise customer service, automatically intervening and generating highly empathetic responses with a soothing nature when user emotions are detected as agitated or dissatisfied, effectively calming user anger and improving customer satisfaction assessment (CSAT) and complaint handling efficiency. In virtual companionship and role-playing scenarios, it can be used to create virtual companions or game NPCs with "personal charm," transforming them from cold, impersonal question-and-answer machines into intelligent partners capable of understanding player emotions and providing emotional value. It can also be applied to model enhancement scenarios in low-resource environments. Since this embodiment does not require model retraining, it is particularly suitable for edge computing devices with limited computing power or private deployment scenarios. Enterprises or developers can directly integrate this embodiment as a lightweight "empathy plugin" into the inference process of existing open-source models (such as LLaMA, Qwen, etc.), making it plug-and-play and low-cost to upgrade general large models to emotion-specific vertical models.
[0076] Based on the same inventive concept, this application also provides a large model empathy enhancement device for implementing the large model empathy enhancement method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations of the one or more large model empathy enhancement device embodiments provided below can be found in the limitations of the large model empathy enhancement method described above, and will not be repeated here.
[0077] This application provides a large model empathy enhancement device based on activation subspace guidance, as shown in Figure 3. The large model empathy enhancement device 30 based on activation subspace guidance includes: an original activation vector determination module 31, an original activation vector splitting module 32, a sub-vector enhancement module 33, and a target response instruction determination module 34.
[0078] The original activation vector determination module 31 is used to obtain the original activation vector based on the user's query instruction and a pre-trained large language model. The original activation vector is used to represent the tendency of the initial response with inherent semantic and emotional information. The original activation vector splitting module 32 is used to obtain an orthogonal basis matrix and, based on the orthogonal basis matrix, project the original activation vector onto the corresponding empathy subspace to split the original activation vector into a first sub-vector and a second sub-vector. The first sub-vector is used to represent the emotional color of the initial response, and the second sub-vector is used to represent the semantic information of the initial response. The sub-vector enhancement module 33 is used to enhance the first sub-vector to obtain an enhanced first sub-vector, and then fuse the enhanced first sub-vector with the second sub-vector to obtain a fused vector. The target response instruction determination module 34 is used to determine the target response of the query instruction based on the fused vector.
[0079] In one embodiment of this application, when obtaining the orthogonal basis matrix, the original activation vector splitting module 32 is specifically used for: performing an orthogonal basis matrix determination operation for each query instruction sample to obtain the orthogonal basis matrix corresponding to the query instruction; wherein, the orthogonal basis matrix determination operation includes: obtaining first type instruction information and second type instruction information corresponding to the query instruction sample; the sentiment matching degree between the first type instruction information and the query instruction sample is greater than a preset threshold, and the sentiment matching degree between the second type instruction information and the query instruction sample is not greater than a preset threshold; obtaining the first empathy average activation vector corresponding to each layer in the model based on the query instruction sample and the first type instruction information, and through the large language model to be enhanced; obtaining the first empathy average activation vector based on the first empathy average activation vector. The first activation value set; based on the query instruction sample and the second type of instruction information, and through the large language model to be enhanced, the second empathy average activation vector corresponding to each layer in the model is obtained; the second activation value set is obtained based on the second empathy average activation vector; the sensitive layer and the guiding vector set are determined based on the first activation value set and the second activation value set; the sensitive layer feature vector is extracted based on the sensitive layer; the sensitive layer is determined based on the cosine similarity between the first empathy average activation vector and the second empathy average activation vector; principal component analysis is performed on the guiding vector set to extract the principal component vectors; the orthogonal basis matrix corresponding to the query instruction is determined based on the sensitive layer feature vector and the principal component vector; the orthogonal basis matrix library is determined based on the orthogonal basis matrices corresponding to all query instructions.
[0080] In one embodiment of this application, in determining the guide vector set based on the first activation value set and the second activation value set, the original activation vector splitting module 32 is specifically used to: for each layer of the large language model to be enhanced, determine the initial guide vector of the layer based on the difference between the first empathy average activation vector and the second empathy average activation vector corresponding to the layer; and set all the initial guide vectors together to obtain the guide vector set.
[0081] In one embodiment of this application, a sensitive layer is determined based on a first set of activation values and a second set of activation values. The original activation vector splitting module 32 is specifically used to: for each layer of the large language model to be enhanced, calculate the cosine similarity corresponding to the layer based on the first empathy average activation vector and the second empathy average activation vector corresponding to the layer, and calculate the cosine similarity corresponding to the layer using the cosine similarity calculation formula; select the layer corresponding to the smallest cosine similarity among all cosine similarities, and take that layer as the sensitive layer.
[0082] In one embodiment of this application, principal component analysis is performed on the guiding vector set to extract principal component vectors. The original activation vector splitting module 32 is specifically used for: centering the guiding vector set to obtain a centered guiding vector matrix; performing singular value decomposition on the centered guiding vector matrix to obtain singular values and eigenvectors; calculating the explanatory variance contribution rate of each eigenvector based on the singular values; sorting all eigenvectors in descending order according to their corresponding explanatory variance contribution rates, and selecting the first preset number of eigenvectors as principal component vectors.
[0083] In one embodiment of this application, the orthogonal basis matrix corresponding to the query instruction is determined based on the sensitive layer feature vector and the principal component vector. The original activation vector splitting module 32 is specifically used to: concatenate the sensitive layer feature vector and the principal component vector to obtain a concatenated vector group; perform Schmitt orthogonalization on the concatenated vector group to obtain an orthogonal vector group; and use the orthogonal vector group as column vectors to form an orthogonal basis matrix.
[0084] In one embodiment of this application, the enhanced first sub-vector and the second sub-vector are fused to obtain a fused vector. The sub-vector enhancement module 33 is specifically used to: fuse the enhanced first sub-vector and the second sub-vector according to a preset fusion algorithm to obtain a fused vector. The preset fusion algorithm includes: a preset first fusion formula and a preset second fusion formula; wherein, the fused vector is obtained based on the first sub-vector and the second sub-vector and through the preset first fusion formula. The preset first fusion formula is: ,in, This represents the fused vector. Denotes the second subvector. Indicates the enhancement coefficient. Denotes the first subvector. This represents the first subvector after enhancement.
[0085] This embodiment significantly reduces deployment costs and improves computational efficiency. Feature extraction can be completed by constructing only a small number of high and low empathy instruction pairs, and the intervention process involves only simple linear algebra operations (vector projection and addition), without the need for complex backpropagation. This allows the model to enhance empathy without consuming huge amounts of power and GPU computing resources, greatly lowering the R&D and deployment threshold for enterprises, and is especially suitable for latency-sensitive real-time dialogue systems.
[0086] This embodiment effectively solves the problem of "catastrophic forgetting" and achieves perfect compatibility between empathy and general abilities. By decomposing the activation vector, this embodiment explicitly defines the "empathy intervention zone" (projective component) and the orthogonal complement component. This mechanism mathematically ensures that while the model is guided to generate high-EQ responses, its original grammatical structure, logical chains, and factual knowledge (i.e., information orthogonal to the empathy subspace) remain unaffected. This method significantly improves empathy scores while incurring almost zero performance loss on general tasks, outperforming traditional full-parameter fine-tuning methods.
[0087] This embodiment provides more refined and stable emotion control capabilities. Utilizing a dimensional subspace rather than a single vector, it captures rich details of empathy features (e.g., different aspects such as emotion recognition and soothing strategies). This fine-grained control makes the model-generated responses more natural, varied, and emotionally resonant, avoiding rigid, template-based responses and significantly improving the user experience of human-computer interaction.
[0088] Referring to Figure 4, which is a schematic block diagram of an electronic device provided in an embodiment of this application, the electronic device 400 in this embodiment shown in Figure 4 may include: one or more processors 401, one or more input devices 402, one or more output devices 403, and one or more memories 404. The processors 401, input devices 402, output devices 403, and memories 404 communicate with each other via a communication bus 405. The memories 404 are used to store computer programs, which include program instructions. The processors 401 are used to execute the program instructions stored in the memories 404. The processors 401 are configured to invoke the program instructions to execute the functions of each module / unit in the above-described device embodiments, such as the functions of the original activation vector determination module 31, the original activation vector splitting module 32, the sub-vector enhancement module 33, and the target response instruction determination module 34 shown in Figure 3.
[0089] It should be understood that, in the embodiments of this application, the processor 401 may be a central processing unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0090] Input device 402 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint orientation information), a microphone, etc., and output device 403 may include a display (LCD, etc.), a speaker, etc.
[0091] The memory 404 may include read-only memory and random access memory, and provides instructions and data to the processor 401. A portion of the memory 404 may also include non-volatile random access memory. For example, the memory 404 may also store information such as the original activation vector, orthogonal basis matrix, first sub-vector, second sub-vector, and fused vector.
[0092] In specific implementations, the processor 401, input device 402, and output device 403 described in the embodiments of this application can execute the implementation method described in the large model empathy enhancement method provided in the embodiments of this application, or they can execute the implementation method of the electronic device described in the embodiments of this application, which will not be repeated here.
[0093] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which includes program instructions. When executed by a processor, the program instructions implement all or part of the processes in the methods described above. Alternatively, the computer program can instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0094] The computer-readable storage medium can be an internal storage unit of the electronic device in any of the foregoing embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., provided on the electronic device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the electronic device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0095] Those skilled in the art will recognize that the modules / units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0096] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the electronic devices and units described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0097] In the several embodiments provided in this application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules, units, or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces or modules / units, or it may be an electrical, mechanical, or other form of connection.
[0098] The modules / units described as separate components may or may not be physically separate. Similarly, the components shown as modules / units may or may not be physical modules / units; they may be located in one place or distributed across multiple network modules / units. Some or all of the modules / units can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.
[0099] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The integrated modules / units described above can be implemented in hardware or in the form of software functional modules / units.
[0100] The above are merely specific embodiments of this application, but the scope of protection 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 scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for enhancing empathy in large models based on activation subspace guidance, characterized in that, include: Based on the user's query, the original activation vector is obtained through a pre-trained large language model. The original activation vector is used to represent the tendency of the initial response with inherent semantic and emotional information. Obtain an orthogonal basis matrix, and based on the orthogonal basis matrix, project the original activation vector onto the corresponding empathy subspace to split the original activation vector into a first sub-vector and a second sub-vector. The first sub-vector is used to represent the emotional tone of the initial response, and the second sub-vector is used to represent the semantic information of the initial response. Enhance the first sub-vector to obtain an enhanced first sub-vector, and fuse the enhanced first sub-vector with the second sub-vector to obtain a fused vector. Based on the fused vector, determine the target response of the query instruction.
2. The method as described in claim 1, characterized in that, The process of determining the orthogonal basis matrix is as follows: For each query instruction sample, an orthogonal basis matrix determination operation is performed to obtain the orthogonal basis matrix corresponding to the query instruction; wherein, the orthogonal basis matrix determination operation includes: obtaining first-type instruction information and second-type instruction information corresponding to the query instruction sample; the sentiment matching degree between the first-type instruction information and the query instruction sample is greater than a preset threshold, and the sentiment matching degree between the second-type instruction information and the query instruction sample is not greater than a preset threshold; based on the query instruction sample and the first-type instruction information, and through the large language model to be enhanced, the first empathy average activation vector corresponding to each layer in the model is obtained; based on the first empathy average activation vector, the first activation value set is obtained. The process involves: combining the query instruction sample with the second type of instruction information, and obtaining the second empathy average activation vector corresponding to each layer of the large language model to be enhanced; obtaining a second set of activation values based on the second empathy average activation vector; determining a sensitive layer and a set of guiding vectors based on the first and second set of activation values; extracting a sensitive layer feature vector based on the sensitive layer; the sensitive layer being determined based on the cosine similarity between the first and second empathy average activation vectors; performing principal component analysis on the set of guiding vectors to extract principal component vectors; and determining the orthogonal basis matrix corresponding to the query instruction based on the sensitive layer feature vector and the principal component vector.
3. The method as described in claim 2, characterized in that, Determining a set of guiding vectors based on the first set of activation values and the second set of activation values includes: for each layer of the large language model to be enhanced, determining an initial guiding vector for that layer based on the difference between the first average activation vector of empathy and the second average activation vector of empathy corresponding to that layer; and aggregating all the initial guiding vectors to obtain the set of guiding vectors.
4. The method as described in claim 3, characterized in that, Determining a sensitive layer based on the first set of activation values and the second set of activation values includes: for each layer of the large language model to be enhanced, calculating the cosine similarity corresponding to that layer based on the first average activation vector of empathy and the second average activation vector of empathy; selecting the layer corresponding to the smallest cosine similarity among the cosine similarities and using that layer as the sensitive layer.
5. The method as described in claim 2, characterized in that, The step of performing principal component analysis on the set of guiding vectors to extract principal component vectors includes: centering the set of guiding vectors to obtain a centered guiding vector matrix; performing singular value decomposition on the centered guiding vector matrix to obtain singular values and eigenvectors; the square of the singular value is used to characterize the strength of the variability of the data represented by the corresponding eigenvector; calculating the explanatory variance contribution rate of each eigenvector based on the singular value; sorting all eigenvectors in descending order according to their corresponding explanatory variance contribution rates, and selecting the first preset number of eigenvectors as principal component vectors.
6. The method as described in claim 5, characterized in that, The step of determining the orthogonal basis matrix corresponding to the query instruction based on the sensitive layer feature vector and the principal component vector includes: concatenating the sensitive layer feature vector and the principal component vector to obtain a concatenated vector group; performing Schmitt orthogonalization on the concatenated vector group to obtain an orthogonal vector group; and using the orthogonal vector group as column vectors to construct the orthogonal basis matrix.
7. The method as described in claim 1, characterized in that, The step of fusing the enhanced first sub-vector and the second sub-vector to obtain the fused vector includes: obtaining the fused vector based on the first sub-vector and the second sub-vector using the preset first fusion formula, wherein the preset first fusion formula is: ,in, This represents the fused vector. Denotes the second subvector. Indicates the enhancement coefficient. Denotes the first subvector. This represents the first subvector after enhancement.
8. A large-model empathy enhancement device based on activation subspace guidance, characterized in that, include: The original activation vector determination module is used to obtain the original activation vector based on the user's query command and through a pre-trained large language model. The original activation vector is used to characterize the tendency of the initial response with inherent semantic and emotional information. The original activation vector splitting module is used to obtain an orthogonal basis matrix and, based on the orthogonal basis matrix, project the original activation vector onto the corresponding empathy subspace to split the original activation vector into a first sub-vector and a second sub-vector. The first sub-vector is used to characterize the emotional tone of the initial response, and the second sub-vector is used to characterize the semantic information of the initial response. A sub-vector enhancement module is used to enhance the first sub-vector to obtain an enhanced first sub-vector, and to fuse the enhanced first sub-vector with the second sub-vector to obtain a fused vector; The target response instruction determination module is used to determine the target response of the query instruction based on the fused vector.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.