Model adjustment method and device, equipment and medium

CN117174254BActive Publication Date: 2026-10-20PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310795046.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2026-10-20
Estimated Expiration
2043-06-30

AI Technical Summary

Technical Problem

[0004]本发明提供一种模型调整方法、装置、设备及介质,以解决对大语言模型进行调整时效率较低的技术问题

Benefits of technology

[0017]上述模型调整方法、装置、设备及介质所实现的方案中,可以获取初始大语言模型,所述初始大语言模型包括K层转换器模型,将所述初始大语言模型包括的K层转换器模型分别连接自编码适配器模块,以得到第一大语言模型,所述自编码适配器模块用于将自编码适配器模块的传递函数与转换器模型的输入端接收的初始输入数据进行乘法运算,得到的第一运算结果,以及将第一运算结果确定为转换器模型的输入数据,所述第一运算结果包括偏置向量,获取样本数据集,以及获取所述第一大语言模型的重构损失函数,在固定所述第一大语言模型中的初始权重之后,通过所述样本数据集对所述第一大语言模型中自编码适配器模块和所述偏置向量的权重进行调整,在所述重构损失函数的函数值收敛后得到第二大语言模型,在本申请中,可以通过在大语言模型中设置自编码适配器模块,并通过样本数据集对添加了自编码适配器模块的第一大语言模型进行训练,从而无需对初始语言模型进行重新训练,仅对自编码适配器模块和偏置向量的权重进行调整训练,从而极大的减少了对大语言模型进行调整时所需的时间,提升了对大语言模型进行调整时的效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117174254B_ABST
    Figure CN117174254B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of artificial intelligence, natural language processing and medical health technology, and discloses a model adjustment method and device, equipment and a medium, which comprise the following steps: acquiring an initial large language model, wherein the initial large language model comprises K-layer converter models; connecting the K-layer converter models included in the initial large language model with self-encoding adapter modules respectively to obtain a first large language model; acquiring a sample data set and a reconstruction loss function of the first large language model; after fixing initial weights in the first large language model, adjusting the weights of the self-encoding adapter modules and the bias vector in the first large language model through the sample data set, and obtaining a second large language model after the reconstruction loss function converges. The efficiency of adjusting the large language model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence technology, natural language processing, and medical and health technology, and in particular to a model adjustment method, device, equipment, and medium. Background Technology

[0002] With my country's economic and social development, people are paying more attention to their mental health and are increasingly seeking mental health services to improve or resolve their psychological problems. Typically, during psychological counseling sessions, clients undergo task assessments. The results of these assessments are then used to conduct psychological analysis of the client, yielding analytical findings. These findings may include information about the client's emotions.

[0003] Currently, when clients undergo task assessments, the process typically involves therapists setting specific tasks tailored to the client's experience and presenting these tasks to the client. However, due to individual differences among therapists, the acquired tasks vary significantly, leading to inaccurate task assignments and biases in subsequent psychological analysis, thus reducing its accuracy. To address this issue and improve the accuracy of psychological analysis, deep learning techniques are being used to construct network analysis models. Widely used models include large language models. After training, these models require fine-tuning to adapt to specific application scenarios. Currently, large language models are typically retrained, but this method becomes inefficient due to the increasing size and volume of data. Summary of the Invention

[0004] This invention provides a model adjustment method, apparatus, device, and medium to solve the technical problem of low efficiency when adjusting large language models.

[0005] Firstly, a model adjustment method is provided, the method comprising:

[0006] Obtain an initial large language model, which includes a K-layer converter model;

[0007] The K-layer converter models included in the initial large language model are respectively connected to the autoencoder adapter module to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0008] Obtain the sample dataset and the reconstruction loss function of the first largest language model;

[0009] After fixing the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained.

[0010] Secondly, a model adjustment device is provided, the device comprising:

[0011] The first acquisition unit is used to acquire an initial large language model, wherein the initial large language model includes a K-layer converter model;

[0012] A connection unit is used to connect the K-layer converter models included in the initial large language model to the autoencoder adapter module respectively to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0013] The second acquisition unit is used to acquire the sample dataset and the reconstruction loss function of the first large language model;

