A large language model character setting privatization method and related device

By generating and fine-tuning the persona question and answer data of the large language model, we solve the problem of answering questions that do not conform to the set persona in the privatization of the persona of the large language model, achieve customized persona answers, improve model stability, and reduce the cost of construction. cost.

CN118228829BActive Publication Date: 2024-10-18IFLYTEK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410624896.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-10-18
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

It is difficult to privatize the persona of a large language model with the existing technology, and it is impossible to provide answers that are consistent with the company's specific persona to the persona-related questions raised by users. There are situations where the answers do not conform to the set persona and there are problems in constructing persona question and answer data. A difficult and costly problem.

Method used

By generating answers consistent with the character information based on the set character information and question and answer templates, the character question and answer data is constructed, and these data are used to fine-tune and train the large language model to ensure that the model can generate questions consistent with the character for the input character-related questions. answer specific information and, if necessary, construct supplementary data to cover uncovered attribute elements.

Benefits of technology

It realizes the privatization of personas of large language models, meets the customized needs of enterprises, improves the accuracy and stability of answers, and reduces the difficulty and cost of constructing personas Q&A data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118228829B_ABST
    Figure CN118228829B_ABST
Patent Text Reader

Abstract

The present application discloses a method for privatizing the personality of a large language model and related devices, and relates to the field of model training technology. The method includes: generating answers that conform to the personality information for questions in the question and answer template according to the set personality information and the answers in the created question and answer template, and obtaining the personality answers corresponding to the questions in the question and answer template; obtaining personality question and answer data according to the questions in the question and answer template and the corresponding personality answers; and fine-tuning the large language model using the personality question and answer data. The method for privatizing the personality of a large language model disclosed in the present application can automatically construct personality question and answer data that matches the needs of the enterprise, and then, fine-tune the large language model using the constructed personality question and answer data, and can obtain a large language model that generates answers that conform to the set personality information for input personality-related questions. The method for privatizing the personality of a large language model disclosed in the present application can meet the customization needs of the enterprise.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of model training technology, and in particular to a method for privatizing a large language model personality and related devices. Background Art

[0002] Large language models are one of the hottest research directions in the field of artificial intelligence in recent years. They have excellent comprehension capabilities and can understand and generate coherent and reasonable text content based on the context. They are widely used in many fields such as intelligent dialogue systems and intelligent customer service, bringing convenience and efficiency improvements to people's lives and work.

[0003] The personality ability of the large language model is a type of self-cognition ability, which has attracted much attention in the training process of the large language model. The personality ability of the large language model refers to a broad description of how the large language model views itself and answers personality portrait questions, such as the large language model's cognition of questions such as "Who are you?" and "Who created you".

[0004] In recent years, enterprises have increasingly demanded the private deployment of large language models. However, how to realize the privatization of the personality of large language models (that is, how to make the large language model give answers that are consistent with the enterprise's specific personality in response to personality-related questions raised by users) is an issue that needs to be solved urgently. Summary of the invention

[0005] In view of this, the present application provides a large language model personality privatization method and related devices to achieve the personality privatization of the large language model, and its technical solution is as follows:

[0006] The first aspect of the present application provides a method for privatizing a large language model persona, comprising:

[0007] According to the set character information and the answers in the created question and answer template, an answer that conforms to the character information is generated for the question in the question and answer template, and the character answer corresponding to the question in the question and answer template is obtained;

[0008] Obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template;

[0009] The large language model is fine-tuned and trained using the character question and answer data to obtain a large language model that can generate answers that conform to the character information for input character-related questions.

[0010] In a possible implementation, generating answers that match the personality information for questions in the question and answer template according to the set personality information and the answers in the created question and answer template includes:

[0011] The set personality information and the created question-and-answer template are input into the large language model, and the large language model generates answers that conform to the personality information for the questions in the question-and-answer template based on the personality information and the answers in the question-and-answer template.

[0012] In a possible implementation, obtaining the persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template includes:

[0013] Rewriting the question in the question-answer template to obtain a rewritten question, wherein the rewritten question has the same semantics as the original question but a different expression;

[0014] Performing quality assessment on the questions in the question-and-answer template and the rewritten questions respectively;

[0015] Questions that meet the quality requirements and the corresponding character answers are combined into character question and answer data.

[0016] In a possible implementation, the personality information includes a plurality of personality attribute elements and personality attribute element values ​​corresponding to the plurality of personality attribute elements respectively;

[0017] The large language model personality privatization method further includes:

[0018] Input the user question into the fine-tuned large language model to obtain the answer corresponding to the user question;

[0019] Determine whether the answer corresponding to the user question is consistent with the persona information;

[0020] If the answer corresponding to the user question does not conform to the personality information, determining whether there are personality attribute elements not covered by the personality information in the answer corresponding to the user question;

[0021] If the answer to the user question contains a personality attribute element that is not covered by the personality information, a preset fallback reply is fed back to the user, and personality question and answer data is constructed for the personality attribute element that is not covered by the personality information; if the answer to the user question does not contain a personality attribute element that is not covered by the personality information, the answer to the user question is fed back to the user, and personality question and answer data is constructed for the user question;

[0022] The fine-tuned large language model is optimized using the constructed human-set question-answering data.

[0023] In a possible implementation, determining whether the answer to the user question is consistent with the persona information includes:

[0024] Determining whether the answer to the user question is harmless;

[0025] If the answer to the user question is harmless, scoring the answer to the user question according to the persona information;

[0026] If the score of the answer corresponding to the user question is less than a preset score threshold, it is determined that the answer corresponding to the user question does not conform to the personality information; if the score of the answer corresponding to the user question is greater than or equal to the preset score threshold, it is determined that the answer corresponding to the user question conforms to the personality information.

[0027] In a possible implementation, constructing the personality question and answer data for the personality attribute elements not covered by the personality information includes:

[0028] Acquire, from the enterprise knowledge base, knowledge information related to the personality attribute elements not covered by the personality information as the personality attribute element values ​​corresponding to the personality attribute elements not covered by the personality information;

[0029] Supplementing the personal attribute elements not covered by the personal information and the personal attribute element values ​​corresponding to the personal attribute elements not covered by the personal information into the personal information to obtain supplemented personal information;

[0030] The supplemented personality information and the question and answer template are used to construct personality question and answer data.

[0031] In a possible implementation, constructing the persona question-and-answer data for the user question includes:

[0032] Extracting personality attribute elements from the user question;

[0033] Obtaining a personality attribute element value corresponding to the extracted personality attribute element from the personality information;

[0034] According to the user question, the extracted personality attribute elements and the personality attribute element values ​​corresponding to the extracted personality attribute elements, personality question and answer data are constructed.

[0035] In a possible implementation, the large language model persona privatization method further includes:

[0036] If the answer corresponding to the user question is consistent with the personality information, the answer corresponding to the user question is fed back to the user.

[0037] In a possible implementation, the large language model persona privatization method further includes:

[0038] If the personality answer corresponding to the user's question is harmful, the preset catch-all response will be fed back to the user.

[0039] A second aspect of the present application provides a large language model persona privatization device, including: a persona question and answer data generation module and a model training module;

[0040] The character setting question and answer data generation module is used to generate answers that conform to the character setting information for questions in the question and answer template according to the set character setting information and the answers in the created question and answer template, and obtain the character setting answers corresponding to the questions in the question and answer template; and obtain the character setting question and answer data according to the questions in the question and answer template and the character setting answers corresponding to the questions in the question and answer template;

[0041] The model training module is used to use the character question and answer data to fine-tune the large language model to obtain a large language model that can generate answers that conform to the character information for input character-related questions.

[0042] A third aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0043] The memory is used to store computer programs;

