Model training method, intention recognition method and related equipment
By constructing labeled training data and multi-task fine-tuning datasets to optimize large language models, the problems of insufficient long text processing and generalization capabilities of classification models in the field of intelligent customer service were solved, achieving more efficient user intent recognition.
Patent Information
- Application Number
- CN202510363315.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-09-23
AI Technical Summary
Existing classification models in the field of intelligent customer service are unable to effectively cope with long text conversation scenarios, and their generalization capabilities are insufficient, resulting in inaccurate user intent recognition.
By constructing labeled training data, using supervised training methods to train the intent retrieval model, and optimizing the large language model based on a multi-task fine-tuning dataset, the model's intent recognition capability is improved.
The model's intent recognition accuracy and generalization capabilities in long text processing and new domain dialogue scenarios have been improved, and its performance in the field of intelligent customer service has been enhanced.
Smart Images

Figure CN120687819A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and specifically to a model training method, an intent recognition method, and related equipment. Background Art
[0002] In the field of intelligent customer service, identifying user intent is a key step in improving service efficiency and quality. Related technologies typically perform intent identification tasks based on classification models. However, due to the limited performance of classification models in processing long texts, they struggle to effectively handle long conversations. Furthermore, classification models are often limited by their scale, resulting in insufficient generalization capabilities, making it difficult to accurately identify user intent in conversations in new domains. Summary of the Invention
[0003] The present application provides a model training method, an intent recognition method and related equipment to solve the problem in related technologies that the model performing intent recognition tasks has difficulty in accurately identifying user intent due to its difficulty in coping with long text scenarios and insufficient generalization ability.
[0004] A first aspect of an embodiment of the present application provides a model training method, comprising: training a first initial model based on a first training data set to obtain a first model, wherein the first training data set includes interaction data; based on the first model, obtaining a first intent list corresponding to the interaction data; based on the first intent list, constructing a second training data set; and training a second initial model based on the second training data set to obtain a second model.
[0005] The second aspect of an embodiment of the present application provides an intent recognition method, which includes: receiving interaction data input by a user; using an intent recognition model to obtain the user intent corresponding to the interaction data, wherein the intent recognition model is obtained by executing the model training method provided in the first aspect.
[0006] A third aspect of an embodiment of the present application provides a chip system, which is applied to a computer device. The chip system includes one or more processors, which are used to call computer instructions to enable the computer device to input training data into the chip system and execute the steps in the method provided in the first or second aspect above.
[0007] A fourth aspect of an embodiment of the present application provides a model training device, which includes: a training unit for training a first initial model based on a first training data set to obtain a first model, wherein the first training data set includes interaction data; an acquisition unit for acquiring a first intent list corresponding to the interaction data based on the first model; a construction unit for constructing a second training data set based on the first intent list; and the training unit is also used to train a second initial model based on the second training data set to obtain a second model.
[0008] A fifth aspect of an embodiment of the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method provided in the first or second aspect above when executing the computer program.
[0009] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method provided in the first or second aspect are implemented.
[0010] A seventh aspect of the embodiments of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps in the method provided in the first or second aspect above.
[0011] In the model training method of this embodiment, a first model can be obtained based on a first training data set, wherein the first training data set includes interaction data; based on the first model, a first intent list corresponding to the interaction data is obtained; based on the first intent list, a second training data set is constructed; and based on the second training data set, a second model is obtained. The embodiment of the present application constructs labeled training data, trains an intent retrieval model through a supervised training method, and constructs a multi-task fine-tuning data set based on the intent list retrieved by the intent retrieval model. The lightweight model of the large language model is optimized based on the multi-task fine-tuning data set, so that the optimized model can have the intent recognition capability of the large language model, thereby improving the accuracy and generalization capability of the model's intent recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0013] Figure 1This is a flowchart of a model training method provided by an embodiment of the present application;
[0014] Figure 2 This is a flowchart of a method for obtaining a first model based on a first training data set provided by an embodiment of the present application;
[0015] Figure 3 This is a flowchart of a method for obtaining a first intent list provided in an embodiment of the present application;
[0016] Figure 4 is a flowchart of a method for constructing a first data set provided by an embodiment of the present application;
[0017] Figure 5 is a flowchart of a method for optimizing a second initial model based on a first data set provided in an embodiment of the present application;
[0018] Figure 6 is a flowchart of a method for optimizing a second initial model based on a second data set provided in an embodiment of the present application;
[0019] Figure 7 is a flowchart of a method for optimizing a second initial model based on a third data set provided in an embodiment of the present application;
[0020] Figure 8 This is a functional module diagram of a model training device provided in one embodiment of the present application;
[0021] Figure 9 It is a structural diagram of a computer device for implementing a model training method provided in one embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other in the absence of conflict.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing embodiments in some embodiments only and are not intended to limit this application.
[0024] It should be noted that in this application, "at least one" means one or more, and "more than one" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0025] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete manner. The following embodiments and features in the embodiments may be combined with each other unless there is a conflict.
[0026] In some embodiments, in the field of intelligent customer service, accurately identifying user intent is crucial for improving service efficiency and quality. In related technologies, intent identification is often considered the task of classifying user input interaction data. In one example, related technologies often use classification models (such as BERT) to classify interaction data and determine user intent based on the classification results.
[0027] For example, when performing intent recognition, the classification model first encodes the interaction data, extracting semantic features and contextual information. The classification model then uses this feature information to classify the interaction data. The classification result represents the user's likely intent. For example, if the user inputs a consultation about product purchase, the classification model might classify it as a "purchase consultation" intent; if the user asks about product usage, it might be classified as a "help" intent.
[0028] However, classification models have multiple limitations in intent recognition tasks within the intelligent customer service sector, making it difficult for them to accurately identify user intent. For example, the BERT model's computational mechanism is complex and its ability to process long texts is limited. In the intelligent customer service sector, conversations between users and customer service representatives can be numerous, and the corresponding interaction data can be quite long, making existing classification models ineffective in long-text conversation scenarios. Furthermore, BERT models are typically trained using unsupervised methods, making it difficult to accurately identify user intent. Furthermore, BERT models are often limited by their scale, resulting in insufficient generalization capabilities and difficulty accurately identifying user intent in conversational scenarios within new domains.
[0029] In order to solve the above problems, the embodiments of the present application provide a model training method, which can construct labeled training data, train the intent retrieval model through a supervised training method, and construct a multi-task fine-tuning dataset based on the intent list retrieved by the intent retrieval model. The lightweight model of the large language model is optimized based on the multi-task fine-tuning dataset, so that the optimized model can have the long text processing ability and intent recognition ability of the large language model, thereby improving the accuracy and generalization ability of the model's intent recognition.
[0030] refer to Figure 1 As shown, it is a flowchart of the model training method provided by one embodiment of the present application. The model training method can be executed by a computer device, specifically by a processor of the computer device. The computer device may include a terminal device or a server. Among them, the terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook, etc.; the server can be an independent server, or a server cluster composed of multiple servers, or a cloud server capable of cloud computing. The model training method specifically includes the following steps. According to different needs, the order of the steps in the flowchart can be changed, and some can be omitted.
[0031] S101: Train a first initial model based on a first training data set to obtain a first model.
[0032] In some embodiments, the first training data set includes interaction data, which can be obtained based on historical conversation data between the user and customer service, wherein the historical conversation data includes but is not limited to voice data, text data, and image data.
[0033] In one example, obtaining interaction data based on historical conversation data between a user and customer service may include: (a) obtaining desensitized historical conversation data, converting historical conversation data that is not text data into text data. For example, using a speech recognition algorithm to recognize speech data to obtain corresponding text data, using an image description algorithm to obtain text data corresponding to image data, etc. (b) preprocessing the text data. For example, preprocessing includes but is not limited to data cleaning: identifying and filtering typos, repeated words, and preset sensitive words (such as swear words) in the text data. (c) determining target text data in the preprocessed text data and using the target text data as interaction data. For example, in the field of intelligent customer service, intelligent customer service typically provides users with an identity verification statement. Users authenticate themselves based on the identity verification statement, and intelligent customer service provides corresponding services to authenticated users. In this case, users may have already uttered words indicating their intentions before the intelligent customer service provides the identity verification statement. Therefore, preprocessed text data with a time node before the identity verification statement can be used as the target text data.
[0034] Based on the above embodiment, interaction data is obtained by collecting various forms of historical conversation data between users and customer service representatives. Non-text data is converted into text format and preprocessed to eliminate typos, repeated words, and sensitive content. This not only improves the accuracy and readability of the interaction data, but also lays a data foundation for subsequent data analysis, model training, and other steps. In the intelligent customer service scenario, user speech before identity verification is selected as interaction data. This allows for accurate capture of user intent based on interaction data, providing high-quality training data for model training.
[0035] In some embodiments, the first training dataset also includes a first intent corresponding to each interaction data. The first intent can be considered the true intent label of the interaction data, accurately reflecting the user's intended intent in the conversation, such as querying for specific information, requesting a service, or expressing a need. The first intent corresponding to the interaction data can be obtained by receiving user annotations.
[0036] Based on the above embodiment, the first training dataset includes the interaction data and the first intent corresponding to the interaction data. Therefore, the first training dataset can be used to implement supervised training of the model in subsequent processes, allowing the model to learn the first intent corresponding to the interaction data, thereby improving the training efficiency and training effect of the model.
[0037] In some embodiments, the distribution probabilities of different first intents in the first training dataset vary significantly, potentially leading to overfitting during model training. To address this issue, the interaction data can be balanced based on the distribution probabilities of the first intents corresponding to the interaction data. An updated first training dataset is constructed based on the balanced interaction data and the corresponding first intents, and the updated first training dataset is used as the dataset for subsequent model training.
[0038] In one example, based on the distribution probability of the first intention corresponding to the interaction data, the interaction data is balanced, which may include: if the distribution probability of any first intention is greater than a first threshold, the interaction data corresponding to the any first intention is downsampled. The distribution probability of the first intent can be determined based on the ratio of the number of interaction data corresponding to the first intention to the number of all interaction data. The first threshold can be set based on actual needs, for example, 0.1, 0.2, etc., and this application does not impose specific restrictions on this. Downsampling can be achieved by randomly deleting part of the interaction data corresponding to any first intention, so as to achieve the purpose of reducing the proportion of any first intention in the training data set.
[0039] In another example, based on the distribution probability of the first intent corresponding to the interaction data, the interaction data is balanced, which may include: if the distribution probability of any first intent is less than a second threshold, the interaction data corresponding to the any first intent is enhanced. The second threshold can be set based on actual needs, for example, 0.001, 0.01, etc., and this application does not impose specific restrictions on this. Data enhancement can be achieved by performing synonym replacement, sentence transformation, etc. on the interaction data corresponding to any first intent to generate new interaction data related to the any first intent, thereby increasing the number of samples of the interaction data corresponding to the any first intent.
[0040] Based on the above embodiments, the interaction data is downsampled or data enhanced according to the distribution probability of the first intention corresponding to the interaction data to adjust the proportion of different first intentions in the training data set, so as to construct a more balanced and updated first training data set, and provide more comprehensive and accurate data support for subsequent model training.
[0041] In some embodiments, the first initial model can be fine-tuned based on the first training data set, and the fine-tuned vector model can be used as the first model, so that the first model can have representation capabilities in both general fields and intelligent customer service fields. The first initial model can be an open source vector model in a general field, such as an embedding model. The representation capability represents the model's ability to understand and represent interaction data, that is, the model can convert interaction data into effective representation vectors (or feature vectors) and perform subsequent analysis and processing (such as intent retrieval) based on these feature vectors.
[0042] In one example, training the first initial model based on the first training data set to obtain the first model may include: extracting features from the interaction data through the first initial model to obtain its first representation vector, and calculating the first similarity between the vector and the second representation vector of the first intention, as well as the second similarity between the first representation vectors of any two interaction data. Based on these two types of similarities, a first loss value and a second loss value are determined respectively, and finally the first initial model is trained in combination with the two loss values to obtain the first model. In one example, the method for obtaining the first model based on the first training data set can refer to Figure 2 Flowchart shown.
[0043] Based on the above examples, a general-purpose open-source embedding model was fine-tuned to adapt it to data from the intelligent customer service domain, resulting in a first model. During the fine-tuning process, the model optimized the loss value by calculating the similarity between interaction data and the first intent, as well as the similarity between different interaction data, thereby improving its representation capabilities in the intelligent customer service domain.
[0044] S102: Based on the first model, obtain a first intent list corresponding to the interaction data.
[0045] In some embodiments, the first model can be used as an intent retrieval model to retrieve a preset number of intents that are most relevant to the input interaction data from a preset intent library as retrieval intents.
[0046] In one example, the first model can be used to obtain a representation vector of the input interaction data, and then the representation vector and the representation vector of each intent in the preset intent library can be used to calculate the similarity (for example, cosine similarity). Among them, the representation vector of each intent in the preset intent library can be pre-set or obtained based on the first model, and this application does not impose specific restrictions on this. The greater the similarity, the stronger the correlation between the interaction data and the corresponding intent, and the more likely the intent is the first intent corresponding to the interaction data.
[0047] Arrange the intents in the preset intent library in descending order of similarity, and select a preset number of intents that are ranked first in the sequence as search intents. The preset number can be set according to actual needs, for example, the preset number can be 5, 10, etc., and this application does not impose specific restrictions on this.
[0048] In one example, the interaction data can be exemplarily represented as: "Hello, I just made a call and I need to settle all three transactions today. Yes, I have deposited the money now, so please deduct it, okay?" The first intention corresponding to the interaction data can be exemplarily represented as: "Inquire about the rules and procedures for early settlement." According to the order of similarity from large to small, the search intents retrieved by the first model may include: "Inquire about the rules and procedures for early settlement," "Process the repayment of funds by deduction," "Inquire about how to repay quickly," and "Inquire about the reasons for early settlement failure." Among them, the preset intent library includes the first intent corresponding to the interaction data, and the search intent retrieved by the first model with the highest similarity to the interaction intent is the first intent.
[0049] In some embodiments, a first intent list corresponding to the interaction data can be constructed based on the search intent corresponding to the interaction data. For example, a preset number of search intents are arranged in descending order of similarity corresponding to the search intents to obtain the first intent list. The first intent list includes the first intent of the interaction data. In one example, the method for obtaining the first intent list can refer to Figure 3 Flowchart shown.
[0050] Based on the above embodiment, the intent of the interaction data is retrieved through the first model, and a first intent list sorted by similarity and containing the first intent is constructed. The first intent list can provide a data basis for subsequent model training.
[0051] S103: Construct a second training data set based on the first intent list.
[0052] In some embodiments, the second training data set includes at least one of the first data set, the second data set, and the third data set. The data in the first data set can be expressed as <interaction data, the first intention of the interaction data, and the reason for judgment>, where the reason for judgment represents an explanatory text for indicating why the first intention is the accurate intention corresponding to the interaction data. In this way, the first data set can be used in subsequent processes to train the model's reasoning ability to identify the first intention from similar intentions, as well as its ability to distinguish easily confused intentions. In one example, the method for constructing the second data set can refer to Figure 4 The process shown.
[0053] The data in the second dataset can be represented as <interaction data and intent, and a relevance label for the interaction data and intent>, where the relevance label for the interaction data and the first intent is "relevant," and the relevance label for the interaction intent and intents other than the first intent is "unrelevant." This second dataset can be used in subsequent processes to train a model to determine whether a particular intent is relevant to the interaction data. In one example, the method for constructing the second dataset can be found in the following description.
[0054] The data in the third dataset can be represented as <a first intent list corresponding to the interaction data, and a second intent list corresponding to the first intent list>, where the second intent list represents the intent list obtained by randomly shuffling the order of the search intents in the first intent list. This third dataset can then be used in subsequent processes to train the model to restore the second intent list to the first intent list, strengthening the model's ability to discern the correlations between different intents and interaction data. In one example, the method for constructing the third dataset can be found in the subsequent description.
[0055] Based on the above embodiments, the first data set, the second data set and the third data set respectively provide comprehensive and targeted data support for the training model from three aspects: predicting the first intention and explaining the reason, judging the correlation between the intention and the interaction data, and restoring the order of the intent list, thereby effectively improving the accuracy and performance of the model in processing interaction data and intent recognition tasks.
[0056] S104: Train a second initial model based on the second training data set to obtain a second model.
[0057] In some embodiments, a lightweight model corresponding to a preset model can be selected as a second initial model, the second initial model can be trained based on a second training data set, and the trained second initial model can be used as the second model.
[0058] For example, the preset model is the open source Qwen2 110B, and the second initial model can be the Qwen2 7B model. The number of parameters, model size or data capacity of the second initial model are much smaller than the preset model. Although the second initial model is a small model compared to the preset model, in fact, the second initial model is also a large language model. The second initial model has similar language understanding capabilities (such as long text conversation parsing capabilities) and thought chain deduction capabilities as the preset model. The description of the application reasoning process of the second initial model will be omitted in the following embodiments. The second initial model may only have weak performance in specific fields (such as intelligent customer service fields), so it is only necessary to use training data from specific fields to fine-tune or optimize the second initial model. Using the second model obtained by training the second initial model in actual applications can reduce the cost of use.
[0059] In some embodiments, multiple data sets in the second training data set can be used as multiple instruction data, and the second initial model can be fine-tuned for multi-tasks in a specific field based on the task prompts in the instruction data to obtain a second model.
[0060] In one example, the first task of multi-task fine-tuning includes: training a second initial model based on the first data set so that the second initial model learns the first intent of generating interaction data and the reason for generating the first intent, for example, referring to Figure 5 The process shown in the figure is as follows. Setting the second initial model to identify the first intent from multiple similar intents can enhance the second initial model's reasoning ability to identify the correct intent from similar intents and its ability to distinguish easily confused intents.
[0061] In one example, the second task of multi-task fine-tuning includes: training a second initial model based on a second data set so that the second initial model learns to determine the correlation between the interaction data and the retrieval intent, for example, referring to Figure 6 Task 2 explicitly introduces the intent relevance label for the second initial model, which can strengthen the model's understanding of whether the intent is related to the interaction data.
[0062] In one example, task three of multi-task fine-tuning includes: training a second initial model based on a third data set so that the second initial model learns to restore the second intent list to the corresponding first intent list, for example, referring to Figure 7 Task 3 explicitly introduces ranking information of multiple similar intents into the second initial model, which can strengthen the model's understanding of the correlation between intent and interaction data.
[0063] In some embodiments, the more fine-tuning tasks are performed on the second initial model, the better the performance of the resulting second model. Therefore, in one example, all of the above tasks can be performed on the second initial model, and the second initial model that has undergone fine-tuning for all of the above tasks can be used as the second model.
[0064] Based on the above embodiment, a second model is obtained by performing multi-task fine-tuning on the selected second initial model based on the second training data set. While maintaining the core capabilities of the large language model (such as long text recognition and understanding capabilities), the second model is optimized for tasks in specific fields (such as intent recognition tasks in the field of intelligent customer service), reducing the cost of use and effectively improving the performance on specific tasks, thereby improving the generalization ability of the model.
[0065] The model training method provided in the embodiment of the present application can construct labeled training data, train the intent retrieval model through a supervised training method, and construct a multi-task fine-tuning dataset based on the intent list retrieved by the intent retrieval model. The lightweight model of the large language model is optimized based on the multi-task fine-tuning dataset, so that the optimized model can have the intent recognition capability of the large language model, thereby improving the accuracy and generalization ability of the model's intent recognition.
[0066] In some embodiments, as Figure 2 As shown, the method for obtaining a first model based on a first training data set may include the following steps. According to different requirements, the order of the steps in the flowchart may be changed, and some may be omitted.
[0067] S201 , extracting features from interaction data using a first initial model to obtain a first representation vector of the interaction data.
[0068] In some embodiments, the first initial model includes a pre-trained deep learning model that can extract features from the interaction data, thereby converting the interaction data (e.g., text data) into a dense vector representation in a high-dimensional embedding space, i.e., a first representation vector. For example, the first initial model converts the text data into a word vector sequence, and then performs feature encoding on the word vector sequence through a neural network layer (e.g., a convolutional layer, a recurrent layer, or a Transformer layer, etc.), to obtain a feature vector of the interaction data as the first representation vector.
[0069] S202 : Determine a first similarity between the first representation vector and the second representation vector of the first intention, and determine a first loss value of the first initial model according to the first similarity.
[0070] In some embodiments, the second representation vector of the first intent can be a predefined representation vector, representing a fixed vector for different first intents. In another example, the second representation vector of the first intent can be obtained using the first initial model, similar to the method for obtaining the first representation vector of the interaction intent, and will not be repeated here.
[0071] In one example, the first similarity can be obtained by calculating the cosine similarity, Euclidean distance, or other metric between the first representation vector and the second representation vector. The first loss value can be calculated based on the first similarity. For example, the formula used can be exemplarily expressed as:
[0072]
[0073] Among them, L infoNCE Represents the first loss function, L infoNCE The value of represents the first loss value. q represents the first representation vector of the interaction data, k + The second representation vector of the first intention (positive sample) corresponding to the interaction data q, k + It can be defined as the positive sample corresponding to the interaction data q, then the positive sample pair (q, k + ). k i The second representation vector representing the first intent of other samples in the same batch, k i It can be defined as the negative sample corresponding to the interaction data q, then the negative sample pair (q, k i ). τ represents a preset hyperparameter, such as a temperature parameter, which is used to control the scaling of the similarity score. n represents the number of samples (such as interaction data) in each batch when training the first initial model. In a batch, in addition to the positive sample pairs (q, k + ), there are n-1 negative sample pairs (q, k i ).
[0074] exp(qk + / τ) represents the positive sample pair (q, k + ) is the similarity score between them, namely the first similarity. After the exponential function transformation, the positive sample pair (q, k + ), the higher the similarity between them, the greater the first similarity. Represents the sum of the similarity scores between all sample pairs (including positive sample pairs and negative sample pairs), As the denominator, it ensures that the first loss function is a normalized probability distribution, that is, the sum of the similarity scores of all sample pairs is 1. The logarithmic function (-log) is used to convert the similarity score to the first loss value. Since the logarithmic function is monotonically increasing, the higher the similarity score, the smaller the first loss value. For example, the greater the first similarity between positive sample pairs, the smaller the similarity between negative sample pairs.
[0075] Based on the above embodiment, in the intelligent customer service system, the first loss value can be used to train the first initial model, enabling the first initial model to learn an effective representation of the interaction data. By maximizing the first similarity between positive sample pairs and minimizing the similarity between negative sample pairs, the first initial model can better distinguish the user intent corresponding to the interaction data, thereby improving the accuracy and efficiency of intent retrieval.
[0076] S203: Determine a second similarity between the interaction data based on the first representation vector, and determine a second loss value of the first initial model according to the second similarity.
[0077] In some embodiments, a second similarity can be obtained by calculating the similarity (such as cosine similarity) between the first representation vectors of different interaction data. A second loss value can be calculated based on the second similarity. The second loss value can be a regularization term used to penalize interaction data pairs that are semantically similar but have a large distance between the representation vectors, or to reward interaction data pairs that are semantically different but have a certain distance between the representation vectors. The penalty can represent a reduction in the corresponding weight, and the reward can represent an increase in the corresponding weight. The second loss value can enable the first representation vector learned by the model to reflect the semantic similarity between the interaction data, which helps the model learn more discriminative and robust representations.
[0078] In one example, the formula used to calculate the second loss value can be exemplarily expressed as:
[0079]
[0080] Among them, L cosent Represents the second loss function, L cosent The value of represents the second loss value. i, j, k, l represent the numbers of four samples (such as interaction data), u i ,u j ,u k ,u l Represents the first representation vector of the sample with the corresponding number. cos() represents the cosine similarity function, and sim() represents the predefined similarity label between two samples. For example, sim(i,j) represents the similarity label between sample i and sample j, which is used to indicate the similarity between the two samples. λ represents a preset hyperparameter used to control the scaling of the exponential term in the second loss function.
[0081] ∑ sim(i,j)>sim(k,l) Indicates the sum of all two samples (i, j) and (k, l) that satisfy the condition sim(i, j)>sim(k, l). Used to amplify the impact of the similarity difference between the first representation vectors on the second loss value, when (cos(u k ,u l ) is greater than cos(u i ,u j ), the exponential term will increase, thereby increasing the second loss value. Among them, cos(u k ,u l ) represents the second similarity of two samples (k, l) with relatively small similarity; cos(u i ,u j ) represents the second similarity between two samples (i, j) with a high relative similarity. This way, the second loss function prioritizes sample pairs that are considered dissimilar based on their similarity labels but are actually more similar in the embedding space. The logarithmic function log(1+…) is used to convert the exponential term into a smooth loss value. This ensures that even with very large exponential terms, the second loss value does not grow indefinitely.
[0082] Based on the above embodiment, in the intelligent customer service system, the second loss value can be used to train the first initial model, enabling the first initial model to learn an effective embedding space. In this embedding space, similar interaction data and intents are mapped to close locations, while dissimilar ones are mapped to distant locations, helping the model to more accurately understand user intent.
[0083] S204: Train a first initial model based on the first loss value and the second loss value to obtain a first model.
[0084] In some embodiments, the model parameters can be iteratively updated by taking into account the first loss value and the second loss value at the same time through the back-propagation algorithm, thereby achieving iterative training of the first initial model. The training goal can be to find an optimal model parameter configuration so that the first initial model can learn a reasonable representation of the interaction data while predicting the intent, that is, the first representation vector can accurately reflect the first intent and maintain a reasonable distance relationship in the semantic space. After multiple iterative trainings, the first initial model that meets the training goal can be used as the first model. The first model can provide effective intent recognition and data processing capabilities in the field of intelligent customer service. For example, it can be used for intent retrieval of interaction data.
[0085] Based on the above embodiments, the model accurately understands user intent by learning the intent representation capabilities of interaction data. By simultaneously considering the degree of match between the interaction data and the first intent (the first loss value) and the similarity relationship between different interaction data (the second loss value), the model can learn more accurate and robust intent representations, thereby providing effective intent recognition and data processing capabilities in the intelligent customer service system.
[0086] In some embodiments, as Figure 3 As shown, the method for obtaining the first intention list may include the following steps. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0087] S301 , extracting features from the interaction data using the first model to obtain a third representation vector of the interaction data.
[0088] In some embodiments, the first model represents a first initial model after training. The specific implementation of step S301 can refer to the description in step S201 and will not be repeated here.
[0089] S302: Determine a third similarity between the third characterization vector and the fourth characterization vector.
[0090] In some embodiments, the fourth representation vector represents a representation vector for each second intent in a preset intent library. The fourth representation vector may be a predefined representation vector representing a fixed vector for different intents. For example, the preset intent library may include all possible user intents in the field of intelligent customer service, as well as a predefined fourth representation vector for each intent. In another example, the first model may be used to obtain the fourth representation vector for an intent in the preset intent library.
[0091] In some embodiments, the third similarity may be obtained by calculating the cosine similarity, Euclidean distance, or other metrics between the third characterization vector and the fourth characterization vector, which is not specifically limited in this application.
[0092] S303: Select a preset number of retrieval intents from the second intent according to the third similarity, and obtain a first intent list according to the preset number of retrieval intents.
[0093] In some embodiments, the intents in the preset intent library can be arranged in descending order based on the third similarity, and a preset number of intents ranked first in the sequence can be selected as retrieval intents. In another example, intents corresponding to third similarities greater than a preset similarity threshold can also be selected as retrieval intents, where the similarity threshold can be set according to actual needs, for example, 0.5, etc., and this application does not impose specific restrictions on this.
[0094] In some embodiments, a preset number of search intents are arranged in descending order according to the similarities corresponding to the search intents to obtain a first intent list.
[0095] Based on the above embodiment, the intent of the interaction data is retrieved through the first model, and a first intent list sorted by similarity and containing the first intent is constructed. The first intent list can provide a data basis for subsequent model training.
[0096] The following embodiments will respectively introduce methods for constructing the first data set, the second data set, and the third data set.
[0097] In some embodiments, as Figure 4 As shown, the method for constructing the first data set may include the following steps. According to different requirements, the order of the steps in the flowchart may be changed, and some steps may be omitted.
[0098] S401 , based on the retrieval intent in the first intent list corresponding to the interaction data, select the first retrieval intent with the highest similarity to the interaction data through a preset model and obtain the reason for selecting the first retrieval intent.
[0099] In some embodiments, the preset model includes a large language model, such as the open-source Qwen2 110B model. The greater the number of parameters in the preset model, the larger the model size, and the corresponding greater data capacity, the stronger the preset model's command-following and chain-of-thought deduction capabilities, and the stronger its language comprehension and application performance in general domains.
[0100] In this way, there is no need to train or fine-tune the preset model. The preset model can be used directly to select the retrieval intent with the highest similarity to the interaction data from the first intent column based on the input data as the first retrieval intent, and output the reason for selecting the first retrieval intent. The preset model can implement the above application process based on its internal structure and parameters based on a deep learning algorithm, which will not be described in detail in this application. In one example, the selection reason output by the preset model can be used as the accurate reason corresponding to the first intent.
[0101] In one example, the input data of the preset model can be represented as follows: [{"role":"system","content":You are a customer service quality inspector at a financial company's hotline. Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent. After analyzing the reasons, please be sure to output in the following format:' <answer>:intent'}, {"role":"user","content":User question:{query}\nReference information:{context}\nPlease analyze:}].
[0102] Among them, {query}\ represents the interaction data (i.e., user questions), and {context} represents the first intent list. System represents the preset prompt information, i.e., "You are a quality inspector of a financial company's hotline customer service. Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent." The prompt information is used to instruct the preset model to perform the corresponding task and output the corresponding result. For example, let the preset model play the role of "quality inspector of a financial company's hotline customer service" and the task is: "{Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent. After analyzing the reasons, please be sure to output in the following format:' <answer>:intention'}".
[0103] The preset model can output results based on prompt information, interaction data, and the first intent list, for example: "{"User question":"{query}","reason":"{reason}\n\n <answer>:{pred_label}","first intent":"{true_label}"}". Where {query} represents the interaction data, {pred_label} represents the first search intent selected from the first intent column with the highest similarity to the interaction data, {reason} represents the reason for selecting the first search intent, and {true_label} represents the first intent.
[0104] Based on the above embodiment, by using the large language model as the preset model, it is possible to select the first search intent with the highest similarity to the interaction data based on the interaction data and the search intents in the first intent list, and output the reasons for the selection in detail. In this way, the reasoning ability of the large language model can be used to obtain the reasons for the selection of each intent, making the intent selected by the model more explainable.
[0105] S402: If the first search intent is different from the first intent, reselect the second search intent with the highest similarity to the interaction data through the preset model until the second search intent is the same as the first intent.
[0106] In some embodiments, the preset model has not been trained or adjusted, and the first search intent selected may not be the first intent. If the first search intent selected is not the first intent, the preset model can be used to reselect the search intent with the highest similarity to the interaction data as the second search intent, until the second search intent is the same as the first intent corresponding to the interaction data.
[0107] For example, if the input data containing the prompt information is re-entered into the preset model, the preset model will reselect the second search intent with the highest similarity to the interaction data. Alternatively, if the prompt information is updated to "reselect the most relevant intent from the reference information," the preset model will reselect the second search intent with the highest similarity to the interaction data.
[0108] S403: Obtain a second training data set based on the interaction data, the first intention, and the corresponding selection reason.
[0109] In some embodiments, the retrieval intent selected by the preset model is the first intent corresponding to the interaction data, and the selection reason includes the reason that the first intent derived based on the thought chain is an accurate intention relative to the interaction data, and the reason is more explainable.
[0110] Continuing with the above example, the format of the data in the second training dataset (e.g., the first dataset) can be exemplarily represented as follows: {"system":"You are a customer service quality inspector at a financial company's hotline. Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent. After analyzing the reasons, please be sure to output in the following format:' <answer>:intent'", "input": "User question: {query}. Reference information: {context}", "output": {reason}, so the correct intent is {true_label}}. Among them, input represents input data and output represents output data.
[0111] The first dataset also includes the first prompt information, for example, "You are a customer service hotline quality inspector at a financial company. Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent. After analyzing the reasons, please be sure to output in the following format:' <answer>: Intent'. The first prompt information is used as a task prompt in the subsequent training of the second initial model, so that the second initial model can be fine-tuned using the first data set based on the task prompt. For example, please refer to the corresponding description in step S104.
[0112] In some embodiments, when constructing a second training dataset, such as a second dataset, the second dataset can be constructed based on the interaction data, the search intents in the first intent list, and the relevance tags corresponding to the search intents, wherein the relevance tags are used to indicate whether the search intent is relevant to the interaction data.
[0113] In one example, the field of intelligent customer service requires uniqueness of user intent recognition results, so the correlation label of the interaction data and the first intent can be set as related, and the correlation label of the interaction intent and intents other than the first intent can be set as unrelated.
[0114] Continuing with the above example, the format of the data in the second dataset constructed based on relevance tags can be exemplarily represented as follows: {"system":"You are a customer service quality inspector for a consumer finance company's hotline. Please determine whether the user's question is relevant to the reference information. Directly output 'relevant' or 'not relevant', and do not output other information","input":"User question:{query}\nReference information:{search intent in the first intent list}","output":"relevant"}.
[0115] The second dataset also includes a second prompt, such as "You are a customer service quality inspector for a consumer finance company's hotline. Please determine whether the user's question is relevant to the reference information. Directly output 'relevant' or 'not relevant', and do not output other information." This second prompt serves as a task prompt during the subsequent training of the second initial model. Based on this task prompt, the second dataset can be used to fine-tune the instructions of the second initial model. For example, see the corresponding description in step S104.
[0116] In some embodiments, when constructing a second training dataset, such as a third dataset, the multiple search intents in the first intent list can be reordered, for example, by randomly shuffling the order of the multiple search intents in the first intent list to obtain a second intent list. The third dataset is constructed based on the interaction data, the first search list corresponding to the interaction data, and the second intent list.
[0117] In one example, in the first intent list, multiple search intents are arranged in descending order of relevance to the interaction data. After randomly shuffling the order of the multiple search intents in the first intent list, the relevance of the multiple search intents in the second intent list to the interaction data is randomly arranged.
[0118] Continuing with the above example, the format of the data in the third dataset constructed based on the second intent list can be exemplarily represented as follows: {"system":"You are a customer service hotline quality inspector at a consumer finance company. Based on the user's question, sort the intents in the reference information from most to least relevant to the user's question. Please directly output the sorted list of intents from most to least relevant.","output":"{first intent list}","input":"User question:{query}\nReference information:{second intent list}"}}
[0119] The third dataset also includes a third prompt, such as "You are a customer service quality inspector at a consumer finance company's hotline. Based on the user's question, sort the intents in the reference information from highest to lowest relevance to the user's question. Please directly output a list of intents sorted by relevance." This third prompt serves as a task prompt during the subsequent training of the second initial model. Based on this task prompt, the third dataset can be used to fine-tune the instructions of the second initial model. For example, see the corresponding description in step S104.
[0120] The following embodiments will respectively introduce methods for training a second initial model based on the first data set, the second data set, and the third data set to obtain a second model.
[0121] In some embodiments, as Figure 5 As shown, the method for training the second initial model based on the first data set may include the following steps. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0122] S501: Determine a third intent corresponding to the interaction data and a reason corresponding to the third intent through a second initial model.
[0123] Continuing with the above example, you can input the data from the first dataset into the second initial model. For example, the input data is {"system":"You are a customer service quality inspector at a financial company's hotline. Based on the user's question, select the most relevant intent from the reference information. Please describe the reasons and decision-making process step by step, and then output the identified intent. After analyzing the reasons, please be sure to output in the following format:' <answer>:intent'","input":"User question: {query}. Reference information: {context}","output":{reason}, so the correct intent is {true_label}}. The second initial model determines the third intent corresponding to the interaction data based on the first prompt information in the input data, and generates a reason corresponding to the determined third intent. For example, the second initial model selects an intent from the first intent list as the determined third intent, and generates explanatory text corresponding to the third intent as the reason, explaining why the third intent was selected.
[0124] S502: Determine a third loss value of the second initial model based on the similarity between the third intention and the first intention, and the similarity between the reason for generating the second initial model and the reason for selecting the model.
[0125] In some embodiments, the third intent may be an intent selected in the first intent list, and the similarity between the third intent and the first intent (hereinafter referred to as the fourth similarity) can be determined based on the similarity (e.g., cosine similarity) between the representation vector of the third intent (e.g., the fourth representation vector) and the representation vector of the first intent (e.g., the second representation vector).
[0126] In some embodiments, a natural language processing technique may be used to determine the similarity (hereinafter referred to as the fifth similarity) between the reason for generating the second initial model and the selected reason (e.g., the accurate reason). In one example, the natural language processing technique may be a text similarity algorithm, such as BLEU, ROUGE, or the like.
[0127] In some embodiments, the third loss value can be determined based on the weighted sum of the fourth and fifth similarities. For example, the third loss value can be inversely proportional to the weighted sum. Thus, the greater the fourth and fifth similarities, the greater the weighted sum, the smaller the third loss value, and the higher the overall performance of the second initial model in both intent recognition and cause generation.
[0128] S503: Train a second initial model based on the third loss value to obtain a second model.
[0129] In some embodiments, the parameters of the second initial model can be adjusted based on the third loss value using a backpropagation algorithm or other optimization techniques (e.g., gradient descent, Adam Su algorithm, etc.). The adjustment goal is to minimize the third loss value so that the second initial model can more accurately identify intent and generate reasonable reasons when faced with similar interaction data in the future.
[0130] For example, the parameter adjustment process may include adjusting connection weights, bias terms, learning rates, etc. to improve the generalization ability and accuracy of the model. After each adjustment, an updated third loss value of the second initial model may be determined until, after multiple iterative training, the third loss value of the second initial model converges or reaches a preset number of iterations, thereby obtaining a second model.
[0131] Based on the above embodiment, the first data set includes the reasons corresponding to the first intention obtained by the preset model (a very large language model) through the thought chain deduction of the interaction data. During the training of the second initial model (a relatively small large language model), the second initial model can learn the thought chain deduction ability of the preset model. In this way, the knowledge reasoning ability or style of the preset model can be transferred to the second initial model in the form of reasons in the first data set to a certain extent, thereby utilizing the thought chain reasoning ability of the very large language model to guide the relatively small model to solve complex tasks.
[0132] In some embodiments, as Figure 6 As shown, the method for training a second initial model based on a second data set may include the following steps. According to different requirements, the order of the steps in the flowchart may be changed, and some may be omitted.
[0133] S601: Determine the correlation result between the search intention and the interaction data through the second initial model.
[0134] Continuing with the above example, the data from the second dataset can be fed into the second initial model. For example, the input data is {"system":"You are a customer service quality inspector at a consumer finance company's hotline. Based on the user's question, please determine whether it is relevant to the reference information. Directly output 'relevant' or 'not relevant', and do not output other information.","input":"User question:{query}\nReference information:{search intent from the first intent list}","output":"relevant"}}. The second initial model determines the relevance between the search intent and the interaction data based on the second prompt information in the input data. For example, the relevance result may be 'relevant' or 'not relevant'.
[0135] S602: Determine the accuracy of the correlation result based on the correlation label, and determine a fourth loss value of the second initial model according to the accuracy.
[0136] In some embodiments, if the correlation result is consistent with the correlation label, the correlation result is an accurate result. Conversely, if the correlation result is inconsistent with the correlation label, the correlation result is an inaccurate result. The accuracy of the correlation result can be determined based on the ratio of the number of accurate results to the total number of predictions.
[0137] In some embodiments, the fourth loss value can be made inversely proportional to the accuracy rate. The greater the accuracy rate, the smaller the fourth loss value, and the higher the performance of the second initial model in determining the correlation result between the retrieval intent and the interaction data.
[0138] In other embodiments, the fourth loss value may be determined based on other evaluation indicators, such as recall rate, F1 score, etc. Alternatively, the fourth loss value may be determined using a cross entropy loss value, a mean square error loss value, etc. In this way, the fourth loss value may be used to indicate the degree of difference between the prediction result of the second initial model and the actual label, and this application does not impose any specific restrictions on this.
[0139] S603: Train a second initial model based on the fourth loss value to obtain a second model.
[0140] In some embodiments, the specific implementation of step S603 is similar to that of step S503. It is only necessary to replace the third loss value in step S503 with the fourth loss value, and the description will not be repeated.
[0141] Based on the above embodiment, a second initial model can be trained based on the second data set. The model can learn more effectively and reduce the difference between the predicted results and the actual labels, so that the obtained second model can accurately judge the correlation between the retrieval intent and the interaction data, thereby showing higher accuracy and robustness in intent recognition tasks in specific fields.
[0142] In some embodiments, as Figure 7 As shown, the method for training the second initial model based on the third data set may include the following steps. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0143] S701, determine the correlation between the retrieval intent in the second intent list and the corresponding interaction data through the second initial model, arrange the retrieval intent in the second intent list in descending order based on the correlation, and obtain an updated intent list.
[0144] Continuing with the above example, the data from the third dataset can be fed into the second initial model. For example, the input data is {"system":"You are a customer service quality inspector at a consumer finance company's hotline. Based on the user's question, sort the intents in the reference information from highest to lowest relevance to the user's question. Please output a sorted list of intents in descending order of relevance.","output":"{first intent list}","input":"User question:{query}\nReference information:{second intent list}"}." The second initial model determines the relevance of each intent in the second intent list to the interaction data based on the third prompt information in the input data, and sorts the intents in descending order of relevance to obtain an updated intent list.
[0145] S702 : Determine a fifth loss value of the second initial model based on the similarity between the first intent list and the updated intent list.
[0146] In some embodiments, the similarity between the first intent list and the updated intent list (hereinafter referred to as the sixth similarity) can be evaluated based on factors such as the ranking of the intent lists, and the fifth loss value is calculated based on the sixth similarity. The fifth loss value reflects the performance gap of the second initial model in the ranking task. For example, the sixth similarity can be determined by calculating the relative position difference of each intent in the first intent list and the updated intent list. The fifth similarity can be made inversely proportional to the sixth similarity. The greater the sixth similarity, the smaller the fifth similarity, and the higher the performance of the second initial model in determining the order of correlation between the retrieval intent and the interaction data.
[0147] S703: Train a second initial model based on the fifth loss value to obtain a second model.
[0148] In some embodiments, the specific implementation of step S703 is similar to that of step S503. It is only necessary to replace the third loss value in step S503 with the fifth loss value, and the description will not be repeated.
[0149] Based on the above embodiment, the performance of the second initial model in the sorting task can be effectively improved, so that the obtained second model can more accurately determine the relevance of the intention based on the user question.
[0150] In some other embodiments, the second training dataset also includes a fourth dataset. The data in the fourth dataset can be expressed as <interaction data, first intent of the interaction data>. In this way, the fourth dataset can be used in subsequent processes to train the model to directly output the corresponding first intent based on the interaction data.
[0151] Continuing with the above example, the format of the data in the fourth dataset can be exemplarily represented as: {"system":"You are a quality inspector of a hotline customer service of a financial company. Based on the user's question, select the most relevant intent from the reference information.", "input":"User question: {query}. Reference information: {context}", "output":{true_label}}. Among them, the fourth dataset also includes a fourth prompt information, such as "You are a quality inspector of a hotline customer service of a financial company. Based on the user's question, select the most relevant intent from the reference information." The fourth prompt information is used as a task prompt in the subsequent training of the second initial model, so that the fourth dataset can be used to fine-tune the instructions of the second initial model based on the task prompt. For example, the second initial model can be optimized based on the fourth dataset, so that the second initial model learns to generate the first intent corresponding to the interaction data, which is similar to the relevant supervised optimization algorithm and will not be described in detail.
[0152] In some embodiments, the second model trained in the above embodiment has the language understanding ability and thought chain deduction ability of the preset model, and can be used to perform intention recognition tasks in specific fields (such as the field of intelligent customer service). Therefore, the second model can be used as an intention recognition model to receive the interaction data input by the user, and use the intention recognition model to obtain the user intention corresponding to the interaction data. Among them, the accuracy of the user intention output by the intention recognition model is relatively high, which can be used to guide subsequent processes.
[0153] In one example, based on the user intent identified by the intent recognition model, the intelligent customer service can execute the standard operating procedure (SOP) of the corresponding business configuration, which has formulated the corresponding processing procedures and response strategies. For example, the user can be guided step by step through voice broadcast or voice guidance to solve the problem corresponding to the user's intent, ensuring that the intelligent customer service can provide the user with a satisfactory solution in the shortest time. For example, if the user's intention is to repay the loan in advance, the SOP process will be configured to check the user's information status and broadcast relevant information. If the user meets the conditions for early repayment, the intelligent customer service will send the user a repayment link. If the user does not meet the conditions for early repayment, the intelligent customer service will also inform the user of the reason.
[0154] The user identification method provided in the embodiments of the present application can directly obtain the intent corresponding to user interaction data based on the intent recognition model. The intent recognition model is derived based on the aforementioned model training method and can therefore be applied to recognize long text data. The intent recognition accuracy in specific domains is high, and the obtained user intent can be used to accurately trigger subsequent processes, thereby improving the user's service experience.
[0155] In another example, the first model can be used as an intent retrieval model to obtain a representation vector of the interaction data input by the user. A list of intents can be retrieved based on the representation vector. The intent recognition model can then be used to select the intent most relevant to the interaction data from the list of intents as the recognized user intent.
[0156] Based on the above embodiment, the intent retrieval model's ability to extract accurate representation vectors of interaction data can be utilized to obtain precise representation vectors of the interaction data. Based on the precise representation vectors, a list of intents is retrieved from a preset intent library. This list of intents is used to reduce the difficulty of intent recognition by the intent recognition model, and the most relevant intent is determined from the list. This improves the accuracy of intent recognition based on the coordinated use of the two models.
[0157] like Figure 8 The figure shows a functional module diagram of a model training device provided by an embodiment of the present application. The model training device 8 includes a training unit 81, an acquisition unit 82, and a construction unit 83. The module / unit referred to in this application refers to a type of unit that can be processed by a processor (e.g. Figure 9 A series of computer readable instruction segments are obtained by the processor 1101 shown in FIG. 1 and are capable of completing fixed functions, which are stored in a memory (eg Figure 9 In the memory 1102 shown.
[0158] The training unit 81 is used to train a first initial model based on a first training data set to obtain a first model, wherein the first training data set includes interaction data and a first intent corresponding to the interaction data; the acquisition unit 82 is used to obtain a first intent list corresponding to the interaction data based on the first model; the construction unit 83 is used to construct a second training data set based on the first intent list; the training unit 81 is also used to train a second initial model based on the second training data set to obtain a second model.
[0159] In one embodiment, the training unit 81 is specifically used to: perform feature extraction on the interaction data through the first initial model to obtain a first representation vector of the interaction data; determine a first similarity between the first representation vector and the second representation vector of the first intention, and determine a first loss value of the first initial model based on the first similarity; determine a second similarity between the interaction data based on the first representation vector, and determine a second loss value of the first initial model based on the second similarity; train the first initial model based on the first loss value and the second loss value to obtain the first model.
[0160] In one embodiment, the acquisition unit 82 is specifically used to: perform feature extraction on the interaction data through the first model to obtain a third representation vector of the interaction data; determine a third similarity between the third representation vector and a fourth representation vector, wherein the fourth representation vector represents a representation vector of each second intention in a preset intention library; select a preset number of retrieval intentions from the second intentions according to the third similarity; and obtain the first intention list according to the preset number of retrieval intentions.
[0161] In one embodiment, the first training data set constructed by the construction unit 83 also includes the first intention corresponding to the interaction data. The construction unit 83 is specifically used to: based on the retrieval intention in the first intention list corresponding to the interaction data, select the first retrieval intention with the highest similarity to the interaction data through a preset model and obtain the reason for selecting the first retrieval intention; if the first retrieval intention is different from the first intention, reselect the second retrieval intention with the highest similarity to the interaction data through the preset model until the second retrieval intention is the same as the first intention; based on the interaction data, the first intention and the corresponding selection reason, obtain the second training data set.
[0162] In one embodiment, the training unit 81 is further specifically used to: determine the third intention corresponding to the interaction data through the second initial model, and generate the reason corresponding to the third intention; determine the third loss value of the second initial model based on the similarity between the third intention and the first intention, and the similarity between the reason generated by the second initial model and the selection reason; train the second initial model based on the third loss value to obtain the second model.
[0163] In one embodiment, the construction unit 83 is further specifically used to obtain the second training data set based on the interaction data, the retrieval intent in the first intent list, and the relevance label corresponding to the retrieval intent, wherein the relevance label is used to indicate whether the retrieval intent is related to the interaction data.
[0164] In one embodiment, the training unit 81 is further specifically used to: determine the correlation result between the retrieval intention and the interaction data through the second initial model; determine the accuracy of the correlation result based on the correlation label, and determine the fourth loss value of the second initial model according to the accuracy; train the second initial model based on the fourth loss value to obtain the second model.
[0165] In one embodiment, the construction unit 83 is further specifically used to: reorder multiple retrieval intentions in the first intention list to obtain a second intention list; and obtain the second training data set based on the interaction data, the first retrieval list corresponding to the interaction data, and the second intention list.
[0166] In one embodiment, the training unit 81 is further specifically used to: determine the correlation between the retrieval intent in the second intent list and the corresponding interaction data through the second initial model, arrange the retrieval intent in the second intent list in descending order based on the correlation, and obtain an updated intent list; determine the fifth loss value of the second initial model based on the similarity between the first intent list and the updated intent list; train the second initial model based on the fifth loss value to obtain the second model.
[0167] In multiple embodiments of the present application, it is possible to construct labeled training data, train an intent retrieval model through a supervised training method, and construct a multi-task fine-tuning dataset based on the intent list retrieved by the intent retrieval model. The lightweight model of the large language model is optimized based on the multi-task fine-tuning dataset, so that the optimized model can have the intent recognition capability of the large language model, thereby improving the accuracy and generalization ability of the model's intent recognition.
[0168] Figure 9 Schematic diagram of the structure of a computer device for implementing the model training method provided in the embodiment of the present application. Figure 9 The computer device 90 shown is used to perform Figure 1-Figure 7 The method shown.
[0169] The computer device 90 includes at least one processor 1101 , a memory 1102 , and at least one network interface 1103 .
[0170] The processor 1101 is, for example, a general-purpose central processing unit (CPU), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the solution of the present application. For example, the processor 1101 includes an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0171] The memory 1102 is, for example, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. Optionally, the memory 1102 exists independently and is connected to the processor 1101 via an internal connection 1104. Alternatively, the memory 1102 and the processor 1101 are optionally integrated together.
[0172] The network interface 1103 uses any transceiver-like device for communicating with other devices or communication networks. For example, the network interface 1103 includes at least one of a wired network interface and a wireless network interface. For example, the wired network interface is an Ethernet interface. For example, the Ethernet interface is an optical interface, an electrical interface, or a combination thereof. For example, the wireless network interface is a wireless local area network (WLAN) interface, a cellular network interface, or a combination thereof.
[0173] In some embodiments, the processor 1101 includes one or more CPUs, such as Figure 9 CPU0 and CPU1 are shown in the figure.
[0174] In some embodiments, the computer device 90 optionally includes multiple processors, such as Figure 9 1 and 1105. Each of these processors is, for example, a single-CPU or a multi-CPU. A processor herein optionally refers to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0175] In some embodiments, computer device 90 further includes internal connections 1104. Processor 1101, memory 1102, and at least one network interface 1103 are connected via internal connections 1104. Internal connections 1104 include pathways that transmit information between these components. Internal connections 1104 may optionally be a single board or bus. Internal connections 1104 may optionally be divided into an address bus, a data bus, a control bus, and the like.
[0176] In some embodiments, the computer device 90 further includes an input / output interface 1106 . The input / output interface 1106 is connected to the internal connection 1104 .
[0177] Optionally, the processor 1101 implements the method in the above embodiment by reading the program code 910 stored in the memory 1102, or the processor 1101 implements the method in the above embodiment by internally stored program code. In the case where the processor 1101 implements the method in the above embodiment by reading the program code 910 stored in the memory 1102, the memory 1102 stores the program code that implements the method provided in the embodiment of the present application.
[0178] For more details on how the processor 1101 implements the above functions, please refer to the descriptions in the previous method embodiments, which will not be repeated here.
[0179] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer device, the computer device executes the above-mentioned related method steps to implement the method in the above-mentioned embodiment.
[0180] This embodiment further provides a computer program product, including a computer program / instruction. When the computer program product is run on a computer device, the computer device is caused to execute the above-mentioned related steps to implement the methods in the above-mentioned method embodiments.
[0181] This embodiment also provides a chip system, which is applied to a computer device. The chip system includes one or more processors, which are used to call computer instructions to enable the computer device to input a first training data set into the chip system and execute the methods in the above-mentioned method embodiments.
[0182] The chip system can apply the method in the above-mentioned method embodiment to obtain a first model based on a first training data set, construct a second training data set, and perform multi-task fine-tuning on a lightweight model of a large language model based on the second training data set to obtain a second model, and use the second model as an intent recognition model, which significantly improves the computing efficiency and model performance at the hardware level.
[0183] In one example, a classification model needs to be trained as an intent recognition model. Due to the complex calculation mechanism of the classification model and its weak ability to process long texts, a large amount of data and a lot of time are required. Only through unsupervised training can a more accurate classification model for user recognition be obtained.
[0184] In contrast, the chip system, through the aforementioned built-in method, can use a lightweight version of the large language model as the initial model and fine-tune it in a supervised manner using labeled data from a specific domain. This reduces the amount of training data required and improves model training efficiency. Furthermore, the resulting intent recognition model can process longer interaction data and more accurately identify user intent in specific domains.
[0185] In this way, the chip system can significantly reduce the data cost and number of iterations of model training, thereby reducing the waste of chip system resources, lowering the difficulty of model learning, significantly improving computing efficiency at the hardware level, and directly improving the accuracy and generalization ability of the final model.
[0186] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory to enable the chip to execute the methods in the above-mentioned method embodiments.
[0187] Among them, the computer device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0188] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0189] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0190] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0191] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0192] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially 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, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0193] The above is only a specific embodiment of the present application, but the scope of protection of this application is not limited to this. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.< / answer> < / answer> < / answer> < / answer> < / answer> < / answer>
Claims
1. A model training method, characterized in that: The method comprises: Training a first initial model based on a first training data set to obtain a first model, wherein the first training data set includes interaction data; Based on the first model, obtaining a first intent list corresponding to the interaction data; Based on the first intent list, construct a second training data set; A second initial model is trained based on the second training data set to obtain a second model.
2. The method according to claim 1, characterized in that The first training data set also includes a first intent corresponding to the interaction data, and the step of training a first initial model based on the first training data set to obtain a first model includes: Performing feature extraction on the interaction data using the first initial model to obtain a first representation vector of the interaction data; determining a first similarity between the first representation vector and a second representation vector of the first intent, and determining a first loss value of the first initial model based on the first similarity; Determine a second similarity between the interaction data based on the first representation vector, and determine a second loss value of the first initial model according to the second similarity; The first initial model is trained based on the first loss value and the second loss value to obtain the first model.
3. The method according to claim 1, characterized in that The acquiring, based on the first model, a first intent list corresponding to the interaction data includes: Extracting features from the interaction data using the first model to obtain a third representation vector for the interaction data; determining a third similarity between the third representation vector and a fourth representation vector, wherein the fourth representation vector represents a representation vector of each second intent in a preset intent library; selecting a preset number of retrieval intents from the second intents according to the third similarity; The first intent list is obtained according to the preset number of retrieval intents.
4. The method according to claim 1, wherein The first training data set also includes a first intent corresponding to the interaction data, and constructing a second training data set based on the first intent list includes: Based on the search intents in the first intent list corresponding to the interaction data, selecting a first search intent having the highest similarity to the interaction data through a preset model and obtaining a reason for selecting the first search intent; If the first search intent is different from the first intent, reselecting a second search intent having the highest similarity to the interaction data through the preset model until the second search intent is the same as the first intent; The second training data set is obtained based on the interaction data, the first intention and the corresponding selection reason.
5. The method according to claim 4, characterized in that The step of training a second initial model based on the second training data set to obtain a second model comprises: Determining, by using the second initial model, a third intent corresponding to the interaction data and a reason corresponding to generating the third intent; determining a third loss value of the second initial model based on a similarity between the third intention and the first intention, and a similarity between the reason generated by the second initial model and the selection reason; The second initial model is trained based on the third loss value to obtain the second model.
6. The method according to claim 1, characterized in that The constructing a second training data set based on the first intent list includes: The second training data set is obtained based on the interaction data, the retrieval intent in the first intent list, and the relevance label corresponding to the retrieval intent, wherein the relevance label is used to indicate whether the retrieval intent is relevant to the interaction data.
7. The method according to claim 6, characterized in that The step of training a second initial model based on the second training data set to obtain a second model comprises: Determining the correlation result between the search intention and the interaction data by using the second initial model; Determining an accuracy rate of the correlation result based on the correlation label, and determining a fourth loss value of the second initial model according to the accuracy rate; The second initial model is trained based on the fourth loss value to obtain the second model.
8. The method according to claim 1, characterized in that Constructing a second training dataset based on the first intent list includes: Reordering the multiple search intents in the first intent list to obtain a second intent list; The second training data set is obtained according to the interaction data, the first search list corresponding to the interaction data, and the second intention list.
9. The method according to claim 8, characterized in that The step of training a second initial model based on the second training data set to obtain a second model comprises: Determining, using the second initial model, the relevance between the search intents in the second intent list and the corresponding interaction data, and arranging the search intents in the second intent list in descending order of the relevance to obtain an updated intent list; determining a fifth loss value of the second initial model based on a similarity between the first intent list and the updated intent list; The second initial model is trained based on the fifth loss value to obtain the second model.
10. A method for identifying intention, characterized in that: The method comprises: Receive interaction data input by the user; The user intent corresponding to the interaction data is obtained by using an intent recognition model, wherein the intent recognition model is obtained by executing the model training method according to any one of claims 1 to 9.
11. A chip system, characterized in that: The chip system is applied to a computer device, and the chip system includes one or more processors, which are used to call computer instructions to enable the computer device to input a training data set into the chip system and execute the model training method as described in any one of claims 1 to 9, or the intention recognition method as described in claim 10.
12. A computer device, characterized in that: The computer device includes a processor and a memory, and the processor is used to implement the model training method as described in any one of claims 1 to 9, or the intention recognition method as described in claim 10 when executing the computer program stored in the memory.