[0014] An adjustment unit is used to adjust the weights of the autoencoder adapter module and the bias vector in the first large language model after fixing the initial weights in the first large language model, using the sample dataset, and to obtain the second large language model after the function value of the reconstruction loss function converges.

[0015] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described model adjustment method.

[0016] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described model adjustment method.

[0017] In the scheme implemented by the above-mentioned model adjustment method, device, equipment, and medium, an initial large language model can be obtained. The initial large language model includes a K-layer converter model. The K-layer converter models included in the initial large language model are respectively connected to an autoencoder adapter module to obtain a first large language model. The autoencoder adapter module is used to perform a multiplication operation between its transfer function and the initial input data received at the input end of the converter model, obtaining a first operation result. The first operation result is then determined as the input data of the converter model. The first operation result includes a bias vector. A sample dataset is obtained, and the reconstruction loss function of the first large language model is obtained. Under a fixed... After setting the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained. In this application, an autoencoder adapter module can be set in the large language model, and the first large language model with the autoencoder adapter module added can be trained using the sample dataset. Therefore, it is not necessary to retrain the initial language model. Only the weights of the autoencoder adapter module and the bias vector are adjusted and trained, which greatly reduces the time required to adjust the large language model and improves the efficiency of adjusting the large language model. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of an application environment for the model adjustment method in one embodiment of the present invention;

[0020] Figure 2 This is a flowchart illustrating a model adjustment method in one embodiment of the present invention;

[0021] Figure 3 This is a schematic diagram of the model adjustment device in one embodiment of the present invention;

[0022] Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] The model adjustment method provided in this embodiment of the invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. When a target user seeks psychological counseling or mental health services, such as visiting a hospital for counseling or mental health treatment, the client can determine the counseling task during communication with the counselor. Specifically, after a topic is discussed, the client can determine the counseling task. The target user reads the task and provides corresponding psychological descriptions. The counselor then uses these descriptions to conduct a comprehensive psychological analysis of the target user.

[0025] Therefore, it can assist in psychological analysis, etc. Specifically, the client can obtain a set of psychological counseling tasks corresponding to the target user. For example, the set of psychological counseling tasks can be determined based on the current topic of communication between the counselor and the target user. The psychological counseling tasks in the set can be tasks used for psychological analysis, such as "Hello, how are you feeling lately? Can you tell me?" or "Hello, can you do some relaxation exercises with me?" etc. Then, the client obtains the target user's current psychological counseling information and historical psychological counseling information, as well as the target user's target user information. The current psychological counseling information can be the dialogue text between the counselor and the target user, etc., and the target user information can be the target user's basic personal information, such as age, gender, occupation, education, etc. The server determines new psychological counseling tasks based on the target user information, the current psychological counseling information, and the historical psychological counseling information through an adjusted large language model. After determining the new psychological counseling tasks, the new psychological counseling tasks are displayed, thereby obtaining multiple psychological counseling information of the target user. Finally, psychological analysis is performed based on multiple psychological counseling information.

[0026] When tuning large language models (LLMs), existing solutions typically involve retraining the LLM using sample data, but this is inefficient during training. To address this issue, a popular technique called Low-Rank Adaptation (LoRA) is often used. LoRA freezes the weights of the pre-trained model (LLM) and inserts a trainable rank decomposition matrix into each Transformer layer. LoRA can reduce the number of trainable parameters by 10,000 times and reduce GPU (Central Processing Unit) memory requirements by 3 times. LoRA has achieved performance comparable to or better than fine-tuning on various LLMs, including RoBERTa, DeBERTa, GPT-2, and GPT-3, while offering fewer trainable parameters, higher training throughput, and no additional inference latency compared to adapters.

[0027] LORA uses low-rank decomposition to represent task-related parameter increments, injecting a trainable rank decomposition matrix into each Transformer layer while freezing the original model weights. This significantly reduces the number of trainable parameters and GPU memory requirements without increasing inference latency. However, in this approach, the low-rank matrix may not fully capture the information and complexity of the original weight matrix, leading to a decrease in the model's expressive power and accuracy. Especially when the rank of the low-rank matrix is ​​very small or the rank of the original weight matrix is ​​very large, the approximation error can be substantial.