[0044] The processor is used to execute the computer program so that the electronic device can implement any one of the above-mentioned large language model personality privatization methods.

[0045] In a fourth aspect, the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any one of the above-mentioned large language model personality privatization methods.

[0046] A fifth aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the above-mentioned methods for privatizing a large language model personality.

[0047] By means of the above technical scheme, the large language model personality privatization method provided in the present application first generates answers that conform to the personality information for questions in the question and answer template based on the set personality information and the answers in the created question and answer template, and obtains the personality answers corresponding to the questions in the question and answer template, and then obtains the personality question and answer data based on the questions in the question and answer template and the personality answers corresponding to the questions in the question and answer template, and finally uses the personality question and answer data to fine-tune the large language model to obtain a large language model that can generate answers that conform to the set personality information for input personality-related questions. The large language model personality privatization method provided in the present application can automatically construct personality question and answer data that matches the needs of the enterprise, and then, by using the constructed personality question and answer data to fine-tune the large language model, a large language model can be obtained that generates answers that conform to the set personality information for input personality-related questions. The large language model personality privatization method provided in the present application can realize the personality privatization of the large language model and meet the customization needs of the enterprise. In addition, the large language model personality privatization method provided in this application can automatically construct personality question and answer data using the set personality information and the created question and answer template. The construction efficiency of the personality question and answer data is high, the construction difficulty is low, and the construction cost is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0049] Figure 1 A schematic diagram of a system architecture involved in this application;

[0050] Figure 2 for Figure 1 A schematic diagram of the structure of the middle terminal;

[0051] Figure 3 for Figure 1 A structural diagram of a server in FIG.

[0052] Figure 4 A flowchart of a method for privatizing a large language model persona provided in this application;

[0053] Figure 5 A schematic diagram of inputting the set character information and question-answer template into a large language model provided in this application to obtain character answers corresponding to the questions in the question-answer template;

[0054] Figure 6 A flowchart of another method for privatizing the persona of a large language model is provided for this application;

[0055] Figure 7 A schematic diagram of the structure of the large language model personality privatization device provided in this application. DETAILED DESCRIPTION

[0056] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0057] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0058] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0059] Before introducing the large language model personality privatization method provided by the present invention, the system architecture involved in the present invention is first described.

[0060] like Figure 1 As shown, the system architecture of the present invention may include: a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 A server is included as an example for explanation).

[0061] Terminal 100 can obtain user-defined personality information and created question and answer templates, and send the user-defined personality information and created question and answer templates to the server. The server constructs personality question and answer data based on the set personality information and the created question and answer template, and uses the personality question and answer data to fine-tune the large language model.

[0062] Next describe Figure 1 The product form of the mid-terminal 100;

[0063] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any limitation on this.

[0064] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.

[0065] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 This is merely an example of a terminal and does not constitute a limitation on the terminal. The terminal may include more or fewer components than shown in the figure, or a combination of certain components, or different components.

[0066] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the terminal. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0067] The display unit 140 may be used to display information input by a user or information provided to a user, various menus of the terminal 100, an interactive interface, file display, and / or playback of any multimedia file.

[0068] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.

[0069] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.

[0070] The radio frequency unit 110 (optional) can be used to receive and send information or receive and send signals during a call. For example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the radio frequency unit 110 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LowNoiseAmplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General PacketRadio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.

[0071] In the embodiment of the present application, the radio frequency unit 110 can send data to other devices, and can also receive data sent by other devices. It should be understood that the radio frequency unit 110 is optional, and can be replaced by other communication interfaces, such as a network port.

[0072] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.

[0073] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .

[0074] Although not shown, the terminal 100 may further include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which will not be described in detail herein.

[0075] Next describe Figure 1 The product form of the server 200;

