Text classification model training method, text classification method and related equipment

By downsampling and sample length processing of text classification samples, combined with text coverage threshold, the problem of sample imbalance in text classification model training is solved, and the classification accuracy and recognition ability of the model are improved.

CN118568259APending Publication Date: 2024-08-30CHONGQING CHANGAN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410682586.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing technology, due to sample imbalance during text classification model training, the model training effect is reduced and the classification accuracy is reduced.

Method used

By obtaining multiple text classification sample sets, setting the sample proportion limit range, downsampling the samples to ensure a balanced number of various types of samples, and combining the text coverage threshold and sample length limit parameters to train the model and adjust the model parameters to Improve classification accuracy.

Benefits of technology

It has improved the training effect of the text classification model, improved the model's recognition ability and classification accuracy of different categories of text, and solved the model training problem caused by sample imbalance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568259A
    Figure CN118568259A
Patent Text Reader

Abstract

The invention relates to the technical field of data classification, in particular to a text classification model training method, a text classification method and related equipment. According to the embodiment of the invention, text classification sample sets corresponding to different categories are firstly obtained, then a sample proportion limitation range for limiting the number proportion of training samples in each text classification sample set is obtained, and then the training samples in the text classification sample sets are obtained based on the sample proportion limitation range and the actual number of the training samples in the text classification sample sets. And performing down-sampling processing on each text classification sample set to obtain a target text sample set meeting the limitation of the sample proportion limitation range so as to perform model training. In this way, downsampling is carried out on the initially collected text classification sample set, the sample balancing effect can be achieved, the training effect of the model can be improved, the ability of the model to recognize various classification texts can be balanced, and the classification accuracy when the model is used for text classification subsequently is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data classification, and in particular to a text classification model training method, a text classification method and related equipment. Background Art

[0002] With the development of science and technology, the amount of data that needs to be processed is also increasing. For example, text data can be classified to determine the category to which the text belongs, so that different processing methods can be determined for different texts. With the development of models such as deep learning models and neural network models, classification through models has also received more and more attention. Before using the model to classify text, the model needs to be trained to ensure the accuracy of the classification results.

[0003] In the related art, a large number of text samples for model training are usually collected, and then the model training is performed based on the collected text samples. The problem with the prior art is that in the scenario of sample collection, the number of samples of different categories may be unbalanced, resulting in an unbalanced number of samples of various categories collected for training, which in turn affects the training effect of the model, causing the model to inaccurately identify the classification with a small number of samples, that is, reducing the classification accuracy during the use of the model.

[0004] Therefore, the relevant technology needs to be improved and enhanced. Summary of the invention

[0005] The present application provides a text classification model training method, a text classification method and related equipment to solve the technical problem that the number of samples collected for training in the related technology is unbalanced, which affects the training results of the model and thus reduces the accuracy of classification during the use of the model.

[0006] To achieve the above objectives, this application adopts the following technical solutions:

[0007] A first aspect of an embodiment of the present application provides a text classification model training method, the text classification model training method comprising:

[0008] Acquire multiple text classification sample sets, wherein each of the text classification sample sets includes multiple training samples of the same category;

[0009] Obtaining a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set;

[0010] According to the sample ratio limit range and the number of training samples in each of the text classification sample sets, downsampling is performed on each of the text classification sample sets to obtain multiple target text sample sets;

[0011] The preset model to be trained is trained according to the above target text sample set to obtain a trained text classification model.

[0012] According to the above technical means, the embodiment of the present application first obtains the text classification sample sets corresponding to different categories, and then obtains the sample ratio limit range used to limit the ratio of the number of training samples under each text classification sample set, and then based on the sample ratio limit range and the actual number of training samples in the text classification sample set, each text classification sample set is downsampled to obtain a target text sample set that meets the sample ratio limit range for model training. In this way, downsampling the initially collected text classification sample set can achieve the effect of sample balance, which is conducive to improving the training effect of the model, can balance the model's ability to recognize texts of various categories, and improve the classification accuracy when the model is used for text classification in the future.

[0013] Optionally, in some embodiments of the present application, the step of obtaining a plurality of text classification sample sets includes:

[0014] Acquire multiple training speech samples, and perform speech recognition on each of the training speech samples to obtain multiple training samples;

[0015] The above training samples are clustered to obtain multiple text classification sample sets.

[0016] According to the above technical means, in the embodiment of the present application, training voice samples are directly collected, voice recognition is performed on the training voice samples to obtain corresponding training samples in text form, and clustering is performed to obtain each text classification sample set. In this way, the text classification model obtained by training based on the embodiment of the present application can meet the needs of processing and classifying the text converted from the user's voice. At the same time, clustering the training samples first is conducive to improving the efficiency and effect of subsequent data downsampling.

[0017] Optionally, in some embodiments of the present application, the preset model to be trained is trained according to the target text sample set to obtain a trained text classification model, including:

[0018] Get text coverage threshold;

[0019] Perform sample length distribution statistics on the training samples in the above target text sample set;

[0020] According to the sample length distribution statistics and the text coverage threshold, determine a text length limit parameter that makes the proportion of covered samples in the training samples not less than the text coverage threshold, wherein the covered samples are training samples whose sample length is not greater than the text length limit parameter;

[0021] According to the above target text sample set and the above text length limit parameter, the above model to be trained is trained to obtain a trained text classification model.

[0022] According to the above-mentioned technical means, in the embodiment of the present application, a text length limit parameter that meets the requirements is determined based on the text coverage threshold and the actual sample length distribution statistics in the target text sample set, so that the number of samples that are fully covered when sample processing is performed based on the text length limit parameter can meet the requirements, further improving the model training effect.

[0023] Optionally, in some embodiments of the present application, the training of the model to be trained according to the target text sample set and the text length limit parameter to obtain a trained text classification model includes:

[0024] Input the training samples in the target text sample set into the model to be trained, so as to trigger the model to be trained to segment the training samples, add word units, perform word unit mapping, and perform sample truncation or sample padding based on the text length limit parameter, so as to obtain the training data under each target text sample set;

[0025] The above-mentioned model to be trained is trained according to the training data under each of the above-mentioned target text sample sets to adjust the model parameters of the above-mentioned model to be trained until a trained text classification model is obtained.

[0026] According to the above-mentioned technical means, in an embodiment of the present application, the training sample is first input into the model to be trained for word segmentation, adding word units, word unit mapping, and adjusting the sample length by sample truncation or sample padding, so as to obtain training data that meets the subsequent processing format requirements of the model. Using the training data that meets the subsequent processing format requirements of the model can effectively realize model training and improve the model training effect.

[0027] Optionally, in some embodiments of the present application, the training of the model to be trained according to the training data under each of the target text sample sets to adjust the model parameters of the model to be trained until a trained text classification model is obtained includes:

[0028] Obtain the number of training data corresponding to each of the above target text sample sets;

