Large language model character shaping method and device, electronic equipment and storage medium

By introducing personality prompts and dialogue content to generate personality adjustment vectors in large language models, the problem of insufficient personalization ability of large language models is solved, and flexible personalized response and dynamic adjustment ability in different situations is achieved.

CN119721126APending Publication Date: 2025-03-28BEIJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202510220601.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing large language models lack personalization capabilities, rely on a large amount of manual annotations and complex prompt information, and have limited dynamic adjustment capabilities, making it difficult to flexibly adjust personalized responses in diverse scenarios.

Method used

By inputting personality prompts and dialogue content into the large language model, a dialogue vector is generated, and a neural network model trained based on historical dialogue data with personality annotations generates personality adjustment vectors, and dynamically adjusts the output of the large language model to achieve personalized response.

Benefits of technology

It realizes flexible and personalized response of large language models in different situations, avoiding relying on a large number of customized data sets and complex prompt information, and the dynamic generation function allows users to adjust the model personality in real time to adapt to various practical application needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119721126A_ABST
    Figure CN119721126A_ABST
Patent Text Reader

Abstract

The invention provides a big language model character shaping method and device, electronic equipment and a storage medium, and belongs to the technical field of data processing.The method comprises the steps that character prompts and dialogue content are input into a big language model, and dialogue vectors are obtained; inputting the dialogue vector into a character vector generator to obtain a character adjustment vector; the character vector generator is a neural network model obtained by training on the basis of a historical dialogue data set with character annotations; inputting the character adjustment vector into a large language model to adjust a first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by a large language model based on the dialogue vector, and the second output vector is an output vector containing character features. According to the big language model character shaping method and device, the electronic equipment and the storage medium provided by the invention, personalized flexible adjustment of the big language model can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of data processing technology, and more specifically, relates to a large language model personality shaping method and device, electronic equipment, and storage medium. Background Art

[0002] The personalization of large language models is the key to improving their efficiency in interacting with humans. However, current research mainly focuses on improving reasoning capabilities, and the personalization capabilities of large language models are insufficient. Existing methods for improving the personalization of large language models have many limitations. For example, character personality relies on a large amount of manual annotation, and personality expression is rigid, making it difficult to adapt to the environment. The details are as follows: Reliance on detailed character prompts: Existing methods generally carefully design complex prompts for each character, covering basic information, background stories, and personality traits. This makes the model too dependent on data and has great difficulty in flexibly adjusting personality.

[0003] Insufficient dynamic adjustment capability: Once the prompt definition is completed, the individual characteristics of the model are fixed and cannot be dynamically adjusted according to actual needs. This limitation makes the model inflexible when facing diverse scenarios. Summary of the invention

[0004] The purpose of the present disclosure is to provide a large language model personality shaping method and device, electronic device, and storage medium to achieve flexible adjustment of the personalization of the large language model.

[0005] A first aspect of the embodiments of the present disclosure provides a method for shaping a large language model personality, comprising: Input personality cues and conversation content into a large language model to obtain a conversation vector; Inputting the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations; The personality adjustment vector is input into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

[0006] A second aspect of the embodiments of the present disclosure provides a large language model personality shaping device, comprising: The first input module is used to input the personality hint and the conversation content into the large language model to obtain the conversation vector; A personality shaping module, used for inputting the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations; The output adjustment module is used to input the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned large language model character shaping method when executing the computer program.

[0008] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the large language model character shaping method are implemented.