[0076] Figure 3A schematic diagram of the structure of the server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0077] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0078] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0079] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).

[0080] Among them, the memory 204 can be used to store software codes related to the large language model personality privatization method, the processor 202 can execute the steps of the large language model personality privatization method, and can also schedule other units to implement corresponding functions.

[0081] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0082] In order to realize the privatization of the personality of the large language model, research was conducted. The initial idea was to adopt a model fine-tuning strategy and / or a prompt word constraint strategy.

[0083] Among them, the model fine-tuning strategy refers to constructing character Q&A data (character-related questions and corresponding answers). Specifically, a large amount of character Q&A data is collected, and it is manually screened, modified, and processed to obtain high-quality character Q&A data. After obtaining high-quality character Q&A data, these character Q&A data are used to fine-tune the large language model. Through fine-tuning training, the large language model will learn and absorb character knowledge to better understand and answer questions related to the character, thereby giving answers that are consistent with the set character.

[0084] Among them, the prompt word constraint strategy refers to splicing the set personality information with the user's question, inputting the spliced ​​text into the large language model, and the large language model identifies the personality keywords in the input text and generates relevant answers based on the personality keywords.

[0085] Research on the above-mentioned model fine-tuning strategy found that the model fine-tuning strategy requires the construction of persona Q&A data. Considering that if the user's questions are not exhaustively simulated, there is a possibility that the answers generated by the model will not conform to the set persona. In view of this, when constructing persona Q&A data, it is necessary to collect as much persona Q&A data as possible, and manually screen, modify, and process it to ensure that the large language model can accurately understand and answer various possible persona-related questions. It can be seen that the construction of persona Q&A data is difficult and costly (both labor costs and resource costs are high). In addition, in actual application scenarios, even if a large amount of high-quality persona Q&A data is obtained and the large language model is fine-tuned with this data, due to the unstable performance of the large language model in dealing with various situations, the answers generated by the model may still not conform to the set persona.

[0086] Research on the above-mentioned prompt word constraint strategy found that since the output of the large language model itself is uncontrollable, it is unreliable to limit the answer of the large language model only by prompt words. For example, the large language model may misunderstand certain specific words and cause the answer to deviate from the set personality. In addition, in actual applications, the prompt words may be inconsistent with the original training data. When this happens, the large language model tends to answer according to the knowledge learned from the original training data, which causes the answer to deviate from the set personality.

[0087] In view of the problems existing in the above ideas, further research was conducted, and finally a method for privatizing the large language model persona with better effect was proposed. Next, the method for privatizing the large language model persona provided by this application is introduced through the following embodiments.

[0088] See also Figure 4 , showing a flow chart of a method for privatizing a large language model persona provided in an embodiment of the present application, the method may include:

[0089] Step S401: Based on the set personality information and the answers in the created question and answer template, answers that meet the set personality information are generated for the questions in the question and answer template, and the personality answers corresponding to the questions in the question and answer template are obtained.

[0090] In this embodiment, the set personal information is the personal information set by the enterprise according to its own needs, and the set personal information may include a number of personal attribute elements and personal attribute element values ​​corresponding to the number of personal attribute elements. An example of personal information is given below:

[0091] Company: Company A

[0092] Age: 18

[0093] Hobbies: reading knowledge and summarizing

[0094] Disadvantages: A little bit wordy

[0095] …

[0096] "Company", "age", "hobbies", "shortcomings" and so on in the above examples are all personality attribute elements. "Company A" is the personality attribute element value corresponding to the personality attribute element "Company", "18 years old" is the personality attribute element value corresponding to the personality attribute element "age", "Reading knowledge and summary" is the personality attribute element value corresponding to the personality attribute element "hobbies", and "a little bit long-winded" is the personality attribute element value corresponding to the personality attribute element "shortcomings".

[0097] In this embodiment, the created question and answer template may be question and answer data that is not related to a specific instance of the enterprise. The question and answer template may be human-computer dialogue question and answer data, or may be general question and answer data involving human settings.

[0098] In one possible implementation, the process of generating answers that conform to the set personality information for questions in a question and answer template based on the set personality information and the answers in the created question and answer template may include: inputting the set personality information and the created question and answer template into a large language model, and obtaining answers that conform to the set personality information generated by the large language model for the questions in the question and answer template based on the personality information and the answers in the question and answer template.

[0099] like Figure 5 As shown, the process of inputting the set character information and the created question and answer template into the large language model may include: filling the set character information and the created question and answer template into the first prompt format template, obtaining the first prompt instruction, and inputting the first prompt instruction into the large language model.

[0100] It should be noted that the first prompt format template includes a character information slot, a template question slot and a template answer slot. The first prompt format template is used to instruct the large language model to generate an answer to the template question in the template question slot based on the character information in the character information slot and the template answer in the template answer slot. When the set character information and question and answer template are filled into the first prompt format template, the set character information is filled into the character information slot, the question in the question and answer template is filled into the template question slot, and the answer in the question and answer template is filled into the template answer slot.

[0101] Step S402: Obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template.

[0102] In this embodiment, since the personality question and answer data is constructed based on the set personality information (personality information set by the enterprise according to its own business needs) and the question and answer template, the personality question and answer data matches the business needs of the enterprise.

[0103] There are multiple ways to obtain personality Q&A data based on the questions in the Q&A template and the personality answers corresponding to the questions in the Q&A template. In one possible implementation method, the questions in the Q&A template and the personality answers corresponding to the questions in the Q&A template can be directly combined into personality Q&A data. Since there are usually multiple Q&A templates, the questions in each Q&A template are combined with the corresponding personality answers to obtain multiple personality Q&A data.

