CN118035425A - Interaction method and device based on natural language model, electronic equipment and medium - Google Patents

Interaction method and device based on natural language model, electronic equipment and medium Download PDF

Info

Publication number
CN118035425A
CN118035425A CN202410439866.6A CN202410439866A CN118035425A CN 118035425 A CN118035425 A CN 118035425A CN 202410439866 A CN202410439866 A CN 202410439866A CN 118035425 A CN118035425 A CN 118035425A
Authority
CN
China
Prior art keywords
language model
natural language
training
learning rate
interaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410439866.6A
Other languages
Chinese (zh)
Inventor
汪玉
宁雪妃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tsinghua University
Original Assignee
Tsinghua University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tsinghua University filed Critical Tsinghua University
Priority to CN202410439866.6A priority Critical patent/CN118035425A/en
Publication of CN118035425A publication Critical patent/CN118035425A/en
Pending legal-status Critical Current

Links

Landscapes

  • Electrically Operated Instructional Devices (AREA)

Abstract

The present invention relates to the field of computer data processing, and in particular, to an interaction method, apparatus, electronic device, and medium based on a natural language model. The method comprises the following steps: receiving current interactive content of a user; inputting the current interaction content into a pre-trained natural language model, and outputting an interaction result corresponding to the current interaction content, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data; and sending the interaction result corresponding to the current interaction content to the user. Therefore, through utilizing the first learning rate and the second learning rate to carry out multi-stage training on the natural language model, the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the language model are different in a clear way after the question asking mode is changed for the same subject questions are solved, and the accuracy and the generalization capability of the natural language model are improved.

Description