[0009] The large language model personality shaping method and device, electronic device, and storage medium provided by the embodiments of the present disclosure have the following beneficial effects: In the disclosed embodiment, a personality vector generator is obtained by learning a large number of dialogues with personality annotations. The personality vector generator can capture the characteristics and rules of different personalities in language expression, thereby generating a personality adjustment vector that matches the input dialogue vector, and adjusting the first output vector output by the large language model based on the personality adjustment vector, so that the large language model can flexibly adjust the personalized response in different situations, avoiding reliance on a large number of customized data sets and complex prompt information. In addition, the dynamic generation function of the present invention enables users to adjust the personalized features of the generated content by inputting personality prompts, and can adjust the personality of the large language model in real time without retraining the large language model to meet various practical application needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0011] Figure 1 A schematic diagram of a process of a large language model character shaping method provided by an embodiment of the present disclosure; Figure 2 A schematic diagram of a training process of a personality evaluator provided in an embodiment of the present disclosure; Figure 3 A schematic diagram of a training process of a personality vector generator provided in an embodiment of the present disclosure; Figure 4 A schematic diagram of a personality adjustment process provided by an embodiment of the present disclosure; Figure 5 A structural block diagram of a large language model character shaping device provided by an embodiment of the present disclosure; Figure 6 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0012] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.

[0013] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, specific embodiments will be described below in conjunction with the accompanying drawings.

[0014] Please refer to Figure 1 , Figure 1 A flowchart of a method for shaping a character using a large language model provided by an embodiment of the present disclosure, the method comprising: S101: Input personality cues and conversation content into a large language model to obtain a conversation vector.

[0015] In this embodiment, the large language model has mastered rich language knowledge and semantic understanding capabilities after pre-training on large-scale text. The personality hint (such as "You are a humorous person") and the conversation content (such as "What's the weather like today") are input together, and the model can encode and integrate this information to generate a conversation vector that contains the basic conversation meaning and preliminary personality tendencies. This step uses the powerful language understanding and feature extraction capabilities of the large language model to provide a vector representation that integrates basic information for subsequent character shaping.

[0016] S102: Input the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations.

[0017] In this embodiment, a personality vector generator can be obtained by inputting a historical conversation data set with personality annotations into a pre-trained neural network for training. The personality vector generator can generate a personality adjustment vector that matches the conversation vector based on the previously learned characteristic patterns of different personalities in conversation. For example, if the "humorous and witty" personality in the historical data tends to use exaggerated and humorous vocabulary expressions when responding to daily greetings, the personality vector generator can generate an adjustment vector representing this humorous expression tendency based on the conversation vector.

[0018] The neural network model used in the training process can be an existing recurrent neural network (RNN), convolutional neural network (CNN), attention mechanism (Transformer) or generative adversarial network (GAN), etc. The historical dialogue dataset with personality annotations can be obtained by manually annotating the historical dialogue dataset or automatically annotating the historical dialogue dataset.

[0019] S103: Input the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

[0020] In this embodiment, the first output vector is an output vector obtained by the large language model based on the dialogue vector. The first output vector contains basic language generation results, but the personality characteristics are not obvious. By inputting the personality adjustment vector into the large language model, the large language model will modify the first output vector according to the personality characteristics in the adjustment vector, thereby outputting a second output vector containing obvious personality characteristics. The second output vector is decoded and output, and a reply content with personality characteristics can be obtained.

[0021] Taking the personality prompt of "humorous and witty" as an example, by inputting the personality adjustment vector into the large language model, the original bland answer can be modified into a humorous answer.

[0022] For example, the existing large language model generates the first output vector, which after decoding may be "Today's weather is nice, sunny and windy." After adding the personality adjustment vector, the second output vector obtained after decoding may be "Hey, look at the weather today, the sun must have eaten a lot of happy nuts, and it is smiling so brightly!".

[0023] It can be concluded from the above that this embodiment obtains a personality vector generator by learning a large number of dialogues with personality annotations. The personality vector generator can capture the characteristics and rules of different personalities in language expression, thereby generating a personality adjustment vector that matches the input dialogue vector, and adjusting the first output vector output by the large language model based on the personality adjustment vector, so that the large language model can flexibly adjust the personalized response in different situations, avoiding reliance on a large number of customized data sets and complex prompt information. In addition, the dynamic generation function of the present invention enables users to adjust the personalized features of the generated content by inputting personality prompts, and can adjust the personality of the large language model in real time without retraining the large language model to meet various practical application needs.