[0104] Considering that the number of question and answer templates is usually limited, the amount of persona question and answer data obtained according to the first implementation method is limited. Considering that there are multiple ways to express the same semantics, in order to obtain a large number of high-quality persona question and answer pairs, this embodiment provides another possible implementation method for obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template:

[0105] Step a1: rewrite the questions in the question-and-answer template to obtain rewritten questions.

[0106] Among them, the rewritten questions have the same semantics as the original questions but different expressions.

[0107] Step a2: Conduct quality assessment on the questions in the question and answer template and the rewritten questions respectively.

[0108] In a possible implementation, the questions in the question and answer template and the rewritten questions may be scored separately based on the scoring model to obtain the scores of the questions in the question and answer template and the scores of the rewritten questions.

[0109] It should be noted that when the scoring model scores questions, it can score questions based on the quality of the question itself, the relevance of the question to the corresponding persona's answer, etc. It should be noted that the persona's answer corresponding to the rewritten question is the persona's answer corresponding to the original question.

[0110] Step a3: Questions that meet the quality requirements and the corresponding character answers are combined into character question and answer data.

[0111] Specifically, the score is greater than the preset score threshold S1 th The questions and the corresponding character answers constitute the character question and answer data.

[0112] For example, a question in a question template is question A, and the answer of the persona corresponding to question A is answer B. Question A is rewritten in different forms to obtain rewritten questions A1′, A2′, and A3′. The rewritten questions A1′, A2′, and A3′ have the same semantics as A but different expressions. A, A1′, A2′, and A3′ are scored based on the scoring model to obtain the scores of A, A1′, A2′, and A3′. Assume that the scores of A and A2′ are greater than the preset score threshold S1. th , then question A and answer B form one-person question and answer data, and question A2′ and answer B form one-person question and answer data.

[0113] Through steps a1 to a3, a plurality of high-quality character-setting question-and-answer data can be obtained, and the plurality of high-quality character-setting question-and-answer data can be stored in a fine-tuning training database.

[0114] Step S403: fine-tune the large language model using the character question and answer data to obtain a large language model that can generate answers that conform to the set character information for input character-related questions.

[0115] When fine-tuning the large language model using the persona Q&A data, the goal is to make the answers generated by the large language model for questions in the persona Q&A data close to the answers in the persona Q&A data. Through training, the large language model can learn and absorb persona information, so that it can generate answers that match the set persona information for input persona-related questions.

[0116] The method for privatizing the personality of a large language model provided in the embodiment of the present application first generates answers that conform to the set personality information for questions in the question and answer template based on the set personality information and the answers in the created question and answer template, and obtains the personality answers corresponding to the questions in the question and answer template, and then obtains personality question and answer data based on the questions in the question and answer template and the personality answers corresponding to the questions in the question and answer template, and finally uses the personality question and answer data to fine-tune the large language model to obtain a large language model that can generate answers that conform to the set personality information for input personality-related questions. The method for privatizing the personality of a large language model provided in the embodiment of the present application can automatically construct personality question and answer data that matches the needs of the enterprise, and then, by using the constructed personality question and answer data to fine-tune the large language model, a large language model can be obtained that generates answers that conform to the set personality information for input personality-related questions. The method for privatizing the personality of a large language model provided in the embodiment of the present application can realize the personality privatization of the large language model, and can meet the customization needs of the enterprise. In addition, the large language model personality privatization method provided in the embodiment of the present application can automatically construct high-quality personality question and answer data using the set personality information and the created question and answer template. The construction efficiency of the personality question and answer data is high, the construction difficulty is low, and the construction cost is low.

[0117] Considering the uncontrollability of user issues and content generated by large language models, in order to improve the stability of large language models, this application embodiment provides another method for privatizing the persona of large language models. Figure 6 , showing a flow chart of the method for privatizing the large language model persona, the method may include:

[0118] Step S601: Based on the set personality information and the answers in the created question and answer template, generate answers that match the set personality information for the questions in the question and answer template, and obtain personality answers corresponding to the questions in the question and answer template.

[0119] Among them, the set personal information is the personal information set by the enterprise according to its own needs, and the set personal information includes a number of personal attribute elements and personal attribute element values ​​corresponding to the number of personal attribute elements.

[0120] Step S602: Obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template.

[0121] Step S603: fine-tune the large language model using the character question and answer data to obtain a large language model that can generate answers that conform to the set character information for input character-related questions.

[0122] The specific implementation process and related description of steps S601 to S603 can be found in the specific implementation process and related description of steps S401 to S403 in the above embodiment, which will not be described in detail in this embodiment.

[0123] Step S604: Input the user question into the fine-tuned large language model to obtain an answer corresponding to the user question.

[0124] Among them, user questions are personality-related questions. The user questions are input into the fine-tuned large language model. The fine-tuned large language model generates answers for the input user questions to obtain answers corresponding to the user questions.

[0125] Step S605: Determine whether the answer to the user question is consistent with the set personality information. If the answer to the user question is not consistent with the set personality information, execute steps S606a to S608a. If the answer to the user question is consistent with the set personality information, execute step S606b.

[0126] In a possible implementation, the answer to the user's question can be scored using a scoring model based on the set person information to obtain the score of the answer to the user's question. If the score of the answer to the user's question is less than a preset score threshold S2, th, it is determined that the answer to the user's question does not conform to the set personality information; if the score of the answer to the user's question is greater than or equal to the preset score threshold S2 th , it is determined that the answer corresponding to the user's question conforms to the set personality information.