[0029] Determine the accuracy contribution adjustment coefficient corresponding to each of the target text sample sets according to the number of training data corresponding to each of the target text sample sets, and determine the accuracy calculation function of the to-be-trained model according to the accuracy contribution adjustment coefficient;

[0030] Input the training data under each of the above target text sample sets into the above to-be-trained model to obtain the prediction value corresponding to each of the above training data;

[0031] According to the predicted value and the true value corresponding to the training data, and the target text sample set to which the training data belongs, the accuracy corresponding to the model to be trained is obtained by calculating the accuracy calculation function;

[0032] The model parameters of the model to be trained are adjusted according to the accuracy, and the step of inputting the training data under each of the target text sample sets into the model to be trained is returned to execute until a text classification model that meets the preset training completion conditions is obtained.

[0033] According to the above technical means, in the embodiment of the present application, according to the actual number of training data in the target text sample set corresponding to each classification, the accuracy contribution adjustment coefficient corresponding to the target text sample set corresponding to each classification is determined, thereby adjusting the accuracy calculation function. That is, in the present application, the accuracy calculation function is adjusted based on the actual number of training data in the target text sample set, thereby adjusting the contribution of categories with different numbers of training data when calculating the accuracy, improving the balance of the influence of training samples of different categories during the model training process, and thus improving the model training effect.

[0034] Optionally, in some embodiments of the present application, after the preset model to be trained is trained according to the target text sample set to obtain a trained text classification model, the text classification model training method further includes:

[0035] Obtain the loss and / or accuracy of the above text classification model during training;

[0036] According to the above loss and / or the above accuracy, the fitting condition of the above trained text classification model is judged;

[0037] According to the above fitting judgment results, the model parameters of the above trained text classification model are optimized and adjusted to obtain an optimized text classification model.

[0038] According to the above-mentioned technical means, in an embodiment of the present application, after the text classification model training is completed, the fitting situation is judged based on the loss and / or accuracy during the training process, so as to further fine-tune the model parameters according to the fitting situation judgment result, thereby achieving a text classification model with better classification effect.

[0039] A second aspect of an embodiment of the present application provides a text classification method, the text classification method comprising:

[0040] Get the text to be classified;

[0041] The text to be classified is input into a text classification model to obtain a text classification result output by the text classification model, wherein the text classification model is trained based on any one of the text classification model training methods provided in the first aspect of the embodiment of the present application.

[0042] According to the above technical means, for the text to be classified, the text classification model trained by the text classification model training method provided in the first aspect of the embodiment of the present application is used for classification. During the training process of the text classification model, the influence of unbalanced samples on the model training effect is taken into account, and the samples are processed to ensure the balance of the number of samples, thereby ensuring the classification effect of the trained text classification model. Using the text classification model for text classification is conducive to improving the accuracy of text classification.

[0043] Optionally, in some embodiments of the present application, the above text classification method further includes:

[0044] Determine the target processing model corresponding to the text to be classified according to the text classification result corresponding to the text to be classified;

[0045] The text to be classified is input into the target processing model to determine the operation instruction corresponding to the text to be classified through the target processing model.

[0046] According to the above technical means, for the text to be classified, after the text classification is performed, the target processing model for further processing the text to be classified is determined according to the classification result, so as to determine the corresponding operation instruction according to the target processing model, so as to realize the subsequent operation control based on the text to be classified and meet the actual control needs of the user. On the basis of improving the accuracy of text classification, the accuracy of selecting the corresponding target processing model can be improved, thereby improving the control accuracy and improving the user experience.

[0047] Optionally, in some embodiments of the present application, the above text classification method further includes:

[0048] If the text classification result corresponding to the text to be classified is a preset target category, then obtaining a supplementary text associated with the text to be classified based on an interactive operation, wherein the target category is used to indicate that the text to be classified has no specified implementation object;

[0049] Searching for the longest common subsequence matching the supplementary text from a plurality of preset entity libraries respectively to obtain a target entity in the supplementary text;

[0050] Based on the target entity, an operation instruction corresponding to the text to be classified is determined.

[0051] According to the above technical means, when it is determined according to the text classification results that the text to be classified does not specify an implementation object, the supplementary text associated with the text to be classified is obtained, so as to extract the target entity from the supplementary text based on the preset entity library to determine the operation instruction, which can improve the user experience.

[0052] Optionally, in some embodiments of the present application, before determining the operation instruction corresponding to the text to be classified based on the target entity, the method further includes:

[0053] If the target entity in the supplementary text is not obtained based on the entity library, the supplementary text is input into a preset conditional random field model, and entity recognition is performed through the conditional random field model to obtain the target entity in the supplementary text.

[0054] According to the above technical means, when the target entity is not extracted based on the preset entity library, the target entity is extracted based on the preset conditional random field model, which can further ensure that the corresponding target entity is extracted, thereby further improving the user experience.

[0055] A third aspect of the present application embodiment provides a text classification model training system, the text classification model training system comprising:

[0056] A sample acquisition module, used to acquire multiple text classification sample sets, wherein each of the above text classification sample sets includes multiple training samples of the same category;

[0057] A sample ratio acquisition module is used to obtain a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set;

[0058] A downsampling module is used to perform downsampling processing on each of the above text classification sample sets according to the above sample ratio limit range and the number of training samples in each of the above text classification sample sets, so as to obtain multiple target text sample sets;

[0059] The model training module is used to train the preset model to be trained according to the above target text sample set to obtain a trained text classification model.

[0060] Optionally, in some embodiments of the present application, the sample acquisition module includes:

[0061] A speech recognition unit, used to obtain a plurality of training speech samples, and perform speech recognition on each of the training speech samples to obtain a plurality of training samples;

[0062] The sample clustering unit is used to cluster the above training samples to obtain multiple text classification sample sets.

[0063] Optionally, in some embodiments of the present application, the above-mentioned model training module includes:

[0064] A text coverage rate threshold acquisition unit, used to acquire a text coverage rate threshold;

[0065] A length distribution statistics unit is used to perform sample length distribution statistics on the training samples in the target text sample set;

[0066] A parameter determination unit, for determining, based on the sample length distribution statistics and the text coverage threshold, a text length limit parameter so that the proportion of covered samples in the training samples is not less than the text coverage threshold, wherein the covered samples are training samples whose sample length is not greater than the text length limit parameter;

[0067] The training unit is used to train the above-mentioned model to be trained according to the above-mentioned target text sample set and the above-mentioned text length limit parameter to obtain a trained text classification model.

[0068] Optionally, in some embodiments of the present application, the training unit includes:

[0069] The sample processing subunit is used to input the training samples in the target text sample set into the model to be trained, so as to trigger the model to be trained to perform word segmentation, word-gram addition, word-gram mapping on the training samples, and sample truncation or sample padding based on the text length limit parameter, so as to obtain the training data under each target text sample set;

[0070] The model parameter adjustment subunit is used to train the above-mentioned model to be trained according to the training data under each of the above-mentioned target text sample sets, so as to adjust the model parameters of the above-mentioned model to be trained until a trained text classification model is obtained.