[0024] In one embodiment of the present disclosure, the large language model character shaping method further includes: Input the historical dialogue dataset and personality theory knowledge base of each character into the large language model to obtain the personality annotation of each character; Each personality annotation is added to the historical dialogue dataset of the corresponding character to obtain a historical dialogue dataset with personality annotations.

[0025] In this embodiment, a specific implementation method of obtaining a historical conversation dataset with personality annotations through automatic annotation is provided.

[0026] The large language model has powerful language understanding and analysis capabilities. The historical dialogue datasets of each character contain the dialogue content of different characters in various scenarios. These dialogues are the specific manifestation of the character's personality in language expression. The personality theory knowledge base provides theoretical knowledge on personality dimensions and characteristics, such as the definition and description of openness, conscientiousness, extroversion, agreeableness and neuroticism in the Big Five personality theory.

[0027] The historical dialogue data set and personality theory knowledge base are input into the large language model. The model will analyze and judge the personality of each character based on the language patterns, word usage habits, emotional tendencies and other information in the dialogue data, combined with the standards in the personality theory knowledge base.

[0028] For example, if a character frequently uses imaginative words in dialogue and expresses a strong interest in new things, the large language model may judge that the character scores high on the openness dimension based on the characteristic description of openness in personality theory, and thus derive the annotation information about the character's personality as openness = 5.

[0029] By adding personality annotations to the corresponding historical conversation data set, the original simple conversation data is given personality attributes. For example, after adding personality annotations such as "openness = 5, agreeableness = -2" to a series of historical conversations of character A, these conversations become data samples with personality labels, providing more valuable information for the subsequent training of the personality vector generator.

[0030] For example, please refer to Figure 2 , a personality evaluator can be constructed based on the big language model and the Big Five personality theory knowledge. The personality evaluator evaluates the personality of the character on the five dimensions of the Big Five personality based on the character's multiple rounds of dialogue, and then forms a [character dialogue content, character personality score] data set, that is, a historical dialogue data set with personality annotations.

[0031] It can be concluded from the above that this embodiment adopts the Big Five Personality Theory to quantify personalized characteristics into actionable values, and accurately models these personality characteristics through neural network training, thereby giving the large language model the ability to dynamically generate and adjust personality characteristics.

[0032] Please refer to Figure 3 In one embodiment of the present disclosure, the large language model character shaping method further includes: Embed the pre-trained neural network between every two attention layers of the large language model; The historical conversation dataset with personality annotations is input into the pre-trained neural network and the large language model respectively, and trained using the gradient backpropagation method to obtain a trained personality vector generator.

[0033] In this embodiment, a specific implementation method for training a personality vector generator is provided. When processing text, the attention layer in the large language model can capture the dependencies between information in different positions, which plays a key role in understanding and generating natural language. The pre-trained neural network is embedded between every two attention layers, so that the pre-trained neural network can intervene at the key nodes of the large language model processing text.

[0034] The pre-trained neural network can use the intermediate results processed by the attention layer to dynamically generate personality-related parameters based on this information. For example, the attention layer has weighted the importance of different words and sentences in the input dialogue text. The pre-trained neural network can further generate corresponding adjustment parameters based on personality characteristics based on this weighted information, so as to better integrate with the language processing process of the large language model.

[0035] During the training process, the error between the model prediction result and the actual personality label is back-propagated by gradient backpropagation. The parameters of the pre-trained neural network and the large language model are adjusted according to the gradient information, so that the model can gradually learn how to accurately generate personality vectors and outputs that match the personality label according to the conversation content. For example, if the response generated by the model does not match the labeled humorous personality, the parameters can be adjusted by gradient backpropagation, and the model may generate a more humorous response the next time a similar conversation occurs.

[0036] Specifically, the pre-trained neural network specifically uses a super neural network, which can adjust the generated parameters in real time according to the specific dialogue scenario and personality requirements, so that the output of the large language model can more accurately reflect the desired personality characteristics.

[0037] It can be concluded from the above that this embodiment combines the dynamic generation capability of the pre-trained neural network with the powerful language processing capability of the large language model, so that the personality vector generator can more flexibly generate accurate personality vectors according to different conversation contents and personality annotations.