[0028] In this application, by connecting autoencoder adapter modules to the K-layer converter models included in the initial large language model to obtain the first large language model, and setting the corresponding reconstruction loss function for training, the final second large language model is obtained. This allows unsupervised learning to extract and compress effective information from the parameter matrix of the initial large language model, thereby enhancing the expressive and generalization capabilities of the adapter modules and improving the accuracy of the model.

[0029] The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will now be described in detail through specific embodiments.

[0030] Please see Figure 2 As shown, Figure 2 This is a schematic flowchart illustrating a model adjustment method provided in an embodiment of the present invention. Figure 2 The model adjustment method described above can be applied to the server side, including the following steps:

[0031] S201. Obtain the initial large language model, which includes a K-layer converter model.

[0032] The initial large language model can be RoBERTa, DeBERTa, GPT-2, or GPT-3, etc. Specifically, this initial large language model can be obtained from the internet, or it can be obtained through user input. The transformer model can be a Transformer model.

[0033] S202. Connect the K-layer converter models included in the initial large language model to the autoencoder adapter module to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0034] The autoencoder adapter module has a parameter matrix similar to that of the initial large language model, but with a lower parameter dimensionality. It includes an encoder and a decoder. The encoder compresses the input data into a low-dimensional vector (latent variables or codes), and the decoder restores the latent variables into a vector similar to the input data (reconstruction process). The autoencoder adapter module can utilize more unsupervised learning to extract and compress effective information from the parameter matrix of the initial large language model, thereby enhancing its expressive and generalization capabilities. Furthermore, the multi-layer transformer model improves the model's expressive power and accuracy, making the subsequently trained second large language model applicable to more scenarios and enhancing its overall applicability.

[0035] Autoencoder adapter modules may include sparse autoencoders, variational autoencoders, convolutional autoencoders, etc.

[0036] When connecting the autoencoder adapter module to the converter model, it can be connected between two converter models. It can perform multiplication operations, etc., on the initial input data received at the input end of the converter model to obtain a first calculation result, which is then used as the input data for subsequent converter models. Specifically, for example, when the converter model is a Transformer model, which includes a multi-head attention mechanism and a feedforward neural network, the autoencoder adapter module performs multiplication operations with the initial input data of the Transformer model to obtain a first calculation result, which is then used as the input data for the multi-head attention mechanism.

[0037] S203. Obtain the sample dataset and the reconstruction loss function of the first large language model.

[0038] The sample dataset contains user feedback and questions related to medical issues. Medical questions can be tasks for psychological analysis or inquiries about user symptoms. Specific examples of medical questions include, "Hello, how have you been feeling lately? Can you tell me?" or "Hello, can you describe your recent physical condition?". Medical feedback can be, for example, "I'm not feeling well, my mental state is poor," or "I feel restless every day, very anxious, have no interest in anything, feel depressed, and don't feel happy." In this case, the sample data could be "I'm not feeling well, my mental state is poor" (medical feedback) and "Hello, can you describe your recent physical condition?" (the medical question, which is the specific medical question displayed in response to the feedback).

[0039] The method to obtain the reconstruction loss function of the first major language model can be as follows: obtain the first encoding function associated with the autoencoder adapter module, the first decoding function associated with the autoencoder adapter module, the parameter matrix of the converter model, and the first regularization coefficient. Then, perform norm operations based on the above functions, parameter data frames, and regularization coefficients to obtain the reconstruction loss function. Therefore, the reconstruction loss function can be accurately determined.

[0040] Alternatively, the type of reconstruction loss function can be determined based on the application scenario information of the primary language model. Multiple reference reconstruction loss functions corresponding to this type information can then be retrieved from the database. Finally, the reconstruction loss function for the primary language model can be determined from these reference functions based on the associated applications of the primary language model. This ensures that the determined reconstruction loss function is compatible with the application scenario of the primary language model, improving the accuracy of the reconstruction loss function determination.

[0041] S204. After fixing the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained.

[0042] When adjusting and training the first large language model, the initial weights of the first large language model can be fixed. These initial weights are the weights corresponding to the initial large language model, for example, the initial weights are the weights in the Transformer model.

[0043] The method for adjusting the weights of the autoencoder adapter module and the bias vector in the first large language model using the sample dataset can be achieved using general model training adjustment methods, which will not be elaborated here.