[0071] Optionally, in some embodiments of the present application, the above-mentioned model parameter adjustment subunit is specifically used to:

[0072] Obtain the number of training data corresponding to each of the above target text sample sets;

[0073] Determine the accuracy contribution adjustment coefficient corresponding to each of the target text sample sets according to the number of training data corresponding to each of the target text sample sets, and determine the accuracy calculation function of the to-be-trained model according to the accuracy contribution adjustment coefficient;

[0074] Input the training data under each of the above target text sample sets into the above to-be-trained model to obtain the prediction value corresponding to each of the above training data;

[0075] According to the predicted value and the true value corresponding to the training data, and the target text sample set to which the training data belongs, the accuracy corresponding to the model to be trained is obtained by calculating the accuracy calculation function;

[0076] The model parameters of the model to be trained are adjusted according to the accuracy, and the step of inputting the training data under each of the target text sample sets into the model to be trained is returned to execute until a text classification model that meets the preset training completion conditions is obtained.

[0077] Optionally, in some embodiments of the present application, the above-mentioned text classification model training system further includes:

[0078] A training indicator acquisition module is used to obtain the loss and / or accuracy of the above text classification model during the training process;

[0079] A fitting condition determination module, used to determine the fitting condition of the trained text classification model according to the above loss and / or the above accuracy;

[0080] The model optimization module is used to optimize and adjust the model parameters of the trained text classification model according to the above fitting judgment results to obtain an optimized text classification model.

[0081] A fourth aspect of the present application provides a text classification system, the text classification system comprising:

[0082] A text acquisition module is used to acquire the text to be classified;

[0083] A text classification module is used to input the above-mentioned text to be classified into a text classification model to obtain a text classification result output by the above-mentioned text classification model, wherein the above-mentioned text classification model is trained based on any one of the text classification model training methods provided in the first aspect of the embodiment of the present application.

[0084] Optionally, in some embodiments of the present application, the text classification system further includes:

[0085] A target model determination module, used to determine a target processing model corresponding to the text to be classified according to the text classification result corresponding to the text to be classified;

[0086] The first operation instruction determination module is used to input the above-mentioned text to be classified into the above-mentioned target processing model to determine the operation instruction corresponding to the above-mentioned text to be classified through the above-mentioned target processing model.

[0087] Optionally, in some embodiments of the present application, the text classification system further includes:

[0088] A supplementary text acquisition module, used for acquiring supplementary text associated with the text to be classified based on an interactive operation if the text classification result corresponding to the text to be classified is a preset target category, wherein the target category is used to indicate that the text to be classified has no specified implementation object;

[0089] A target entity extraction module, used to search for the longest common subsequence matching the supplementary text from a plurality of preset entity libraries respectively, so as to obtain the target entity in the supplementary text;

[0090] The second operation instruction determination module is used to determine the operation instruction corresponding to the above-mentioned text to be classified based on the above-mentioned target entity.

[0091] Optionally, in some embodiments of the present application, the target entity extraction module is also used for: if the target entity in the supplementary text is not obtained based on the entity library, the supplementary text is input into a preset conditional random field model, and entity recognition is performed through the conditional random field model to obtain the target entity in the supplementary text.

[0092] A fifth aspect of an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a text classification model training program stored in the memory and executable on the processor. When the processor executes the text classification model training program, the steps of the text classification model training method are implemented.

[0093] A sixth aspect of an embodiment of the present application provides a vehicle, comprising a memory, a processor, and a text classification program stored in the memory and executable on the processor, wherein when the processor executes the text classification program, the steps of the text classification method are implemented.

[0094] A seventh 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 run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the text classification model training method, or the computer program is used to enable the electronic device to execute the steps of the text classification method.

[0095] Beneficial effects of this application:

[0096] (1) The embodiment of the present application first obtains the text classification sample sets corresponding to different categories, and then obtains the sample ratio limit range used to limit the ratio of the number of training samples under each text classification sample set, and then based on the sample ratio limit range and the actual number of training samples in the text classification sample set, downsamples each text classification sample set to obtain a target text sample set that meets the sample ratio limit range for model training. In this way, downsampling the initially collected text classification sample set can achieve the effect of sample balance, which is conducive to improving the training effect of the model, can balance the model's ability to recognize texts of various categories, and improve the classification accuracy when the model is used for text classification in the future.

[0097] (2) In the embodiment of the present application, the training samples are first clustered to obtain sample sets of each text classification, and then data downsampling is performed for each classification, which is beneficial to improving the efficiency and effect of data downsampling.

[0098] (3) In the embodiment of the present application, the accuracy contribution adjustment coefficient corresponding to the target text sample set corresponding to each classification is determined according to the actual number of training data in the target text sample set corresponding to each classification, thereby adjusting the accuracy calculation function. That is, in the present application, the accuracy calculation function is adjusted based on the actual number of training data in the target text sample set, thereby adjusting the contribution of categories with different numbers of training data when calculating the accuracy, improving the balance of the influence of training samples of different categories during the model training process, and thus improving the model training effect.

[0099] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0100] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0101] Figure 1 It is a schematic diagram of the overall process of the text classification model training method provided in the embodiment of the present application;

[0102] Figure 2 This is an embodiment of the present application Figure 1 Specific flow diagram of step S400;

[0103] Figure 3 This is a schematic diagram of a word segmentation process provided by an embodiment of the present application;

[0104] Figure 4 It is a schematic diagram of the overall process of the text classification method provided in the embodiment of the present application;

[0105] Figure 5 This is an overall business scenario architecture diagram provided by an embodiment of the present application;

[0106] Figure 6 This is a schematic diagram of the overall training process of a text classification model provided in an embodiment of the present application;

[0107] Figure 7 This is a schematic diagram of a text classification process provided by an embodiment of the present application;

[0108] Figure 8 It is a structural diagram of a text classification model training system provided in an embodiment of the present application;

[0109] Fig. 9 It is a structural diagram of a text classification system provided in an embodiment of the present application;

[0110] Fig.10 It is a block diagram of the internal structure principle of an electronic device provided by an embodiment of the present application;

[0111] Fig.11 It is a block diagram of the internal structure principle of a vehicle provided in an embodiment of the present application. DETAILED DESCRIPTION

[0112] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0113] At present, there is an increasing demand for text classification. For example, when users use voice control or voice commands based on the in-vehicle voice system, they need to convert the voice into text and use text classification to determine which category the in-vehicle voice belongs to, so as to determine which module to call for subsequent processing (for example, whether to call the voice question and answer module or the voice vehicle control module, or other modules). In other words, the distribution of in-vehicle voice needs to be realized based on text classification. In some application scenarios, the corresponding distribution system can be simplified to a judgment system for two-certificate classification, that is, it is used to determine whether a certain voice needs to call the base large model to answer or needs to use other complex functions. At this time, the corresponding distribution system can be simplified to a pre-rejection module.