[0038] In one embodiment of the present disclosure, the large language model character shaping method further includes: When training a pre-trained neural network using gradient backpropagation, all parameters of the large language model are frozen.

[0039] In this embodiment, the parameters of the large language model contain a large number of common language features and semantic understanding capabilities. When training the pre-trained neural network, freezing the parameters of the large language model can prevent the knowledge of the large language model from being destroyed or forgotten during specific task training, so that the large language model can still use the powerful language understanding and generation capabilities learned in the pre-training stage when performing personalized adjustments, laying a good foundation for personalized tasks.

[0040] At the same time, only gradient updates are performed on the parameters of the pre-trained neural network, which enables the training to focus on specific tasks or personalized needs, more efficiently optimize the performance of large language models on specific tasks, and better generate responses that meet the requirements based on personality cues.

[0041] Please refer to Figure 4 In one embodiment of the present disclosure, the dialogue vector is input into a personality vector generator to obtain a personality adjustment vector, including: Performing dot product operations on the dialogue vector, the first adapter matrix and the second adapter matrix in sequence to obtain a personality adjustment vector; The first adapter matrix and the second adapter matrix are both adapter matrices generated by the personality vector generator based on the dialogue vector.

[0042] In this embodiment, Figure 4The left part of the figure shows the existing input and output methods of the large language model, and the right part shows the personality vector generator. The personality vector generator is embedded in the middle of every two layers of the attention module (Attention) of the pre-trained large language model. The personality vector generator generates two adapter matrices (adapter matrix A and adapter matrix B) that conform to the personality prompts based on the personality prompts and the conversation content vectors. The personality prompts and the conversation content vectors are first dot-producted with the first adapter matrix A to obtain a low-rank matrix C, and the low-rank matrix C is then dot-producted with the second adapter matrix B to obtain the personality adjustment vector.

[0043] Among them, when the dialogue vector is dot-producted with the first adapter matrix A, the first adapter matrix A will perform a weighted transformation on the dialogue vector according to its own parameters, preliminarily adjusting the characteristics of the dialogue vector so that it changes in the direction that meets the personality requirements. Then, the vector after the first dot-product transformation (i.e., the low-rank matrix C) is dot-producted with the second adapter matrix B, which can further fine-tune the vector. Through two dot-product operations, the vague personality tendencies in the dialogue vector are gradually transformed into specific personality adjustment vectors that meet the requirements.

[0044] It should be noted that in this embodiment, the adapter matrix generated by the personality vector generator can be one or more. Considering that the more adapter matrices there are, the more conducive it is to refine the personality adjustment process. However, the increase in the number of adapter matrices will make the model too complex and easily lead to overfitting. Therefore, after a large number of experimental studies, this embodiment finally determines that the number of adapter matrices is two, including the first adapter matrix A and the first adapter matrix B.

[0045] In addition, the personality vector generator can dynamically generate weights (the weights are used to construct the first adapter matrix A and the second adapter matrix B), and then dynamically adjust the first adapter matrix A and the second adapter matrix B, so that the large language model can flexibly adjust personalized responses in different situations, avoiding reliance on large customized data sets and complex prompt information.

[0046] From the above, it can be concluded that this embodiment dynamically generates a corresponding adapter matrix according to the different dialogue vectors input each time, so that no matter how the dialogue content and expected personality change, the model can generate adaptive adjustment parameters in real time, and realize dynamic personalized adjustment of the output of the large language model. Compared with the model with fixed parameters, the model's ability to meet diverse personality requirements in different scenarios is greatly improved.

[0047] At the same time, through two dot product operations, personality traits are gradually integrated into the dialogue vector, which can quickly and accurately adjust personality without changing the core structure of the large language model, reducing the computational burden and potential risks brought about by complex model structure adjustments, while ensuring the accuracy and effectiveness of personality adjustments.