Interaction method and device based on natural language model, electronic equipment and medium
Technical Field
The present invention relates to the field of computer data processing, and in particular, to an interaction method, apparatus, electronic device, and medium based on a natural language model.
Background
A large natural language model (Large Language Model, LLM for short), such as ChatGPT (CHAT GENERATIVE PRE-trained Transformer), is widely applied, powerful text understanding and dialogue capability are exclusionary, and besides, the model has rich discipline knowledge (such as deep knowledge of middle school, university, physical, chemical, biological, tuofu, elegance, computer, law and the like), various related questions can be consulted, answers to the questions can be given, and detailed explanation can be given according to questions of users, so that the model is easier to understand compared with fragmented results searched by a traditional search engine, and learning production efficiency is greatly improved. The training data of the large natural language model with the open source mainly comprises internet crawler data, only has a small amount of discipline knowledge data, and has weaker capability of answering discipline questions, so that fine adjustment is needed on the large natural language model with the open source, and knowledge in certain specific fields is provided.
In the related art, the specific mode of fine tuning is not unified at present, and how to better inject discipline knowledge into a large natural language model so as to improve the interactive experience of the model is a problem to be solved.
Disclosure of Invention
The invention provides an interaction method, an interaction device, electronic equipment and a medium based on a natural language model, which are used for solving the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the natural language model are possibly different after the question asking mode is changed for the same subject questions, so that the accuracy and generalization capability of the natural language model are improved.
To achieve the above objective, an embodiment of a first aspect of the present invention provides an interaction method based on a natural language model, including the following steps:
receiving current interactive content of a user;
Inputting the current interaction content into a pre-trained natural language model, and outputting an interaction result corresponding to the current interaction content, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data, and the first learning rate and the second learning rate are both used for determining a weight updating amplitude of the pre-trained natural language model;
And sending an interaction result corresponding to the current interaction content to the user.
According to one embodiment of the present invention, before inputting the current interactive content into the pre-trained natural language model and outputting the interactive result corresponding to the current interactive content, the method further includes:
Acquiring the general training data, the plurality of discipline knowledge data and weights of an initial language model;
Generating a first training sample according to the general training data and the plurality of disciplinary knowledge data, acquiring first prompt information corresponding to the first training sample from a preset prompt library, training the initial language model by using the first training sample and the first prompt information based on the weight of the initial language model and the first learning rate, and obtaining an intermediate language model;
Generating a second training sample according to the plurality of subject knowledge data, acquiring second prompt information corresponding to the second training sample from the preset prompt library, training the intermediate language model by using the second training sample and the second prompt information based on the weight of the intermediate language model and the second learning rate, and obtaining the pre-trained natural language model.
According to one embodiment of the invention, before obtaining the pre-trained natural language model, the method further comprises:
Judging whether a language model obtained by training the intermediate language model by using the second training sample and the second prompt information meets a preset training standard or not;
if the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training the initial language model by using the first training sample;
and if the preset training standard is met, determining the obtained language model as the pre-trained natural language model.
According to an embodiment of the present invention, before obtaining the first prompt information corresponding to the first training sample from the preset prompt library, the method further includes:
Acquiring a plurality of prompt templates;
Inputting the prompt templates into a preset dialogue language model to obtain a plurality of synonymous prompts corresponding to each prompt template;
And generating the preset prompt library according to the plurality of synonymous prompts corresponding to each prompt template.
According to one embodiment of the invention, the second learning rate is less than the first learning rate.
According to one embodiment of the invention, the first learning rate is 1e-4; the second learning rate is 2e-5.
According to the interaction method based on the natural language model, the current interaction content of the user is input into the pre-trained natural language model, and the interaction result corresponding to the current interaction content is output, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data; and sending the interaction result corresponding to the current interaction content to the user. Therefore, through utilizing the first learning rate and the second learning rate to carry out multi-stage training on the natural language model, the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the language model are different in a clear way after the question asking mode is changed for the same subject questions are solved, and the accuracy and the generalization capability of the natural language model are improved.
To achieve the above object, a second aspect of the present invention provides an interaction device based on a natural language model, including:
the receiving module is used for receiving the current interactive content of the user;
The training module is used for inputting the current interaction content into a pre-trained natural language model and outputting an interaction result corresponding to the current interaction content, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data, and the first learning rate and the second learning rate are both used for determining a weight updating range of the pre-trained natural language model;
and the sending module is used for sending the interaction result corresponding to the current interaction content to the user.
According to one embodiment of the invention, the training module further comprises:
The obtaining unit is used for obtaining the weights of the general training data, the plurality of discipline knowledge data and the initial language model before inputting the current interaction content into the pre-trained natural language model and outputting the interaction result corresponding to the current interaction content;
The first training unit is used for generating a first training sample according to the general training data and the plurality of disciplinary knowledge data, acquiring first prompt information corresponding to the first training sample from a preset prompt library, training the initial language model by using the first training sample and the first prompt information based on the weight of the initial language model and the first learning rate, and obtaining an intermediate language model;
The second training unit is used for generating a second training sample according to the plurality of subject knowledge data, acquiring second prompt information corresponding to the second training sample from the preset prompt library, training the intermediate language model by using the second training sample and the second prompt information based on the weight of the intermediate language model and the second learning rate, and obtaining the pre-trained natural language model.
According to an embodiment of the invention, before obtaining the pre-trained natural language model, the second training unit is further configured to:
Judging whether a language model obtained by training the intermediate language model by using the second training sample and the second prompt information meets a preset training standard or not;
if the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training the initial language model by using the first training sample;
and if the preset training standard is met, determining the obtained language model as the pre-trained natural language model.
According to an embodiment of the present invention, before obtaining the first prompt information corresponding to the first training sample from the preset prompt library, the first training unit is further configured to:
Acquiring a plurality of prompt templates;
Inputting the prompt templates into a preset dialogue language model to obtain a plurality of synonymous prompts corresponding to each prompt template;
And generating the preset prompt library according to the plurality of synonymous prompts corresponding to each prompt template.
According to one embodiment of the invention, the second learning rate is less than the first learning rate.
According to one embodiment of the invention, the first learning rate is 1e-4; the second learning rate is 2e-5.
According to the interaction device based on the natural language model, the current interaction content of the user is input into the pre-trained natural language model, and the interaction result corresponding to the current interaction content is output, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data; and sending the interaction result corresponding to the current interaction content to the user. Therefore, through utilizing the first learning rate and the second learning rate to carry out multi-stage training on the natural language model, the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the language model are different in a clear way after the question asking mode is changed for the same subject questions are solved, and the accuracy and the generalization capability of the natural language model are improved.
To achieve the above object, an embodiment of a third aspect of the present invention provides an electronic device, including: the system comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the program to realize the interaction method based on the natural language model as described in the embodiment.
To achieve the above object, a fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program for execution by a processor for implementing the natural language model based interaction method as described in the above embodiments.
To achieve the above object, an embodiment of a fifth aspect of the present invention proposes a computer program product comprising a computer program for implementing a natural language model based interaction method as described in the above embodiment, when the computer program is executed by a processor.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
FIG. 1 is a flow chart of an interaction method based on a natural language model according to an embodiment of the present invention;
FIG. 2 is a flow chart of another interaction method based on a natural language model according to an embodiment of the present invention;
FIG. 3 is a block diagram of an interaction device based on a natural language model according to an embodiment of the present invention;
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative and intended to explain the present invention and should not be construed as limiting the invention.
The following describes an interaction method, an apparatus, an electronic device and a medium based on a natural language model according to an embodiment of the present invention with reference to the accompanying drawings, and first describes an interaction method based on a natural language model according to an embodiment of the present invention with reference to the accompanying drawings.
FIG. 1 is a flow chart of a natural language model based interaction method in accordance with one embodiment of the present invention.
As shown in fig. 1, the interaction method based on the natural language model includes the following steps:
In step S101, the current interactive content of the user is received.
It will be appreciated that the current interactive content of the user includes, but is not limited to, text entered by the user, mouse position and click events, keyboard keys, and the like.
In step S102, the current interaction content is input to a pre-trained natural language model, and an interaction result corresponding to the current interaction content is output, where the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on the general training data and the plurality of subject knowledge data, and the first learning rate and the second learning rate are both used for determining a weight update range of the pre-trained natural language model.
Specifically, after receiving the current interactive content of the user, necessary preprocessing can be performed on the interactive content, such as data cleaning, format conversion, word segmentation, stop word removal and the like, so that the natural language model can better process and understand the data; inputting the preprocessed interactive content into a pre-trained natural language model, wherein the natural language model mainly receives and processes the input content of a user in a text form in the interactive process, namely the user can input the current interactive content in a text, voice or handwriting mode, and the step can be realized by calling an API (Application Programming Interface, application program interface) of the language model or directly using a related interface of the language model; after receiving the current interactive content, the pre-trained natural language model can perform reasoning and calculation according to the learning parameters and algorithms in the pre-trained natural language model so as to generate an interactive result corresponding to the current interactive content.
The pre-trained natural language model can be obtained by training a large amount of text data, namely general training data (such as web crawler data) and a plurality of disciplinary knowledge data by using a first learning rate and a second learning rate, wherein the first learning rate and the second learning rate are used for controlling the amplitude of the pre-trained natural language model when the weight is updated each time, so that various modes and context information of the language are understood.
In step S103, an interaction result corresponding to the current interaction content is sent to the user.
That is, after the interactive result corresponding to the current interactive content is obtained, the interactive result corresponding to the current interactive content is extracted from the pre-trained natural language model, that is, the interactive result corresponding to the current interactive content is sent to the user, and the results can be presented in the forms of text, voice and the like, for example, in the chat robot application, the results can be replied to the user in the form of text messages; in a voice assistant application, the results may be conveyed to the user in the form of a voice broadcast.
For ease of understanding, the following describes in detail how the present invention may be implemented in a pre-trained natural language model.
As a possible implementation manner, in some embodiments, before inputting the current interaction content into the pre-trained natural language model and outputting the interaction result corresponding to the current interaction content, the method further includes: acquiring general training data, a plurality of discipline knowledge data and weights of an initial language model; generating a first training sample according to the general training data and the plurality of subject knowledge data, acquiring first prompt information corresponding to the first training sample from a preset prompt library, training an initial language model based on the weight and the first learning rate of the initial language model, and utilizing the first training sample and the first prompt information to obtain an intermediate language model; generating a second training sample according to the plurality of subject knowledge data, acquiring second prompt information corresponding to the second training sample from a preset prompt library, training the intermediate language model by using the second training sample and the second prompt information based on the weight and the second learning rate of the intermediate language model, and obtaining a pre-trained natural language model.
Further, in some embodiments, the first learning rate is 1e-4; the second learning rate is 2e-5.
It will be appreciated that in order for a large natural language model to master knowledge in a particular domain, a large amount of generic training data is collected first, which is from a wide variety of domains and scenarios, with extensive coverage and representativeness, while a plurality of discipline knowledge data is collected, which covers knowledge and information in different domains, and can provide specialized knowledge and support for the pre-trained natural language model.
Specifically, as shown in fig. 2, first, an initial language model is trained based on general training data, so that a large natural language model has basic capabilities such as language understanding, and weights of the large natural language model are obtained, wherein the weights refer to parameters in a neural network, the parameters are used for adjusting and learning behaviors of the model, so that effective characteristics can be effectively mapped and extracted from input data, and when the model is trained, the weights of the model are updated through back propagation derivative so as to finally obtain a model with stronger generalization capability. Therefore, the weight for obtaining the natural language big model mentioned in the embodiment of the invention is the natural language big model under the corresponding weight. For the large model of open source natural language (such as Llama 2), the training of this stage is completed, and the weight of the large model of open source natural language can be directly obtained as the weight of the initial language model of the embodiment of the present invention (such as the first stage shown in FIG. 2), for example, some companies and institutions disclose a model available for downloading by all persons on the Internet. The training of the initial language model is performed based on the weight of the initial language model and the first learning rate, so that an intermediate language model and the weight thereof (as shown in the second stage of fig. 2) can be obtained, and the training of the intermediate language model is performed based on the weight of the intermediate language model and the second learning rate, so that a pre-trained natural language model (as shown in the third stage of fig. 2) can be obtained.
Taking the injection of subject knowledge data into a large natural language model as an example, firstly expanding a vocabulary of an initial language model, screening data (such as published Chinese and English data in a network) related to a pre-trained natural language model processing task from general training data, wherein the data has certain representativeness, universality and diversity, simultaneously screening data (such as a part of subset of published data sets) related to a specific domain (such as the domain of the science) from a plurality of subject knowledge data, wherein the data comprises information of professional knowledge, terms, concepts and the like of the domain, generating a first training sample according to the screened general training data and the subject knowledge data, wherein each data set is not subjected to oversampling (namely, each sample is only trained once), acquiring first prompt information corresponding to the first training sample from a preset prompt library, and gradually acquiring intermediate training data and training data according to the weight and the first learning rate (such as 1e-4, namely 0.0001, or 2e-4, namely, 0.0002) of the initial language model, and utilizing the generated first training sample and the first prompt information to acquire intermediate training sample, and gradually acquire the accuracy of the intermediate language model and the training performance in the training model and the training model.
It can be understood that the main forms of the knowledge data of the subjects used in the embodiment of the present invention are selection questions and gap filling questions, and corresponding answers and analyses, and in the training process, first prompt information (such as "the selection questions (or gap filling questions) related to the subjects of mathematics (or english, etc.) are added to the current face of each question, please select (or fill in) the correct options") can be added, so that the language model can clearly define the meanings of the task of "selection questions" and the task of "gap filling questions" in the training process, and the first prompt information can be obtained from a preset prompt library, where the preset prompt library includes a plurality of prompt information of a plurality of subjects. The training process is added with universal training data of multiple languages (such as Chinese and English), the language model can contact the training data of different languages, the language (such as Chinese) understanding capability of the language model can be enhanced, catastrophic forgetting can be avoided, and the memory of the previously learned universal knowledge is still reserved while new discipline knowledge data is injected, so that more comprehensive knowledge reserve is maintained.
Further, after obtaining the intermediate language model, fine tuning is performed on the plurality of discipline knowledge data based on the weights of the intermediate language model, and since the learning of discipline knowledge is more complex than general knowledge, the plurality of discipline knowledge data needs to be additionally trained to enhance the expertise capability of the language model with respect to a specific domain, the fine tuning process can adjust the language model parameters using a second learning rate (e.g., 2e-5, i.e., 0.00002, or 2e-6, i.e., 0.000002) in order to better adapt and optimize the performance of the language model in the specific domain. Generating a second training sample according to the plurality of subject knowledge data, wherein each data set is still not oversampled (i.e. each sample is trained only once), acquiring second prompt information corresponding to the second training sample from a preset prompt library, and training the intermediate language model by using the generated second training sample and the second prompt information based on the weight and the second learning rate of the intermediate language model, thereby obtaining a pre-trained natural language model (such as Llama2, the underlying structure of which can be a transducer). Through fine adjustment on subject knowledge data, the obtained pre-trained natural language model can better understand and apply the expertise in the specific field, thereby improving the accuracy of the model in related tasks and adapting to the requirements and applications in different fields.
Wherein, in some embodiments, the second learning rate is less than the first learning rate.
It should be noted that the learning rate is an important parameter of the language model, it determines the updating amplitude of the weight of the language model in the training process, the specific value of the learning rate can be determined according to the information or personal experience in each large model publication, and a lower learning rate means that the variation of the parameter is smaller when updating each time, which is helpful for the language model to converge more stably in the fine tuning process. Therefore, in the two training of the language model, in order to avoid the catastrophic forgetting phenomenon, the second learning rate is set to be smaller than the first learning rate, for example, the second learning rate may be 5 times smaller, 10 times smaller, 50 times smaller, 100 times smaller, or the like than the first learning rate, and is not particularly limited herein.
It can be understood that if the same prompt information is adopted for all the discipline knowledge training samples, the language model has poor generalization ability for understanding the natural language processing task, that is, when the user interacts with the language model by using the prompt information of another expression, the language model may have a condition of answering questions, for example, the prompt information used in the training process is "the following is a choice question about english discipline, please select a correct option", and the user asks "the following is the correct option" when testing, so that the situation that the language model cannot accurately answer the user question is very likely to occur. Based on the problem, the embodiment of the invention establishes a preset prompt library to increase the diversity of discipline knowledge prompts, and how to obtain the preset prompt library will be described below.
As a possible implementation manner, in some embodiments, before acquiring the first prompt information corresponding to the first training sample from the preset prompt library, the method further includes: acquiring a plurality of prompt templates; inputting a plurality of prompt templates into a preset dialogue language model to obtain a plurality of synonymous prompts corresponding to each prompt template; and generating a preset prompt library according to a plurality of synonymous prompts corresponding to each prompt template.
Specifically, a plurality of prompt templates are obtained, each prompt template represents a problem prompt, the problem prompt can be set manually in a self-defined manner, the prompt templates are input into a preset dialogue language model (such as ChatGPT), each prompt template can obtain a plurality of prompts with the same meaning but different expressions (namely synonymous prompts), or a plurality of synonymous prompts can be obtained based on each prompt template in a manual operation mode, the prompts with problems in the prompts (such as obviously outlier prompts after clustering or prompts with the length lower than a threshold value) can be filtered out by a computer based on a preset standard or manual operation, the rest synonymous prompts can meet requirements, and the rest synonymous prompts are constructed into a set, namely a preset prompt library. The prompt library comprises a plurality of synonymous prompts corresponding to each prompt template, and when the subject knowledge data sample is trained each time, any prompt can be extracted from the preset prompt library in a random or cyclic mode and the like to serve as the prompt information of the current training sample, so that the generalization capability of the language model for understanding the natural language processing task is improved.
Further, in some embodiments, before deriving the pre-trained natural language model, further comprising: judging whether a language model obtained by training the intermediate language model by using the second training sample and the second prompt information meets a preset training standard or not; if the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training an initial language model by using the first training sample; if the preset training standard is met, the obtained language model is determined to be a pre-trained natural language model.
It can be understood that, in order to ensure the accuracy and the professional level of the pre-trained natural language model, the training method is better applied to the natural language processing task, and after the intermediate language model is trained by using the second training sample and the second prompt information, the language model obtained by training the intermediate language model can be evaluated and judged according to the preset training standard. That is, it is determined whether the language model obtained by training the intermediate language model using the second training sample and the second prompt information meets a preset training standard, where the preset training standard may be a performance index of the language model on a specific task, such as an index of accuracy, recall, loss being less than a threshold, and the like. If the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training the initial language model by using the first training sample, that is, repeatedly executing the step of training according to the general training data and the plurality of disciplinary knowledge data until the language model meets the preset training standard; if the preset training criteria have been met, the resulting language model may be determined to be a pre-trained natural language model. Thus, the generalization ability of the language model is enhanced, and the expertise level of the language model in a specific field is enhanced.
According to the interaction method based on the natural language model, the current interaction content of the user is input into the pre-trained natural language model, and the interaction result corresponding to the current interaction content is output, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data; and sending the interaction result corresponding to the current interaction content to the user. Therefore, through utilizing the first learning rate and the second learning rate to carry out multi-stage training on the natural language model, the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the language model are different in a clear way after the question asking mode is changed for the same subject questions are solved, and the accuracy and the generalization capability of the natural language model are improved.
Next, an interaction device based on a natural language model according to an embodiment of the present invention will be described with reference to the accompanying drawings.
FIG. 3 is a block diagram of an interaction device based on a natural language model in accordance with one embodiment of the present invention.
As shown in fig. 3, the natural language model based interaction device 10 includes: a receiving module 100, a training module 200 and a transmitting module 300.
The receiving module 100 is configured to receive current interactive content of a user;
The training module 200 is configured to input the current interaction content into a pre-trained natural language model, and output an interaction result corresponding to the current interaction content, where the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on the general training data and the multiple discipline knowledge data, and the first learning rate and the second learning rate are both used to determine a weight update range of the pre-trained natural language model;
and the sending module 300 is used for sending the interaction result corresponding to the current interaction content to the user.
Further, in some embodiments, training module 200 further comprises:
The acquisition unit is used for acquiring the general training data, the plurality of discipline knowledge data and the weight of the initial language model before inputting the current interaction content into the pre-trained natural language model and outputting the interaction result corresponding to the current interaction content;
the first training unit is used for generating a first training sample according to the general training data and the plurality of disciplinary knowledge data, acquiring first prompt information corresponding to the first training sample from a preset prompt library, training an initial language model by using the first training sample and the first prompt information based on the weight and the first learning rate of the initial language model, and obtaining an intermediate language model;
The second training unit is used for generating a second training sample according to the plurality of subject knowledge data, acquiring second prompt information corresponding to the second training sample from a preset prompt library, training the intermediate language model by using the second training sample and the second prompt information based on the weight and the second learning rate of the intermediate language model, and obtaining a pre-trained natural language model.
Further, in some embodiments, the second training unit is further configured to, prior to deriving the pre-trained natural language model:
judging whether a language model obtained by training the intermediate language model by using the second training sample and the second prompt information meets a preset training standard or not;
If the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training an initial language model by using the first training sample;
if the preset training standard is met, the obtained language model is determined to be a pre-trained natural language model.
Further, in some embodiments, before acquiring the first prompt information corresponding to the first training sample from the preset prompt library, the first training unit is further configured to:
Acquiring a plurality of prompt templates;
Inputting a plurality of prompt templates into a preset dialogue language model to obtain a plurality of synonymous prompts corresponding to each prompt template;
and generating a preset prompt library according to a plurality of synonymous prompts corresponding to each prompt template.
Further, in some embodiments, the second learning rate is less than the first learning rate.
Further, in some embodiments, the first learning rate is 1e-4; the second learning rate is 2e-5.
It should be noted that the foregoing explanation of the embodiment of the interaction method based on the natural language model is also applicable to the interaction device based on the natural language model of this embodiment, which is not repeated herein.
According to the interaction device based on the natural language model, the current interaction content of the user is input into the pre-trained natural language model, and the interaction result corresponding to the current interaction content is output, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data; and sending the interaction result corresponding to the current interaction content to the user. Therefore, through utilizing the first learning rate and the second learning rate to carry out multi-stage training on the natural language model, the problems that the prior training injection field knowledge scheme is not clear, and the answer results of the language model are different in a clear way after the question asking mode is changed for the same subject questions are solved, and the accuracy and the generalization capability of the natural language model are improved.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device may include:
memory 401, processor 402, and a computer program stored on memory 401 and executable on processor 402.
The processor 402 implements the interaction method based on the natural language model provided in the above embodiment when executing a program.
Further, the electronic device further includes:
A communication interface 403 for communication between the memory 401 and the processor 402.
A memory 401 for storing a computer program executable on the processor 402.
Memory 401 may include high-speed RAM (Random Access Memory ) memory, and may also include non-volatile memory, such as at least one disk memory.
If the memory 401, the processor 402, and the communication interface 403 are implemented independently, the communication interface 403, the memory 401, and the processor 402 may be connected to each other by a bus and perform communication with each other. The bus may be an ISA (Industry Standard Architecture ) bus, a PCI (PERIPHERAL COMPONENT INTERCONNECT, external device interconnect) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus.
Alternatively, in a specific implementation, if the memory 401, the processor 402, and the communication interface 403 are integrated on a chip, the memory 401, the processor 402, and the communication interface 403 may perform communication with each other through internal interfaces.
The processor 402 may be a CPU (Central Processing Unit ) or an ASIC (Application SPECIFIC INTEGRATED Circuit, application specific integrated Circuit) or one or more integrated circuits configured to implement embodiments of the present invention.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when being executed by a processor, implements the interaction method based on the natural language model as above.
The embodiment of the invention also provides a computer program product, comprising a computer program, wherein the computer program is executed by a processor to realize the interaction method based on the natural language model.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present invention, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.