[0114] For the needs of text classification, text classification can usually be achieved by training text classification models. At present, big models have begun to move from general big models to vertical big models, so the application of big models is becoming more and more extensive. For example, the automotive industry has also begun to develop its own base big models to improve the user experience. On the basis of the base big model, many vertical application big models can be derived to cope with different usage scenarios. In this way, the basic knowledge obtained from the rich training corpus of the base big model can be used, and the model performance in the segmented scenario can be better and more targeted. However, for different application big models, a front-end intelligent scheduling module is required to realize the distribution of the corpus to the corresponding application big model after recognition, so as to save resource costs and improve processing efficiency.

[0115] Specifically, in the car use scenario, there may be a large amount of voice input at any time, and most of them are small talk and do not interact with the car. The in-vehicle voice system needs to recognize these voice inputs at any time and determine whether to call the corresponding function or give an answer. If it directly accesses the base large model to determine whether each user's voice has an interactive or operational intention, it will consume a lot of computing resources and may be difficult to meet the real-time requirements. Therefore, in an application scenario, a classification model that is lighter than the base large model but can also meet the requirements can be used as a front-end scheduling module for diversion.

[0116] In one application scenario, traditional machine learning models can be used for text classification, but the traditional model structure is relatively simple, the knowledge and information learned are relatively limited, and the performance of the model is difficult to meet the various more sophisticated needs of users. The use of deep learning models can complete increasingly complex tasks based on the large amount of accumulated data and the ever-increasing computing power. However, when training deep learning models, if the training samples used are unbalanced, it will affect the model training effect, thereby affecting the classification effect of the trained model.

[0117] In order to solve at least one of the above-mentioned multiple technical problems, the embodiments of the present application provide a text classification model training method, a text classification method and related equipment, which are described in detail below in conjunction with the accompanying drawings. In this embodiment, the execution subject is taken as an example of a terminal device. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.

[0118] The first aspect of the present application embodiment provides a text classification model training method, see Figure 1 , the text classification model training method includes the following steps:

[0119] Step S100, obtaining a plurality of text classification sample sets, wherein each of the text classification sample sets includes a plurality of training samples of the same category;

[0120] Step S200, obtaining a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set;

[0121] Step S300, performing downsampling processing on each of the above text classification sample sets according to the above sample ratio limit range and the number of training samples in each of the above text classification sample sets, so as to obtain multiple target text sample sets;

[0122] Step S400: training the preset model to be trained according to the target text sample set to obtain a trained text classification model.

[0123] Among them, a text classification sample set stores one type of training samples, and the specific categories and the number of categories can be pre-set and adjusted according to actual needs, and are not specifically limited here.

[0124] It should be noted that in the embodiment of the present application, the text classification corresponding to the speech of the user during the use of the car is used as an example for explanation, but it is not a specific limitation. In actual application, the text classification model provided in the embodiment of the present application can also be applied to other application scenarios to train the text classification model required by other application scenarios.

[0125] The above sample ratio limit range can be preset or adjusted according to actual needs. For example, it can be input in real time by the control personnel during the model training process, and is not specifically limited here.

[0126] In one application scenario, the above sample ratio limit range may be a preset fixed ratio. For example, if there are 4 categories, the sample ratio limit range may be set to be fixed at 1:1:1:1 (the specific value may be determined based on actual needs). In another application scenario, the above sample ratio limit range may be a preset ratio for limiting the number of samples corresponding to the two text classification sample sets with the largest difference in the number of training samples. For example, it may be set to a ratio of 1:1.5 for the number of samples corresponding to the two text classification sample sets with the largest difference in the number of training samples after downsampling. Thus, the downsampling process may be controlled according to the sample ratio limit range to achieve sample balance. This in turn improves the overall model training effect.

[0127] In some embodiments of the present application, the step of obtaining multiple text classification sample sets includes:

[0128] Acquire multiple training speech samples, and perform speech recognition on each of the training speech samples to obtain multiple training samples;

[0129] The above training samples are clustered to obtain multiple text classification sample sets. In the embodiment of the present application, the above training voice samples are pre-collected voices of users in car use scenarios. Specifically, the data sources in actual application scenarios can be divided into four categories (the actual categories and the number of categories can be determined according to actual needs). The first category is chat scene data, the second category is single-intent data, the third category is multi-intent data, and the fourth category belongs to scene arrangement data. For each training voice sample, it is isolated and labeled (that is, label data is set). For example, the chat scene label is set to 0, the single intent is 1, the multi-intent is 2, and the scene arrangement is 3. The label data is used to indicate the actual classification of the sample. The specific label value can be defined and adjusted according to actual needs.

[0130] Specifically, a single-intent data is: "Open the car window", a multi-intent data is: "Navigate home and play a certain singer's music", and a scene arrangement data is: "When I get in the car on a weekday morning, navigate to the company and turn on the seat heating." Clustering is performed on data of different categories to obtain text classification sample sets corresponding to different categories. For example, in the embodiment of the present application, four text classification sample sets can be obtained after clustering, and each text classification sample set corresponds to a category of data.

[0131] For the collected samples, there may be a sample imbalance. For example, the number of samples in the chat scene data is several times that of other sample data, making the sample distribution uneven. If the samples are directly input into the model according to the original ratio, it will cause the model to learn other classifications insufficiently, resulting in inaccurate recognition of other classifications. To address this problem, the chat scene data can be undersampled. The specific method is to cluster the samples first, and then randomly downsample under each cluster. In this way, the sample size of the chat scene and the sample size of other classifications can be relatively balanced under the premise of losing less sample information.

[0132] In one application scenario, such as Figure 2 As shown, the above step S400 specifically includes the following steps:

[0133] Step S401, obtaining a text coverage threshold;

[0134] Step S402, performing sample length distribution statistics on the training samples in the target text sample set;

[0135] Step S403, according to the statistical result of the sample length distribution and the text coverage threshold, determine the text length limit parameter so that the proportion of covered samples in the training samples is not less than the text coverage threshold, wherein the covered samples are training samples whose sample length is not greater than the text length limit parameter;

[0136] Step S404: training the model to be trained according to the target text sample set and the text length limit parameter to obtain a trained text classification model.

[0137] Specifically, after sampling is completed, the data of the entire sample is preprocessed and cleaned, and then the word count distribution of the entire sample is counted to determine the text length limit parameter (max_length parameter) corresponding to the subsequent model. It should be noted that data preprocessing and cleaning can be performed according to pre-set fixed steps, which are not specifically limited here.

[0138] In one application scenario, after data preprocessing, the word count distribution of the sample text can be directly counted, and the corresponding statistical results can be viewed, for example, viewing the text length limit parameters that can cover 75% (or 90%, 95%, etc.) of the text, so as to determine a suitable text length limit parameter.

[0139] In another application scenario, the length of the longest text can be directly used as the text length limit parameter to ensure that all training samples are covered. However, this will result in a large amount of data processing and affect the model training speed.