[0048] In one embodiment of the present disclosure, inputting the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain the second output vector includes: Input the personality adjustment vector between every two attention layers of the large language model, starting from the first attention layer of the large language model, and perform the vector summation operation multiple times until the first output vector of the last attention layer is obtained; The vector summation operation includes: adding the first output vector of the nth attention layer to the personality adjustment vector to obtain a third output vector; Input the third output vector into the n+1th attention layer to obtain the first output vector of the n+1th attention layer; The first output vector of the last attention layer is determined as the second output vector.

[0049] In this embodiment, the personality adjustment vector is embedded between every two attention layers of the large language model. Taking the nth attention layer as an example, the first output vector of the nth attention layer is first added to the personality adjustment vector to obtain the third output vector, and then the third output vector is input into the n+1th attention layer to obtain the first output vector of the n+1th attention layer.

[0050] Among them, the first output vector of the nth attention layer contains the model's feature representation and understanding of the text up to that layer, and the personality adjustment vector carries information related to the target personality. By adding the two together, personality-related information is injected into the output of the current layer of the model. For example, if the personality adjustment vector corresponds to the "humorous and fun" personality, then the third output vector after addition will reflect the feature changes related to the humorous and fun personality to a certain extent.

[0051] The third output vector after injecting the personality adjustment vector becomes the input of the next layer (the n+1th attention layer), and the n+1th attention layer continues to perform attention calculation and feature transformation based on the third output vector.

[0052] The vector summation operation is performed multiple times in the same way until the first output vector of the last attention layer is obtained, and the first output vector of the last attention layer is used as the adjusted output vector, that is, the second output vector. Through the above process, personality traits can be deeply integrated with the semantics, syntax and other information of the text, so that personality traits can be continuously propagated and strengthened in the processing flow of the large language model.

[0053] From the above, it can be concluded that this embodiment incorporates personality adjustment vectors into each attention layer of the large language model, so that the personality characteristics can be closely integrated with the model's understanding process of the text and naturally penetrate into the final output, thereby ensuring that the generated content not only conforms to the target personality in terms of surface style, but also fits the personality characteristics at the semantic and logical levels, and the generated text is more coherent, reasonable and personalized.

[0054] In one embodiment of the present disclosure, the first output vector of the nth attention layer is added to the personality adjustment vector to obtain a third output vector, including: By formula Get the third output vector; where, represents the third output vector, represents the first output vector of the nth attention layer, represents the personality adjustment vector, It is an adjustment parameter between 0 and 1.

[0055] In this embodiment, the adjustment parameter can be introduced , to dynamically adjust the impact of the personality adjustment vector on the output of the large language model, The bigger it is, the more stylized it is. The smaller it is, the closer it is to the traditional output of a large language model.

[0056] By setting different adjustment parameters, users can precisely control the degree of personalization of output content according to their own preferences and specific application scenarios. For example, in social chat applications, some users may want the chatbot's replies to have a strong sense of humor, so the adjustment parameters can be increased; while in formal business writing scenarios, users may prefer relatively traditional, less stylized outputs, in which case the adjustment parameters can be reduced to meet a variety of different personalized needs.

[0057] In summary, traditional large language models mainly rely on a large amount of pre-training data and complex network structures. They often lack personalized performance when processing dialogues, and it is difficult to flexibly adjust personality characteristics according to different user needs and scenarios, and there is a lack of clear measurement standards for personality dimensions. In order to make up for this shortcoming, this embodiment adopts the Big Five personality theory, quantifies personalized characteristics into actionable values, and accurately models these personality characteristics through neural network training, thereby giving the large language model the ability to dynamically generate and adjust personality characteristics.

[0058] In the training process of the personality vector generator, this embodiment introduces the hypernetwork technology, generates weights according to the quantified personality data, and constructs an adapter matrix based on the weights to dynamically adjust the personality characteristics of the large language model. Unlike the traditional fine-tuning method, the present invention dynamically generates each weight parameter in the adapter matrix through the hypernetwork, so that the model can flexibly adjust the personalized response in different situations, avoiding reliance on a large number of customized data sets and complex prompt information. In addition, the dynamic generation module of the present invention enables users to adjust the personalized characteristics of the generated content by inputting personalized prompts (for example: openness = 3, agreeableness = -2), and the personality of the model can be adjusted in real time without retraining the model to adapt to various practical application needs. In this way, the model can not only provide accurate personalized services according to the needs of users, but also perform personalized continuation according to the historical information of the conversation, maintaining the coherence and personalized characteristics of the conversation.