[0127] Considering that the fine-tuned large language model may generate harmful answers (such as rude answers, uncomfortable answers, misleading answers, discriminatory answers, etc.), in order to avoid feeding back harmful answers to users, in one possible implementation, it is possible to first determine whether the answer corresponding to the user's question is harmless. If the answer corresponding to the user's question is harmless, then the answer corresponding to the user's question is scored using a scoring model based on the set person information to obtain the score of the answer corresponding to the user's question. If the score of the answer corresponding to the user's question is less than a preset score threshold S2, th , it is determined that the answer to the user's question does not conform to the set personality information; if the score of the answer to the user's question is greater than or equal to the preset score threshold S2 th , it is determined that the answer corresponding to the user's question conforms to the set personality information.

[0128] It should be noted that if the answer to the user's question is harmful, the preset fallback response will be fed back to the user.

[0129] Step S606a: Determine whether there are any personality attribute elements in the answer corresponding to the user question that are not covered by the set personality information. If there are any personality attribute elements in the answer corresponding to the user question that are not covered by the set personality information, execute step S607a-a. If there are no personality attribute elements in the answer corresponding to the user question that are not covered by the set personality information, execute step S607a-b.

[0130] Exemplarily, the set personality information includes the personality attribute elements "company", "age", "hobbies", and "shortcomings", and the answer to the user's question is "My advantages are...". Since the set personality information does not include the personality attribute element "advantages", the answer to the user's question contains personality attribute elements that are not covered by the set personality information.

[0131] Exemplarily, the set personality information includes the personality attribute elements "company", "age", "hobbies", and "shortcomings", and the answer to the user's question is "My shortcomings are...". Since the set personality information includes the personality attribute element "shortcomings", the set personality information covers the personality attribute elements in the answer to the user's question, that is, the answer to the user's question does not contain any personality attribute elements that are not covered by the set personality information.

[0132] Step S606b: Feedback the answer corresponding to the user's question to the user.

[0133] If the answer to the user's question matches the set personality information, the answer to the user's question will be directly fed back to the user.

[0134] Step S607a-a: Feedback the preset catch-all reply to the user, and construct personality question and answer data for personality attribute elements not covered by the set personality information.

[0135] When there are personality attribute elements in the answer corresponding to the user's question that are not covered by the set personality information, the preset catch-all reply will be fed back to the user, and personality question and answer data will be constructed for the personality attribute elements that are not covered by the set personality information.

[0136] It should be noted that if the answer corresponding to the user's question contains personality attribute elements that are not covered by the set personality information, it means that the personality attribute elements are missing in the set personality information. Since the personality question and answer data used to fine-tune the large language model is constructed according to the set personality information and question and answer template, the personality question and answer data used to fine-tune the large language model does not involve the personality attribute elements. In view of this, this embodiment constructs personality question and answer data for the personality attribute elements that are not covered by the set personality information.

[0137] In a possible implementation, the process of constructing personality question-and-answer data for personality attribute elements not covered by the set personality information may include:

[0138] Step b1: Acquire knowledge information related to the personality attribute elements not covered by the set personality information from the enterprise knowledge base as the personality attribute element values ​​corresponding to the personality attribute elements not covered by the set personality information.

[0139] In one possible implementation, the knowledge information directly obtained from the enterprise knowledge base may be used as the personality attribute element value corresponding to the personality attribute element not covered by the set personality information. Considering that sometimes the knowledge information obtained from the enterprise knowledge base may contain some useless and / or harmful knowledge information, in order to ensure the quality of the knowledge information, in another possible implementation, after obtaining the knowledge information from the enterprise knowledge base, the obtained knowledge information may be filtered to eliminate useless and / or harmful knowledge information, and the knowledge information after knowledge filtering may be used as the personality attribute element value corresponding to the personality attribute element not covered by the set personality information.

[0140] Step b2: Supplement the personal attribute elements not covered by the set personal information and the personal attribute element values ​​corresponding to the personal attribute elements not covered by the set personal information into the set personal information to obtain supplemented personal information.

[0141] Exemplarily, the set personality information includes four personality attribute elements A, B, C, and D, and the personality attribute element values ​​corresponding to these four personality attribute elements respectively. The personality attribute element E in the answer corresponding to the user's question that is not covered by the set personality information is E. Then, knowledge information related to personality attribute element E is obtained from the enterprise knowledge base, and the knowledge information related to personality attribute element E is used as the personality attribute element value corresponding to personality attribute element E. Personality attribute element E and the personality attribute element value corresponding to personality attribute element E are supplemented to the set personality information to obtain the supplemented personality information. The supplemented personality information includes five personality attribute elements A, B, C, D, and E, and the personality attribute element values ​​corresponding to these five personality attribute elements respectively.

[0142] Step b3: Use the supplemented personality information and question and answer template to construct personality question and answer data.

[0143] In a possible implementation, the process of constructing the persona question and answer data using the supplemented persona information and question and answer template may include:

[0144] Step b31: Based on the supplemented personality information and the answers in the question and answer template, generate answers that match the supplemented personality information for the questions in the question and answer template, and obtain personality answers corresponding to the questions in the question and answer template.

[0145] In one possible implementation, the supplemented personality information and question-and-answer template may be input into a fine-tuned large language model, and the fine-tuned large language model may generate answers that conform to the supplemented personality information for questions in the question-and-answer template based on the supplemented personality information and the answers in the question-and-answer template.

[0146] Specifically, the supplemented character information and question-and-answer template are filled into the first prompt format template to obtain a second prompt instruction, and the second prompt instruction is input into the fine-tuned large language model to obtain the character answers corresponding to the questions in the question-and-answer template.

[0147] Step b32: Obtain the persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template.

[0148] The specific implementation process of step b31 can refer to the specific implementation process of step S402, which will not be described in detail in this embodiment.

[0149] Step S607a-b: Feedback the answer corresponding to the user's question to the user, and construct the character question and answer data according to the user's question.