[0044] In this example, an autoencoder adapter module can be set up in the large language model, and the first large language model with the autoencoder adapter module added can be trained using a sample dataset. During training, the initial weights in the first large language model are fixed, so there is no need to retrain the initial language model. Only the weights of the autoencoder adapter module and the bias vector are adjusted during training, which greatly reduces the time required to adjust the large language model and improves the efficiency of adjusting the large language model.

[0045] At the same time, it avoids the problem of choosing the rank size in existing low-rank adaptation schemes. That is, it does not require manually setting or searching for a suitable rank size, but allows the autoencoder to automatically learn a suitable dimension, thus improving accuracy.

[0046] In one possible implementation, the reconstruction loss function of the first large language model can be accurately determined based on the first encoding function associated with the self-encoding adapter module, the first decoding function associated with the self-encoding adapter module, the parameter matrix of the converter model, and the first regularization coefficient. Specifically, one method for obtaining the reconstruction loss function of the first large language model includes:

[0047] A1. Obtain the first encoding function associated with the self-encoding adapter module, and obtain the first decoding function associated with the self-encoding adapter module;

[0048] A2. Obtain the parameter matrix of the converter model and the first regularization coefficient;

[0049] A3. Determine the first norm based on the parameter matrix, the first encoding function, and the first decoding function;

[0050] A4. Determine the second norm based on the first encoding function and the parameter matrix;

[0051] A5. Determine the reconstruction loss function based on the first regularization coefficient, the first norm, and the second norm.

[0052] Specifically, the first encoding function and the first decoding function are corresponding attribute functions in the self-encoding adapter module. After the self-encoding adapter module is built, the first encoding function and the first decoding function are built accordingly. They can be set through empirical values ​​or historical data.

[0053] The first encoding function can be represented by the following formula:

[0054] f:

[0055] Where f is the first encoding function, d h R is the dimension of the hidden layer in the converter model, where R is the vector space and r is the dimension of the vector space.

[0056] The first decoding function can be represented by the following formula:

[0057] g:

[0058] Where g is the first decoding function, d h R is the dimension of the hidden layer in the converter model, where R is the vector space and r is the dimension of the vector space.

[0059] When obtaining the parameter matrix of the converter model, we can obtain the dimensional information of the hidden layers in the converter model and the parameter information of the multi-head attention mechanism in the converter model, and determine the parameter matrix of the converter model, etc.

[0060] The first encoding function can be determined as the input parameter of the first decoding function, and the first encoding function can be substituted into the first decoding function to obtain the first sub-processing result. Norm operations can then be performed on the parameter matrix and the first sub-processing result to obtain the first norm. Specifically, this can be done as follows:

[0061] D1 = ||Wg(f(W))|| F ,

[0062] Where g(f(W)) is the result of the first subprocessing, D1 is the first norm, and ||·|| F It is a Frobenius norm operation, where W is the parameter matrix.

[0063] The method for determining the second norm based on the first encoding function and the parameter matrix can be as shown in the following formula:

[0064] D2 = ||f(W)||1,

[0065] Where D2 is the second norm, ||·||1 is the L1 norm operation, f is the first encoding function, and W is the parameter matrix.

[0066] The reconstruction loss function can be determined using the following formula:

[0067]

[0068] Where H1 is the reconstruction loss function, min f,gThe period (.) represents the minimization operation on functions f and g, and λ is the first regularization coefficient. The first regularization coefficient can be set using empirical values ​​or historical data.

[0069] In this example, the reconstruction loss function of the first large language model is determined by obtaining the first encoding function associated with the self-encoding adapter module, the first decoding function associated with the self-encoding adapter module, the parameter matrix of the converter model, and the first regularization coefficient, thereby improving the accuracy of the reconstruction loss function determination.

[0070] In one possible implementation, a method for obtaining the parameter matrix of the converter model includes:

[0071] B1. Obtain the dimensional information of the hidden layers in the converter model;

[0072] B2. Based on the dimensional information and the parameter information in the multi-head attention mechanism of the converter model, determine the parameter matrix of the converter model.

[0073] Since the converter model has been fixed in the initial large language model, its dimensions are also fixed accordingly. Therefore, the dimension information of the hidden layer in the converter model can be determined from the attribute information of the initial large language model.