Claims (10)

1. An interaction method based on a natural language model is characterized by comprising the following steps:
receiving current interactive content of a user;
Inputting the current interaction content into a pre-trained natural language model, and outputting an interaction result corresponding to the current interaction content, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data, and the first learning rate and the second learning rate are both used for determining a weight updating amplitude of the pre-trained natural language model;
And sending an interaction result corresponding to the current interaction content to the user.
2. The natural language model based interaction method of claim 1, wherein before inputting the current interaction content into the pre-trained natural language model and outputting the interaction result corresponding to the current interaction content, the method further comprises:
Acquiring the general training data, the plurality of discipline knowledge data and weights of an initial language model;
Generating a first training sample according to the general training data and the plurality of disciplinary knowledge data, acquiring first prompt information corresponding to the first training sample from a preset prompt library, training the initial language model by using the first training sample and the first prompt information based on the weight of the initial language model and the first learning rate, and obtaining an intermediate language model;
Generating a second training sample according to the plurality of subject knowledge data, acquiring second prompt information corresponding to the second training sample from the preset prompt library, training the intermediate language model by using the second training sample and the second prompt information based on the weight of the intermediate language model and the second learning rate, and obtaining the pre-trained natural language model.
3. The natural language model based interaction method of claim 2, wherein prior to deriving the pre-trained natural language model, the method further comprises:
Judging whether a language model obtained by training the intermediate language model by using the second training sample and the second prompt information meets a preset training standard or not;
if the preset training standard is not met, re-executing the steps of generating a first training sample according to the general training data and the plurality of disciplinary knowledge data and training the initial language model by using the first training sample;
and if the preset training standard is met, determining the obtained language model as the pre-trained natural language model.
4. The interaction method based on a natural language model according to claim 2, wherein before obtaining the first prompt information corresponding to the first training sample from the preset prompt library, the method further comprises:
Acquiring a plurality of prompt templates;
Inputting the prompt templates into a preset dialogue language model to obtain a plurality of synonymous prompts corresponding to each prompt template;
And generating the preset prompt library according to the plurality of synonymous prompts corresponding to each prompt template.
5. The natural language model based interaction method of any of claims 1-4, wherein the second learning rate is less than the first learning rate.
6. The method of natural language model based interactions of claim 5,
The first learning rate is 1e-4;
The second learning rate is 2e-5.
7. An interaction device based on a natural language model, comprising:
the receiving module is used for receiving the current interactive content of the user;
The training module is used for inputting the current interaction content into a pre-trained natural language model and outputting an interaction result corresponding to the current interaction content, wherein the pre-trained natural language model is obtained by training with a first learning rate and a second learning rate based on general training data and a plurality of subject knowledge data, and the first learning rate and the second learning rate are both used for determining a weight updating range of the pre-trained natural language model;
and the sending module is used for sending the interaction result corresponding to the current interaction content to the user.
8. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the natural language model based interaction method of any one of claims 1-6.
9. A computer readable storage medium having stored thereon a computer program, the program being executable by a processor for implementing the natural language model based interaction method of any of claims 1-6.
10. A computer program product comprising a computer program for implementing the natural language model based interaction method of any one of claims 1-6 when executed by a processor.
CN202410439866.6A 2024-04-12 2024-04-12 Interaction method and device based on natural language model, electronic equipment and medium Pending CN118035425A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410439866.6A CN118035425A (en) 2024-04-12 2024-04-12 Interaction method and device based on natural language model, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410439866.6A CN118035425A (en) 2024-04-12 2024-04-12 Interaction method and device based on natural language model, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN118035425A true CN118035425A (en) 2024-05-14

