Classification model training method, dialogue processing method, device, equipment and medium
By employing a multi-stage training strategy and segmented training method for large language models, a target classification model was constructed, which solved the problem of low processing efficiency in call content analysis, achieved efficient classification and annotation of massive amounts of data, and improved classification accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SF TECH CO LTD
- Filing Date
- 2024-12-18
- Publication Date
- 2026-06-19
AI Technical Summary
Existing technologies are inefficient in analyzing call content, especially when dealing with massive amounts of data, making it difficult to classify and label it efficiently.
A large language model training method is adopted, which involves multi-stage training and segmented training strategies, including joint training of the first text processing sub-model, the second text processing sub-model, and the large language sub-model, to construct a target classification model. The model is then used to classify and label dialogue texts by combining structures such as multi-head attention mechanism layers, residual connections, and normalization layers with the Qwen and Baichuan models.
It improves the efficiency and accuracy of call content processing and classification, enabling effective classification and management of massive amounts of data within a limited time.
Smart Images

Figure CN122242715A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a classification model training method, a dialogue processing method, an apparatus, a device, and a medium. Background Technology
[0002] In the service industry, analyzing the content of customer service calls is of great significance to businesses. By analyzing the call content, businesses can understand customer needs, feedback issues, and other information, enabling them to better optimize service quality.
[0003] Currently, call content analysis typically employs pre-set keyword matching or manual analysis to determine the main content of the call. However, these methods are inefficient for processing massive amounts of call content. Summary of the Invention
[0004] The main objective of this application is to propose a classification model training method, a dialogue processing method, an apparatus, a device, and a medium, which aim to improve the processing efficiency of call content.
[0005] To achieve the above objectives, a first aspect of this application proposes a classification model training method, the method comprising:
[0006] Multiple training samples are obtained, each training sample including dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label of the dialogue text, wherein the first classification label is one of multiple preset classification labels;
[0007] The target classification model is obtained by training the large language model using multiple training samples.
[0008] In some embodiments, the large language model includes: a first text processing sub-model, a second text processing sub-model, a first large language sub-model, and a second large language sub-model; the first text processing sub-model is used to learn using the dialogue text; the second text processing sub-model is used to learn using the judgment result; the first large language sub-model is used to learn using the first classification label; and the second large language sub-model is used to learn the relationship between the dialogue text, the first classification label, and the judgment result.
[0009] The step of training a large language model using multiple training samples to obtain a target classification model includes:
[0010] With the configuration parameters of the first large language sub-model enabled, the first text processing sub-model is trained based on multiple training samples, and the configuration parameters of the first large language sub-model are disabled after training ends. The configuration parameters being enabled indicates that the model parameters of the first large language sub-model can be adjusted.
[0011] With the configuration parameters of both the first text processing sub-model and the second text processing sub-model enabled, the first text processing sub-model and the second text processing sub-model are trained based on multiple training samples. After training ends, the configuration parameters of the first text processing sub-model and the second text processing sub-model are disabled. The enabled configuration parameters indicate that the model parameters of the first text processing sub-model and the second text processing sub-model can be adjusted.
[0012] With the configuration parameters of the first text processing sub-model, the second text processing sub-model, the first large language sub-model, and the second large language sub-model all enabled, the large language model is trained based on multiple training samples to obtain the target classification model.
[0013] In some embodiments, the first text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the first large language sub-model is the Qwen model; the second text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the second large language sub-model is the Baichuan model.
[0014] In some embodiments, after training the large language model using multiple training samples to obtain the target classification model, the method further includes:
[0015] Multiple inference samples are obtained, each inference sample including inference text and a second classification label, the second classification label being one of multiple preset classification labels;
[0016] The inference sample is input into the target classification model to obtain the first preset parameters corresponding to the first text processing sub-model and the second preset parameters corresponding to the first large language sub-model.
[0017] Save the first preset parameter and the second preset parameter. The first preset parameter is used to configure the parameters of the first text processing sub-model when the inference sample includes the inference text. The second preset parameter is used to configure the parameters of the first large language sub-model when the inference sample includes the first classification label.
[0018] A second aspect of this application provides a dialogue processing method, the method comprising:
[0019] Obtain the dialogue content to be processed and convert the dialogue content to be processed into dialogue text;
[0020] Based on the dialogue text and multiple classification tags, multiple texts to be classified are obtained;
[0021] Each text to be classified is input into the target classification model to obtain the label result corresponding to each text to be classified. The target classification model is obtained by the classification model training method described in the first aspect.
[0022] Based on the label results corresponding to each of the texts to be classified, determine the target classification label for the dialogue content;
[0023] The correspondence between the dialogue content and the target category label is stored.
[0024] In some embodiments, obtaining multiple texts to be classified based on the dialogue text and multiple classification tags includes:
[0025] For each of the aforementioned category labels, the following processing is performed:
[0026] Obtain a preset template, the preset template including: a first placeholder and a second placeholder;
[0027] The first placeholder is replaced with the dialogue text, and the second placeholder is replaced with the category label to obtain the text to be categorized.
[0028] In some embodiments, determining the target classification label for the dialogue content based on the label results corresponding to each of the texts to be classified includes:
[0029] The label results corresponding to each of the texts to be classified are identified to obtain the label results containing the classification labels;
[0030] Obtain the category label mapped from the label result containing the category label, and use the mapped category label as the target category label.
[0031] To achieve the above objectives, a third aspect of this application provides a classification model training apparatus, the apparatus comprising:
[0032] The first acquisition module is used to acquire multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label of the dialogue text. The first classification label is one of multiple preset classification labels.
[0033] The training module is used to train the large language model using multiple training samples to obtain the target classification model.
[0034] To achieve the above objectives, a fourth aspect of the embodiments of this application provides a dialogue processing apparatus, the apparatus comprising:
[0035] The second acquisition module is used to acquire the dialogue text to be processed.
[0036] The processing module is used to obtain multiple texts to be classified based on the dialogue text and multiple classification tags respectively;
[0037] The processing module is also used to input each of the texts to be classified into the target classification model to obtain the label result corresponding to each of the texts to be classified, wherein the target classification model is obtained by the classification model training method described in the first aspect;
[0038] The determination module is used to determine the target classification label of the dialogue content based on the label results corresponding to each of the texts to be classified;
[0039] The storage module is used to store the correspondence between the dialogue content and the target category tags.
[0040] To achieve the above objectives, a fifth aspect of the present application provides an electronic device, the electronic device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method described in the first or second aspect above.
[0041] To achieve the above objectives, a sixth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first or second aspect.
[0042] The classification model training method, dialogue processing method, apparatus, device, and medium proposed in this application obtain a target classification model by training a large language model. The target classification model can classify dialogue content and is suitable for classifying massive amounts of data. Compared with existing technologies, it can improve processing efficiency and classification accuracy. Attached Figure Description
[0043] Figure 1 This is a flowchart of a classification model training method provided in an embodiment of this application;
[0044] Figure 2 This is another flowchart of the classification model training method provided in the embodiments of this application;
[0045] Figure 3This is a schematic diagram of the large language model structure provided in an embodiment of this application;
[0046] Figure 4 This is a flowchart of a dialogue processing method provided in an embodiment of this application;
[0047] Figure 5 This is a schematic diagram of the output and input of a target classification model provided in an embodiment of this application;
[0048] Figure 6 This is a schematic diagram of the output and input of a large language model provided in an embodiment of this application;
[0049] Figure 7 This is a schematic diagram of the structure of the classification model training device provided in the embodiments of this application;
[0050] Figure 8 This is a schematic diagram of the structure of the dialogue processing device provided in the embodiments of this application;
[0051] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0055] In the service industry, analyzing the content of customer service calls is of great significance to businesses. By analyzing the call content, businesses can understand customer needs, feedback issues, and other information, enabling them to better optimize service quality.
[0056] Currently, call content analysis typically employs pre-set keyword matching or manual analysis to determine the main content of the call. However, these methods are inefficient for processing massive amounts of call content.
[0057] Based on this, embodiments of this application provide a classification model training method, a dialogue processing method, an apparatus, a device, and a medium, aiming to improve the processing efficiency of call content.
[0058] The classification model training method, dialogue processing method, apparatus, device, and medium provided in the embodiments of this application are specifically described through the following embodiments. First, the classification model training method in the embodiments of this application is described.
[0059] The classification model training method provided in this application relates to the field of natural language processing technology. This method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the classification model training method, but is not limited to the above forms.
[0060] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0061] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, user location information, and user call content, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to a confirmation page. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the normal operation of embodiments of this application obtained.
[0062] First, let's analyze the terms used in this application:
[0063] Large Language Model (LLM) refers to a deep learning model trained on a large amount of text data that can generate natural language text or understand the meaning of language text.
[0064] Figure 1 This is a flowchart of a classification model training method provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S101 to S102, wherein:
[0065] Step S101: Obtain multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label for the dialogue text. The first classification label is one of multiple preset classification labels.
[0066] In this embodiment, multiple dialogue contents, i.e., call content, are pre-acquired. The dialogue content is then converted to obtain dialogue text. Specifically, a conversion tool is used to convert the dialogue content from speech to text. A first category label is obtained, which is one of multiple preset category labels, including, for example, complaints / suggestions, returns, and logistics inquiries. Multiple dialogue contents are pre-labeled, i.e., a labeling judgment result is assigned to each dialogue content. This judgment result determines whether the first category label is the correct label for the dialogue text. Specifically, manual labeling can be used. Based on the dialogue text, the first category label, and the judgment result of whether the first category label is the correct label for the dialogue text, training samples are pre-constructed. Multiple pre-constructed training samples are then obtained.
[0067] Step S102: Train the large language model using multiple training samples to obtain the target classification model.
[0068] In this embodiment, multiple training samples are used to train the large language model to obtain a target classification model. The target classification model is used to annotate the dialogue text and classify and manage the dialogue content according to the label results.
[0069] Steps S101 to S102 as illustrated in this embodiment involve acquiring multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result indicating whether the first classification label is the correct label for the dialogue text. The first classification label is one of multiple preset classification labels. By training the large language model with multiple training samples, a target classification model is obtained. The target classification model can classify dialogue content and is suitable for classifying massive amounts of data. Compared with existing technologies, it can improve processing efficiency and classification accuracy.
[0070] Figure 2 This is another flowchart of the classification model training method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S201 to S205, wherein:
[0071] Step S201: Obtain multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label for the dialogue text. The first classification label is one of multiple preset classification labels.
[0072] In this embodiment, multiple dialogue contents, i.e., call content, are pre-acquired. The dialogue content is then converted to obtain dialogue text. Specifically, a conversion tool is used to convert the dialogue content from speech to text. A first category label is obtained, which is one of multiple preset category labels, including, for example, complaints / suggestions, returns, and logistics inquiries. Multiple dialogue contents are pre-labeled, i.e., a labeling judgment result is assigned to each dialogue content. This judgment result determines whether the first category label is the correct label for the dialogue text. Specifically, manual labeling can be used. Based on the dialogue text, the first category label, and the judgment result of whether the first category label is the correct label for the dialogue text, training samples are pre-constructed. Multiple pre-constructed training samples are then obtained.
[0073] Step S202: Train the large language model using multiple training samples to obtain the target classification model.
[0074] In this embodiment, multiple training samples are used to train the large language model to obtain a target classification model. The target classification model is used to annotate the dialogue text and classify and manage the dialogue content according to the label results.
[0075] In some embodiments, the large language model includes: a first text processing sub-model, a second text processing sub-model, a first large language sub-model, and a second large language sub-model; the first text processing sub-model is used for learning using dialogue text; the second text processing sub-model is used for learning using judgment results; the first large language sub-model is used for learning using a first classification label; the second large language sub-model is used for learning the relationship between dialogue text, the first classification label, and the judgment results; step S202 includes:
[0076] With the configuration parameters of the first major language sub-model enabled, the first text processing sub-model is trained using multiple training samples. After training, the configuration parameters of the first major language sub-model are disabled. Enabling the configuration parameters indicates that the model parameters of the first major language sub-model can be adjusted. With the configuration parameters of both the first and second text processing sub-models enabled, the first and second text processing sub-models are trained using multiple training samples. After training, the configuration parameters of both the first and second text processing sub-models are disabled. Enabling the configuration parameters indicates that the model parameters of both the first and second text processing sub-models can be adjusted. With the configuration parameters of the first and second text processing sub-models, as well as the first and second major language sub-models, all enabled, the major language model is trained using multiple training samples to obtain the target classification model.
[0077] In this embodiment, the large language model includes: a first text processing sub-model, a second text processing sub-model, a first large language sub-model, and a second large language sub-model. The first text processing sub-model is used to learn using dialogue text; the second text sub-model is used to learn from the judgment result; the first large language sub-model is used to learn using the first classification label; and the second large language sub-model is used to learn the relationship between the dialogue text, the first classification label, and the judgment result.
[0078] To reduce the learning difficulty of the network, a segmented training strategy is designed. The first stage: training the first large language sub-model; the second stage: training the first text processing sub-model and the second text processing sub-model; the third stage: training the entire large language model.
[0079] Specifically, for the first stage: Enable the configuration parameters of the first major language sub-model, such as setting all attributes of `is_training` to "true". This is a commonly used variable in machine learning and deep learning to control the model's training and testing process. Generally, during model training, the value of `is_training` is used to determine whether to perform data augmentation, dropout, etc. With the configuration parameters of the first major language sub-model enabled, train the first text processing sub-model using multiple training samples. After training, disable the configuration parameters of the first major language sub-model. Enabling the configuration parameters indicates that adjustments to the model parameters of the first major language sub-model are allowed, while disabling them indicates that further adjustments to the model parameters are not permitted, i.e., setting all attributes of `is_training` to "true". The purpose of the first stage of training is to enable the model to understand the relationships between labels and the knowledge within the labels, such as the association between labels (which category labels can appear simultaneously) or the mutual exclusion relationship between labels (which category labels cannot appear simultaneously).
[0080] Furthermore, regarding the second stage: The configuration parameters of the first and second text processing sub-models are enabled. With both configuration parameters enabled, the first and second text processing sub-models are trained based on multiple training samples. After training, the configuration parameters of the first and second text processing sub-models are disabled. Enabling the configuration parameters indicates that adjustments to the model parameters of the first and second text processing sub-models are allowed, while disabling them indicates that further adjustments to the first and second text processing sub-models are not permitted. The purpose of the second stage of training is to enable the model to learn the relationship between the dialogue text and the decision result.
[0081] Furthermore, regarding the third stage: enabling the configuration parameters of the first text processing sub-model, the second text processing sub-model, the first large language sub-model, and the second large language sub-model; with all configuration parameters of the first text processing sub-model, the second text processing sub-model, the first large language sub-model, and the second large language sub-model all enabled, the large language model is trained based on multiple training samples. Enabling all parameters refers to adjusting the model parameters of the large language model. The purpose of the training in the third stage is to learn the relationship between the dialogue text, the label, and the judgment result.
[0082] In some embodiments, the first text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the first large language sub-model is the Qwen model; the second text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the second large language sub-model is the Baichuan model.
[0083] See Figure 3 , Figure 3 This is a schematic diagram of the large language model structure provided in an embodiment of this application. The input dialogue text, the first category label, and the determination result of whether the first category label is a correct label for the dialogue text are included. Specifically, Input = "The following is a dialogue between customer service and a customer. Please determine whether the dialogue content contains label information. The dialogue content is as follows:"<conversat ion> The tag information is as follows:<Labe l> The output is as follows <answer>".in, <conversation>、<Labe l>、 <answer>These are placeholders, where "conversation" is replaced with the dialogue text, "Label" is replaced with the first category label, and "answer" is replaced with the judgment result. The training data and test data are constructed according to the above format, for example, constructing 100,000 training data entries and 10,000 test data entries.
[0084] in, Figure 3 The left side of the image shows the first text processing sub-model, which consists of a multi-head attention mechanism layer, a residual connection and normalization layer (Add&Norn), a feed-forward layer, and another residual connection and normalization layer (Add&Norn) connected sequentially. Dialogue content is converted into tokens and input to the multi-head attention mechanism layer. This layer performs self-supervised computation on the data, dividing the input into multiple sub-semantic spaces, allowing each head to independently focus on different information dimensions, thereby capturing richer semantic features and outputting a feature vector. The tokens are then input to the residual connection and normalization layer. Here, the tokens and the feature vector output by the multi-head attention mechanism layer are added and normalized, resulting in an accumulated and normalized feature vector. The accumulated and normalized feature vector is then processed... The input is fed to the feedforward layer, a mature operator primarily composed of gate activation functions. These functions enhance the nonlinear characteristics of the input feature vector, outputting a nonlinear feature vector. This output is then fed to the residual connection and normalization layer, which performs addition and normalization operations on the accumulated and normalized feature vector and the nonlinear feature vector, outputting the accumulated and normalized feature vector. The first text processing sub-model comprises four layers: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and another residual connection and normalization layer. The output of the residual connection and normalization layer is again fed to the multi-head attention mechanism layer for the same operation, ultimately yielding the accumulated and normalized feature vector. The large language model also includes a first embedding layer, which inputs the final accumulated and normalized feature vector. The embedding layer primarily transforms discrete data into continuous numerical vectors that the model can process, outputting the feature vector corresponding to the dialogue text.
[0085] in, Figure 3 The middle section represents the first major language sub-model, the Qwen model. The transformation of the first classification label is built into the Qwen model, requiring no additional transformation. The Qwen model takes the first classification label as input and primarily learns the seft-attention from the input content, outputting a feature vector learned by the Qwen model. The major language model also includes a position-embedding layer, which is an offline positional encoding vector that can be obtained directly without input data. Its vector dimension is the same as the vector dimension output by the Qwen model, so the two can be directly added together, resulting in the feature vector enhanced by positional encoding. Furthermore, the major language model includes a second embedding layer, which takes the positional-encoded feature vector as input and outputs the feature vector corresponding to the first classification label.
[0086] in, Figure 3 The right side shows the second text processing sub-model, whose structure is similar to the first text processing sub-model. The second text processing sub-model includes a multi-head attention mechanism layer, a residual connection and normalization layer (Add&Norn), a feedforward layer, and another residual connection and normalization layer (Add&Norn) connected sequentially. After being converted into tokens, the second text processing sub-model inputs them to the multi-head attention mechanism layer. This layer performs self-supervised computation on the data, dividing the input into multiple sub-semantic spaces, where each head can independently focus on different information dimensions, thereby capturing richer semantic features and outputting a feature vector. The tokens are then input to the residual connection and normalization layer, where addition and normalization operations are performed on the tokens and feature vectors, outputting a cumulative and normalized feature vector. This cumulative and normalized feature vector is then input to the feedforward layer. The first layer, the feedforward layer, is a mature operator, primarily using gate activation functions to enhance the nonlinear characteristics of the input feature vector. The resulting nonlinear feature vector is then fed into the residual connection and normalization layer. This layer performs addition and normalization operations on the accumulated and normalized feature vector and the nonlinear feature vector, outputting the accumulated and normalized feature vector. The second text processing sub-model comprises four layers: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and another residual connection and normalization layer. The output of the residual connection and normalization layer is again fed into the multi-head attention mechanism layer for the same operation, ultimately yielding the accumulated and normalized feature vector. The large language model also includes a third embedding layer. This third embedding layer inputs the final accumulated and normalized feature vector, transforming discrete data into continuous numerical vectors that the model can process, and outputting the feature vector corresponding to the judgment result.
[0087] Furthermore, the feature vectors corresponding to the dialogue text, the first classification label, and the judgment result are fused together. The three vectors are then concatenated in sequence, and the output is the concatenated vector.
[0088] The large language model also includes a second large language sub-model, the baichuan model. The concatenated vectors are input into the baichuan model, which consists of 32 multi-head attention layers. The input of each layer is the feature vector of the upper layer, and the output is the feature vector calculated by sef-attention.
[0089] The loss function is SFT-Loss, which is the standard softmax-Loss, and the formula is as follows:
[0090]
[0091] Where w is the network weight, b is the network bias parameter, and x is the network weight. T For network input.
[0092] This formula reveals the relationship between the parameter wk and the loss l, allowing us to adjust the parameters of the large language model using the chain rule. The closer the value is to the true value, the smaller the loss function; conversely, the further away it is, the larger the loss function. The optimization process involves continuously increasing the probability value closest to the true value, thereby decreasing the loss function.
[0093] Step S203: Obtain multiple inference samples. Each inference sample includes inference text and a second category label, which is one of multiple preset category labels.
[0094] In this embodiment, multiple inference samples are obtained, namely the test samples mentioned above. Each inference sample includes inference text and a second category label, which is one of multiple preset category labels.
[0095] Step S204: Input the inference sample into the target classification model to obtain the first preset parameters corresponding to the first text processing sub-model and the second preset parameters corresponding to the first large language sub-model.
[0096] In this embodiment, the inference sample is input into the target classification model to obtain the first preset parameters corresponding to the first text processing sub-model and the second preset parameters corresponding to the first large language sub-model. The first preset parameters include K parameters and V parameters, and the second preset parameters also include K parameters and V parameters. The QKV parameters are core concepts in the Attention Mechanism, representing Query, Key, and Value, respectively. Key: The key vector K is a representation of each element in the input sequence, used for comparison with the query vector Q. In the attention mechanism, the K vector is typically generated by another part of the model (such as the encoder). Value: The value vector V is also a representation of the input sequence, but unlike the K vector, the V vector contains specific information about the input sequence. In the attention mechanism, the V vector is also generated by the encoder.
[0097] Step S205: Save the first preset parameter and the second preset parameter. The first preset parameter is used to configure the parameters of the first text processing sub-model when the inference sample includes inference text. The second preset parameter is used to configure the parameters of the first large language sub-model when the inference sample includes the first classification label.
[0098] In this embodiment, a first preset parameter and a second preset parameter are saved. The K parameter and V parameter in the first preset parameter are used to configure the parameters of the first text processing sub-model when the inference sample includes inference text. The K parameter and V parameter in the second preset parameter are used to configure the parameters of the first large language sub-model when the inference sample includes the first classification label. By saving the relevant parameters, the inference efficiency can be accelerated during inference, effectively saving time and meeting the actual production needs.
[0099] Figure 4 This is a flowchart of a dialogue processing method provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S401 to S405, wherein:
[0100] S401, Obtain the dialogue text to be processed.
[0101] In this embodiment, the dialogue content to be processed is obtained and converted into dialogue text. It should be noted that the dialogue content is obtained with the customer's consent.
[0102] S402, based on the dialogue text and multiple classification labels, obtain multiple texts to be classified.
[0103] In this embodiment, multiple texts to be classified are obtained based on the dialogue text and multiple classification tags, and each text to be classified includes the dialogue text and a classification tag.
[0104] In some embodiments, step S402 includes:
[0105] For each category tag, perform the following processing: obtain a preset template, which includes a first placeholder and a second placeholder; replace the first placeholder with dialogue text and replace the second placeholder with the category tag to obtain the text to be categorized.
[0106] In this embodiment, a preset template is obtained for each category tag. This preset module includes a first placeholder and a second placeholder. The first placeholder is replaced with dialogue text, and the second placeholder is replaced with the category tag. The preset module also includes a third placeholder, which is: The output result is as follows <answer>.
[0107] S403, each text to be classified is input into the target classification model to obtain the label result corresponding to each text to be classified. The target classification model is obtained based on the above classification model training method.
[0108] In this embodiment, each text to be classified is input into the target classification model, which is obtained through the classification model training method described above. The target classification model outputs the label result corresponding to each text to be classified, and the label result is used to replace the content in the third placeholder.
[0109] S404, determine the target classification label for the dialogue content based on the label results corresponding to each text to be classified.
[0110] In this embodiment, the target classification label of the dialogue content is determined based on the label results corresponding to each text to be classified. One dialogue content may correspond to multiple classification labels, and the target classification label of the dialogue content is determined based on the multiple label results.
[0111] In some embodiments, step S404 includes:
[0112] The label results corresponding to each text to be classified are identified to obtain the label results containing the classification labels; the classification labels mapped to the label results containing the classification labels are obtained, and the mapped classification labels are used as the target classification labels.
[0113] In one application scenario, see Figure 5 Multiple category tags include: shipping and receiving process, order inquiry, complaints and suggestions, fee inquiry, and express delivery tracking. Based on the dialogue text and these category tags, multiple texts to be classified are obtained. Each text to be classified is input into the target classification model to obtain the corresponding tag result. The tag result for each text to be classified is then identified, resulting in a tag result that includes the category tags. See [link to relevant documentation]. Figure 5 The system retrieves the category tags mapped to the tag results containing category tags. Specifically, the mapped category tags are "shipping process" and "fee consultation," indicating that the conversation between the user and the customer is about shipping process and fee consultation. Therefore, "shipping process" and "fee consultation" are used as the target category tags for the conversation content.
[0114] S405, store the correspondence between the dialogue content and the target category label.
[0115] In this embodiment, the correspondence between dialogue content and target category tags is stored to facilitate the classification and management of dialogue content. See [link to relevant documentation]. Figure 5 The system stores the correspondence between the dialogue content and the collection and delivery process and fee consultation, so as to classify and manage the dialogue content and improve the service of collection and delivery process and fee consultation based on the dialogue content related to the collection and delivery process and fee consultation.
[0116] In this embodiment, a target classification model is used to classify dialogue content. This model is suitable for classifying massive amounts of data. Compared with existing technologies, it can improve processing efficiency and classification accuracy, so as to facilitate the subsequent classification and management of dialogue content. This allows the large model to complete the classification of all audio within a limited timeframe.
[0117] The following provides an example of the classification model training method provided in the embodiments of this application.
[0118] Step 1, Task Definition: Match each user's voice (i.e., the dialogue text above) with each category tag (i.e., the first category tag above), and determine whether the user's voice contains the content defined by the tag. The task definition is as follows: Figure 6 As shown, the determination of whether a label is included is made manually (i.e., the result of determining whether the label is the correct label for the dialogue text mentioned above).
[0119] Step 2: Prepare the training dataset. The data preparation format is as follows:
[0120] Input = "The following is a conversation between customer service and a customer. Please determine whether the conversation contains tag information. The conversation content is as follows:"<conversat ion> The tag information is as follows:<Labe l> Your output is as follows <answer>".in,<conversat ion> ,<Labe l> , <answer>These are placeholders; fill them with the actual text. You need to prepare 100,000 training data entries and 10,000 test data entries in the format shown above.
[0121] Step 3: Construct the large language model network structure and train the large language model:
[0122] Regarding network structure: See [link to large language model network structure] Figure 3 The Large Language Model (LLM) comprises: a first text processing sub-model, a second text processing sub-model, a first large language sub-model, and a second large language sub-model. The first text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and another residual connection and normalization layer; the first large language sub-model is the Qwen model, which can be Qwen2-0.5B. The second text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and another residual connection and normalization layer; the second large language sub-model is the Baichuan model, which can be Baichuan2-7B.
[0123] Training for large language models:
[0124] 1) Extract training data and train the Qwen2-0.5B model with all parameters based on the pretraining technique. The goal is to enable the model to understand the relationship between classification labels and the knowledge within the classification labels.
[0125] 2) Extract training data, fix the parameters of Qwen2-0.5B and baichuan2-7B, and train the encoding parameters of the first text processing sub-model and the second text processing sub-model. The purpose is to enable the model to learn the relationship between dialogue content and answer (i.e., the result of the preceding text).
[0126] 3) Extract training data, fully learn all parameters, and fine-tune the parameters of baichuan2-7B through fine-tuning techniques. The purpose is to learn the relationship between dialogue, classification labels, and answers.
[0127] Step 4: Use the trained large language model for reasoning:
[0128] After training is completed according to the above steps, a well-trained large language model is obtained, and then the next step of inference is performed. For example, if N*M inferences need to be completed within 24 hours, where N is 200,000 sound data points and M is 1,000 tags, traditional inference models are far from achieving this goal. Therefore, a "fixed prefix" inference acceleration scheme is designed to improve the inference speed. The specific steps are as follows:
[0129] 1) The format of Input is shown in step 2 above.<conversat ion> Replace with the dialogue text used for reasoning. <label>The model replaces the classification labels that need to be verified in sequence, and generates ③ (the result) based on the content of ① (the dialogue text) and ② (the classification labels).
[0130] 2) Since the tokens in ① do not change when polling to verify the tags, the corresponding K and V parameters are cached first (i.e., the first preset parameters are saved above) so that they can be assigned to other rounds for use, which saves a lot of computation time during inference.
[0131] 3) in different<conversat ion> In the context of different dialogue texts, the classification labels in ② are consistent. After the first round of ② calculation is completed, the corresponding K and V parameters can also be cached (i.e., the second preset parameters are saved as mentioned above) and assigned to other dialogue reasoning. Actual calculations show that this greatly improves the reasoning speed.
[0132] Based on schemes 2) and 3), the current reasoning is sufficient to meet actual production needs.
[0133] Training a large language model using label embedding improves its recognition capabilities. Input is the prompt given to the large language model; a fixed-prefix prompt construction method reduces computation of identical tokens, thus accelerating the inference process.
[0134] Please see Figure 7 This application embodiment also provides a classification model training apparatus that can implement the above-described classification model training method. The apparatus includes: a first acquisition module 701 and a training module 702, wherein:
[0135] The first acquisition module 701 is used to acquire multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label for the dialogue text. The first classification label is one of multiple preset classification labels. The training module 702 is used to train the large language model using the multiple training samples to obtain the target classification model.
[0136] In some embodiments, the training module 702 is further configured to: train the first text processing sub-model based on multiple training samples when the configuration parameters of the first large language sub-model are enabled; and disable the configuration parameters of the first large language sub-model after training is completed, wherein enabling the configuration parameters indicates that the model parameters of the first large language sub-model are allowed to be adjusted; train the first text processing sub-model and the second text processing sub-model based on multiple training samples when the configuration parameters of both the first text processing sub-model and the second text processing sub-model are enabled; and disable the configuration parameters of both the first text processing sub-model and the second text processing sub-model after training is completed, wherein enabling the configuration parameters indicates that the model parameters of both the first text processing sub-model and the second text processing sub-model are allowed to be adjusted; and train the large language model based on multiple training samples when the configuration parameters of the first text processing sub-model, the second text processing sub-model, the first large language sub-model, and the second large language sub-model are all enabled to obtain a target classification model.
[0137] In some embodiments, the first acquisition module 701 is further configured to acquire multiple inference samples, each inference sample including inference text and a second classification label, the second classification label being one of multiple preset classification labels. The training module 702 is further configured to input the inference samples into the target classification model to obtain first preset parameters corresponding to the first text processing sub-model and second preset parameters corresponding to the first large language sub-model; save the first preset parameters and the second preset parameters, the first preset parameters being used to configure the parameters of the first text processing sub-model when the inference samples include inference text, and the second preset parameters being used to configure the parameters of the first large language sub-model when the inference samples include the first classification label.
[0138] The specific implementation of this classification model training device is basically the same as the specific implementation of the classification model training method described above, and will not be repeated here.
[0139] Please see Figure 8 This application also provides a dialogue processing apparatus that can implement the above-described dialogue processing method. The apparatus includes: a second acquisition module 801, a processing module 802, a determination module 803, and a storage module 804, wherein:
[0140] The second acquisition module 801 is used to acquire the dialogue text to be processed. The processing module 802 is used to obtain multiple texts to be classified based on the dialogue text and multiple classification labels. The processing module 802 is also used to input each text to be classified into a target classification model to obtain the label result corresponding to each text to be classified. The target classification model is obtained based on the above-mentioned classification model training method. The determination module 803 is used to determine the target classification label for the dialogue content based on the label result corresponding to each text to be classified. The storage module 804 is used to store the correspondence between the dialogue content and the target classification label.
[0141] The specific implementation of this dialogue processing device is basically the same as the specific embodiment of the dialogue processing method described above, and will not be repeated here.
[0142] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described classification model training method or dialogue processing method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0143] Please see Figure 9 , Figure 9 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. The electronic device includes:
[0144] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0145] The memory 902 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the classification model training method or dialogue processing method of the embodiments of this application.
[0146] The input / output interface 903 is used to implement information input and output;
[0147] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0148] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);
[0149] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0150] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described classification model training method or dialogue processing method.
[0151] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0152] The classification model training method, dialogue processing method, apparatus, device, and medium provided in this application embodiment obtain a target classification model by training a large language model. The target classification model can classify dialogue content and is suitable for classifying massive amounts of data. Compared with the prior art, it can improve processing efficiency and classification accuracy.
[0153] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0154] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0155] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0156] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0157] The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0158] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0159] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0160] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0161] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0162] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0163] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.< / label> < / answer> < / answer> < / answer> < / answer> < / conversation> < / answer>
Claims
1. A classification model training method, characterized in that, The method includes: Multiple training samples are obtained, each training sample including dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label of the dialogue text, wherein the first classification label is one of multiple preset classification labels; The target classification model is obtained by training the large language model using multiple training samples.
2. The method of claim 1, wherein, The large language model includes: a first text processing sub-model, a second text processing sub-model, a first large language sub-model, and a second large language sub-model; the first text processing sub-model is used to learn using the dialogue text; the second text processing sub-model is used to learn using the judgment result; the first large language sub-model is used to learn using the first classification label; the second large language sub-model is used to learn the relationship between the dialogue text, the first classification label, and the judgment result; The step of training a large language model using multiple training samples to obtain a target classification model includes: With the configuration parameters of the first large language sub-model enabled, the first text processing sub-model is trained based on multiple training samples, and the configuration parameters of the first large language sub-model are disabled after training ends. The configuration parameters being enabled indicates that the model parameters of the first large language sub-model can be adjusted. With the configuration parameters of both the first text processing sub-model and the second text processing sub-model enabled, the first text processing sub-model and the second text processing sub-model are trained based on multiple training samples. After training ends, the configuration parameters of the first text processing sub-model and the second text processing sub-model are disabled. The enabled configuration parameters indicate that the model parameters of the first text processing sub-model and the second text processing sub-model can be adjusted. With the configuration parameters of the first text processing sub-model, the second text processing sub-model, the first large language sub-model, and the second large language sub-model all enabled, the large language model is trained based on multiple training samples to obtain the target classification model.
3. The method of claim 2, wherein, The first text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the first large language sub-model is the Qwen model; the second text processing sub-model includes: a multi-head attention mechanism layer, a residual connection and normalization layer, a feedforward layer, and a residual connection and normalization layer; the second large language sub-model is the Baichuan model.
4. The method of claim 2, wherein, After training the large language model using multiple training samples to obtain the target classification model, the method further includes: Multiple inference samples are obtained, each inference sample including inference text and a second classification label, the second classification label being one of multiple preset classification labels; The inference sample is input into the target classification model to obtain the first preset parameters corresponding to the first text processing sub-model and the second preset parameters corresponding to the first large language sub-model. Save the first preset parameter and the second preset parameter. The first preset parameter is used to configure the parameters of the first text processing sub-model when the inference sample includes the inference text. The second preset parameter is used to configure the parameters of the first large language sub-model when the inference sample includes the first classification label.
5. A dialog processing method characterized by, The method includes: Get the dialogue text to be processed; Based on the dialogue text and multiple classification tags, multiple texts to be classified are obtained; Each text to be classified is input into the target classification model to obtain the label result corresponding to each text to be classified. The target classification model is obtained based on the classification model training method described in any one of claims 1 to 4. Based on the label results corresponding to each of the texts to be classified, determine the target classification label for the dialogue content; The correspondence between the dialogue content and the target category label is stored.
6. The method of claim 5, wherein, The process of obtaining multiple texts to be classified based on the dialogue text and multiple classification tags includes: For each of the aforementioned category labels, the following processing is performed: Obtain a preset template, the preset template including: a first placeholder and a second placeholder; The first placeholder is replaced with the dialogue text, and the second placeholder is replaced with the category label to obtain the text to be categorized.
7. The method of claim 5, wherein, The step of determining the target classification label for the dialogue content based on the label results corresponding to each of the texts to be classified includes: The label results corresponding to each of the texts to be classified are identified to obtain the label results containing the classification labels; Obtain the category label mapped from the label result containing the category label, and use the mapped category label as the target category label.
8. A classification model training apparatus characterized by comprising: The device includes: The first acquisition module is used to acquire multiple training samples. Each training sample includes dialogue text, a first classification label, and a determination result of whether the first classification label is the correct label of the dialogue text. The first classification label is one of multiple preset classification labels. The training module is used to train the large language model using multiple training samples to obtain the target classification model.
9. A dialog processing apparatus characterized by comprising: The device includes: The second acquisition module is used to acquire the dialogue text to be processed. The processing module is used to obtain multiple texts to be classified based on the dialogue text and multiple classification tags respectively; The processing module is further configured to input each of the texts to be classified into the target classification model to obtain the label result corresponding to each of the texts to be classified, wherein the target classification model is obtained based on the classification model training method described in any one of claims 1 to 4; The determination module is used to determine the target classification label of the dialogue content based on the label results corresponding to each of the texts to be classified; The storage module is used to store the correspondence between the dialogue content and the target category tags.
10. An electronic device, comprising: The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the classification model training method according to any one of claims 1 to 4, or the dialogue processing method according to any one of claims 5 to 7.
11. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: receiving a request for a resource from a client; determining whether the client is authorized to access the resource; and if the client is authorized to access the resource, providing the resource to the client. When the computer program is executed by the processor, it implements the classification model training method according to any one of claims 1 to 4, or the dialogue processing method according to any one of claims 5 to 7.