[0074] The parameters at the corresponding positions in the parameter matrix can be determined based on the parameter information in the multi-head attention mechanism, and then the parameter matrix can be constructed based on this dimensional information. A general construction method can be used for this purpose.

[0075] In one possible implementation, another method for obtaining the reconstruction loss function of the first large language model includes:

[0076] C1. Obtain the application scenario information of the first large language model;

[0077] C2. Determine the type information of the reconstruction loss function based on the application scenario information;

[0078] C3. Obtain K reference reconstruction loss functions corresponding to the type information from a preset database;

[0079] C4. Obtain the associated application information of the first large language model;

[0080] C5. Determine the reconstruction loss function of the first large language model from the K reference reconstruction functions based on the associated application information.

[0081] The application scenario information can include text classification scenarios, text prediction scenarios, text processing scenarios, etc. Different application scenario information can correspond to different type information; therefore, based on this mapping relationship, the type information of the reconstruction loss function can be determined from the application scenario information. For example, the type information corresponding to the text classification scenario can include the cross-entropy loss function, etc.

[0082] Type information can correspond to multiple reconstruction loss functions, thus allowing the retrieval of K reference reconstruction loss functions corresponding to that type information from a pre-defined database. These K reference reconstruction loss functions may include, for example, the cross-entropy loss function.

[0083] The associated application information of the primary language model can include application information of its upstream and downstream applications. Upstream and downstream applications can be understood as follows: applications called by the primary language model are upstream applications, and applications that call the primary language model are downstream applications, etc. This allows us to obtain the application information of upstream and downstream applications and determine whether they are associated application information.

[0084] We can obtain the matching degree between associated application information and K reference reconstruction functions to get the corresponding matching degree value; the reference reconstruction function with the highest matching degree value is determined as the reconstruction loss function of the first language model. Here, the matching degree between associated application information and reference reconstruction functions can be understood as: the fit between the reference reconstruction function and the application corresponding to the associated application information. The higher the fit, the higher the matching degree value, and the lower the fit, the lower the matching degree value.

[0085] In this example, based on the type information of the reconstruction loss function determined by the application scenario information of the first language model, K reference reconstruction loss functions can be determined from a preset database. Then, based on the associated application information of the first language model, the reconstruction loss function of the first language model can be determined from the K reference reconstruction loss functions. This allows the reconstruction loss function to be determined in conjunction with the application scenario of the first language model, thus improving the accuracy of the reconstruction loss function determination.

[0086] In one possible implementation, another method for obtaining the reconstruction loss function of the first large language model includes:

[0087] D1. Obtain the first encoding function associated with the self-encoding adapter module, and obtain the first decoding function associated with the self-encoding adapter module;

[0088] D2. Obtain the parameter matrix of the converter model;

[0089] D3. Determine the first norm based on the parameter matrix, the first encoding function, and the first decoding function;

[0090] D4. Determine the first potential distribution based on the first encoding function and parameter matrix;

[0091] D5. Obtain the first potential distribution and the prior distribution of the autoencoder adapter module, and determine the first divergence;

[0092] D6. Determine the reconstruction loss function of the first large language model based on the first divergence and the first norm.

[0093] Steps D1-D3 can be implemented with reference to the specific implementation of steps A1-A3 in the aforementioned embodiments, and will not be repeated here.

[0094] The method for determining the first latent distribution based on the first encoding function and parameter matrix can be as shown in the following formula:

[0095] q(f(W)),

[0096] Where q(f(W)) is the first potential distribution, W is the parameter matrix, and f is the first encoding function.

[0097] The method for determining the first divergence by obtaining the first latent distribution and the prior distribution of the autoencoder adapter module can be as follows:

[0098] G = KL(q(f(W))||p(Z)),

[0099] Where G is the first divergence, KL(·||·) is the KL divergence operation, q(f(W)) is the first latent distribution, and p(Z) is the prior distribution of the autoencoder adapter module. After the autoencoder adapter module is connected to the Transformer model, its prior distribution can be determined based on the parameters of the autoencoder adapter module. Specifically, a general method for determining the prior distribution of the autoencoder adapter module can be used.

[0100] The reconstruction loss function can be determined using the following formula:

[0101]

[0102] Where H2 is the reconstruction loss function, and min is the minimization operation.