[0140] In an embodiment of the present application, a user can pre-set or adjust a corresponding text coverage threshold, thereby flexibly adjusting the number of training samples required to be limited, thereby increasing the model training speed while ensuring the model training effect.

[0141] Specifically, the above-mentioned training model is trained according to the above-mentioned target text sample set and the above-mentioned text length limit parameter to obtain a trained text classification model, including:

[0142] Input the training samples in the target text sample set into the model to be trained, so as to trigger the model to be trained to segment the training samples, add word units, perform word unit mapping, and perform sample truncation or sample padding based on the text length limit parameter, so as to obtain the training data under each target text sample set;

[0143] The above-mentioned model to be trained is trained according to the training data under each of the above-mentioned target text sample sets to adjust the model parameters of the above-mentioned model to be trained until a trained text classification model is obtained.

[0144] It should be noted that in the embodiment of the present application, the above-mentioned model to be trained is a pre-trained BERT model, that is, the pre-trained BERT model is further trained to obtain a trained text classification model. The BERT model is a pre-trained language representation model. Using the BERT model as the model to be trained, a good feature identifier can be learned for each character through self-supervised learning based on a large amount of corpus. Only a small amount of training data needs to be fine-tuned according to the specific task to achieve good results. Compared with the traditional model, it does not require a lot of pre-processing work to extract features, and the effect is better.

[0145] Specifically, the samples are converted into a format that BERT can receive and process to ensure the training effect of the model. The BERT model itself has the functions of segmenting training samples, adding word units, word unit mapping, and truncating or filling samples based on the above text length limit parameters, so the training samples can be processed based on the BERT model.

[0146] In the embodiment of the present application, a Dataset class is created to convert samples into the data format required by the model. Figure 3 This is a schematic diagram of a word segmentation process provided by an embodiment of the present application. Figure 3 As shown in the figure, for each training sample, word segmentation is performed and word units (i.e., tokens) such as [CLS], [SEP], and [PAD] are automatically added. This process is called tokenization. After word segmentation, word unit mapping is performed, for example Figure 3 Map the token to an id, including Figure 4 The input id (Inputids), token type id (Tokentypeids) and attention mask (Attentionmask) in the above process are called encoding. Among them, [CLS] is a special token for classification tasks, [SEP] is a separator token, and [PAD] is a token that fills the sample to a specified length.

[0147] It should be noted that the core module of the Dataset class is the BertTokenizer function of Transformer, which corresponds to important parameters such as padding, max_length, truncation, and return_tensors. Among them, the padding parameter is the set padding length. The value of the padding parameter can be set to the text length limit parameter to ensure the coverage requirement of the text length. Alternatively, the value of the padding parameter can be set to (max_length) so that each sentence is automatically filled with the specified maximum sentence length to ensure that the length of each sample is the same, which is convenient for matrix calculation. Among them, the padding words will be represented by 0.

[0148] max_length specifies the maximum length of the sentence, and a reasonable value can be set based on the distribution statistics of the number of sample words. trunction is used to specify whether to truncate sentences exceeding max_length, and is generally set to True; return_tensors is to set the return tensor type, which can be set to "pt" or "tf" depending on whether pytorch or tensorflow is used; after the tokenizer function, the data will contain input_ids, token_type_ids, and attention_mask, where input_ids will store the id corresponding to each word, and token_type_ids is used to identify which text the token belongs to. If there is only one text, then all token_type_ids are 0. In the embodiment of this application, it is applied to text classification tasks, so this parameter can be omitted when building the model. The attention_mask records which words are truly meaningful. Generally, [PAD] will be marked as 0, and words marked as 1 will participate in subsequent attention calculations.

[0149] It should be noted that BERT is based on the idea of ​​pre-training language models of the bidirectional encoding network architecture of Transformer, and the overall framework is composed of the encoder parts of multiple layers of transformers stacked together. BERT has two outputs, one is the pooler output, which can be used for classification / regression tasks, and the other is the sequence output, which can be used for sequence tasks. In the embodiment of the present application, the pooler output is used to perform classification tasks, that is, the pooling layer output (pooler output) of the BERT model is used as the output result of the model. Furthermore, for the pooler output, processing layers such as nn.Dropout, nn.Linear, and nn.Relu activation functions can also be added after the pooling layer. The pooler output is further processed to obtain better classification results. Specifically, adding nn.Dropout means performing dropout processing on the output layer to avoid overfitting, adding nn.Liner and nn.Relu, and combining them as a classifier to process the results of BERT into the required multi-classification.

[0150] In one application scenario, the total training samples can be divided into a training set, a validation set, and a test set according to a ratio (e.g., 80:10:10, the specific ratio can be set and adjusted according to actual needs) to complete the training, validation, and testing tasks of the model respectively. In another application scenario, the above training samples can also be used as training sets, and validation sets and test sets can be set additionally, which is not specifically limited here.

[0151] Specifically, use the DataLoader method that comes with Pytorch to load the training data, and set parameters such as batch_size and shuffle according to actual needs. The loaded data needs to be passed to a suitable device. In this embodiment of the application, cuda is selected for training to improve training efficiency. Among them, shuffle is set to True to disrupt the order of samples to avoid relying on a fixed sample input order and affecting the model training effect. The value of batch_size can be set and adjusted according to actual needs, and is not specifically limited here.

[0152] Use nn.CrossEntropyLoss to define the loss function (the cross entropy loss function is used in this example), which is the result of combining softmax\log\NLLLoss. Use optim.Adam to define the optimizer, which needs to specify the learning rate parameter. Set the appropriate number of epochs according to the task, and use the loss function to calculate the loss at each iteration, and then update the parameters.

[0153] Further, in the embodiment of the present application, the problem of sample imbalance affecting the model training effect is solved from two aspects. The first point is the above-mentioned undersampling of the classification with a large number of samples, that is, the samples are first clustered and then randomly sampled under the clustering. The second point is to improve the evaluation indicators in the model training process to more reasonably judge the evaluation of the accuracy of the model for the classification of unbalanced samples. For example, for the classification with a small number of samples, after calculating the accuracy by category, the accuracy of the classification with a small number of samples can be multiplied by a coefficient greater than 1, and for the classification with a large number of samples, the category accuracy can be multiplied by a coefficient less than 1. In this way, the contribution ratio of the accuracy of a small number of samples can be increased and the contribution ratio of the accuracy of a large number of samples can be reduced, so that the model can consider the performance of the model in each category more evenly when evaluating the accuracy, avoiding the problem that the accuracy of the model is more biased towards the accuracy of the large number of categories when directly using the overall accuracy evaluation. Among them, the category accuracy time value model is the accuracy of a certain classification, not the overall accuracy.

[0154] Specifically, the training of the model to be trained according to the training data under each of the target text sample sets to adjust the model parameters of the model to be trained until a trained text classification model is obtained includes:

[0155] Obtain the number of training data corresponding to each of the above target text sample sets;

