A personalized intelligent customer service method and system for Non-IID language data
By fine-tuning the pre-trained model and adding noise processing to the gradient on the client, and combining the personalized LoRA model for parameter aggregation, the model differences and resource limitation problems of intelligent customer service methods in the Non-IID language data scenario are solved, and efficient training and reply efficiency of personalized intelligent customer service models are achieved.
Patent Information
- Application Number
- CN202510257415.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-03-05
AI Technical Summary
The existing intelligent customer service methods have problems such as large model differences, limited computing resources and high communication overhead in the Non-IID language data scenario, which cannot meet the balance between personalized needs and efficient fine-tuning.
The method of client-side local fine-tuning and server-side aggregation is adopted, combined with the personalized LoRA aggregation model, and fine-tuning of the pre-trained model and gradient addition noise processing are performed on the client, and the personalized LoRA model is used for parameter aggregation and optimization to enhance model adaptability.
It realizes efficient training of personalized intelligent customer service models in the Non-IID language data scenario, meets the personalized needs of different clients, ensures response efficiency, and protects user privacy and security.
Smart Images

Figure CN120106225B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a personalized intelligent customer service method and system for Non-IID language data. Background Art
[0002] Intelligent customer service combines advanced technologies to provide more efficient and personalized customer service. Pre-trained language models (PLMs) for intelligent customer service, such as BERT and RoBERTa, have demonstrated outstanding performance in natural language processing (NLP), making them a key model in real-world applications. However, traditional centralized fine-tuning approaches rely on large amounts of data collected from individual customers, small businesses, or large enterprises, which poses significant challenges amidst increasingly stringent privacy and data protection laws.
[0003] To address this issue, the federated learning framework was introduced. This approach protects data privacy by fine-tuning the model on local devices and uploading the parameters to a central server for aggregation. While this approach overcomes the data collection barrier, it also exposes the following key technical challenges:
[0004] 1. There is often statistical heterogeneity between clients. The fine-tuning data distributed on different clients is inherently highly non-independent and identically distributed (Non-IID). There are significant differences in data distribution between clients, resulting in large differences in the models trained on each client, which in turn leads to suboptimal global model performance.
[0005] 2. High communication overhead: Pre-trained language models are usually large in scale, and the fine-tuning process requires frequent exchange of millions or even billions of model parameters or gradients, which causes serious latency problems due to the limited bandwidth in the federated learning system.
[0006] 3. Limited computing and storage resources: Due to the limited computing power of client devices, global fine-tuning of large pre-trained language models is difficult to achieve under current conditions, resulting in a significant decline in model performance.
[0007] To address these challenges, researchers have proposed a variety of improvements. For example, they have introduced technologies such as Adapter Tuning and LORA (Low-Rank Adaptation) to fine-tune federated large models to reduce the number of communication parameters. They have also used model compression to decompose large models into an upstream general model and downstream task adapters, and only update the adapters on the client side, thereby improving performance in non-independent and identically distributed (Non-IID) scenarios.
[0008] However, the above method does not consider the balance of each client and adopts a general federated aggregation method, which still allows extremely heterogeneous clients to participate in training. It does not take into account the heterogeneity between clients and cannot meet the personalized needs of different clients. It still fails to fully solve the balance between personalized needs and efficient fine-tuning, resulting in low personalization of intelligent customer service responses to different groups of people. Summary of the Invention
[0009] The present invention provides a personalized intelligent customer service method and system for Non-IID language data, which can meet the personalized needs of different clients and ensure the response efficiency of the target customer service model on each client.
[0010] To achieve the above objectives, the present invention provides a personalized intelligent customer service method for Non-IID language data, comprising:
[0011] The client's processing chip collects customer question information from the user interface and inputs the customer question information into the client's target customer service model. The target customer service model outputs the answer content, and the processing chip outputs the answer content to the client's display;
[0012] The client's target customer service model construction process includes:
[0013] The server initializes the fine-tuning parameters of the pre-built customer service model and distributes the fine-tuning parameters and pre-trained parameters of the pre-built customer service model to each client.
[0014] The client uses the local question-answering dataset to fine-tune the pre-built customer service model. After training, the fine-tuning parameters of the pre-built customer service model are updated to obtain updated fine-tuning parameters. The gradient corresponding to the updated fine-tuning parameters is added with noise and uploaded to the server.
[0015] The server aggregates the gradients corresponding to the updated fine-tuning parameters uploaded by all clients to obtain the aggregated fine-tuning parameters, and distributes the aggregated fine-tuning parameters to each client.
[0016] The client receives the aggregate fine-tuning parameters and uses the personalized LoRA aggregation model to train the aggregate fine-tuning parameters to obtain the final fine-tuning parameters, and uploads the final fine-tuning parameters to the server;
[0017] The server-side aggregates the final fine-tuning parameters to obtain global parameters, and distributes the global parameters to each client. Each client uses the personalized LoRA aggregation model to process the global parameters to obtain personalized parameters, and uses the personalized parameters to update the pre-built customer service model to obtain the target customer service model.
[0018] Optionally, the client uses a local question-answer pair dataset to fine-tune the pre-built customer service model, including:
[0019] Obtain the local client question-answer text pair and convert it into an input sequence embedding matrix;
[0020] Based on the number of transformer network layers in the pre-built customer service model, the positional encoding function is used to output the embedded representation of the input sequence in each transformer network layer. The transformer network includes multiple layers of encoders and decoders.
[0021] The encoder uses a multi-layer self-attention mechanism to process the input sequence embedding representation, and the decoder generates the output sequence embedding representation through multi-layer self-attention, and uses the feedforward neural network in the decoder to obtain the final sequence embedding representation;
[0022] The final sequence embedding representation of the decoder is converted into a text prediction probability distribution using the softmax layer in the fully connected layer. The temperature sampling strategy is used to adjust the text prediction probability distribution, and the predicted text content is generated based on the adjusted text prediction probability distribution.
[0023] The prediction error of the pre-built customer service model is calculated using the cross-entropy loss function based on the predicted text content and the input sequence embedding representation, and the model parameters of the pre-built customer service model are updated using the gradient descent method.
[0024] Optionally, the step of adding noise to the gradient corresponding to the updated fine-tuning parameter and uploading the result to the server includes:
[0025] Calculate the gradient of the updated fine-tuning parameters with respect to the fine-tuning parameters of the pre-built customer service model;
[0026] The noise term of Gaussian distribution is used to add noise to the gradient and then uploaded to the server.
[0027] Optionally, the client receives the aggregation fine-tuning parameter and trains the aggregation fine-tuning parameter using a personalized LoRA aggregation model, including:
[0028] Step 1: The client receives the aggregation fine-tuning parameter W e ={B,A}, where B is the feature dimension reduction projection matrix, A is the feature reconstruction matrix, and the aggregation fine-tuning parameter after initialization of the i-th client is Where i is the client index, i is a positive integer, B i is the feature dimension reduction projection matrix of the i-th client, A i Reconstruct the feature matrix for the i-th client, and the i-th client has a personalized LoRA aggregation model To control A i The first coefficient of the parameter weight of the l×d modules in the high level, To control B iThe second coefficient of the parameter weight of the high-level l×d modules, where l×d is the input dimension of the module, l is a hyperparameter that controls the personalized LoRa aggregation model applied to several high-level transformer layers, typically l=20, and d is the number of LoRa modules applied to each transformer layer, typically d=2;
[0029] Step 2: The client initializes the personalized LoRA aggregation model
[0030] Where 1 is a matrix whose elements are all 1;
[0031] Step 3: Use the personalized LoRA aggregation model W i,A ,W i,B renew get
[0032]
[0033] Where ⊙ represents the Hadamard product, B i(1) is the feature dimension reduction projection matrix obtained after the iterative training of client i, A i(1) is the feature reconstruction matrix obtained after the iterative training of client i is completed, is the fine-tuning parameter obtained after the iterative training is completed, With The same network shape as the middle and lower layer personalized LoRA model, The feature reconstruction matrix for the i-th client during the t-1 round of training, With The same network shape as the middle and lower layer personalized LoRA model, is the feature dimension reduction projection matrix of the i-th client during the t-1 round of training, The elements in are all 1 (constant);
[0034] Step 4: Freeze the parameters of the personalized LoRA model except the aggregate fine-tuning parameters, and use the client's local data to adjust the W i,A ,W i,B To train:
[0035]
[0036] Where η represents the learning rate, L represents the loss function, and W p is the large model parameter of the pre-built customer service model, W i,A For the simplified W i,B For the simplified is the gradient operation;
[0037] Step 5: W i,A ,W i,B Clip the elements in the array so that they remain between [0,1]:
[0038] σ(w A )=min(1,max(0,w A ))
[0039] σ(w B )=min(1,max(0,w B ))
[0040] Among them, w A ,w B ∈[0,1], w A is the first weighted average parameter, w B is the second weighted average parameter;
[0041] Step 6: Repeat steps 3-5 until convergence to obtain a personalized LoRA aggregation model.
[0042] Optionally, the personalized LoRA aggregation model performs multiple aggregation operations to obtain final fine-tuning parameters.
[0043] Optionally, the client calculates the gradient of the final fine-tuning parameters and the fine-tuning parameters of the pre-built customer service model, and uploads the gradient to the server after adding noise.
[0044] Optionally, the server aggregates the final fine-tuning parameters to obtain personalized parameters Use the following formula:
[0045]
[0046] Where N is the number of clients, t is the number of training rounds, and p i =|D i | / |D|,p i is the weighted coefficient in the weighted aggregation of client i, |D| represents the total number of samples, |D i | is the number of samples of client i, For the final fine-tuning parameters.
[0047] In order to solve the above problems, the present invention also provides a system for a personalized intelligent customer service method for Non-IID language data, wherein the system includes a server and one or more clients connected to the server.
[0048] Optionally, the client includes local data stored on the client and a pre-built customer service model stored on the client.
[0049] Optionally, the server side includes initializing fine-tuning parameters of a pre-built customer service model, and distributing the fine-tuning parameters and pre-training parameters of the pre-built customer service model to each client.
[0050] The present invention uses the client to fine-tune the pre-built customer service model using the local question-answer pair dataset. After the training is completed, the fine-tuning parameters of the pre-built customer service model are updated to obtain updated fine-tuning parameters, and the gradient corresponding to the updated fine-tuning parameters is added with noise and uploaded to the server, which can effectively protect the user's privacy and security. The client receives the aggregated fine-tuning parameters and uses the personalized LoRA aggregation model to train the aggregated fine-tuning parameters to obtain the final fine-tuning parameters. Through the personalized LoRA aggregation model, each client can adjust according to local data, enhance the adaptability of the intelligent customer service model to different user groups, and meet the personalized needs of different clients. The client uses the personalized parameters to update the pre-built customer service model to obtain the target customer service model, wherein the personalized parameters are obtained through multiple parameter aggregation and optimization training, which can ensure the response efficiency of the target customer service model on each client. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A flowchart of a personalized intelligent customer service method for Non-IID language data provided by one embodiment of the present invention;
[0052] Figure 2 A system structure diagram of a personalized intelligent customer service method for Non-IID language data provided by one embodiment of the present invention;
[0053] Figure 3 A diagram illustrating the training process of a personalized LoRA aggregation model for a personalized intelligent customer service method for Non-IID language data provided by one embodiment of the present invention.
[0054] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0055] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0056] The embodiment of the present application provides a personalized intelligent customer service method for Non-IID language data. The execution subject of the personalized intelligent customer service method for Non-IID language data includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the personalized intelligent customer service method for Non-IID language data can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0057] Reference Figure 1 FIG. 1 is a flow chart of a personalized intelligent customer service method for Non-IID language data provided by an embodiment of the present invention. In this embodiment, the personalized intelligent customer service method for Non-IID language data includes:
[0058] S1. The processing chip of the client collects customer question information from the user interface, inputs the customer question information into the target customer service model of the client, the target customer service model outputs the answer content, and the processing chip outputs the answer content to the display of the client.
[0059] In the embodiment of the present invention, the user interface refers to an interface for collecting customer problem information. For example, the user interface includes but is not limited to a keyboard interface and a network interface.
[0060] In the embodiment of the present invention, customer question information refers to questions raised by customers to merchant customers.
[0061] The client's target customer service model construction process includes steps S2-S6:
[0062] S2. The server initializes the fine-tuning parameters of the pre-built customer service model and distributes the fine-tuning parameters and the pre-trained parameters of the pre-built customer service model to each client.
[0063] In the embodiment of the present invention, the client plays an important role in federated learning and is the owner of the data, such as a mobile phone, hospital or enterprise. Each client holds its own data and is responsible for training the local model.
[0064] In the embodiment of the present invention, the server side is another important role in federated learning. It is mainly responsible for aggregating updates from various clients, calculating a global model, and distributing the global model to all clients for the next round of training. The whole process is iterative until the model reaches a predetermined accuracy or completes a specified number of training rounds.
[0065] For example, the fine-tuning parameters and pre-trained parameters of the pre-built customer service model are distributed to each client by the following implementation steps:
[0066] 101: Server initializes fine-tuning parameter W for aggregation e
[0067] For B i , (i∈(1,2,…,N)), all parameters are initialized to 0;
[0068] B i =0
[0069] For A i , (i∈(1,2,…,N)), its distribution is:
[0070] A i ~N(0,σ 2 I)
[0071] That is, the mean is 0 and the covariance matrix is σ 2 Gaussian distribution of I.
[0072] 102: The server sends all parameters to each client.
[0073] S3. The client uses the local question-answer pair dataset to fine-tune the pre-built customer service model. After the training is completed, the fine-tuning parameters of the pre-built customer service model are updated to obtain updated fine-tuning parameters. The gradient corresponding to the updated fine-tuning parameters is added with noise and uploaded to the server.
[0074] In the embodiment of the present invention, the local question-answer pair dataset refers to a dataset owned by each client.
[0075] In the embodiment of the present invention, the pre-built customer service model refers to a local model stored on the client.
[0076] For example, the pre-built customer service model consists of N layers of transformer modules with parameters W p ={w p,1 ,w p,2 ,…,w p,N}, fine-tune the parameter W e ={B,A}, where B is the feature dimension reduction projection matrix, A is the feature reconstruction matrix, B = {B1, B2,…, BN},A={A1,A2,…,A N}, where w p,i ∈R m×n (i∈(1,2,…,N)),w d ∈R d_embedding×r , input feature h∈R d_embedding , where r is usually much smaller than d_embedding, indicating dimensionality reduction. u ∈R r×d_embedding , B i ∈R m×rank ,A i ∈R rank×n ,(i∈(1,2,…,N)) and rank<<min(m,n) The client has a paired local structured fine-tuning dataset D={(q1,d1),(q2,d2),…,(q n ,d n )}, where (q n ,d n ) represents the nth question-answer pair.
[0077] As an embodiment of the present invention, the client uses a local question-answer pair dataset to fine-tune and train a pre-built customer service model, including:
[0078] Obtain the local client question-answer text pair and convert it into an input sequence embedding matrix;
[0079] Based on the number of transformer network layers in the pre-built customer service model, the positional encoding function is used to output the embedded representation of the input sequence in each transformer network layer. The transformer network includes multiple layers of encoders and decoders.
[0080] The encoder uses a multi-layer self-attention mechanism to process the input sequence embedding representation, and the decoder generates the output sequence embedding representation through multi-layer self-attention, and uses the feedforward neural network in the decoder to obtain the final sequence embedding representation;
[0081] The final sequence embedding representation of the decoder is converted into a text prediction probability distribution using the softmax layer in the fully connected layer. The temperature sampling strategy is used to adjust the text prediction probability distribution, and the predicted text content is generated based on the adjusted text prediction probability distribution.
[0082] The prediction error of the pre-built customer service model is calculated using the cross-entropy loss function based on the predicted text content and the input sequence embedding representation, and the model parameters of the pre-built customer service model are updated using the gradient descent method.
[0083] For example, the client uses the local question-answer pair dataset to fine-tune the pre-built customer service model using the following implementation steps:
[0084] 201: Word embedding for local structured fine-tuning dataset:
[0085] D new ={(q1,d1),(q2,d2),…,(q m ,d m )}
[0086] Where (q m ,d m ) represents the mth question-answer pair.
[0087] For q m , are transformed into a corresponding input sequence embedding matrix X∈R input_size×d_embedding , for d m , are transformed into a corresponding output sequence embedding matrix Y∈R output_siz e ×d_embedding
[0088] The following defaults to training each matrix once
[0089] 202: The first N layers of the model are transformer models:
[0090] X (i) =EnCoder(X (i-1) +PE(X (i-1) ))
[0091] Y (i) =DeCoder(X (i) ,Y (i-1) +PE(Y (i-1) ))
[0092] where X (i) is the embedding representation of the input sequence of layer i, Y (i) is the embedding representation of the target sequence at layer i, and PE represents the position encoding function;
[0093] EnCoder is composed of multiple encoder layers connected together, W Q,i ,W K,i ,W V,i ∈w p,i is the pre-trained weight matrix, B Q,i ,B V,i ∈B i ,A Q,i ,A V,i ∈A i
[0094] Each encoder layer is structured as follows:
[0095] a. Calculate the query, key, and value matrices:
[0096] Q i =(X (i) +PE(X (i) ))(W Q,i +B Q,i A Q,i ),K i =(X (i) +PE(X (i) ))W K,i ,V i
[0097] =(X (i) +PE(X (i) ))(W V,i +B V,i A V,i )
[0098] b. Calculate attention score:
[0099]
[0100] where d k is the dimension of the key
[0101] c. Calculate self-attention output:
[0102] Z i =Score i V i
[0103] d. Encoder layer output:
[0104] EncoderLayer(X (i) )=LayerNorm(X (i) +Z i )
[0105] EncoderLayer(X (i) )=LayerNorm(EncoderLayer(X (i) )+FFN(ZEncoderLayer(X (i) )))
[0106] Where FFN(Z)=max(0,ZW1+b1)W2+b2, repeat this for multiple encoder layers to get the encoder output
[0107] Decoder is composed of multiple decoder layers connected together, W′ Q,i ,W′ K,i,W′ V,i ,W″ Q,i ,W″ K,i ,W″ V,i ,M i ∈w p,i is the pre-trained weight matrix, B′ Q,i ,B′ V,i ,B″ Q,i ,B″ V,i ∈B i ,A′ Q,i ,A′ V,i ,A″ Q,i ,A″ V,i ∈A i
[0108] Each decoder layer is structured as follows:
[0109] a. Compute the query, key, and value matrices of the masked self-attention mechanism:
[0110] Q′ i =(Y (i) +PE(Y (i) ))(W′ Q,i +B′ Q,i A′ Q,i )
[0111] K′ i =(Y (i) +PE(Y (i) ))W′ K,i
[0112] V′ V =(Y (i) +PE(Y (i) ))(W′ V,i +B′ V,i A′ V,i )
[0113] b. Calculate attention score:
[0114]
[0115] where d k is the dimension of the key, M i is the mask matrix
[0116] c. Calculate self-attention output:
[0117] Z′ i =Score′ i V′ i
[0118] d. Compute the query, key, and value matrices of the masked self-attention mechanism:
[0119] Q″ i =Z′ i (W″ Q,i +B″ Q,i A″ Q,i )
[0120] K″ i =X (i+1) W″ K,i
[0121] V i =X (i+1) (W″ V,i +B″ V,i A″ V,i )
[0122] e. Calculate attention score:
[0123]
[0124] f. Calculate the encoder-decoder attention output:
[0125] Z″ i =Score″ i V i
[0126] g. Decoder layer output:
[0127] DecoderLayer(Y)=LayerNorm(Y+Z′)
[0128] DecoderLayer(Y)=LayerNorm(DecoderLayer(Y)+Z″)
[0129] DecoderLayer(Y)=LayerNorm(DecoderLayer(Y)+FFN(DecoderLayer(Y)))
[0130] FFN() is the same as in the decoder, which represents a feedforward neural network. Multiple decoder layers are repeated to obtain the final sequence embedding representation of the decoder.
[0131] 203: The N+1th layer is a fully connected layer, which serves as the model output layer for text prediction:
[0132]
[0133] in, is the predicted label distribution of local text; is the fully connected layer weight.
[0134] 204: Generate words y1, y2, ..., y output_size :
[0135] Temperature sampling introduces a temperature parameter T (usually a real number greater than 0, with 0.2 being the recommended value). By adjusting this parameter, the shape of the original probability distribution can be changed.
[0136]
[0137] Where sample(·) represents the The probability distribution of the i-th row is randomly sampled to select the generated vocabulary
[0138] Batch stochastic gradient descent with cross entropy as the loss function.
[0139] 205: Calculate cross entropy loss:
[0140] For each generated word y i , whose probability is P(y i |x,y1,y2,…,y i-1 ) where x, y1, y2, …, y i-1 are the input and the generated words.
[0141]
[0142] Where k represents the corresponding position of the selected word, that is The corresponding probability
[0143] The loss function is the sum of the negative log-likelihoods of all generated words:
[0144]
[0145] 206: Update parameters:
[0146] Among them, C is the number of classes, η is the learning rate, θ represents all trainable parameters, and m represents the number of question-answer pairs.
[0147] As an embodiment of the present invention, the step of adding noise to the gradient corresponding to the updated fine-tuning parameter and uploading the noise to the server includes:
[0148] Calculate the gradient of the updated fine-tuning parameters with respect to the fine-tuning parameters of the pre-built customer service model;
[0149] The noise term of Gaussian distribution is used to add noise to the gradient and then uploaded to the server.
[0150] For example, the gradient corresponding to the updated fine-tuning parameter is added with noise and then uploaded to the server using the following implementation steps:
[0151] 301: For client i, during initial training, the local model fine-tuning parameters are set to Add noise to the gradient:
[0152]
[0153] in, represents the parameter after adding noise, ∈ represents the noise term, and its distribution is:
[0154] ∈~N(0,σ 2 I)
[0155] That is, the mean is 0, and the covariance matrix is σ 2 Gaussian distribution of I.
[0156] 302: Will Transmitted to the central server.
[0157] S4. The server aggregates the gradients corresponding to the updated fine-tuning parameters uploaded by all clients to obtain an aggregated fine-tuning parameter, and distributes the aggregated fine-tuning parameter to each client.
[0158] Exemplarily, the server aggregates the gradients corresponding to the updated fine-tuning parameters uploaded by all clients to obtain the aggregated fine-tuning parameters, which can be implemented in the following steps:
[0159] 401: The server aggregates the gradient parameters of all clients to obtain the fine-tuning parameter W e :
[0160]
[0161] p i =|D i | / |D|,|D| represents the total number of samples, |D i Number of samples for client i
[0162] 402: W e Distribute to each client.
[0163] S5. The client receives the aggregate fine-tuning parameters and uses the personalized LoRA aggregation model to train the aggregate fine-tuning parameters to obtain the final fine-tuning parameters, and uploads the final fine-tuning parameters to the server.
[0164] In an embodiment of the present invention, a personalized LoRA (Low-Rank Adaptation) aggregation model refers to a machine learning method that combines low-rank adaptation (LoRA) technology with a model aggregation mechanism, aiming to achieve customized model optimization for different users or scenarios, and combining the weights of multiple LoRA modules to improve the personalized performance of the model.
[0165] As an embodiment of the present invention, the client receives the aggregation fine-tuning parameter and trains the aggregation fine-tuning parameter using the personalized LoRA aggregation model, including:
[0166] Step 1: The client receives the aggregation fine-tuning parameter W e ={B,A}, where B is the feature dimension reduction projection matrix, A is the feature reconstruction matrix, and the aggregation fine-tuning parameter after initialization of the i-th client is Where i is the client index, i is a positive integer, B i is the feature dimension reduction projection matrix of the i-th client, A i Reconstruct the feature matrix for the i-th client, and the i-th client has a personalized LoRA aggregation model To control A i The first coefficient of the parameter weight of the l×d modules in the high level, To control B i The second coefficient of the parameter weight of the l×d modules at the top level, the network shape of the i-th client with the personalized LoRA aggregation model is respectively {B i ,A i The l×d modules at the top level are identical, where l×d is the module input dimension, l is a hyperparameter that controls how the personalized LoRA aggregation model is applied to several high-level transformer layers, typically l=20, and d is the number of LoRA modules applied to each transformer layer, typically d=2;
[0167] Step 2: The client initializes the personalized LoRA aggregation model
[0168] Where 1 is a matrix whose elements are all 1;
[0169] Step 3: Use the personalized LoRA aggregation model W i,A ,W i,B renew get
[0170]
[0171] Where ⊙ represents the Hadamard product, B i(1) is the feature dimension reduction projection matrix obtained after the iterative training of client i, Ai(1) is the feature reconstruction matrix obtained after the iterative training of client i is completed, is the fine-tuning parameter obtained after the iterative training is completed, With The same network shape as the middle and lower layer personalized LoRA model, The feature reconstruction matrix for the i-th client during the t-1 round of training, With The same network shape as the middle and lower layer personalized LoRA model, is the feature dimension reduction projection matrix of the i-th client during the t-1 round of training, The elements in are all 1 (constant);
[0172] Step 4: Freeze the parameters of the personalized LoRA model except the aggregate fine-tuning parameters, and use the client's local data to adjust the W i,A ,W i,B To train:
[0173]
[0174] Where η represents the learning rate, L represents the loss function, and W p is the large model parameter of the pre-built customer service model, W i,A For the simplified W i,B For the simplified is the gradient operation;
[0175] Step 5: W i,A ,W i,B Clip the elements in the array so that they remain between [0,1]:
[0176] σ(w A )=min(1,max(0,w A ))
[0177] σ(w B )=min(1,max(0,w B ))
[0178] Among them, w A ,w B ∈[0,1], w A is the first weighted average parameter, w B is the second weighted average parameter;
[0179] Step 6: Repeat steps 3-5 until convergence to obtain a personalized LoRA aggregation model.
[0180] In the embodiment of the present invention, the high layer refers to the deep network structure connected to the output end in the personalized LoRA aggregation model.
[0181] In the embodiment of the present invention, the network shape refers to the deep network structure connected to the output end. For example, the network shape in the present invention can be a 1-layer transformer network structure before the output layer.
[0182] Furthermore, the personalized LoRA aggregation model performs multiple aggregation operations to obtain the final fine-tuning parameters.
[0183] For example, the personalized LoRA aggregation model performs multiple aggregation operations to obtain the final fine-tuning parameters by adopting the following implementation steps:
[0184] Perform steps 3-5 once to update the personalized LoRA aggregation model W i,A ,W i,B , and in round t, use the personalized LoRA aggregation model W i,A ,W i,B renew get
[0185]
[0186] According to the initialized Use the local question-answering dataset to fine-tune the pre-built customer service model and obtain the final fine-tuning parameters after training.
[0187] Furthermore, the client calculates the gradient of the final fine-tuning parameters and the fine-tuning parameters of the pre-built customer service model, and uploads the gradient to the server after adding noise.
[0188] For example, the client calculates the gradient of the final fine-tuning parameter and the fine-tuning parameter of the pre-built customer service model, and uploads the gradient to the server after adding noise. The following implementation steps can be used:
[0189] 501: For client k, during the tth round of training, the local model fine-tuning parameters are set to Add noise to the gradient:
[0190]
[0191] in, represents the parameter after adding noise, ∈ represents the noise term, and its distribution is:
[0192] ∈~N(0,σ 2 I)
[0193] That is, the mean is 0, and the covariance matrix is σ 2Gaussian distribution of I.
[0194] 502: Will Transmitted to the central server.
[0195] S6. The server aggregates the final fine-tuned parameters to obtain global parameters, and distributes the global parameters to each client. Each client uses the personalized LoRA aggregation model to process the global parameters to obtain personalized parameters, and uses the personalized parameters to update the pre-built customer service model to obtain the target customer service model.
[0196] As an embodiment of the present invention, the server aggregates the final fine-tuning parameters to obtain personalized parameters Use the following formula:
[0197]
[0198] Where N is the number of clients, t is the number of training rounds, and p i =|D i | / |D|,p i is the weighted coefficient in the weighted aggregation of client i, |D| represents the total number of samples, |D i | is the number of samples of client i, For the final fine-tuning parameters.
[0199] The present invention uses the client to fine-tune the pre-built customer service model using the local question-answer pair dataset. After the training is completed, the fine-tuning parameters of the pre-built customer service model are updated to obtain updated fine-tuning parameters, and the gradient corresponding to the updated fine-tuning parameters is added with noise and uploaded to the server, which can effectively protect the user's privacy and security. The client receives the aggregated fine-tuning parameters and uses the personalized LoRA aggregation model to train the aggregated fine-tuning parameters to obtain the final fine-tuning parameters. Through the personalized LoRA aggregation model, each client can adjust according to local data, enhance the adaptability of the intelligent customer service model to different user groups, and meet the personalized needs of different clients. The client uses the personalized parameters to update the pre-built customer service model to obtain the target customer service model, wherein the personalized parameters are obtained through multiple parameter aggregation and optimization training, which can ensure the response efficiency of the target customer service model on each client.
[0200] Reference Figure 2 , which is a system structure diagram of a personalized intelligent customer service method for Non-IID language data provided by an embodiment of the present invention.
[0201] As an embodiment of the present invention, the system includes a server and one or more clients connected to the server.
[0202] Furthermore, the client includes local data stored on the client and a pre-built customer service model stored on the client.
[0203] Furthermore, the server side includes initializing fine-tuning parameters of the pre-built customer service model, and distributing the fine-tuning parameters and pre-training parameters of the pre-built customer service model to each client.
[0204] Reference Figure 3 , which is a diagram of the training process of a personalized LoRA aggregation model for a personalized intelligent customer service method for Non-IID language data provided by one embodiment of the present invention.
[0205] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0206] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0207] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0208] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.
[0209] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. Terms such as "first" and "second" are used to indicate names and do not imply any particular order.
[0210] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A personalized intelligent customer service method for Non-IID language data, characterized by: The method comprises: The client's processing chip collects customer question information from the user interface and inputs the customer question information into the client's target customer service model. The target customer service model outputs the answer content, and the processing chip outputs the answer content to the client's display; The client's target customer service model construction process includes: The server initializes the fine-tuning parameters of the pre-built customer service model and distributes the fine-tuning parameters and pre-trained parameters of the pre-built customer service model to each client. The client uses the local question-answering dataset to fine-tune the pre-built customer service model. After training, the fine-tuning parameters of the pre-built customer service model are updated to obtain updated fine-tuning parameters. The gradient corresponding to the updated fine-tuning parameters is added with noise and uploaded to the server. The server aggregates the gradients corresponding to the updated fine-tuning parameters uploaded by all clients to obtain the aggregated fine-tuning parameters, and distributes the aggregated fine-tuning parameters to each client. The client receives the aggregate fine-tuning parameters and trains the aggregate fine-tuning parameters using the personalized LoRA aggregation model to obtain the final fine-tuning parameters, and uploads the final fine-tuning parameters to the server. The client receives the aggregate fine-tuning parameters and trains the aggregate fine-tuning parameters using the personalized LoRA aggregation model, including: Step 1: The client receives the aggregation fine-tuning parameters ,in, is the feature dimension reduction projection matrix, is the feature reconstruction matrix, The aggregate fine-tuning parameters after client initialization are: ,in, For client index, is a positive integer, For the The feature dimension reduction projection matrix of each client, For the The feature reconstruction matrix of the client, Each client has a personalized LoRA aggregation model , For control High-level The first coefficient of the parameter weight of the module, For control High-level The second coefficient of the parameter weight of the module, where is the input dimension of the module, It is a hyperparameter that controls the personalized LoRA aggregation model acting on the high-level transformer layer. is the number of LoRA modules applied in each transformer layer; Step 2: The client initializes the personalized LoRA aggregation model : ,in is a matrix whose elements are all 1; Step 3: Use a personalized LoRA aggregation model renew get : in represents the Hadamard product, Is the client The feature dimension reduction projection matrix obtained after the iterative training is completed is: Is the client The feature reconstruction matrix obtained after the iterative training is completed is: is the fine-tuning parameter obtained after the iterative training is completed, With The same network shape as the middle and lower layer personalized LoRA model, For the Clients in The feature reconstruction matrix during round training, With The same network shape as the middle and lower layer personalized LoRA model, For the Clients in The feature dimension reduction projection matrix during round training, All elements in are 1; Step 4: Freeze the parameters of the personalized LoRA model except for the aggregate fine-tuning parameters, and use the local data of the client to To train: in represents the learning rate, represents the loss function, The large model parameters for the pre-built customer service model, For the simplified , For the simplified , is the gradient operation, For customers The number of samples; Step 5: The elements are cropped to make The values of the elements in are kept between [0,1]: in, , is the first weighted average parameter, is the second weighted average parameter; Step 6: Repeat steps 3-5 until convergence to obtain a personalized LoRA aggregation model; The server-side aggregates the final fine-tuning parameters to obtain global parameters, and distributes the global parameters to each client. Each client uses the personalized LoRA aggregation model to process the global parameters to obtain personalized parameters, and uses the personalized parameters to update the pre-built customer service model to obtain the target customer service model.
2. The personalized intelligent customer service method for Non-IID language data according to claim 1, characterized in that: The client uses the local question-answer pair dataset to fine-tune the pre-built customer service model, including: Obtain the local client question-answer text pair and convert it into an input sequence embedding matrix; Based on the number of transformer network layers in the pre-built customer service model, the positional encoding function is used to output the embedded representation of the input sequence in each transformer network layer. The transformer network includes multiple layers of encoders and decoders. The encoder uses a multi-layer self-attention mechanism to process the input sequence embedding representation, and the decoder generates the output sequence embedding representation through multi-layer self-attention, and uses the feedforward neural network in the decoder to obtain the final sequence embedding representation; The final sequence embedding representation of the decoder is converted into a text prediction probability distribution using the softmax layer in the fully connected layer. The temperature sampling strategy is used to adjust the text prediction probability distribution, and the predicted text content is generated based on the adjusted text prediction probability distribution. The prediction error of the pre-built customer service model is calculated using the cross-entropy loss function based on the predicted text content and the input sequence embedding representation, and the model parameters of the pre-built customer service model are updated using the gradient descent method.
3. The personalized intelligent customer service method for Non-IID language data according to claim 1, characterized in that: The step of adding noise to the gradient corresponding to the updated fine-tuning parameter and uploading it to the server includes: Calculate the gradient of the updated fine-tuning parameters with respect to the fine-tuning parameters of the pre-built customer service model; The noise term of Gaussian distribution is used to add noise to the gradient and then uploaded to the server.
4. The personalized intelligent customer service method for Non-IID language data according to claim 3, characterized in that: The personalized LoRA aggregation model performs multiple aggregation operations to obtain the final fine-tuning parameters.
5. The personalized intelligent customer service method for Non-IID language data according to claim 4, characterized in that: The client calculates the gradient of the final fine-tuning parameters and the fine-tuning parameters of the pre-built customer service model, and uploads the gradient to the server after adding noise.
6. The personalized intelligent customer service method for Non-IID language data according to claim 1, characterized in that: The server aggregates the final fine-tuning parameters to obtain personalized parameters , using the following formula: in, is the number of clients, is the number of training rounds, , For the client The weighting coefficient in weighted aggregation, represents the total number of samples, For the client The number of samples, For the final fine-tuning parameters.
7. A system for implementing the personalized intelligent customer service method for Non-IID language data as described in any one of claims 1 to 6, the system comprising a server and one or more clients connected to the server.
8. The system of the personalized intelligent customer service method for Non-IID language data as claimed in claim 7, wherein the client includes local data stored on the client and a pre-built customer service model stored on the client.
9. The system for a personalized intelligent customer service method for Non-IID language data as claimed in claim 7, wherein the server side includes initializing fine-tuning parameters of a pre-built customer service model and distributing the fine-tuning parameters and pre-trained parameters of the pre-built customer service model to each client.
Citation Information
Patent Citations
Pre-training model fine tuning method and system
CN117852627A
Federal intelligent language translation method based on low-rank adaptation
CN118446232A