[0103] In this example, the reconstruction loss function of the first large language model is determined by obtaining the first encoding function associated with the self-encoding adapter module, the first decoding function associated with the self-encoding adapter module, and the parameter matrix of the converter model, thereby improving the accuracy of the reconstruction loss function determination.

[0104] In one possible implementation, the first operation result can also be obtained. Specific methods for obtaining the first operation result include:

[0105] The first calculation result is obtained using the method shown in the following formula:

[0106]

[0107] Where y is the first operation result, x is the initial input data received at the input terminal of the converter model, and b is the bias vector. This is the pass function for the autoencoder adapter module, (.). T This is for the transpose operation.

[0108] Determining the first calculation result using the method shown in the above formula can improve the efficiency of obtaining the first calculation result.

[0109] In one possible implementation, after adjusting the weights of the autoencoder adapter module and the bias vector in the first large language model using the sample dataset, and obtaining the second large language model after the function value of the reconstruction loss function converges, the second large language model can also be used to predict medical problems, as follows:

[0110] F1. Receive the first medical feedback information corresponding to the first medical problem;

[0111] F2. Process the first medical feedback information using the second major language model to obtain the second medical question corresponding to the first medical feedback information.

[0112] The client can send initial medical feedback information to the client, and the client can receive initial medical feedback information corresponding to the initial medical question. The initial medical question could be, "Hello, how have you been feeling lately? Can you tell me?", and the initial medical feedback information could be, "I'm not feeling well, my mental state is poor." The initial medical question can be a pre-set medical question (e.g., the initial medical question during a question-and-answer session), or it can be a medical question generated based on the received medical feedback information (e.g., a second medical question generated based on the initial medical feedback information).

[0113] The first medical feedback information can then be processed using a second language model to obtain a second medical question, such as "Hello, could you describe your recent health condition?". This allows for the quick and accurate identification of the second medical question corresponding to the first medical feedback information, improving the efficiency of subsequent analysis.

[0114] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0115] In one embodiment, a model adjustment device is provided, which corresponds one-to-one with the model adjustment method in the above embodiments. For example... Figure 3 As shown, the model adjustment device includes a first acquisition unit 301, a connection unit 302, a second acquisition unit 303, and an adjustment unit 304. Detailed descriptions of each functional module are as follows:

[0116] The first acquisition unit 301 is used to acquire an initial large language model, wherein the initial large language model includes a K-layer converter model;

[0117] The connection unit 302 is used to connect the K-layer converter models included in the initial large language model to the autoencoder adapter module respectively to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0118] The second acquisition unit 303 is used to acquire the sample dataset and the reconstruction loss function of the first large language model;

[0119] The adjustment unit 304 is used to adjust the weights of the autoencoder adapter module and the bias vector in the first large language model after fixing the initial weights in the first large language model, and to obtain the second large language model after the function value of the reconstruction loss function converges.

[0120] In one embodiment, the second acquisition unit 303 is specifically used for: acquiring the reconstruction loss function of the first large language model.

[0121] Obtain the first encoding function associated with the self-encoding adapter module, and obtain the first decoding function associated with the self-encoding adapter module;

[0122] Obtain the parameter matrix of the converter model, and obtain the first regularization coefficient;

[0123] The first norm is determined based on the parameter matrix, the first encoding function, and the first decoding function;

[0124] The second norm is determined based on the first encoding function and the parameter matrix;

[0125] The reconstruction loss function is determined based on the first regularization coefficient, the first norm, and the second norm.

[0126] In one embodiment, regarding the acquisition of the parameter matrix of the converter model, the second acquisition unit 303 is specifically used for:

[0127] Obtain the dimensional information of the hidden layers in the converter model;

[0128] Based on the dimensional information and the parameter information in the multi-head attention mechanism of the converter model, the parameter matrix of the converter model is determined.

[0129] In one embodiment, the second acquisition unit 303 is specifically used for: acquiring the reconstruction loss function of the first large language model.

[0130] Obtain application scenario information for the first large language model;

[0131] The type information of the reconstruction loss function is determined based on the application scenario information;

[0132] Retrieve K reference reconstruction loss functions corresponding to the type information from a preset database;

[0133] Obtain the associated application information of the first large language model;