[0059] This invention solves the problem of personality quantification of traditional large language models, and at the same time improves the adaptability and personality flexibility of the model in diversified scenarios. Whether in the fields of intelligent customer service, virtual assistants, mental health, education and training, or in game role-playing, the dynamic personality generation method based on the Big Five personality theory can provide a more humane and personalized interactive experience, and promote the further development and application of large language model technology.

[0060] Corresponding to the large language model character shaping method in the above embodiment, Figure 5 This is a structural block diagram of a large language model personality shaping device provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 5 The large language model personality shaping device 20 includes: a first input module 21, a personality shaping module 22 and an output adjustment module 23. The first input module 21 is used to input the personality hint and the conversation content into the large language model to obtain a conversation vector; The personality shaping module 22 is used to input the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations; The output adjustment module 23 is used to input the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

[0061] In one embodiment of the present disclosure, the personality shaping module 22 is specifically used to: Input the historical dialogue dataset and personality theory knowledge base of each character into the large language model to obtain the personality annotation of each character; Each personality annotation is added to the historical dialogue dataset of the corresponding character to obtain a historical dialogue dataset with personality annotations.

[0062] In one embodiment of the present disclosure, the personality shaping module 22 is specifically used to: Embed the pre-trained neural network between every two attention layers of the large language model; The historical conversation dataset with personality annotations is input into the pre-trained neural network and the large language model respectively, and trained using the gradient backpropagation method to obtain a trained personality vector generator.

[0063] In one embodiment of the present disclosure, the personality shaping module 22 is further used to: When training a pre-trained neural network using gradient backpropagation, all parameters of the large language model are frozen.

[0064] In one embodiment of the present disclosure, the personality shaping module 22 is further used to: Performing dot product operations on the dialogue vector, the first adapter matrix and the second adapter matrix in sequence to obtain a personality adjustment vector; The first adapter matrix and the second adapter matrix are both adapter matrices generated by the personality vector generator based on the dialogue vector.

[0065] In one embodiment of the present disclosure, the output adjustment module 23 is specifically used to: Input the personality adjustment vector between every two attention layers of the large language model, starting from the first attention layer of the large language model, and perform the vector summation operation multiple times until the first output vector of the last attention layer is obtained; Vector sum operations include: Add the first output vector of the nth attention layer to the personality adjustment vector to obtain the third output vector; Input the third output vector into the n+1th attention layer to obtain the first output vector of the n+1th attention layer; The first output vector of the last attention layer is determined as the second output vector.

[0066] In one embodiment of the present disclosure, the output adjustment module 23 is further configured to: By formula Get the third output vector; where, represents the third output vector, represents the first output vector of the nth attention layer, represents the personality adjustment vector, To adjust the parameters.

[0067] See also Figure 6 , Figure 6 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 6 The electronic device 300 in the embodiment shown may include: one or more processors 301, one or more input devices 302, one or more output devices 303 and one or more memories 304. The processors 301, input devices 302, output devices 303 and memories 304 communicate with each other via a communication bus 305. The memory 304 is used to store computer programs, which include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. The processor 301 is configured to call the program instructions to execute the functions of each module / unit in the above-mentioned device embodiments, such as Figure 5 The functions of modules 21 to 23 are shown.

[0068] It should be understood that in the embodiment of the present disclosure, the processor 301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0069] The input device 302 may include a touch panel, a fingerprint collection sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc., and the output device 303 may include a display (LCD, etc.), a speaker, etc.

[0070] The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. A portion of the memory 304 may also include a non-volatile random access memory. For example, the memory 304 may also store information about the device type.

[0071] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure can execute the implementation methods described in the first and second embodiments of the large language model character shaping method provided in the embodiments of the present disclosure, and can also execute the implementation methods of the electronic device described in the embodiments of the present disclosure, which will not be repeated here.