[0156] Determine the accuracy contribution adjustment coefficient corresponding to each of the target text sample sets according to the number of training data corresponding to each of the target text sample sets, and determine the accuracy calculation function of the to-be-trained model according to the accuracy contribution adjustment coefficient;

[0157] Input the training data under each of the above target text sample sets into the above to-be-trained model to obtain the prediction value corresponding to each of the above training data;

[0158] According to the predicted value and the true value corresponding to the training data, and the target text sample set to which the training data belongs, the accuracy corresponding to the model to be trained is obtained by calculating the accuracy calculation function;

[0159] The model parameters of the model to be trained are adjusted according to the accuracy, and the step of inputting the training data under each of the target text sample sets into the model to be trained is returned to execute until a text classification model that meets the preset training completion conditions is obtained.

[0160] Specifically, in the embodiment of the present application, the model is optimized and iterated with reference to the accuracy of the model in classifying samples. However, due to the imbalance of the classified sample data, even after downsampling of a large number of samples, the obtained ratios are not necessarily equal. Therefore, in the embodiment of the present application, the evaluation index of the classification accuracy is improved, and a more reasonable evaluation index is used to evaluate the performance of the model for different classifications.

[0161] Specifically, the accuracy calculation function (Accuracy function) is improved. An Accuracy function before improvement is shown in the following formula (1):

[0162]

[0163] The improved Accuracy function in the embodiment of the present application is shown in the following formula (2):

[0164]

[0165] In the above formulas (1) and (2), Accuracy old and Accuracy new They represent the accuracy calculated based on the function before improvement and the accuracy calculated based on the function after improvement. A, B and C are samples of different categories, N is the number of sample types, and α, β and λ are the accuracy contribution adjustment coefficients. count(label A =red A ) represents that for a sample in category A, if its label value (i.e., true value) and predicted value are equal, the count is 1. Totalsample represents the total number of samples, sample represents the number of samples in category A, and so on, which will not be elaborated here. The value of the accuracy contribution adjustment coefficient is determined based on the number of samples in the corresponding category. For example, for a category with a small number of samples, its coefficient is set to be greater than 1, and vice versa for a category with a large number of samples, its coefficient is set to be less than 1. In this way, more accuracy contribution can be provided for categories with a small number of samples, and the accuracy contribution of categories with a large number of samples can be appropriately reduced, further improving the balance of the model training process. Among them, the specific value of the coefficient can be set and adjusted according to actual needs, and is not specifically limited here.

[0166] Furthermore, after the preset model to be trained is trained according to the target text sample set to obtain a trained text classification model, the text classification model training method further includes:

[0167] Obtain the loss and / or accuracy of the above text classification model during training;

[0168] According to the above loss and / or the above accuracy, the fitting condition of the above trained text classification model is judged;

[0169] According to the above fitting judgment results, the model parameters of the above trained text classification model are optimized and adjusted to obtain an optimized text classification model.

[0170] Specifically, during the training process, the loss and accuracy of each round of training set and validation set can be checked through the log to check whether the model is overfitting or underfitting, and then the parameters or data can be adjusted to obtain a better model. When building the model, there is a dropout parameter, which is in the range of 0-1, and the overfitting and underfitting can be adjusted based on this parameter. In the embodiment of the present application, the dropout parameter can be set in the range of 0.3-0.5. When 0.5 is taken, all neuron permutations and combinations are considered to be the maximum value, and the randomness is greater. A relatively good process is that with each round of training, the loss of the training set and the validation set is decreasing and tending to be consistent.

[0171] Furthermore, after the model training is completed, the trained model is saved to a specified path for subsequent reading to perform reasoning tasks. The model is initially saved in bin file format. Since the actual usage scenario needs to meet relatively low time requirements, the model file is converted to ONNX format for reasoning. In this way, the average reasoning time per text can be reduced by more than 6 times after conversion.

[0172] It should be noted that the above model training process can be executed by a server or by a vehicle, and is not specifically limited here. In the embodiment of the present application, after the above text classification model training is completed, it is deployed in the vehicle to help the vehicle realize text classification, that is, the text classification method in the embodiment of the present application can be executed by the vehicle.

[0173] like Figure 4 As shown, the second aspect of the embodiment of the present application provides a text classification method, which includes the following steps:

[0174] Step A100, obtaining the text to be classified;

[0175] Step A200: input the text to be classified into a text classification model to obtain a text classification result output by the text classification model.

[0176] Among them, the above-mentioned text classification model is trained based on any one of the text classification model training methods provided in the first aspect of the embodiment of the present application.

[0177] For the text to be classified, the text classification model trained by the text classification model training method provided in the first aspect of the embodiment of the present application is used for classification. During the training process of the text classification model, the influence of unbalanced samples on the model training effect is taken into account, and the samples are processed to ensure the balance of the number of samples, thereby ensuring the classification effect of the trained text classification model. Using the text classification model for text classification is conducive to improving the accuracy of text classification.

[0178] In some embodiments of the present application, the above text classification method further includes:

[0179] Determine the target processing model corresponding to the text to be classified according to the text classification result corresponding to the text to be classified;

[0180] The text to be classified is input into the target processing model to determine the operation instruction corresponding to the text to be classified through the target processing model.

[0181] In the embodiments of the present application, the above-mentioned text classification model training method and / or the above-mentioned text classification method are also described in detail based on a specific application scenario. Figure 5 This is an overall business scenario architecture diagram provided by an embodiment of the present application, such as Figure 5 As shown, the collected speech to be processed can be subjected to ASR automatic speech recognition to obtain the corresponding text to be classified. The text classification model obtained by training the above text classification model is applied to the intelligent scheduling module of the vehicle, so as to classify the text to be classified based on the text classification model in the intelligent scheduling module, determine the scene category corresponding to the text to be classified, and then select the target processing model corresponding to different scene categories.

[0182] Figure 6 is a schematic diagram of the overall training process of a text classification model provided in an embodiment of the present application. Specifically, Figure 6 As shown, the upstream speech text for model training is first obtained, and then sample equalization processing is performed to construct a data set for training. After the model is constructed, the model is trained based on the data set. After the training is completed, the model is evaluated to obtain a trained text classification model.

[0183] Figure 7 is a schematic diagram of a text classification process provided by an embodiment of the present application, such as Figure 7 As shown in the figure, for a single sentence of speech text to be classified, after word segmentation, it is input into the trained BERT model to obtain the corresponding classification label. It should be noted that the word segmentation process can be implemented by using an additional word segmenter, or the word segmenter in the BERT model can be directly used, which is not specifically limited here.

[0184] In summary, in the embodiment of the present application, the task of classifying speech text is completed by fine-tuning the BERT pre-trained model with own business data, and the fine-tuned model is used to determine which category the in-vehicle speech input belongs to after being converted into text, and then the corresponding modules are called, such as large model question and answer, simple vehicle control operation, complex vehicle control operation and in-vehicle scene arrangement, etc. The problem of using the base large model to judge the user's voice intention is solved.