[0150] When the score of the answer to the user's question is less than the preset score threshold S2 thIn this case, the answer corresponding to the user question does not contain any personality attribute elements that are not covered by the set personality information, indicating that the personality answer generated by the fine-tuned large language model for the user question is not good. In view of this, this embodiment constructs personality question and answer data for the user question.

[0151] In a possible implementation, the process of constructing person-set question-answering data for user questions may include:

[0152] Step c1: extract personality attribute elements from user questions.

[0153] For example, if the user question is “What are your shortcomings?”, the personality attribute element “shortcomings” is extracted from the user question.

[0154] Step c2: Obtain the personality attribute element value corresponding to the personality attribute element extracted in step c1 from the set personality information.

[0155] Exemplarily, the set personality information includes personality attribute elements such as "company", "age", "hobbies", and "shortcomings", as well as the personality attribute element values ​​corresponding to these personality attribute elements. If the personality attribute element extracted from the user's question is "shortcomings", the personality attribute element value corresponding to "shortcomings" is extracted from the set personality information.

[0156] Step c3: construct personality question and answer data based on user questions, extracted personality attribute elements, and personality attribute element values ​​corresponding to the extracted personality attribute elements.

[0157] In a possible implementation, the process of constructing the personality question and answer data according to the user question, the extracted personality attribute elements, and the personality attribute element values ​​corresponding to the extracted personality attribute elements may include:

[0158] Step c31: input the user question, the extracted personality attribute elements, and the personality attribute element values ​​corresponding to the extracted personality attribute elements into the fine-tuned large language model to obtain the answer generated by the fine-tuned large language model for the user question.

[0159] Specifically, the user question, the extracted personality attribute elements, and the personality attribute element values ​​corresponding to the extracted personality attribute elements are filled into the second prompt format template to obtain a third prompt instruction, and the third prompt instruction is input into the fine-tuned large language model to obtain the answer generated by the fine-tuned large language model for the user question.

[0160] Among them, the second prompt format template includes a question slot and a personality attribute information slot. When the user question, the extracted personality attribute elements, and the personality attribute element values ​​corresponding to the extracted personality attribute elements are filled into the second prompt format template, the user question is filled into the question slot, and the extracted personality attribute elements and the personality attribute element values ​​corresponding to the extracted personality attribute elements are filled into the personality attribute information slot. The second prompt format template is used to instruct the fine-tuned large language model to generate an answer to the question in the question slot according to the personality attribute information in the personality attribute information slot.

[0161] Step c32: Obtain the persona question and answer data based on the user question and the answer generated by the fine-tuned large language model for the user question.

[0162] The specific implementation process of step c32 can refer to the specific implementation process of step S402, which will not be described in detail in this embodiment.

[0163] Step S608a: Utilize the newly constructed character question and answer data to optimize the fine-tuned large language model.

[0164] The method for privatizing the personality of a large language model provided in an embodiment of the present application first constructs personality question and answer data according to the set personality information and the created question and answer template, and then uses the constructed personality question and answer data to fine-tune the large language model. Considering that the fine-tuned large language model may not be stable enough, the embodiment of the present application introduces the following strategy: during the use of the fine-tuned large language model, it is determined whether the answer corresponding to the user question (the answer generated by the fine-tuned large language model for the user question) meets the set personality information. If the answer corresponding to the user question does not meet the set personality information, it is further determined whether the answer corresponding to the user question has personality attribute elements that are not covered by the set personality information. If the answer corresponding to the user question has personality attribute elements that are not covered by the set personality information, personality question and answer data is constructed for the personality attribute elements that are not covered by the set personality information. If the answer corresponding to the user question does not contain the personality attribute elements that are not covered by the set personality information, personality question and answer data is constructed for the user question. Finally, the fine-tuned large language model is optimized using the newly constructed personality question and answer data.

[0165] The method for privatizing the personality of a large language model provided in the embodiment of the present application can automatically construct personality question and answer data that matches the needs of the enterprise. The construction efficiency of the personality question and answer data is high, the construction difficulty is low, and the construction cost is low. After obtaining the personality question and answer data, the embodiment of the present application uses the personality question and answer data to fine-tune the large language model, thereby obtaining a large language model that can generate answers that meet the set personality information for input personality-related questions, thereby achieving the personality privatization of the large language model. In order to improve the stability of the large language model, the embodiment of the present application evaluates the answers generated during the use of the large language model, and when the generated answers do not meet the set personality information, constructs new personality question and answer data according to the corresponding questions, and then uses the new personality question and answer data to optimize the large language model. Through optimization, a large language model with better stability and stronger response ability can be obtained.

[0166] A method for privatizing a large language model personality provided in an embodiment of the present application is introduced above. A device for executing the method for privatizing a large language model personality described above will be introduced below.

[0167] See also Figure 7 , Figure 7 A structural diagram of a large language model personality privatization device provided in an embodiment of the present application, the large language model personality privatization device may include: a personality question and answer data generation module 701 and a model training module 702.

[0168] The character question and answer data generation module 701 is used to generate answers that conform to the set character information for questions in the question and answer template based on the set character information and the answers in the created question and answer template, and obtain the character answers corresponding to the questions in the question and answer template; and obtain character question and answer data based on the questions in the question and answer template and the character answers corresponding to the questions in the question and answer template.

[0169] The set personality information may include a number of personality attribute elements and personality attribute element values ​​corresponding to the number of personality attribute elements.

[0170] In this embodiment, the enterprise manager can set the personal information and create a question and answer template. The personal question and answer data generation module 701 can store the set personal information and question and answer template. When it is necessary to construct personal question and answer data, the personal question and answer data generation module 701 can construct personalized personal question and answer data according to the set personal information and the created question and answer template. The personal question and answer data generation module 701 has flexibility and adaptability.