[0134] The reconstruction loss function of the first large language model is determined from the K reference reconstruction functions based on the associated application information.

[0135] In one embodiment, the second acquisition unit 303 is specifically used for: acquiring the reconstruction loss function of the first large language model.

[0136] Obtain the first encoding function associated with the self-encoding adapter module, and obtain the first decoding function associated with the self-encoding adapter module;

[0137] Obtain the parameter matrix of the converter model;

[0138] The first norm is determined based on the parameter matrix, the first encoding function, and the first decoding function;

[0139] The first potential distribution is determined based on the first encoding function and the parameter matrix;

[0140] Obtain the first potential distribution and the prior distribution of the autoencoder adapter module, and determine the first divergence;

[0141] Based on the first divergence and the first norm, the reconstruction loss function of the first large language model is determined.

[0142] In one embodiment, the device is further configured to:

[0143] Obtain the first calculation result;

[0144] Obtaining the first calculation result includes:

[0145] The first calculation result is obtained using the method shown in the following formula:

[0146]

[0147] Where y is the first operation result, x is the initial input data received at the input terminal of the converter model, and b is the bias vector. This is the pass function for the self-encoding adapter module. This is for the transpose operation.

[0148] In one embodiment, after obtaining the second large language model, the device is further configured to:

[0149] Receive the first medical feedback information corresponding to the first medical problem;

[0150] The first medical feedback information is processed using the second major language model to obtain a second medical question corresponding to the first medical feedback information.

[0151] In this example, an autoencoder adapter module can be set up in the large language model, and the first large language model with the autoencoder adapter module added can be trained using a sample dataset. During training, the initial weights in the first large language model are fixed, so there is no need to retrain the initial language model. Only the weights of the autoencoder adapter module and the bias vector are adjusted during training, which greatly reduces the time required to adjust the large language model and improves the efficiency of adjusting the large language model.

[0152] Specific limitations regarding the model adjustment device can be found in the limitations of the model adjustment method described above, and will not be repeated here. Each module in the aforementioned model adjustment device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0153] In one embodiment, a computer device is provided, which may be a server. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a model adjustment method on the server side.

[0154] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:

[0155] Obtain an initial large language model, which includes a K-layer converter model;

[0156] The K-layer converter models included in the initial large language model are respectively connected to the autoencoder adapter module to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0157] Obtain the sample dataset and the reconstruction loss function of the first largest language model;

[0158] After fixing the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained.

[0159] In this example, an autoencoder adapter module can be set up in the large language model, and the first large language model with the autoencoder adapter module added can be trained using a sample dataset. During training, the initial weights in the first large language model are fixed, so there is no need to retrain the initial language model. Only the weights of the autoencoder adapter module and the bias vector are adjusted during training, which greatly reduces the time required to adjust the large language model and improves the efficiency of adjusting the large language model.

[0160] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0161] Obtain an initial large language model, which includes a K-layer converter model;

[0162] The K-layer converter models included in the initial large language model are respectively connected to the autoencoder adapter module to obtain the first large language model. The autoencoder adapter module is used to perform a multiplication operation between the transfer function of the autoencoder adapter module and the initial input data received at the input end of the converter model to obtain a first operation result, and to determine the first operation result as the input data of the converter model. The first operation result includes a bias vector.

[0163] Obtain the sample dataset and the reconstruction loss function of the first largest language model;

[0164] After fixing the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained.

[0165] In this example, an autoencoder adapter module can be set up in the large language model, and the first large language model with the autoencoder adapter module added can be trained using a sample dataset. During training, the initial weights in the first large language model are fixed, so there is no need to retrain the initial language model. Only the weights of the autoencoder adapter module and the bias vector are adjusted during training, which greatly reduces the time required to adjust the large language model and improves the efficiency of adjusting the large language model.

