Language model training method and man-machine interaction method based on language model
By fine-tuning training of multi-field large language models, the problem of limitations in the application scope of models in different fields is solved, and the target model applicable to multiple fields is realized, which reduces resource costs and improves the scope of interaction.
Patent Information
- Application Number
- CN202310810044.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-03
- Publication Date
- 2025-01-07
AI Technical Summary
The existing large language models have limited scope of application in human-computer interaction applications in different fields and need to be deployed separately, which increases resource costs.
By obtaining training data from multiple different fields, fine-tuning training of multi-field large language models to be trained, update the initial fine-tuning parameters of different fields, obtaining the target multi-field large language model, making it suitable for many different fields, and supporting dynamics Load targeted large language models for different fields.
It has achieved widespread application of multi-field large language models, reduced resource costs, avoided the separate deployment of models in different fields, and improved the application scope of data construction efficiency and human-computer interaction.
Smart Images

Figure CN119271764A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to the field of artificial intelligence technologies such as deep learning and human-computer interaction. Background Art
[0002] Large language models (LLM, Large Language Model, which is essentially a generative model), such as ChatGPT (Chat Generative Pre-trained Transformer, a chatbot program developed by OpenAI), can generate fluent human-like responses for many downstream tasks (such as task-oriented dialogue and question answering). Among them, large language models are trained with question-answering data in specific fields, so that large language models can achieve better results on downstream tasks in specific fields.
[0003] However, different fields have different corresponding question-answering data, and the large language model of a specific field is only applicable to human-computer interaction in that field, which has a limited scope of application. In addition, large language models in different fields need to be deployed separately, which increases resource costs. Therefore, there is an urgent need for a large language model that is applicable to multiple fields, so that the large language model can be applied more widely. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a human-computer interaction method based on a language model and a human-computer interaction method based on a language model, as well as corresponding devices, electronic devices and computer-readable storage media.
[0005] According to a first aspect of an embodiment of the present disclosure, a method for training a language model is provided, the method comprising:
[0006] Acquire a training data set, wherein the training data set includes training data in multiple different fields;
[0007] Determine a multi-domain large language model to be trained, wherein the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, and the parameters of the basic model are pre-trained;
[0008] The multi-domain large language model to be trained is fine-tuned using the training data of the multiple different domains, and the first initial fine-tuning parameters of the different domains are updated to obtain a target multi-domain large language model.
[0009] According to a second aspect of an embodiment of the present disclosure, a human-computer interaction method based on a language model is provided, the method comprising:
[0010] Obtaining question data that needs to be answered input by the user, and determining the target field to which the question data belongs;
[0011] Based on the target domain and the target multi-domain large language model, determining a target large language model corresponding to the target domain, wherein the target multi-domain large language model is obtained based on the language model training method described in the first aspect above;
[0012] The question data is input into the target large language model to obtain and output a target answer to the question data.
[0013] According to a third aspect of an embodiment of the present disclosure, a language model training device is provided, the device comprising:
[0014] An acquisition module, used to acquire a training data set, wherein the training data set includes training data in a variety of different fields;
[0015] A determination module is used to determine a multi-domain large language model to be trained, wherein the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, and the parameters of the basic model are pre-trained;
[0016] A training module is used to use the training data of the multiple different fields to fine-tune the multi-domain large language model to be trained, and to update the first initial fine-tuning parameters of the different fields to obtain a target multi-domain large language model.
[0017] According to a fourth aspect of an embodiment of the present disclosure, a human-computer interaction device based on a language model is provided, the device comprising:
[0018] An acquisition module is used to acquire question data that needs to be answered input by the user and determine the target field to which the question data belongs;
[0019] A determination module, configured to determine a target large language model corresponding to the target domain based on the target domain and the target multi-domain large language model, wherein the target multi-domain large language model is obtained based on the language model training device described in the third aspect above;
[0020] The output module is used to input the question data into the target large language model to obtain and output the target answer to the question data.
[0021] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0022] processor;
[0023] a memory for storing processor-executable instructions;
[0024] The processor is configured to implement the method described in any one of the first aspect or the second aspect.
[0025] According to the sixth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, wherein the computer storage medium stores computer-executable instructions; after the computer-executable instructions are executed by a processor, the method described in any one of the first aspect or the second aspect can be implemented.
[0026] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0027] In a training method for a language model proposed in the present disclosure, the method includes: obtaining a training data set, wherein the training data set includes training data from a variety of different fields; determining a multi-field large language model to be trained, wherein the multi-field large language model to be trained includes a basic model and first initial fine-tuning parameters for different fields, and the parameters of the basic model are pre-trained; using the training data from a variety of different fields to perform fine-tuning training on the multi-field large language model to be trained, and updating the first initial fine-tuning parameters for different fields to obtain a target multi-field large language model. Thus, the present disclosure trains the multi-field large language model to be trained through training in a variety of different fields to obtain a target multi-field large language model, so that the target multi-field large language model can be applied to a variety of different fields and has a wide range of applications. At the same time, the target multi-field large language model can simultaneously deploy and dynamically load target large language models in different fields, without the need to deploy large language models in different fields separately, thereby reducing resource costs.
[0028] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0030] Figure 1 is a flowchart of a language model training method according to some embodiments of the present disclosure;
[0031] Figure 2 is a flowchart of a language model training method according to some embodiments of the present disclosure;
[0032] Figure 3 is a flowchart of a language model training method according to some embodiments of the present disclosure;
[0033] Figure 4 is a flowchart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure;
[0034] Figure 5 is a flowchart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure;
[0035] Figure 6 is a flowchart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure;
[0036] Figure 7 is a structural schematic diagram of a language model training device according to some embodiments of the present disclosure;
[0037] Figure 8 is a structural schematic diagram of a human-computer interaction device based on a language model according to some embodiments of the present disclosure;
[0038] Fig. 9 It is a block diagram of an electronic device suitable for executing a language model training method and / or a language model-based human-computer interaction method according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0039] Some embodiments of the present disclosure will be described in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. Various changes, modifications and equivalents of the methods, devices and / or systems described herein will become apparent after understanding the present disclosure. For example, the order of operations described herein is merely an example and is not limited to those orders set forth herein, but can be changed as becomes apparent after understanding the present disclosure, except for operations that must be performed in a specific order. In addition, for clarity and brevity, descriptions of features known in the art may be omitted.
[0040] The embodiments described in some embodiments of the present disclosure below do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0041] Figure 1 is a flowchart of a method for training a language model according to some embodiments of the present disclosure, such as Figure 1 As shown, the method may include the following steps:
[0042] In step 101, a training data set is obtained, wherein the training data set includes training data in various fields.
[0043] It should be noted that the executor of the above-mentioned language model training method is a language model training device, which can be implemented by software and / or hardware. The language model training device in this embodiment can be configured in an electronic device.
[0044] In this example embodiment, the electronic device may include devices such as terminal devices and servers, and this embodiment does not limit the electronic device.
[0045] In the disclosed embodiment, the above-mentioned training data set may include training data in a variety of different fields, such as the legal field and the film field. Also, in the disclosed embodiment, the training data may include question-and-answer data, that is, question data in different fields and the corresponding real answers. Based on this, it is necessary to obtain question-and-answer data in a variety of different fields. In the prior art, training data in different fields are manually constructed. This method requires a lot of manual construction, and the construction takes a long time and is inefficient. In the disclosed embodiment, a training data set can be obtained through a trained large language model.
[0046] Specifically, in the disclosed embodiments, the method for obtaining a training data set may include obtaining text data from different fields, inputting the text data from different fields into a trained large language model through a text template, and obtaining question-answer data corresponding to different fields; and determining the question-answer data corresponding to different fields as the training data set. This part will be described in detail in the subsequent embodiments.
[0047] In step 102, a multi-domain large language model to be trained is determined, where the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains.
[0048] In the disclosed embodiment, the parameters of the above basic model are pre-trained, and there is no need to train the parameters of the basic model in the subsequent training of the multi-domain large language model to be trained. In the disclosed embodiment, the above basic model may include: an Embedding layer, N Transformer layers and a prediction layer, where N is a positive integer.
[0049] Furthermore, in the embodiment of the present disclosure, different fields correspond to different first initial fine-tuning parameters.
[0050] Further, in the embodiment of the present disclosure, the N Transformer layers in the above basic model can be set as needed. For example, the above basic model can include 32 Transformer layers.
[0051] In step 103, the multi-domain large language model to be trained is fine-tuned using training data from a variety of different domains, and the first initial fine-tuning parameters of different domains are updated to obtain a target multi-domain large language model.
[0052] Among them, in the embodiments of the present disclosure, the method of fine-tuning the multi-domain large language model to be trained using training data from multiple different fields, and updating the first initial fine-tuning parameters of different fields to obtain the target multi-domain large language model may include: fine-tuning the multi-domain large language model to be trained using question and answer data (i.e., question data and true answers) from multiple different fields, and updating the first initial fine-tuning parameters of different fields to obtain the target multi-domain large language model.
[0053] Specifically, in the disclosed embodiment, the method of fine-tuning the multi-domain large language model to be trained using question-answering data from a variety of different fields, and updating the first initial fine-tuning parameters of different fields to obtain the target multi-domain large language model may include: inputting the question data of the same field into the Embedding layer to obtain the first vector representation of the question data, and then inputting the first vector representation of the question data and the first initial fine-tuning parameters corresponding to the field into the N-layer Transformer layer to obtain the target vector representation of the question data, and inputting the target vector representation into the prediction layer to obtain the predicted answer of the question data, and based on the predicted answer and the true answer, obtain the corresponding loss value, and then update the first initial fine-tuning parameters corresponding to the field based on the loss value until convergence, or, when the number of iterations of the first initial fine-tuning parameters corresponding to the field reaches a preset number, obtain the target fine-tuning parameters corresponding to the field, repeat the above steps until the target fine-tuning parameters corresponding to different fields are obtained, and obtain the target multi-domain large language model through the basic model and the target fine-tuning parameters corresponding to different fields. This part will be described in detail in subsequent embodiments.
[0054] Among them, in the disclosed embodiment, the above-mentioned target multi-domain large language model can dynamically load the target large language models corresponding to different fields. Specifically, in the disclosed embodiment, the target multi-domain large language model can first load the basic model, and after determining the target field that needs to be interacted, the target fine-tuning parameters corresponding to the target field can be loaded, so that the target large language model composed of the target fine-tuning parameters and the basic model can perform subsequent interaction processes.
[0055] Furthermore, in the disclosed embodiments, when the target domain that needs to interact changes, the previous target fine-tuning parameters can be uninstalled and the target fine-tuning parameters corresponding to other target domains can be loaded, so that the target multi-domain large language model can be deployed and dynamically loaded with target large language models of multiple domains at the same time, without the need to deploy large language models of different domains separately, thereby reducing resource costs.
[0056] For example, assuming that the target multi-domain large language model includes target fine-tuning parameters for two fields, namely, the legal field and the film review field, the target multi-domain large language model can be deployed on one machine, and human-computer interaction services in the two fields can be provided by dynamically loading the corresponding target fine-tuning parameters.
[0057] It should be noted that in the embodiments of the present disclosure, the multi-domain large language model to be trained can be trained through training in a variety of different fields to obtain a target multi-domain large language model, so that the target multi-domain large language model can be applicable to a variety of different fields and has a wide range of applications.
[0058] In one or more embodiments of the present disclosure, a training data set is obtained, wherein the training data set includes training data from a variety of different fields; a multi-field large language model to be trained is determined, the multi-field large language model to be trained includes a basic model and first initial fine-tuning parameters for different fields, and the parameters of the basic model are pre-trained; the multi-field large language model to be trained is fine-tuned using the training data from a variety of different fields, and the first initial fine-tuning parameters for different fields are updated to obtain a target multi-field large language model. Thus, the present disclosure trains the multi-field large language model to be trained through training in a variety of different fields to obtain a target multi-field large language model, so that the target multi-field large language model can be applied to a variety of different fields and has a wide range of applications. At the same time, the target multi-field large language model can simultaneously deploy and dynamically load target large language models in different fields, without the need to deploy large language models in different fields separately, thereby reducing resource costs.
[0059] Figure 2 is a flowchart of a method for training a language model according to some embodiments of the present disclosure, such as Figure 2 As shown, the method may include the following steps:
[0060] In step 201, text data in different fields is obtained.
[0061] Among them, in the embodiments of the present disclosure, text data in different fields can be obtained through existing databases or public data (such as public documents, public audio data).
[0062] In step 202, text data based on different fields are input into a trained large language model through a text template to obtain question and answer data corresponding to different fields.
[0063] In the disclosed embodiment, after acquiring text data in different fields, the text data can be embedded into a text model, and the text template embedded in the text data can be input into a trained large language model to obtain question and answer data corresponding to different fields.
[0064] For example, suppose the acquired text data is "If I get into a car accident on the way to work, is it considered a work-related injury?", and the text template is "You are an AI smart assistant and will help us build training data in different fields for another AI model. You will read the text below and build question-and-answer data based on it. First, you need to determine the possible field of the data, such as legal advice, and then build question-and-answer data in this field based on the characteristics of this field. The text content is {}, and the constructed question-and-answer data will be text parsed in json. Please fully consider possible situations and provide enough question-and-answer data." The acquired text data is embedded in the position where the text content needs to be entered in the above text template, and then the text template with embedded text data is input into the trained large language model to obtain the corresponding training data.
[0065] Furthermore, in the disclosed embodiment, after obtaining text data in different fields, the text data can be embedded into a text template that can generate different language expression types, so as to obtain question and answer data corresponding to different language expression types in different fields. For example, "Please provide enough straightforward question and answer data" or "Please provide enough euphemistic question and answer data" can be added to the text template.
[0066] Furthermore, in the embodiments of the present disclosure, the above-mentioned trained large language model may be Chatgpt.
[0067] In step 203, the question-and-answer data corresponding to different fields are determined as training data sets.
[0068] In the embodiment of the present disclosure, after obtaining the question and answer data corresponding to different fields through the above steps, the question and answer data corresponding to different fields can be determined as a training data set so that the training data set can be used for subsequent model training.
[0069] In the embodiments of the present disclosure, the question and answer data corresponding to different fields can be automatically obtained through the above steps without relying on manual processing, thereby reducing labor costs and improving the efficiency of constructing training data sets.
[0070] In step 204, a multi-domain large language model to be trained is determined, where the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains.
[0071] In step 205, the multi-domain large language model to be trained is fine-tuned using training data from a variety of different domains, and the first initial fine-tuning parameters of different domains are updated to obtain a target multi-domain large language model.
[0072] For the relevant introduction of steps 204 to 205, please refer to the detailed introduction in the above embodiment, and the embodiment of the present disclosure will not be described in detail here.
[0073] In one or more embodiments of the present disclosure, a training data set is obtained, wherein the training data set includes training data from a variety of different fields; a multi-field large language model to be trained is determined, the multi-field large language model to be trained includes a basic model and first initial fine-tuning parameters for different fields, and the parameters of the basic model are pre-trained; the multi-field large language model to be trained is fine-tuned using the training data from a variety of different fields, and the first initial fine-tuning parameters for different fields are updated to obtain a target multi-field large language model. Thus, the present disclosure trains the multi-field large language model to be trained through training in a variety of different fields to obtain a target multi-field large language model, so that the target multi-field large language model can be applied to a variety of different fields and has a wide range of applications. At the same time, the target multi-field large language model can simultaneously deploy and dynamically load target large language models in different fields, without the need to deploy large language models in different fields separately, thereby reducing resource costs.
[0074] Figure 3 is a flowchart of a method for training a language model according to some embodiments of the present disclosure, such as Figure 3 As shown, the method may include the following steps:
[0075] In step 301, a training data set is obtained, wherein the training data set includes training data in a variety of different fields, and the training data includes question data and real answers.
[0076] In step 302, a multi-domain large language model to be trained is determined, where the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, wherein the basic model includes: an Embedding layer, an N-layer Transformer layer, and a prediction layer.
[0077] For the relevant introduction of steps 301 to 302, please refer to the detailed introduction in the above embodiment, and the embodiment of the present disclosure will not be described in detail here.
[0078] In step 303, the problem data in the same field is input into the Embedding layer to obtain the first vector representation of the problem data.
[0079] In the disclosed embodiment, the multi-domain large language model to be trained is fine-tuned using the training data of each domain to obtain the target fine-tuning parameters of the domain. Based on this, the question data of the same domain can be input into the Embedding layer to obtain the vector representation of each character in the question data, and the vector representation of all characters in the question data is determined as the first vector representation of the question data.
[0080] For example, in the disclosed embodiment, assuming that the character length of the training data is m, and the first n characters are question data, and the last mn characters are true answers, the first n characters are input into the Embedding layer to obtain a D-dimensional vector representation of each of the first n characters. At this time, the first vector representation of the (n, D) dimension corresponding to the question data is obtained.
[0081] In step 304, the first vector representation of the problem data and the first initial fine-tuning parameters corresponding to the domain are input into N layers of Transformer layers to obtain a target vector representation of the problem data.
[0082] In the embodiment of the present disclosure, after obtaining the first vector representation of the problem data through the above steps, the first vector representation and the first initial fine-tuning parameters corresponding to the domain can be input into the N-layer Transformer layer to obtain the target vector representation of the problem data. The first initial fine-tuning parameters include the second initial fine-tuning parameters corresponding to each Transformer layer in the N-layer Transformer layer, and the dimensions of the second initial fine-tuning parameters corresponding to each Transformer layer are the same.
[0083] Specifically, in the embodiment of the present disclosure, the method of inputting the first vector representation of the problem data and the first initial fine-tuning parameter corresponding to the domain into the N-layer Transformer layer to obtain the target vector representation of the problem data may include the following steps:
[0084] In step 3041, the first vector representation is concatenated with the second initial fine-tuning parameter corresponding to the first Transformer layer to obtain a second vector representation of the problem data;
[0085] In the embodiment of the present disclosure, after the first vector representation of the problem data is obtained through the above steps, the second initial fine-tuning parameters corresponding to the first Transformer layer can be concatenated before the first vector representation to obtain the second vector representation of the problem data. In the embodiment of the present disclosure, the dimension of the parameters in the above second initial fine-tuning parameters is the same as the dimension of the vector elements in the first vector representation.
[0086] For example, assuming that the dimension of the second initial fine-tuning parameter corresponding to the first Transformer layer is (k, D), that is, there are k parameters of D dimension in the second initial fine-tuning parameter, and the dimension of the first vector representation is (n, D), then the first vector representation is concatenated with the second initial fine-tuning parameter corresponding to the first Transformer layer to obtain the dimension (k+n, D) of the second vector representation of the problem data.
[0087] In step 3042, the second vector representation is input to the first Transformer layer to obtain a third vector representation of the problem data;
[0088] In the disclosed embodiment, each Transformer layer includes a connected self-attention mechanism layer and a double-layer fully connected layer. Also, in the disclosed embodiment, after obtaining the second vector representation of the problem data through the above steps, the second vector representation can be input into the self-attention mechanism layer and the double-layer fully connected layer in the first Transformer layer to obtain a third vector representation of the problem data.
[0089] And, in the embodiment of the present disclosure, the dimension of the third vector representation is the same as that of the second vector representation. For example, assuming that the dimension of the second vector representation is (k+n, D), the dimension of the third vector representation is also (k+n, D).
[0090] In step 3043, the third vector representation is preprocessed to obtain a fourth vector representation of the problem data;
[0091] In the disclosed embodiment, each Transformer layer will concatenate the output result of the previous layer with the second initial fine-tuning parameter corresponding to the current layer as the input of the current layer. Based on this, after obtaining the third vector representation of the output of the first Transformer layer through the above steps, the third vector representation needs to be preprocessed to obtain the fourth vector representation of the problem data, so that the fourth vector representation has the same dimension as the first vector representation, thereby ensuring the vector dimension of the input to the next Transformer layer.
[0092] Specifically, in an embodiment of the present disclosure, the method for preprocessing the third vector representation to obtain the fourth vector representation of the problem data may specifically include: truncating the first second initial fine-tuning parameter vector elements in the third vector representation to obtain the fourth vector representation of the problem data. For example, assuming that the dimension of the third vector representation is (k+n, D), that is, there are k+n D-dimensional vector elements in the third vector representation, and the number of parameters of the second initial fine-tuning parameter is k, then the first k vector elements in the third vector representation are truncated to obtain the fourth vector representation of the problem data, wherein the dimension of the fourth vector representation is (n, D).
[0093] In step 3044, the above steps 3041 to 3043 are repeated until the Nth layer of Transformer layer processing is completed to obtain the target vector representation of the problem data.
[0094] In an embodiment of the present disclosure, the target vector representation of the question data has the same dimension as the first vector representation of the question data.
[0095] In step 305, the target vector representation is input into the prediction layer to obtain predicted answer probability data, and the corresponding loss value is obtained based on the predicted answer probability data and the true answer.
[0096] In an embodiment of the present disclosure, after obtaining the target vector representation of the question and answer data through the above steps, the target vector representation can be input into the prediction layer to obtain predicted answer probability data, and the corresponding loss value can be obtained based on the predicted answer probability data and the true answer.
[0097] Specifically, in the embodiment of the present disclosure, the method of inputting the target vector representation into the prediction layer to obtain predicted answer probability data, and obtaining the corresponding loss value based on the predicted answer probability data and the true answer may include the following steps:
[0098] In step 3051, the target vector representation is normalized to obtain a processed target vector representation;
[0099] In step 3052, based on the processed target vector representation, the predicted answer probability data is obtained through the softmax function;
[0100] Among them, in the embodiment of the present disclosure, after obtaining the processed target vector representation through the above steps, the predicted answer probability data corresponding to the processed target vector representation can be obtained based on the softmax function, and the character corresponding to the maximum probability in the predicted answer probability data can be determined as the predicted answer to the question data.
[0101] In step 3053, calculations are performed based on the predicted answer probability data, the true answer and the preset loss function to obtain the corresponding loss value.
[0102] In the disclosed embodiment, the preset loss function may be a cross entropy loss function. Based on this, the corresponding loss value may be obtained by performing calculations based on the predicted answer probability data and the true answer by performing a cross entropy loss function.
[0103] It should be noted that in the embodiment of the present disclosure, after the target vector representation is input into the prediction layer, a predicted single character can be obtained. That is, when the character length of the training data is m, and the first n characters are question data, and the last mn characters are true answers, then the character predicted by the above steps is the n+1th character.
[0104] In step 306, the first initial fine-tuning parameters corresponding to the domain are updated based on the loss value until convergence, or when the number of iterations of the first initial fine-tuning parameters corresponding to the domain reaches a preset number, the target fine-tuning parameters corresponding to the domain are obtained.
[0105] In the disclosed embodiment, the obtained loss value can be used for back propagation to update the first initial fine-tuning parameters corresponding to the domain, and then the above steps are repeated for the characters at subsequent positions in the training data to train the target multi-domain large language model to be trained corresponding to the domain until convergence, or, when the number of iterations of the first initial fine-tuning parameters corresponding to the domain reaches a preset number, the target fine-tuning parameters corresponding to the domain are obtained.
[0106] For example, in an embodiment of the present disclosure, the loss value corresponding to the predicted character in the n+1th position is obtained through the above steps, and the first initial fine-tuning parameter corresponding to the field is updated based on the loss value. If the character length of the training data is m and the first n characters are question data, the above steps are repeated for the first n+1 characters to obtain the loss value corresponding to the predicted character in the n+2th position, and so on, until the last position in the answer is predicted.
[0107] In step 307, the above steps are repeated until the target fine-tuning parameters corresponding to different fields are obtained, and the target multi-domain large language model is obtained through the basic model and the target fine-tuning parameters corresponding to different fields.
[0108] In the disclosed embodiment, the target fine-tuning parameters of a certain field can be obtained through the above steps 303 to 306. At this time, the target large language model corresponding to the field can be obtained based on the basic model and the target fine-tuning parameters of the field. That is, human-computer interaction in this field can be performed through the target large language model. Among them, the parameters of the above basic model are pre-trained, the parameters of the basic model are not updated during the above training process, and the parameter amount of the target fine-tuning parameters is relatively small. Based on this, the target fine-tuning parameters of different fields can be obtained through the above method, and the basic model and the target fine-tuning parameters corresponding to different fields are determined as the target multi-domain large language model.
[0109] In addition, it should be noted that, in the disclosed embodiment, the above-mentioned target multi-domain large language model may also include a target language model. Among them, in the disclosed embodiment, the input of the target language model is question data and predicted answers, and the output is the target answer. Specifically, in the disclosed embodiment, the target language model can process the above-mentioned predicted answers by determining the language expression type of the input question data, and obtain a target answer with the same language expression type as the question data, so that the target answer is more in line with the user's language habits. Among them, the predicted answer can be the answer output by the above-mentioned basic model and the target fine-tuning parameters corresponding to different fields.
[0110] Furthermore, in the embodiments of the present disclosure, the target language model may be pre-trained, based on which the predicted answer data may be directly processed using the target language model to obtain a target answer having the same language expression type as the question data.
[0111] Further, in the disclosed embodiment, the preset language model can be trained by using the first question and answer data of different language expression types corresponding to different fields and the second question and answer data of different fields that do not contain any language expression types obtained in the above step 202 to obtain the corresponding target language model. The above first question and answer data includes the first question data and the first answer data; the second question and answer data includes the second question data and the second answer data.
[0112] Specifically, in an embodiment of the present disclosure, the same first question data and second question data, and the corresponding second answer data can be input into a preset language model. The preset language model determines the language expression type corresponding to the question data based on the input question data, and processes the second answer data based on the language expression type to obtain preset answer data. A corresponding loss value is then obtained based on the preset answer data and the first answer data. The loss value is used to update the parameters of the preset language model until the preset model converges to obtain a target language model.
[0113] In one or more embodiments of the present disclosure, a training data set is obtained, wherein the training data set includes training data from a variety of different fields; a multi-field large language model to be trained is determined, the multi-field large language model to be trained includes a basic model and first initial fine-tuning parameters for different fields, and the parameters of the basic model are pre-trained; the multi-field large language model to be trained is fine-tuned using the training data from a variety of different fields, and the first initial fine-tuning parameters for different fields are updated to obtain a target multi-field large language model. Thus, the present disclosure trains the multi-field large language model to be trained through training in a variety of different fields to obtain a target multi-field large language model, so that the target multi-field large language model can be applied to a variety of different fields and has a wide range of applications. At the same time, the target multi-field large language model can simultaneously deploy and dynamically load target large language models in different fields, without the need to deploy large language models in different fields separately, thereby reducing resource costs.
[0114] Figure 4 is a flow chart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure. Figure 4 As shown, the method may include the following steps:
[0115] In step 401, the question data that needs to be answered and is input by the user is obtained, and the target field to which the question data belongs is determined.
[0116] It should be noted that the executor of the above-mentioned language model-based human-computer interaction method is a language model-based human-computer interaction device, which can be implemented by software and / or hardware. The language model-based human-computer interaction device in this embodiment can be configured in an electronic device.
[0117] In this example embodiment, the electronic device may include devices such as terminal devices and servers, and this embodiment does not limit the electronic device.
[0118] In the embodiment of the present disclosure, the user can input question data in multiple different modes, such as voice, picture, video, text, etc. After the user inputs the question data, the question data input by the user is converted into text-type question data to obtain the question data input by the user that needs to be answered. In the embodiment of the present disclosure, when the mode of the question data input by the user is a picture, the text-type question data in the picture can be extracted; when the mode of the question data input by the user is a video or audio, the audio data in the video or audio can be converted into text-type question data.
[0119] Furthermore, in the disclosed embodiment, after obtaining the question data that needs to be answered input by the user, keywords in the question data can be extracted, and the target field to which the question data belongs can be determined based on the extracted keywords. For example, in the disclosed embodiment, assuming that the question data that needs to be answered input by the user is "I was on the way to work and got into a car accident. I am less responsible. Does this count as a work-related injury?", then the keywords corresponding to the question data extracted include "work-related injury", and based on the keywords, it can be determined that the target field to which the question data belongs is the legal field.
[0120] In step 402, based on the target domain and the target multi-domain large language model, a target large language model corresponding to the target domain is determined.
[0121] In one embodiment of the present disclosure, the above-mentioned target multi-domain large language model may include a basic model and target fine-tuning parameters for different domains. Among them, the target fine-tuning parameters corresponding to different domains are different. Based on this, after obtaining the target domain of the problem data, the target fine-tuning parameters of the target domain can be determined from the target multi-domain large language model based on the target domain, and the target fine-tuning parameters of the basic model and the target domain are determined as the target large language model corresponding to the target domain. This part of the content will be described in detail in subsequent embodiments.
[0122] And, in another embodiment of the present disclosure, the above-mentioned target multi-domain large language model may include a target language model, a base model and target fine-tuning parameters for different domains. Wherein, the target fine-tuning parameters corresponding to different domains are different. Based on this, after obtaining the target domain of the problem data, the target fine-tuning parameters of the target domain can be determined from the target multi-domain large language model based on the target domain, and the target language model, the base model and the target fine-tuning parameters of the target domain are determined as the target large language model corresponding to the target domain.
[0123] In step 403, the question data is input into the target large language model to obtain and output the target answer to the question data.
[0124] Among them, in the embodiment of the present disclosure, after the target large language model is determined through the above steps, the question data can be input into the target large language model to obtain the target answer to the question data and output it.
[0125] And, in one embodiment of the present disclosure, the target large language model may include a base model and target fine-tuning parameters corresponding to the target domain. The base model may include: an Embedding layer, N layers of Transformer layers, and a prediction layer, where N is a positive integer.
[0126] Among them, in the disclosed embodiment, after the question data is input into the target large language model, the question data is input into the Embedding layer to obtain the first vector representation of the question data, and then the first vector representation of the question data and the target fine-tuning parameters corresponding to the target domain are input into the N-layer Transformer layer to obtain the target vector representation of the question data, and then the target vector representation is input into the prediction layer to obtain the target answer to the question data and output it. This part will be introduced in detail in the subsequent embodiments.
[0127] And, in another embodiment of the present disclosure, the target large language model may include a target language model, a base model, and target fine-tuning parameters corresponding to the target domain. The base model may include: an Embedding layer, N layers of Transformer layers, and a prediction layer, where N is a positive integer.
[0128] Furthermore, in the disclosed embodiment, after the question data is input into the target large language model, the question data is input into the Embedding layer to obtain a first vector representation of the question data, and then the first vector representation of the question data and the target fine-tuning parameters corresponding to the target domain are input into the N-layer Transformer layer to obtain a target vector representation of the question data, and then the target vector representation is input into the prediction layer to obtain a predicted target answer to the question data, and the predicted target answer and the question data are input into the target language model to obtain and output the target answer to the question data.
[0129] It should be noted that, in the embodiments of the present disclosure, the question data to be answered obtained from the user input may be in different fields, that is, the human-computer interaction method based on the language model may be applicable to multiple different fields and has a wide range of applications.
[0130] For the relevant introduction of steps 401 to 403, reference may be made to the detailed introduction in the above embodiment, which will not be elaborated in detail in this embodiment.
[0131] In one or more embodiments of the present disclosure, the question data that needs to be answered input by the user is obtained, and the target domain to which the question data belongs is determined; based on the target domain and the target multi-domain large language model, the target large language model corresponding to the target domain is determined; the question data is input into the target large language model to obtain the target answer to the question data and output it. Therefore, the present disclosure proposes a human-computer interaction method based on a language model, which can perform human-computer interaction in multiple different fields and has a wide range of applications.
[0132] Figure 5 is a flow chart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure. Figure 5 As shown, the method may include the following steps:
[0133] In step 501, the question data that needs to be answered and input by the user is obtained, and the target field to which the question data belongs is determined.
[0134] In step 502, based on the target domain, target fine-tuning parameters of the target domain are determined from the target multi-domain large language model.
[0135] In the disclosed embodiment, the target multi-domain large language model includes a base model and target fine-tuning parameters for different domains. Also, in the disclosed embodiment, different domains correspond to different target fine-tuning parameters. Based on this, after obtaining the target domain through the above steps, the target fine-tuning parameters of the target domain can be determined from the target multi-domain large language model based on the target domain.
[0136] In step 503, the target fine-tuning parameters of the base model and the target domain are determined as a target large language model corresponding to the target domain.
[0137] In step 504, the question data is input into the target large language model to obtain and output a target answer to the question data.
[0138] For a detailed description of the above steps 501 to 504 , reference may be made to the relevant description in the above embodiment, which will not be elaborated in detail in this embodiment.
[0139] In one or more embodiments of the present disclosure, the question data that needs to be answered input by the user is obtained, and the target domain to which the question data belongs is determined; based on the target domain and the target multi-domain large language model, the target large language model corresponding to the target domain is determined; the question data is input into the target large language model to obtain the target answer to the question data and output it. Therefore, the present disclosure proposes a human-computer interaction method based on a language model, which can perform human-computer interaction in multiple different fields and has a wide range of applications.
[0140] Figure 6 is a flow chart of a human-computer interaction method based on a language model according to some embodiments of the present disclosure. Figure 6 As shown, the method may include the following steps:
[0141] In step 601, the question data that needs to be answered and input by the user is obtained, and the target field to which the question data belongs is determined.
[0142] In step 602, based on the target domain and the target multi-domain large language model, a target large language model corresponding to the target domain is determined, wherein the target large language model includes a basic model and target fine-tuning parameters corresponding to the target domain, and the basic model includes an Embedding layer, an N-layer Transformer layer, and a prediction layer.
[0143] In step 603, the question data is input into the Embedding layer to obtain a first vector representation of the question data.
[0144] In step 604, the first vector representation of the problem data and the target fine-tuning parameters corresponding to the target domain are input into N layers of Transformer layers to obtain the target vector representation of the problem data.
[0145] In step 605, the target vector representation is input into the prediction layer, and the target answer to the question data is obtained and output.
[0146] For a detailed description of the above steps 601 to 605, reference may be made to the relevant description in the above embodiment, which will not be elaborated in detail in this embodiment.
[0147] In one or more embodiments of the present disclosure, the question data that needs to be answered input by the user is obtained, and the target domain to which the question data belongs is determined; based on the target domain and the target multi-domain large language model, the target large language model corresponding to the target domain is determined; the question data is input into the target large language model to obtain the target answer to the question data and output it. Therefore, the present disclosure proposes a human-computer interaction method based on a language model, which can perform human-computer interaction in multiple different fields and has a wide range of applications.
[0148] Figure 7 is a structural diagram of a language model training device according to some embodiments of the present disclosure, such as Figure 7 As shown, the device includes an acquisition module 701, a determination module 702, and a training module 703.
[0149] An acquisition module 701 is used to acquire a training data set, wherein the training data set includes training data in various fields;
[0150] A determination module 702 is used to determine a multi-domain large language model to be trained, where the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, and the parameters of the basic model are pre-trained;
[0151] The training module 703 is used to perform fine-tuning training on the multi-domain large language model to be trained using training data from a variety of different domains, and to update the first initial fine-tuning parameters of different domains to obtain a target multi-domain large language model.
[0152] In one or more embodiments of the present disclosure, a training data set is obtained, wherein the training data set includes training data from a variety of different fields; a multi-field large language model to be trained is determined, the multi-field large language model to be trained includes a basic model and first initial fine-tuning parameters for different fields, and the parameters of the basic model are pre-trained; the multi-field large language model to be trained is fine-tuned using the training data from a variety of different fields, and the first initial fine-tuning parameters for different fields are updated to obtain a target multi-field large language model. Thus, the present disclosure trains the multi-field large language model to be trained through training in a variety of different fields to obtain a target multi-field large language model, so that the target multi-field large language model can be applied to a variety of different fields and has a wide range of applications. At the same time, the target multi-field large language model can simultaneously deploy and dynamically load target large language models in different fields, without the need to deploy large language models in different fields separately, thereby reducing resource costs.
[0153] Optionally, in one embodiment of the present disclosure, the acquisition module is specifically used to:
[0154] Obtain text data from different fields;
[0155] Based on text data from different fields, the text templates are input into the trained large language model to obtain the corresponding question and answer data in different fields.
[0156] The question and answer data corresponding to different fields are determined as training data sets.
[0157] Optionally, in one embodiment of the present disclosure, the above-mentioned basic model includes: an Embedding layer, N conversion Transformer layers and a prediction layer, where N is a positive integer.
[0158] Optionally, in one embodiment of the present disclosure, the above training data includes question data and real answers.
[0159] Optionally, in one embodiment of the present disclosure, the training module is specifically used to:
[0160] Input the problem data in the same field into the Embedding layer to obtain the first vector representation of the problem data;
[0161] Input the first vector representation of the problem data and the first initial fine-tuning parameters corresponding to the domain into N layers of Transformer layers to obtain the target vector representation of the problem data;
[0162] Input the target vector representation into the prediction layer and get the corresponding loss value based on the true answer;
[0163] Based on the loss value, the first initial fine-tuning parameter corresponding to the domain is updated until convergence, or when the number of iterations of the first initial fine-tuning parameter corresponding to the domain reaches a preset number, a target fine-tuning parameter corresponding to the domain is obtained;
[0164] Repeat the above steps until the target fine-tuning parameters corresponding to different fields are obtained, and the target multi-domain large language model is obtained through the basic model and the target fine-tuning parameters corresponding to different fields.
[0165] Optionally, in one embodiment of the present disclosure, the first initial fine-tuning parameters include second initial fine-tuning parameters corresponding to each Transformer layer in the N Transformer layers.
[0166] Optionally, in one embodiment of the present disclosure, the training module is further used to:
[0167] Concatenate the first vector representation with the second initial fine-tuning parameters corresponding to the first Transformer layer to obtain a second vector representation of the problem data, wherein the dimension of the parameters in the second initial fine-tuning parameters is the same as the dimension of the vector elements in the first vector representation;
[0168] Input the second vector representation into the first Transformer layer to obtain the third vector representation of the problem data;
[0169] Preprocessing the third vector representation to obtain a fourth vector representation of the problem data, wherein the fourth vector representation has the same dimension as the first vector representation;
[0170] Repeat the above steps until the Nth Transformer layer is processed and the target vector representation of the problem data is obtained.
[0171] Optionally, in one embodiment of the present disclosure, the training module is further used to:
[0172] Normalizing the target vector representation to obtain a processed target vector representation;
[0173] Based on the processed target vector representation, the predicted answer probability data is obtained through the softmax function;
[0174] Calculation is performed based on the predicted answer probability data, the true answer and the preset loss function to obtain the corresponding loss value.
[0175] Figure 8 is a structural schematic diagram of a human-computer interaction device based on a language model according to some embodiments of the present disclosure, such as Figure 8 As shown, the device includes an acquisition module 801, a determination module 802, and an output module 803.
[0176] The acquisition module 801 is used to acquire the question data that needs to be answered input by the user and determine the target field to which the question data belongs;
[0177] A determination module 802 is used to determine a target large language model corresponding to the target domain based on the target domain and the target multi-domain large language model;
[0178] The output module 803 is used to input the question data into the target large language model to obtain the target answer to the question data and output it.
[0179] In one or more embodiments of the present disclosure, the question data that needs to be answered input by the user is obtained, and the target domain to which the question data belongs is determined; based on the target domain and the target multi-domain large language model, the target large language model corresponding to the target domain is determined; the question data is input into the target large language model to obtain the target answer to the question data and output it. Therefore, the present disclosure proposes a human-computer interaction method based on a language model, which can perform human-computer interaction in multiple different fields and has a wide range of applications.
[0180] Optionally, in one embodiment of the present disclosure, the above-mentioned determination module is specifically used to:
[0181] Based on the target domain, determining a target fine-tuning parameter of the target domain from a target multi-domain large language model, wherein the target multi-domain large language model includes a base model and target fine-tuning parameters of different domains;
[0182] The target fine-tuning parameters of the base model and the target domain are determined as the target large language model corresponding to the target domain.
[0183] Optionally, in one embodiment of the present disclosure, the above-mentioned basic model includes an Embedding layer, N Transformer layers and a prediction layer, where N is a positive integer.
[0184] Optionally, in one embodiment of the present disclosure, the output module is specifically used to:
[0185] Input the problem data into the Embedding layer to obtain the first vector representation of the problem data;
[0186] The first vector representation of the problem data and the target fine-tuning parameters corresponding to the target domain are input into the N-layer Transformer layer to obtain the target vector representation of the problem data;
[0187] The target vector representation is input into the prediction layer to obtain the target answer to the question data.
[0188] Fig. 9A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable electronic devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0189] like Fig. 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0190] A number of components in the electronic device 900 are connected to the I / O interface 905, including: an input unit 908, such as a keyboard, a mouse, etc.; an output unit 909, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the electronic device 900 to exchange information / data with other electronic devices through a computer network such as the Internet and / or various telecommunication networks.
[0191] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as a multi-camera zoom control method. For example, in some embodiments, the multi-camera zoom control method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the multi-camera zoom control method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the multi-camera zoom control method in any other appropriate manner (e.g., by means of firmware).
[0192] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0193] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0194] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or electronic device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or electronic device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage electronic device, a magnetic storage electronic device, or any suitable combination of the foregoing.
[0195] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0196] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0197] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0198] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0199] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training a language model, characterized in that: The method comprises: Acquire a training data set, wherein the training data set includes training data in multiple different fields; Determine a multi-domain large language model to be trained, wherein the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, and the parameters of the basic model are pre-trained; The multi-domain large language model to be trained is fine-tuned using the training data of the multiple different domains, and the first initial fine-tuning parameters of the different domains are updated to obtain a target multi-domain large language model.
2. The method according to claim 1, characterized in that The step of obtaining a training data set includes: Obtain text data from different fields; Based on the text data of the different fields, the text template is input into the trained large language model to obtain the question and answer data corresponding to the different fields; The question and answer data corresponding to the different fields are determined as training data sets.
3. The method according to claim 1, characterized in that The basic model includes: an Embedding layer, N Transformer layers and a prediction layer, wherein N is a positive integer.
4. The method according to claim 3, characterized in that The training data includes question data and real answers; the fine-tuning training of the multi-domain large language model to be trained using the training data of the multiple different fields, and updating the first initial fine-tuning parameters of the different fields to obtain the target multi-domain large language model, includes: Inputting problem data in the same field into the Embedding layer to obtain a first vector representation of the problem data; Inputting the first vector representation of the problem data and the first initial fine-tuning parameter corresponding to the domain into the N-layer Transformer layer to obtain the target vector representation of the problem data; Inputting the target vector representation into the prediction layer to obtain predicted answer probability data, and obtaining a corresponding loss value based on the predicted answer probability data and the true answer; Based on the loss value, the first initial fine-tuning parameter corresponding to the field is updated until convergence, or when the number of iterations of the first initial fine-tuning parameter corresponding to the field reaches a preset number, a target fine-tuning parameter corresponding to the field is obtained; Repeat the above steps until the target fine-tuning parameters corresponding to the different fields are obtained, and based on the basic model and the target fine-tuning parameters corresponding to the different fields, a target multi-domain large language model is obtained.
5. The method according to claim 4, characterized in that The first initial fine-tuning parameters include second initial fine-tuning parameters corresponding to each Transformer layer in the N Transformer layers; the first vector representation of the problem data and the first initial fine-tuning parameters corresponding to the domain are input into the N Transformer layers to obtain a target vector representation of the problem data, including: Concatenating the first vector representation with the second initial fine-tuning parameters corresponding to the first Transformer layer to obtain a second vector representation of the problem data, wherein the dimension of the parameters in the second initial fine-tuning parameters is the same as the dimension of the vector elements in the first vector representation; Inputting the second vector representation into the first Transformer layer to obtain a third vector representation of the problem data; Preprocessing the third vector representation to obtain a fourth vector representation of the problem data, wherein the fourth vector representation has the same dimension as the first vector representation; Repeat the above steps until the Nth Transformer layer processing is completed to obtain the target vector representation of the problem data.
6. The method according to claim 4, characterized in that The inputting the target vector representation into the prediction layer to obtain predicted answer probability data, and obtaining a corresponding loss value based on the predicted answer probability data and the true answer, includes: Normalizing the target vector representation to obtain a processed target vector representation; Based on the processed target vector representation, the predicted answer probability data is obtained through the softmax function; A calculation is performed based on the predicted answer probability data, the true answer and a preset loss function to obtain a corresponding loss value.
7. A human-computer interaction method based on a language model, characterized in that: The method comprises: Obtaining question data that needs to be answered input by the user, and determining the target field to which the question data belongs; Based on the target domain and the target multi-domain large language model, determining a target large language model corresponding to the target domain, wherein the target multi-domain large language model is obtained based on the language model training method according to any one of claims 1 to 6; The question data is input into the target large language model to obtain and output a target answer to the question data.
8. The method according to claim 7, characterized in that The determining, based on the target domain and the target multi-domain large language model, a target large language model corresponding to the target domain includes: Based on the target domain, determining a target fine-tuning parameter of the target domain from a target multi-domain large language model, wherein the target multi-domain large language model includes a base model and target fine-tuning parameters of different domains; The target fine-tuning parameters of the basic model and the target domain are determined as a target large language model corresponding to the target domain.
9. The method according to claim 8, characterized in that The basic model includes: an Embedding layer, N Transformer layers and a prediction layer, wherein N is a positive integer.
10. The method according to claim 9, characterized in that The step of inputting the question data into the target large language model to obtain and output a target answer to the question data comprises: Input the problem data into the Embedding layer to obtain a first vector representation of the problem data; Inputting the first vector representation of the problem data and the target fine-tuning parameters corresponding to the target domain into the N-layer Transformer layer to obtain the target vector representation of the problem data; The target vector representation is input into the prediction layer, and the target answer to the question data is obtained and output.
11. A language model training device, characterized in that: The device comprises: An acquisition module, used to acquire a training data set, wherein the training data set includes training data in a variety of different fields; A determination module is used to determine a multi-domain large language model to be trained, wherein the multi-domain large language model to be trained includes a basic model and first initial fine-tuning parameters of different domains, and the parameters of the basic model are pre-trained; A training module is used to use the training data of the multiple different fields to fine-tune the multi-domain large language model to be trained, and to update the first initial fine-tuning parameters of the different fields to obtain a target multi-domain large language model.
12. A human-computer interaction device based on a language model, characterized in that: The device comprises: An acquisition module is used to acquire question data that needs to be answered input by the user and determine the target field to which the question data belongs; A determination module, configured to determine a target large language model corresponding to the target domain based on the target domain and the target multi-domain large language model, wherein the target multi-domain large language model is obtained based on the language model training device according to claim 11; The output module is used to input the question data into the target large language model to obtain and output the target answer to the question data.
13. An electronic device, characterized in that: include: at least one processor; as well as A memory in communication connection with the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so that the at least one processor can perform the method of any one of claims 1 to 10.
14. A non-transitory computer-readable storage medium, wherein the computer storage medium stores computer-executable instructions; after the computer-executable instructions are executed by a processor, the method according to any one of claims 1 to 10 can be implemented.
Citation Information
Cited By
Multi-domain dialogue model training and task processing method and device, computer equipment, storage medium and program product
CN121681778A
Information processing system, information processing method, and program
WO2026177012A1