[0171] The model training module 702 is used to fine-tune the large language model using the character question and answer data generated by the character question and answer data generation module 701, so as to obtain a large language model that can generate answers that conform to the set character information for input character-related questions.

[0172] In a possible implementation, the character setting question and answer data generation module 701 generates answers that meet the set character setting information for questions in the question and answer template according to the set character setting information and the answers in the created question and answer template, specifically for:

[0173] The set personality information and the created question-and-answer template are input into the large language model, and the large language model generates answers that conform to the set personality information for questions in the question-and-answer template based on the set personality information and the answers in the question-and-answer template.

[0174] In a possible implementation, when the character setting question and answer data generation module 701 obtains the character setting question and answer data according to the questions in the question and answer template and the character setting answers corresponding to the questions in the question and answer template, it is specifically used to:

[0175] Rewrite the question in the question-and-answer template to obtain a rewritten question, wherein the rewritten question has the same semantics as the original question but a different expression;

[0176] Conduct quality assessment on the questions in the Q&A template and the rewritten questions;

[0177] Questions that meet the quality requirements and the corresponding character answers are combined into character question and answer data.

[0178] In order to improve the stability of the large language model, in a possible implementation, the large language model personality privatization device may also include: a model feedback response module 703 and a self-evolution module 704.

[0179] The model feedback reply module 703 can interact directly with the user to:

[0180] Input the user's question into the fine-tuned large language model to obtain the corresponding answer to the user's question;

[0181] After obtaining the answer to the user's question, determine whether the answer to the user's question is consistent with the set persona information;

[0182] If the answer to the user's question does not match the set persona information, determine whether there are persona attribute elements in the answer to the user's question that are not covered by the set persona information;

[0183] If the answer to the user's question contains a personality attribute element that is not covered by the set personality information, the preset fallback reply is fed back to the user, and the personality attribute element that is not covered by the set personality information is provided to the self-evolution module 704;

[0184] If the answer to the user's question does not contain any personality attribute element that is not covered by the set personality information, the answer to the user's question will be fed back to the user, and the user's question will be provided to the self-evolution module 704 or the personality question and answer data generation module 701.

[0185] In a possible implementation, when determining whether the answer to the user's question is consistent with the set personality information, the model feedback reply module 703 is specifically used to:

[0186] Determine whether the answer to the user's question is harmless;

[0187] If the answer to the user's question is harmless, the answer to the user's question is scored according to the set persona information;

[0188] If the score of the answer corresponding to the user question is less than the preset score threshold, it is determined that the answer corresponding to the user question does not conform to the set personality information; if the score of the answer corresponding to the user question is greater than or equal to the preset score threshold, it is determined that the answer corresponding to the user question conforms to the set personality information.

[0189] The model feedback reply module 703 is also used for:

[0190] If the answer to the user's question matches the set personality information, the answer to the user's question will be fed back to the user.

[0191] The model feedback reply module 703 is also used for:

[0192] If the character answer corresponding to the user's question is harmful, the preset fallback response will be fed back to the user.

[0193] The self-evolution module 704 is used to:

[0194] After obtaining the personal attribute elements not covered by the set personal information, obtaining knowledge information related to the personal attribute elements not covered by the set personal information from the enterprise knowledge base as the personal attribute element value corresponding to the personal attribute elements not covered by the set personal information;

[0195] The personality attribute elements not covered by the set personality information and the personality attribute element values ​​corresponding to the personality attribute elements not covered by the set personality information are provided to the personality question and answer data generating module 701 .

[0196] If the model feedback reply module 703 provides the user question to the self-evolution module 704 , the self-evolution module 704 is also used to provide the user question to the persona question and answer data generation module 701 .

[0197] The character setting question and answer data generating module 701 is also used for:

[0198] When obtaining the personality attribute elements not covered by the set personality information and the personality attribute element values ​​corresponding to the personality attribute elements not covered by the set personality information, constructing personality question and answer data for the personality attribute elements not covered by the set personality information;

[0199] When obtaining user questions, construct personal question and answer data based on the user questions.

[0200] The model training module 702 is also used to optimize the fine-tuned large language model using the newly constructed persona question and answer data generated by the persona question and answer data generation module 701.

[0201] In a possible implementation, when constructing the personality question and answer data for the personality attribute elements not covered by the set personality information, the personality question and answer data generating module 701 is specifically used to:

[0202] Supplementing the personality attribute elements not covered by the set personality information and the personality attribute element values ​​corresponding to the personality attribute elements not covered by the set personality information into the set personality information to obtain supplemented personality information;

[0203] Use the supplemented personality information and question and answer templates to build personality question and answer data.

[0204] In a possible implementation, when constructing the persona question and answer data for the user question, the persona question and answer data generating module 701 is specifically used to:

[0205] Extracting personality attributes from user questions;

[0206] Obtaining a personality attribute element value corresponding to the extracted personality attribute element from the set personality information;

[0207] Construct personality question and answer data based on user questions, extracted personality attribute elements, and personality attribute element values ​​corresponding to the extracted personality attribute elements.

[0208] It should be noted that the enterprise manager can modify, add, delete, etc. the person information stored in the person question and answer data generation module 701 as needed. After the person information is updated, the person question and answer data generation module 701 can create person question and answer data based on the updated person information and the question and answer template, and then use the created person question and answer data to optimize the large language model.

[0209] The large language model personality privatization device provided in the embodiment of the present application can realize the personality privatization of the large language model and meet the customization needs of the enterprise.

[0210] An embodiment of the present application also provides an electronic device, which may include: at least one processor, at least one communication interface, at least one memory and at least one communication bus.