[0166] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0167] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0168] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0169] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A model adjustment method, characterized in that, The method includes: Obtain an initial large language model, which includes a K-layer converter model; The K-layer converter models included in the initial large language model are respectively connected to the autoencoder adapter module to obtain the first large language model. When connecting the autoencoder adapter module to the converter model, the autoencoder adapter module is connected between the two converter models. The first calculation result is obtained using the method shown in the following formula: Where y is the result of the first operation, x is the initial input data received at the input end of the converter model, and b is the bias vector. This is the pass function for the self-encoding adapter module. This is for the transpose operation, and to determine the first operation result as the input data for the converter model; The process involves obtaining a sample dataset and a reconstruction loss function for the first large language model. Obtaining the reconstruction loss function includes: obtaining a first encoding function associated with the autoencoder adapter module and a first decoding function associated with the autoencoder adapter module; obtaining a parameter matrix of the converter model and a first regularization coefficient; determining a first norm based on the parameter matrix, the first encoding function, and the first decoding function; determining a second norm based on the first encoding function and the parameter matrix; and determining the reconstruction loss function based on the first regularization coefficient, the first norm, and the second norm. After fixing the initial weights in the first large language model, the weights of the autoencoder adapter module and the bias vector in the first large language model are adjusted using the sample dataset. After the function value of the reconstruction loss function converges, the second large language model is obtained.

2. The model adjustment method according to claim 1, characterized in that, The acquisition of the parameter matrix of the converter model includes: Obtain the dimensional information of the hidden layers in the converter model; Based on the dimensional information and the parameter information in the multi-head attention mechanism of the converter model, the parameter matrix of the converter model is determined.

3. The model adjustment method according to claim 1, characterized in that, Another alternative way to obtain the reconstruction loss function of the first large language model is: Obtain application scenario information for the first large language model; The type information of the reconstruction loss function is determined based on the application scenario information; Retrieve K reference reconstruction loss functions corresponding to the type information from a preset database; Obtain the associated application information of the first large language model; The reconstruction loss function of the first large language model is determined from the K reference reconstruction functions based on the associated application information.

4. The model adjustment method according to claim 1, characterized in that, Another alternative way to obtain the reconstruction loss function of the first large language model is: Obtain the first encoding function associated with the self-encoding adapter module, and obtain the first decoding function associated with the self-encoding adapter module; Obtain the parameter matrix of the converter model; The first norm is determined based on the parameter matrix, the first encoding function, and the first decoding function; The first potential distribution is determined based on the first encoding function and the parameter matrix; Obtain the first potential distribution and the prior distribution of the autoencoder adapter module, and determine the first divergence; Based on the first divergence and the first norm, the reconstruction loss function of the first large language model is determined.

5. The model adjustment method according to claim 4, characterized in that, After adjusting the weights of the autoencoder adapter module and the bias vector in the first large language model using the sample dataset, and obtaining the second large language model after the function value of the reconstruction loss function converges, the method further includes: Receive the first medical feedback information corresponding to the first medical problem; The first medical feedback information is processed using the second major language model to obtain a second medical question corresponding to the first medical feedback information.

6. A model adjustment device, characterized in that, The device includes: The first acquisition unit is used to acquire an initial large language model, wherein the initial large language model includes a K-layer converter model; A connection unit is used to connect the K-layer converter models included in the initial large language model to the autoencoder adapter module respectively to obtain the first large language model. When connecting the autoencoder adapter module to the converter model, the autoencoder adapter module is connected between the two converter models. The first calculation result is obtained using the method shown in the following formula: Where y is the result of the first operation, x is the initial input data received at the input end of the converter model, and b is the bias vector. This is the pass function for the self-encoding adapter module. This is for the transpose operation, and to determine the first operation result as the input data for the converter model; The second acquisition unit is used to acquire a sample dataset and to acquire the reconstruction loss function of the first large language model. Acquiring the reconstruction loss function includes: acquiring a first encoding function associated with the autoencoder adapter module and a first decoding function associated with the autoencoder adapter module; acquiring the parameter matrix of the converter model and a first regularization coefficient; determining a first norm based on the parameter matrix, the first encoding function, and the first decoding function; determining a second norm based on the first encoding function and the parameter matrix; and determining the reconstruction loss function based on the first regularization coefficient, the first norm, and the second norm. An adjustment unit is used to adjust the weights of the autoencoder adapter module and the bias vector in the first large language model after fixing the initial weights in the first large language model, using the sample dataset, and to obtain the second large language model after the function value of the reconstruction loss function converges.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the model adjustment method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the model adjustment method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Language model pre-training method and device

    CN110941945A

  • Fine adjustment method and device for pre-training language model

    CN116090508A