Family

ID=90997248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410439866.6A Pending CN118035425A (en) 2024-04-12 2024-04-12 Interaction method and device based on natural language model, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN118035425A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118278527A (en) * 2024-06-03 2024-07-02 浪潮电子信息产业股份有限公司 Natural language processing task execution and model training method, device and equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116150338A (en) * 2023-02-22 2023-05-23 山东浪潮科学研究院有限公司 Intelligent customer service method and system based on multi-round dialogue
CN116756579A (en) * 2023-08-22 2023-09-15 腾讯科技(深圳)有限公司 Training method of large language model and text processing method based on large language model
CN116976424A (en) * 2023-07-03 2023-10-31 平安科技(深圳)有限公司 Model training method, device, equipment and medium suitable for large language model
CN117112769A (en) * 2023-10-23 2023-11-24 南京国睿信维软件有限公司 Intelligent fault maintenance question-answering system and method based on large language model
CN117390142A (en) * 2023-12-12 2024-01-12 浙江口碑网络技术有限公司 Training method and device for large language model in vertical field, storage medium and equipment
CN117390151A (en) * 2023-10-10 2024-01-12 哈尔滨工业大学 Method for establishing structural health diagnosis visual-language basic model and multi-mode interaction system
CN117521675A (en) * 2023-11-06 2024-02-06 腾讯科技(深圳)有限公司 Information processing method, device, equipment and storage medium based on large language model
CN117609421A (en) * 2023-10-25 2024-02-27 中国电力工程顾问集团西南电力设计院有限公司 Electric power professional knowledge intelligent question-answering system construction method based on large language model
CN117668174A (en) * 2023-10-23 2024-03-08 科大讯飞股份有限公司 Method for constructing medical question-answering language model, and related method and equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116150338A (en) * 2023-02-22 2023-05-23 山东浪潮科学研究院有限公司 Intelligent customer service method and system based on multi-round dialogue
CN116976424A (en) * 2023-07-03 2023-10-31 平安科技(深圳)有限公司 Model training method, device, equipment and medium suitable for large language model
CN116756579A (en) * 2023-08-22 2023-09-15 腾讯科技(深圳)有限公司 Training method of large language model and text processing method based on large language model
CN117390151A (en) * 2023-10-10 2024-01-12 哈尔滨工业大学 Method for establishing structural health diagnosis visual-language basic model and multi-mode interaction system
CN117112769A (en) * 2023-10-23 2023-11-24 南京国睿信维软件有限公司 Intelligent fault maintenance question-answering system and method based on large language model
CN117668174A (en) * 2023-10-23 2024-03-08 科大讯飞股份有限公司 Method for constructing medical question-answering language model, and related method and equipment
CN117609421A (en) * 2023-10-25 2024-02-27 中国电力工程顾问集团西南电力设计院有限公司 Electric power professional knowledge intelligent question-answering system construction method based on large language model
CN117521675A (en) * 2023-11-06 2024-02-06 腾讯科技(深圳)有限公司 Information processing method, device, equipment and storage medium based on large language model
CN117390142A (en) * 2023-12-12 2024-01-12 浙江口碑网络技术有限公司 Training method and device for large language model in vertical field, storage medium and equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118278527A (en) * 2024-06-03 2024-07-02 浪潮电子信息产业股份有限公司 Natural language processing task execution and model training method, device and equipment