[0185] Specifically, by clustering one or several categories that account for a large proportion of samples in different labeled categories and then downsampling to balance the samples, the model can perform more evenly on samples of different categories, which is suitable for model training in scenarios with unbalanced samples.

[0186] Furthermore, the problem that general accuracy cannot well evaluate the performance of the model for imbalanced samples is solved by optimizing the formula for judging the model accuracy.

[0187] The text classification model obtained by training based on the solution provided in the embodiment of the present application can be used as a front-end intelligent scheduling module of the entire in-vehicle voice intelligent system to improve the user experience.

[0188] In one application scenario, the above text classification method further includes:

[0189] If the text classification result corresponding to the text to be classified is a preset target category, then obtaining a supplementary text associated with the text to be classified based on an interactive operation, wherein the target category is used to indicate that the text to be classified has no specified implementation object;

[0190] Searching for the longest common subsequence matching the supplementary text from a plurality of preset entity libraries respectively to obtain a target entity in the supplementary text;

[0191] Based on the target entity, an operation instruction corresponding to the text to be classified is determined.

[0192] Furthermore, if the target entity in the supplementary text is not obtained based on the entity library, the supplementary text is input into a preset conditional random field model, and entity recognition is performed through the conditional random field model to obtain the target entity in the supplementary text.

[0193] The above-mentioned preset target category is a pre-specified text category. The text of this category does not specify a specific implementation object, so it is difficult to directly generate the corresponding operation instructions. For example, the text to be classified entered by the user is "play music", but the text does not specify the specific song name and singer. The in-car voice assistant needs to have a second round of dialogue with the user for confirmation. At this time, the user usually replies with something like "Song B by singer A". "Song B by singer A" can be used as a supplementary text associated with the text to be classified.

[0194] It should be noted that the above-mentioned interactive operations can be voice interaction, text input interaction and other operations, which are not specifically limited here. The above-mentioned "A singer" and "B song" are the specific singer name and specific song name respectively. The singer entity word "A singer" and the song entity word "B song" need to be identified separately, and then passed to other modules to form a complete semantics before implementing these instructions on the car.

[0195] In the embodiment of the present application, multiple entity libraries are pre-set to extract multiple target entities in the supplementary text. It should be noted that in the actual application process, only one entity library can be set, which is not specifically limited here.

[0196] Furthermore, in the embodiment of the present application, entity matching is performed based on named entity recognition (NER) technology. Specifically, the NER technology in the embodiment of the present application is implemented based on a preset entity library and / or a conditional random field (CRF) model.

[0197] Taking the above-mentioned supplementary text related to songs as an example, we can pre-set the song library and singer library as two entity libraries. Based on the code, we implement a "longest common subsequence" search algorithm to find the longest subtext in the vocabulary that can be matched in the current supplementary text. During the matching process, we will traverse the song library and singer library respectively.

[0198] It should be noted that there may be more than one entity word of the same category in the supplementary text, such as "song C sung by singer A and singer B". In this case, the two identified singer entity words are returned as a list structure.

[0199] When the song library and singer library cannot cover the current text, the current supplementary text is input into the CRF model for entity word recognition. When it is necessary to explain, the entity library is used for matching first, which can perform accurate and fast matching, meet the needs of most scenarios, and improve processing speed. When the entity library cannot meet the requirements, the CRF model is used for further entity extraction to improve the user experience.

[0200] In the embodiment of the present application, the CRF model is trained and adjusted using training texts marked in a preset format according to actual task requirements. For example, in the song "Chopin in November", only "Chopin in November" is an entity word of the song type. Therefore, the above preset format is as follows: ['B-SONG', 'M-SONG', 'M-SONG', 'M-SONG', 'M-SONG', 'E-SONG', 'O', 'O', 'O'], where B represents the beginning of the entity word begin, M represents the middle part of the entity word middle, E represents the end of the entity word end, and SONG represents the type of entity word. Although only singers and song types are mentioned in the above examples, in actual applications, there will also be types such as places and institutions, and O represents the non-entity word part, namely the word other.

[0201] Finally, the identified target entities (such as singer list and song list) are combined into dictionaries and sent back in JSON format. One return format is as follows: {"singers":["singer one","singer two",...], "songs":["song one","song two",...]}, but this is not a specific limitation.

[0202] In this way, based on the entity extraction of the supplementary text, the problem of users not specifying the specific implementation object in the first round of conversation can be solved, further improving the user experience.

[0203] The present application also provides a text classification model training system. Figure 8 , the text classification model training system includes the following modules:

[0204] The sample acquisition module 810 is used to acquire multiple text classification sample sets, wherein each of the above text classification sample sets includes multiple training samples of the same category;

[0205] The sample ratio acquisition module 820 is used to acquire a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set;

[0206] A downsampling module 830 is used to perform downsampling processing on each of the above text classification sample sets according to the above sample ratio limit range and the number of training samples in each of the above text classification sample sets, so as to obtain multiple target text sample sets;

[0207] The model training module 840 is used to train the preset model to be trained according to the above target text sample set to obtain a trained text classification model.

[0208] It should be noted that the aforementioned explanation of the text classification model training method embodiment is also applicable to the text classification model training system of this embodiment, and will not be repeated here.

[0209] The present application also provides a text classification system. Fig. 9 , the text classification system includes the following modules:

[0210] A text acquisition module 910 is used to acquire the text to be classified;

[0211] The text classification module 920 is used to input the above-mentioned text to be classified into the text classification model to obtain the text classification result output by the above-mentioned text classification model.

[0212] Among them, the above-mentioned text classification model is obtained by training based on the text classification model training method provided in the first aspect of the embodiment of the present application.

[0213] It should be noted that the explanations of the aforementioned text classification method embodiment are also applicable to the text classification system of this embodiment, and will not be repeated here.

[0214] Fig.10 : is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device comprising:

[0215] A memory 1001, a processor 1002, and a text classification model training program stored in the memory 1001 and executable on the processor 1002. When the processor 1002 executes the text classification model training program, the steps of any one of the text classification model training methods are implemented.

[0216] Furthermore, the electronic device may further include a communication interface 1003 for communication between the memory 1001 and the processor 1002. If the memory 1001, the processor 1002 and the communication interface 1003 are implemented independently, the communication interface 1003, the memory 1001 and the processor 1002 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0217] Optionally, in a specific implementation, if the memory 1001, the processor 1002 and the communication interface 1003 are integrated on a chip, the memory 1001, the processor 1002 and the communication interface 1003 can communicate with each other through an internal interface.

[0218] The processor 1002 may be a central processing unit (CPU) or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0219] Fig.11 : is a structural schematic diagram of a vehicle provided in an embodiment of the present application, the vehicle comprising:

[0220] The memory 1101, the processor 1102 and the text classification program stored in the memory 1101 and executable on the processor 1102. When the processor 1102 executes the text classification program, the steps of any one of the above-mentioned text classification methods are implemented.