[0211] In the embodiment of the present application, the number of the processor, the communication interface, the memory, and the communication bus is at least one, and the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0212] The processor may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application;

[0213] The memory 503 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0214] The memory stores a program, and the processor can call the program stored in the memory, where the program is used to implement the large language model personality privatization method provided in the above embodiment.

[0215] An embodiment of the present application also provides a computer-readable storage medium, which may store a computer program / instruction suitable for execution by a processor. When the computer program / instruction is executed by the processor, the large language model personality privatization method provided in the above embodiment is implemented.

[0216] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the large language model personality privatization method provided in the above embodiment.

[0217] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0218] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0219] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0220] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A method for privatizing a large language model character, characterized in that: include: According to the set character information and the answers in the created question and answer template, an answer that conforms to the character information is generated for the question in the question and answer template, and the character answer corresponding to the question in the question and answer template is obtained; Obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template; Fine-tune the large language model using the character question-answering data to obtain a large language model that can generate answers that match the character information for input character-related questions; The step of generating, based on the set persona information and the answers in the created question and answer template, answers that match the persona information for questions in the question and answer template include: The set personality information and the created question-and-answer template are input into the large language model, and the large language model generates answers that conform to the personality information for the questions in the question-and-answer template based on the personality information and the answers in the question-and-answer template.

2. The method for privatizing a large language model character according to claim 1, characterized in that: The obtaining of the persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template includes: Rewriting the question in the question-answer template to obtain a rewritten question, wherein the rewritten question has the same semantics as the original question but a different expression; Performing quality assessment on the questions in the question-and-answer template and the rewritten questions respectively; Questions that meet the quality requirements and the corresponding character answers are combined into character question and answer data.

3. The method for privatizing a large language model personality according to claim 1, characterized in that: The character information includes a plurality of character attribute elements and character attribute element values ​​corresponding to the plurality of character attribute elements respectively; The large language model personality privatization method further includes: Input the user question into the fine-tuned large language model to obtain the answer corresponding to the user question; Determine whether the answer corresponding to the user question is consistent with the persona information; If the answer corresponding to the user question does not conform to the personality information, determining whether there are personality attribute elements not covered by the personality information in the answer corresponding to the user question; If the answer to the user question contains a personality attribute element that is not covered by the personality information, a preset fallback reply is fed back to the user, and personality question and answer data is constructed for the personality attribute element that is not covered by the personality information; if the answer to the user question does not contain a personality attribute element that is not covered by the personality information, the answer to the user question is fed back to the user, and personality question and answer data is constructed for the user question; The fine-tuned large language model is optimized using the constructed human-set question-answering data.

4. The method for privatizing a large language model character according to claim 3, characterized in that: The determining whether the answer corresponding to the user question conforms to the persona information includes: Determining whether the answer to the user question is harmless; If the answer to the user question is harmless, scoring the answer to the user question according to the persona information; If the score of the answer corresponding to the user question is less than a preset score threshold, it is determined that the answer corresponding to the user question does not conform to the personality information; if the score of the answer corresponding to the user question is greater than or equal to the preset score threshold, it is determined that the answer corresponding to the user question conforms to the personality information.

5. The method for privatizing a large language model character according to claim 3, characterized in that: The constructing of personality question and answer data for personality attribute elements not covered by the personality information includes: Acquire, from the enterprise knowledge base, knowledge information related to the personality attribute elements not covered by the personality information as the personality attribute element values ​​corresponding to the personality attribute elements not covered by the personality information; Supplementing the personal attribute elements not covered by the personal information and the personal attribute element values ​​corresponding to the personal attribute elements not covered by the personal information into the personal information to obtain supplemented personal information; The supplemented personality information and the question and answer template are used to construct personality question and answer data.

6. The method for privatizing a large language model character according to claim 3, characterized in that: The constructing of the persona question and answer data for the user question includes: Extracting personality attribute elements from the user question; Obtaining a personality attribute element value corresponding to the extracted personality attribute element from the personality information; According to the user question, the extracted personality attribute elements and the personality attribute element values ​​corresponding to the extracted personality attribute elements, personality question and answer data are constructed.

7. The method for privatizing a large language model character according to claim 3, characterized in that: Also includes: If the answer corresponding to the user question is consistent with the personality information, the answer corresponding to the user question is fed back to the user.

8. The method for privatizing a large language model character according to claim 4, characterized in that: Also includes: If the personality answer corresponding to the user's question is harmful, the preset catch-all response will be fed back to the user.

9. A large language model personality privatization device, characterized in that: include: Personal question and answer data generation module and model training module; The character setting question and answer data generation module is used to generate answers that match the character setting information for questions in the question and answer template according to the set character setting information and the answers in the created question and answer template, and obtain character setting answers corresponding to the questions in the question and answer template; And, obtaining persona question and answer data according to the questions in the question and answer template and the persona answers corresponding to the questions in the question and answer template; The model training module is used to fine-tune the large language model using the character question and answer data to obtain a large language model that can generate answers that conform to the character information for input character-related questions; The character setting question and answer data generation module is specifically used to generate answers that conform to the character setting information for questions in the question and answer template according to the set character setting information and the answers in the created question and answer template: The set personality information and the created question-and-answer template are input into the large language model, and the large language model generates answers that conform to the personality information for the questions in the question-and-answer template based on the personality information and the answers in the question-and-answer template.

10. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the large language model personality privatization method as described in any one of claims 1 to 8.

11. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the large language model personality privatization method as described in any one of claims 1 to 8.

12. A computer program product, characterized in that The method comprises computer-readable instructions, which, when executed on an electronic device, enable the electronic device to implement the large language model persona privatization method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Dialogue processing method and device based on large language model and electronic equipment

    CN117251552A