[0072] In another embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by the processor, all or part of the processes in the above-mentioned embodiment method are implemented, and the computer program can also be completed by instructing the relevant hardware through the computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0073] The computer-readable storage medium may be an internal storage unit of the electronic device of any of the aforementioned embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the electronic device and an external storage 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 may also be used to temporarily store data that has been output or is to be output.

[0074] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.

[0075] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the electronic devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0076] In the several embodiments provided in the present 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 only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces or units, or it can be an electrical, mechanical or other form of connection.

[0077] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present disclosure.

[0078] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0079] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present disclosure, and these modifications or replacements should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A large language model character shaping method, characterized in that: include: Input personality cues and conversation content into a large language model to obtain a conversation vector; Inputting the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations; The personality adjustment vector is input into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

2. The large language model character shaping method according to claim 1, characterized in that: Also includes: Input the historical dialogue dataset and personality theory knowledge base of each character into the large language model to obtain the personality annotation of each character; Each personality annotation is added to the historical dialogue dataset of the corresponding character to obtain a historical dialogue dataset with personality annotations.

3. The large language model character shaping method according to claim 1, characterized in that: The large language model character shaping method also includes: Embed the pre-trained neural network between every two attention layers of the large language model; The historical conversation data set with personality annotations is input into the pre-trained neural network and the large language model respectively, and training is performed by gradient backpropagation to obtain the trained personality vector generator.

4. The large language model character shaping method according to claim 3, characterized in that: Also includes: When training a pre-trained neural network using gradient backpropagation, all parameters of the large language model are frozen.

5. The large language model character shaping method according to claim 1, characterized in that: The step of inputting the dialogue vector into a personality vector generator to obtain a personality adjustment vector comprises: Performing dot product operations on the dialogue vector, the first adapter matrix and the second adapter matrix in sequence to obtain the personality adjustment vector; The first adapter matrix and the second adapter matrix are both adapter matrices generated by the personality vector generator based on the dialogue vector.

6. The large language model character shaping method according to claim 1, characterized in that: The step of inputting the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain a second output vector includes: Inputting the personality adjustment vector between every two attention layers of the large language model, starting from the first attention layer of the large language model, performing a vector summation operation multiple times until a first output vector of the last attention layer is obtained; The vector summation operation includes: Adding the first output vector of the nth attention layer to the personality adjustment vector to obtain a third output vector; Input the third output vector into the n+1th attention layer to obtain the first output vector of the n+1th attention layer; The first output vector of the last attention layer is determined as the second output vector.

7. The large language model character shaping method according to claim 6, characterized in that: The adding the first output vector of the nth attention layer to the personality adjustment vector to obtain a third output vector comprises: By formula Get the third output vector; where, represents the third output vector, represents the first output vector of the nth attention layer, represents the personality adjustment vector, To adjust the parameters.

8. A large language model character shaping device, characterized in that: include: The first input module is used to input the personality hint and the conversation content into the large language model to obtain the conversation vector; A personality shaping module, used for inputting the conversation vector into a personality vector generator to obtain a personality adjustment vector; the personality vector generator is a neural network model trained based on a historical conversation data set with personality annotations; The output adjustment module is used to input the personality adjustment vector into the large language model to adjust the first output vector output by the large language model to obtain a second output vector; the first output vector is an output vector obtained by the large language model based on the dialogue vector, and the second output vector is an output vector containing personality characteristics.

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, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Digital human with specific language style based on large language model

    CN117034951A

  • Personalized dialogue generation method and system based on large language model

    CN117787293A

  • Directional character construction method and device for large language model and storage medium

    CN118796999A

  • Digital human generation method and device and electronic equipment

    CN119106285A

  • Customized dialogue generation system for increasing reliability by considering personality information about dialogue counterpart, and method therefor

    WO2023095988A1

Cited By

  • Dialogue generation method and system

    CN120725142A

  • Method for enhancing personality and task linkage capability of role large model and related products

    CN121743483A