[0221] Furthermore, the vehicle may further include a communication interface 1103 for communication between the memory 1101 and the processor 1102. It should be noted that the structure of the vehicle may also refer to the structure description of the electronic device, which will not be repeated here.

[0222] This embodiment also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the above text classification model training method or the steps of the text classification method are implemented.

[0223] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0224] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0225] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes additional implementations, in which the order shown or discussed may not be followed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0226] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can read instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or N wirings (electronic devices), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary and then storing it in a computer memory.

[0227] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0228] A person of ordinary skill in the art may understand that all or part of the steps of the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, implements one or a combination of multiple steps of the method embodiment.

[0229] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0230] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A text classification model training method, characterized in that: The text classification model training method comprises: Acquire multiple text classification sample sets, wherein each of the text classification sample sets includes multiple training samples of the same category; Obtaining a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set; According to the sample ratio limit range and the number of training samples in each of the text classification sample sets, downsampling is performed on each of the text classification sample sets to obtain multiple target text sample sets; The preset model to be trained is trained according to the target text sample set to obtain a trained text classification model.

2. The text classification model training method according to claim 1, characterized in that: The obtaining of multiple text classification sample sets includes: Acquire multiple training speech samples, and perform speech recognition on each of the training speech samples to obtain multiple training samples; The training samples are clustered to obtain multiple text classification sample sets.

3. The text classification model training method according to claim 1, characterized in that: The step of training a preset model to be trained according to the target text sample set to obtain a trained text classification model includes: Get text coverage threshold; Performing sample length distribution statistics on the training samples in the target text sample set; According to the result of the sample length distribution statistics and the text coverage threshold, determine a text length limit parameter that makes the proportion of covered samples in the training samples not less than the text coverage threshold, wherein the covered samples are training samples whose sample length is not greater than the text length limit parameter; The model to be trained is trained according to the target text sample set and the text length limit parameter to obtain a trained text classification model.

4. The text classification model training method according to claim 3, characterized in that: The step of training the model to be trained according to the target text sample set and the text length limit parameter to obtain a trained text classification model includes: Input the training samples in the target text sample set into the model to be trained, so as to trigger the model to be trained to segment the training samples, add word units, perform word unit mapping, and perform sample truncation or sample padding based on the text length limit parameter, so as to obtain training data under each target text sample set; The model to be trained is trained according to the training data under each of the target text sample sets to adjust the model parameters of the model to be trained until a trained text classification model is obtained.

5. The text classification model training method according to claim 4, characterized in that: The training of the model to be trained according to the training data under each target text sample set to adjust the model parameters of the model to be trained until a trained text classification model is obtained includes: Obtaining the number of training data corresponding to each of the target text sample sets; Determining the accuracy contribution adjustment coefficient corresponding to each target text sample set according to the number of training data corresponding to each target text sample set, and determining the accuracy calculation function of the to-be-trained model according to the accuracy contribution adjustment coefficient; Input the training data under each target text sample set into the to-be-trained model to obtain the prediction value corresponding to each training data; According to the predicted value and the true value corresponding to the training data, and the target text sample set to which the training data belongs, the accuracy rate corresponding to the model to be trained is calculated by the accuracy rate calculation function; The model parameters of the model to be trained are adjusted according to the accuracy rate, and the step of inputting the training data under each target text sample set into the model to be trained is returned to be executed until a text classification model that meets the preset training completion condition is obtained.

6. The text classification model training method according to any one of claims 1 to 5, characterized in that: After training the preset model to be trained according to the target text sample set to obtain a trained text classification model, the text classification model training method further includes: Obtaining the loss and / or accuracy of the text classification model during training; According to the loss and / or the accuracy, judging the fitting condition of the trained text classification model; According to the fitting judgment result, the model parameters of the trained text classification model are optimized and adjusted to obtain an optimized text classification model.

7. A text classification method, characterized in that: The text classification method comprises: Get the text to be classified; The text to be classified is input into a text classification model to obtain a text classification result output by the text classification model, wherein the text classification model is trained based on the text classification model training method according to any one of claims 1 to 6.

8. The text classification method according to claim 7, characterized in that: The text classification method also includes: Determining a target processing model corresponding to the text to be classified according to a text classification result corresponding to the text to be classified; The text to be classified is input into the target processing model to determine the operation instruction corresponding to the text to be classified through the target processing model.

9. The text classification method according to claim 7, characterized in that: The text classification method also includes: If the text classification result corresponding to the text to be classified is a preset target category, then obtaining a supplementary text associated with the text to be classified based on an interactive operation, wherein the target category is used to indicate that the text to be classified has no specified implementation object; Searching for the longest common subsequence matching the supplementary text from a plurality of preset entity libraries respectively to obtain a target entity in the supplementary text; An operation instruction corresponding to the text to be classified is determined based on the target entity.

10. The text classification method according to claim 9, characterized in that: Before determining the operation instruction corresponding to the text to be classified based on the target entity, the method further includes: If the target entity in the supplementary text is not obtained based on the entity library, the supplementary text is input into a preset conditional random field model, and entity recognition is performed through the conditional random field model to obtain the target entity in the supplementary text.

11. A text classification model training system, characterized in that: The text classification model training system comprises: A sample acquisition module, used to acquire multiple text classification sample sets, wherein each of the text classification sample sets includes multiple training samples of the same category; A sample ratio acquisition module, used to acquire a sample ratio limit range, wherein the sample ratio limit range is used to limit the ratio of the number of training samples in each text classification sample set; A downsampling module, configured to perform downsampling processing on each of the text classification sample sets according to the sample ratio limit range and the number of training samples in each of the text classification sample sets, so as to obtain a plurality of target text sample sets; The model training module is used to train the preset model to be trained according to the target text sample set to obtain a trained text classification model.

12. A text classification system, characterized in that: The text classification system comprises: A text acquisition module is used to acquire the text to be classified; A text classification module is used to input the text to be classified into a text classification model to obtain a text classification result output by the text classification model, wherein the text classification model is trained based on the text classification model training method according to any one of claims 1 to 6.

13. An electronic device, characterized in that: The electronic device includes a memory, a processor, and a text classification model training program stored in the memory and executable on the processor. When the processor executes the text classification model training program, the steps of the text classification model training method according to any one of claims 1 to 6 are implemented.

14. A vehicle, characterized in that: The vehicle includes a memory, a processor, and a text classification program stored in the memory and executable on the processor. When the processor executes the text classification program, the steps of the text classification method according to any one of claims 7 to 10 are implemented.

15. A computer-readable storage medium, characterized in that: A computer program is stored on the computer-readable storage medium. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the text classification model training method described in any one of claims 1 to 6, or the computer program is used to enable the electronic device to execute the steps of the text classification method described in any one of claims 7 to 10.

Citation Information

Cited By

  • Text classification method and device and electronic equipment

    CN118820478A