Similar Documents

Publication Publication Date Title
CN106503236B (en) Artificial intelligence based problem classification method and device
RU2708941C1 (en) Method and apparatus for recognizing segmented sentences for a human-machine intelligent question-answer system
CN109086303A (en) The Intelligent dialogue method, apparatus understood, terminal are read based on machine
CN106875940B (en) Machine self-learning construction knowledge graph training method based on neural network
CN118035425A (en) Interaction method and device based on natural language model, electronic equipment and medium
CN117453885A (en) Question information processing method, device, equipment, storage medium and product
CN116521841A (en) Method, device, equipment and medium for generating reply information
Vishwakarma et al. A review & comparative analysis on various chatbots design
CN111046674B (en) Semantic understanding method and device, electronic equipment and storage medium
CN109002498B (en) Man-machine conversation method, device, equipment and storage medium
CN116822633A (en) Model reasoning method and device based on self-cognition and electronic equipment
CN117952122A (en) Training method of user portrait model, dialogue processing method and related equipment
CN111460106A (en) Information interaction method, device and equipment
CN117235237B (en) Text generation method and related device
CN116898441B (en) Character testing method and device based on man-machine conversation and electronic equipment
CN116991982B (en) Interactive dialogue method, device, equipment and storage medium based on artificial intelligence
CN117556026B (en) Data generation method, electronic device and storage medium
CN117708307B (en) Method and device for fusing micro-tuning and Adapter of large language model
Ali et al. Intelligent Agents in Educational Institutions: AEdBOT–A Chatbot for Administrative Assistance using Deep Learning Hybrid Model Approach
CN111898389B (en) Information determination method, information determination device, computer equipment and storage medium
CN117494761A (en) Information processing and model training method, device, equipment, medium and program product
CN116955556A (en) Dialogue response processing method, device, equipment and storage medium
CN118428400A (en) Large model application system based on self-adaptive intelligence
CN118132721A (en) Intelligent question-answering method, intelligent question-answering device, related equipment and computer program product
CN114239941A (en) Report robot multi-round conversation strategy prediction method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination