Text classification method and device, equipment and medium

By introducing classification-limited text prompts and prefix trees into the deep neural network model, combining coding feature data and hidden layer representation, the problems of data scarcity and large-model illusion in text classification are solved, and the accuracy and efficiency of classification are improved, ensuring that The standardization and consistency of output results.

CN119311870APending Publication Date: 2025-01-14BEIJING UNISOUND INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411052143.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The existing deep neural network models have data scarcity and large-model hallucination problems in text classification tasks, resulting in low classification accuracy and high uncertainty, limiting the generalization ability and robustness of the model.

Method used

By introducing classification-limited text prompts and prefix trees, the text classification process is guided, and the encoding feature data and hidden layer representation can be used to efficiently determine the target category and reduce search space and time consumption.

Benefits of technology

It improves the accuracy and robustness of text classification, ensures the standardization and consistency of output results, and improves the efficiency and accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311870A_ABST
    Figure CN119311870A_ABST
Patent Text Reader

Abstract

The invention discloses a text classification method and device, equipment and a medium. By introducing a classification-limited text prompt, a text classification process can be guided more accurately. The classification limited text prompt not only provides candidate category information to which the to-be-classified text possibly belongs, but also defines the output specification of the classification result. The restrictive information enables the large text classification model to more accurately judge the category of the text when processing a complex or fuzzy classification task, and meanwhile, the normalization and consistency of output results are ensured. Meanwhile, as the candidate range is reduced in the classification result generation process of the large text classification model, the decoding speed can be greatly improved, and the time consumption is reduced. By combining the coding feature data, the target hidden layer representation and the prefix tree corresponding to the classification limiting text prompt, the large text classification model can efficiently determine the target category from the candidate category information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of text processing and deep learning technology, and in particular to a text classification method, device, equipment and medium. Background Art

[0002] In the field of Natural Language Processing (NLP), Deep Neural Networks (DNN) have become one of the key technologies for achieving efficient text classification tasks. These models, especially those based on Convolutional Neural Networks (CNN), Recurrent Neural Networks (RNN) and their variants such as Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), and the Transformer model that has emerged in recent years, have significantly improved the accuracy and efficiency of text classification by automatically learning complex feature representations in text. However, although these methods perform well in scenarios with sufficient annotated data, their promotion in practical applications faces a series of challenges.

[0003] First, the difficulty of data collection and labeling is one of the main factors restricting the widespread application of deep neural network models. In natural language processing tasks, high-quality, large-scale labeled datasets are an indispensable cornerstone for training high-performance models. However, in most practical application scenarios, such as text classification tasks in specific fields, collecting and labeling a sufficient amount of data is often time-consuming and expensive, and may even be difficult to implement due to data privacy and copyright issues. This data scarcity limits the generalization ability and accuracy of the model.

[0004] Secondly, the hallucination problem of large models is another problem that needs to be solved urgently. As the model size continues to increase, its ability to handle complex tasks has improved, but it also introduces higher uncertainty. In text classification tasks, this uncertainty is specifically manifested as the instability of classification label generation, that is, the model may give completely different classification results for input texts with extremely high similarity. This phenomenon not only reduces the reliability of classification, but may also cause misleading and wrong decisions in practical applications.

[0005] Therefore, how to reduce the uncertainty of text classification and improve the robustness and accuracy of large classification models has become a research hotspot in the field of natural language processing. Summary of the invention

[0006] The present application provides a text classification method, apparatus, device and medium for solving the problem of hallucination and low accuracy of existing large text classification models.

[0007] In a first aspect, the present application provides a text classification method, the method comprising:

[0008] Acquire a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt information about candidate categories to which the text to be classified may belong in the target classification task, and output specifications of the classification results;

[0009] Obtaining encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of the pre-trained text classification model; wherein the text classification model supports the classification of the target classification task;

[0010] Determining a target hidden layer representation based on the encoded feature data through a transform decoding layer of the text classification model; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs;

[0011] Determine a target category from the candidate category information based on the target hidden layer representation and the prefix tree corresponding to the category-restricted text prompt through the category output layer of the text classification large model;

[0012] Based on the output specification and the target category, the classification result is output according to the output specification.

[0013] In a second aspect, the present application further provides a text classification device, the device comprising:

[0014] An acquisition unit, used to acquire a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt information about a candidate category to which the text to be classified may belong in the target classification task, and an output specification of a classification result;

[0015] A processing unit is used to obtain encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of a pre-trained text classification model; wherein the text classification model supports the classification of the target classification task; through the transform decoding layer of the text classification model, based on the encoding feature data, determine the target hidden layer representation; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs; through the category output layer of the text classification model, based on the prefix tree corresponding to the target hidden layer representation and the classification-limiting text prompt, determine the target category from the candidate category information;

[0016] An output unit is used to output the classification result according to the output specification based on the output specification and the target category.

[0017] In a third aspect, the present application provides a computer device, the computer device comprising a processor, the processor being configured to implement the steps of the above-described text classification method when executing a computer program stored in a memory.

[0018] In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, which implements the steps of the text classification method as described above when executed by a processor.

[0019] The beneficial effects of this application are as follows:

[0020] 1. By introducing classification-restricted text prompts, the text classification process can be guided more accurately. Classification-restricted text prompts not only provide information about the candidate categories to which the text to be classified may belong, but also clarify the output specifications of the classification results. This restrictive information enables the text classification model to more accurately determine the category to which the text belongs when dealing with complex or ambiguous classification tasks, while ensuring the standardization and consistency of the output results. At the same time, because the text classification model reduces the candidate range in the process of generating classification results, it can greatly improve the decoding speed and reduce time consumption.

[0021] 2. By combining the encoding feature data, the target hidden layer representation and the prefix tree corresponding to the classification-limited text prompt, the text classification model can efficiently determine the target category from the candidate category information. The introduction of the prefix tree reduces the search space, speeds up the classification, and makes the entire classification process more efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. 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 paying creative labor.

[0023] Figure 1 A schematic diagram of a text classification process provided in an embodiment of the present application;

[0024] Figure 2 A diagram showing an example structure of a prefix tree provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of a specific text classification process provided for an embodiment of the present application;

[0026] Figure 4 A schematic diagram of the structure of a text classification device provided in an embodiment of the present application;

[0027] Figure 5 It is a structural schematic diagram of a computer device provided in an optional embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0029] In order to reduce the uncertainty of text classification and improve the robustness and accuracy of large classification models, the present application provides a text classification method, device, equipment and medium.

[0030] Embodiment 1:

[0031] This application provides a text classification method. Figure 1 A schematic diagram of a text classification process provided in an embodiment of the present application, the process includes:

[0032] S101: Obtaining a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt the candidate category information to which the text to be classified may belong in the target classification task, as well as the output specification of the classification result.

[0033] In the present application, the text classification method is applied to a computer device, which may be an intelligent terminal, such as a computer, a robot, etc., or a server, such as an application server, a business server, etc.

[0034] In the present application, a computer device for executing a text classification method can obtain a text to be classified for a certain classification task (recorded as a target classification task), and then classify the text to be classified based on the text classification method provided in the present application. Among them, the text to be classified can be collected by the computer device itself, or it can be received from other devices. There are many ways to collect the text to be classified. It can be entered by the user directly through text input, or it can be recorded by the user. Then, the recorded voice is converted into the text to be classified through speech-to-text technology. In the specific implementation process, it can be flexibly set according to actual needs, and no specific limitation is made here.

[0035] Taking into account the different categories included in different classification tasks, such as news classification tasks may include categories such as "technology", "sports", "entertainment", and "politics", e-commerce product classification tasks may include categories such as "clothing", "electronic products", "household items", and "food", and sentiment analysis tasks may include "positive", "negative", "neutral" and other sentiment tendency categories. Therefore, in order to more accurately guide the text classification process, in this application, corresponding classification-limited text prompts are set in advance for different classification tasks. The classification-limited text prompt not only contains the candidate category information to which the text to be classified may belong in the target classification task, but also clarifies the output specification of the classification result. For example, in the sentiment analysis task, the classification-limited text prompt may be as follows: "Please give the category of the above paragraph in Json format, the format is as follows: {"category":"candidate category"}", and the selectable candidate categories are {'positive emotion', 'negative emotion', 'neutral emotion'}. "Subsequently, when classifying the text to be classified for a certain classification task, the classification-limited text prompt corresponding to the classification task can be obtained, so as to limit the classification range predicted by the text classification model through the classification-limited text prompt, thereby avoiding the hallucination problem of the text classification model and improving the accuracy of the output results of the text classification model.

[0036] S102: Obtaining encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of a pre-trained text classification model; wherein the text classification model supports the classification of the target classification task.

[0037] In the present application, a large text classification model that supports the target classification task is pre-trained to determine the category to which the text to be classified belongs through the large text classification model. After obtaining the text to be classified of the target classification task and the classification-limited text prompt corresponding to the target classification task based on the above embodiment, the text to be classified and the classification-limited text prompt can be spliced, and then the spliced ​​text can be input into the large text classification model. The spliced ​​text is processed through the large text classification model, that is, the text to be processed is classified in combination with the classification-limited text prompt to determine the target category to which the text to be processed belongs.

[0038] In order to facilitate the text classification model to understand the input text, in this application, the text classification model includes an encoding layer, which is the core part of the text classification model and is responsible for converting the input text data into a vector representation in a high-dimensional space, that is, encoding feature data. This process not only captures the lexical information in the text, but also deeply explores the semantic relationship, contextual dependency and potential classification clues between texts.

[0039] Among them, the category-limited text prompts, as a kind of auxiliary information, can guide the encoding layer of the text classification model to focus more on the feature extraction related to the target classification task. For example, in the sentiment analysis task, if the category-limited text prompt specifies the framework of "positive emotion" or "negative emotion", the text classification model will be more sensitive to capture the vocabulary and sentence structure expressing emotions in the text during encoding, thereby generating more discriminative encoding feature data.

[0040] In a possible implementation, the text to be classified and the classification-limited text prompt are input into the encoding layer as a whole. The two types of text information can be distinguished by specific marks (such as special symbols, separators) so that the model can recognize and distinguish them.

[0041] For example, X input =[x1,x2…,x n ] represents the token sequence of the text to be classified, and adds the classification-limited text prompt prompt = [p1, p2, ..., p m ], and X input Putting it together, the input of the entire text classification model can be expressed as:

[0042] model input =X input +prompt

[0043] That is, the input of the text classification model is: model input =[x1,x2…,x n ,p1,p2,…,p m ].

[0044] In one example, the encoding layer of the pre-trained text classification model obtains encoding feature data based on the text to be classified and the classification-limited text prompt, including:

[0045] Through the encoding layer, based on the text to be classified and the classification-limited text prompt, the encoding feature data corresponding to each text unit in the text to be classified is obtained.

[0046] In order to more finely capture the interactive information between the text to be classified and the classification-limited text prompts, as well as the contribution of each unit in the text (such as words, phrases or characters) to the classification decision, in this application, within the encoding layer, the text classification model will perform word segmentation or character segmentation on the input text, and decompose the long text into a series of text units (such as words, phrases or characters). Then, for each text unit, the text classification model will use the neural network structure in the encoding layer (such as convolutional neural network CNN, recurrent neural network RNN ​​or Transformer, etc.) to process the text unit, so as to obtain the encoding feature data corresponding to each text unit. Among them, these encoding feature data not only contain the information of the text unit itself, but also incorporate the contextual information of the surrounding text units.

[0047] Furthermore, in order to more accurately reflect the impact of classification-limited text prompts on the encoded feature data, the text classification model may also pay special attention to these prompt information during the encoding process. For example, the encoded feature data of the classification-limited text prompts is weighted to the encoded feature data of each text unit of the text to be classified through the attention mechanism to enhance the model's attention and sensitivity to the target classification task.

[0048] For example, each text unit corresponds to the encoding feature data u=[u1,u2…,u n ], for the encoding feature data u corresponding to the i-th text unit i It can be expressed as:

[0049] u i =g emb (model input (i))

[0050] Among them, i represents the i-th text unit, g emb Represents the encoding process of the encoding layer, model input Characterize the text to be classified and the classification-limited text prompt.

[0051] S103: Determine a target hidden layer representation based on the encoded feature data through the transform decoding layer of the text classification model; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs.

[0052] After the encoded feature data is obtained, these features will be further processed to make the final classification decision. Based on this, in the present application, the text classification model also includes a variation decoding layer connected to the encoding layer, so as to further process the encoded feature data through the variation decoding layer and extract the target hidden layer representation that can characterize the characteristics of the category to be classified.

[0053] Exemplarily, the transform decoding layer may include multiple neural network layers, such as fully connected layers, convolutional layers, or recurrent neural network layers, which map the encoded feature data to a new feature space through complex nonlinear transformations to form a target hidden layer representation. This hidden layer representation not only retains the key information of the original text, but also strengthens the features related to the classification task through the learning ability of the model, making it more capable of representing the category features to which the text to be classified belongs.

[0054] In one possible implementation, the transform decoding layer includes multiple decoder blocks, which are responsible for processing the decoding process of the current text unit. The multiple decoder blocks are logically processed in sequence according to the order of the text units. The multiple decoders share the same model parameters and run iteratively at each time step. At any decoding time step, the input of the current decoder block includes the encoded feature data of the current text unit and the hidden layer representation of the output of the decoder block at the previous time step.

[0055] In order to more effectively handle the temporal dependency and long-distance dependency problems in text sequences, the transform decoding layer may include multiple decoder blocks, each of which is responsible for processing the decoding process of the current text unit, and may contain multiple neural network layers (such as self-attention layers, feedforward neural network layers, etc.) to perform complex transformations and extractions on the input data. These decoder blocks are logically processed in the order of text units, thereby ensuring that the text classification model can capture the temporal information in the text. When processing a text sequence, multiple decoder blocks will proceed in the order of text units. This means that after processing the decoding of a text unit, the text classification model will move to the next text unit and repeat the same decoding process. Among them, these decoder blocks share the same model parameters, which means that they perform the same transformation operation but are applied to different text units. This parameter sharing mechanism not only reduces the number of parameters of the model, but also helps the model learn more generalized feature representations. At each time step (i.e., when processing each text unit), the input of the current decoder block not only includes the encoded feature data of the current text unit, but also receives the hidden layer representation output from the decoder block of the previous time step. This design allows the model to accumulate and pass contextual information during decoding, so that previous information can be taken into account when processing subsequent text units. The transfer of hidden layer representations enables large text classification models to capture long-range dependencies in text and improve classification accuracy.

[0056] For example, the hidden layer representation of any decoder block output is as follows:

[0057]

[0058] in, represents the hidden representation output by the lth decoder block at the tth time step. There are L decoder blocks in total, t is greater than 1 and less than or equal to n, and n is the total number of text units. Therefore, the target hidden representation is the hidden representation s output by the Lth decoder block at the nth time step. n L .

[0059] S104: Determine a target category from the candidate category information based on the target hidden layer representation and a prefix tree corresponding to the category-restricted text prompt through the category output layer of the text classification large model.

[0060] In the present application, the text classification model also includes a category output layer connected to the transform decoding layer, so that the target category can be determined by combining the target hidden layer representation (i.e., the internal representation generated by the text classification model after processing the text sequence, which captures the important features and contextual information of the text) and the prefix tree corresponding to the classification-limited text prompt through the category output layer.

[0061] Exemplarily, the category output layer can fuse the target hidden layer representation with the category-limited text prompt in some form. This fusion may be achieved through an attention mechanism, a gating mechanism, or other means, so that the text classification model can take into account both the characteristics of the text itself and the category-limited conditions given by the user or the system when making classification decisions. Then, the category output layer can use a prefix tree to quickly retrieve and match the candidate category information most relevant to the given text to narrow the scope of the candidate categories, thereby improving the accuracy and efficiency of classification. Figure 2 This is a diagram showing an example of a prefix tree structure provided by an embodiment of the present application. Finally, the category output layer determines a target category from the candidate category information based on the fused features and the matching results of the prefix tree.

[0062] In a possible implementation, determining the target category from the candidate category information through the category output layer of the text classification model based on the target hidden layer representation and the prefix tree corresponding to the category-restricted text prompt includes:

[0063] Filtering each candidate category information from the category-restricted text prompt through the prefix tree;

[0064] Determine the category features corresponding to each of the candidate category information from the full category feature table;

[0065] For each candidate category information, determining the distribution probability of the to-be-classified text on the candidate category information according to the target hidden layer representation and the category feature corresponding to the candidate category information;

[0066] The target category is determined based on the distribution probabilities respectively corresponding to each of the candidate category information.

[0067] In the present application, the category output layer can use the prefix tree structure that has been constructed to quickly match and retrieve the input classification-limited text prompts. Each node or path in the prefix tree corresponds to one or more classification-limited conditions, through which the candidate category information set that meets the current text classification requirements can be effectively screened out. This step greatly reduces the amount of data to be processed later and improves the classification efficiency. Then, the category output layer retrieves the category features corresponding to each candidate category information from the full category feature table. The full category feature table is a predefined data structure that contains detailed feature descriptions of all possible categories, such as keywords, topic tags, emotional tendencies, etc. By searching this table, a multi-dimensional feature vector can be constructed for each candidate category information, and these feature vectors will be used for subsequent classification decisions. For each candidate category information screened out, the target hidden layer representation (i.e., the high-level abstract representation of the text) of the text classification model and the category features corresponding to the candidate category information are used to calculate the distribution probability of the text to be classified on the candidate category through a specific algorithm (such as a multi-layer perceptron, softmax regression, etc.). This probability reflects the possibility that the text to be processed belongs to the candidate category, which is an important basis for determining the target category later. Finally, based on the distribution probabilities corresponding to all candidate category information, a certain strategy (such as selecting the category with the highest probability, setting a probability threshold, etc.) is used to determine the target category. If the model design considers the possibility of multiple categories (such as multi-label classification), it may be necessary to select multiple categories as target categories at the same time. After determining the target category, it can be output to the subsequent processing flow or user interface to complete the entire text classification task.

[0068] It should be noted that the specific algorithms and parameter settings in the above steps may be adjusted and optimized according to different application scenarios and model architectures. For example, when calculating the distribution probability, different neural network layers or activation functions can be selected to improve the performance of the model; when determining the target category, more complex decision logic can also be designed according to actual needs to cope with complex classification scenarios.

[0069] For example, the category output layer determines the target category from the candidate category information based on the prefix tree corresponding to the target hidden layer representation and the category-restricted text prompt, which can be expressed by the following formula:

[0070] Prob gen =softmax(W·s n L + b);

[0071] Z n =Max(Prob gen );

[0072] Among them, Prob gen represents the distribution probability corresponding to each candidate category information, W represents the category features corresponding to each candidate category information from the full category feature table, b is a hyperparameter, represents the target hidden layer representation, Z n Represents the target category, softmax() represents the softmax function processing, and Max() represents the maximum value of the distribution probability.

[0073] In a possible implementation, the category-limited text prompt includes at least one positive sample text corresponding to candidate category information.

[0074] Positive sample text provides the text classification model with one or more examples that clearly belong to a candidate category. These examples help the text classification model understand the characteristics of the category and strengthen the text classification model's learning of the category characteristics, so that it can more accurately identify text related to the category during the classification process. During classification, the text classification model can more easily classify text with similar characteristics into the candidate category, thereby improving the accuracy of classification.

[0075] When using prefix trees to filter candidate categories, if the category-limiting text prompt contains a positive sample text of a candidate category, then the category is more likely to be selected as a candidate category for further analysis. This helps reduce unnecessary category searches and improve classification efficiency.

[0076] The beneficial effects of this application are as follows:

[0077] 1. By introducing classification-restricted text prompts, the text classification process can be guided more accurately. Classification-restricted text prompts not only provide information about the candidate categories to which the text to be classified may belong, but also clarify the output specifications of the classification results. This restrictive information enables the text classification model to more accurately determine the category to which the text belongs when dealing with complex or ambiguous classification tasks, while ensuring the standardization and consistency of the output results. At the same time, because the text classification model reduces the candidate range in the process of generating classification results, it can greatly improve the decoding speed and reduce time consumption.

[0078] 2. By combining the encoding feature data, the target hidden layer representation and the prefix tree corresponding to the classification-limited text prompt, the text classification model can efficiently determine the target category from the candidate category information. The introduction of the prefix tree reduces the search space, speeds up the classification, and makes the entire classification process more efficient.

[0079] Embodiment 2:

[0080] In order to accurately perform text classification, based on the above embodiments, in this application, the text classification model is trained in the following manner:

[0081] Obtain any sample text in a sample set and classification label data corresponding to the sample text; wherein the sample set includes sample text of at least one classification task, the at least one classification task includes the target classification task, each of the classification tasks corresponds to a classification-restricted text prompt, and the classification label data is used to identify the standard classification to which the sample text belongs;

[0082] Determine the desired classification based on the sample text and the classification-limited text prompt corresponding to the classification task to which the sample text belongs, through the basic text classification model;

[0083] Based on the standard classification and the expected classification, the basic text classification model is trained to obtain the trained text classification model.

[0084] In order to improve the accuracy and generalization ability of the text classification model, in this application, it is necessary to construct a sample set containing at least one classification task sample text, so as to train the basic text classification model through the sample set to obtain a trained text classification model. Among them, the at least one classification task includes a target classification task, and each sample text is accompanied by corresponding classification label data, which clearly indicates the standard classification to which the sample text belongs. In addition, for each classification task, a corresponding classification-limited text prompt is defined to assist the model in better understanding the classification context.

[0085] The text classification model can be an untrained original model or a pre-trained model based on different text data with natural language understanding capabilities. The pre-trained model can use existing knowledge to accelerate the learning process of new tasks.

[0086] Exemplarily, a sample text and its corresponding classification label and classification-limited text prompt are randomly selected from the sample set. The sample text and the corresponding classification-limited text prompt are input into the basic text classification model, and the basic text classification model generates an expected classification based on this information. The expected classification generated by the basic text classification model is compared with the standard classification of the sample text, and the difference between the two (such as cross entropy loss, etc.) is used to update the model parameters. This process is iterated until the performance of the basic text classification model on the training sample reaches a preset convergence condition, such as the loss value is lower than a preset threshold, the loss value continues to decrease and stabilizes, or the set maximum number of iterations is reached.

[0087] In order to evaluate the performance of the trained text classification model, the sample set can be divided into a training set and a validation set. First, the basic text classification model is trained based on the training set, and then the model's classification accuracy, recall rate and other key indicators are evaluated using the validation set. Based on the validation results, the text classification model can be further adjusted and optimized to improve its generalization ability on unknown data.

[0088] Through the above steps, a large text classification model can be trained that can accurately identify text categories under the target classification task. This large text classification model not only has powerful natural language understanding capabilities, but also can provide accurate classification predictions based on specific classification tasks.

[0089] It should be noted that the computer device used to train the basic text classification model can be the same as or different from the computer device for text classification. For example, after the computer device for training the basic text classification model has trained the text classification model, the trained text classification model can be saved in the computer device for text classification.

[0090] Embodiment 3:

[0091] Figure 3 A schematic diagram of a specific text classification process provided in an embodiment of the present application, the process includes:

[0092] S301: Acquire the text to be classified of the target classification task and the classification-limited text prompt corresponding to the target classification task.

[0093] Among them, the classification-limited text prompt is used to prompt the candidate category information to which the text to be classified may belong in the target classification task, as well as the output specifications of the classification results.

[0094] In a possible implementation, the category-limited text prompt may further include at least one positive sample text corresponding to candidate category information.

[0095] For example, the original Prompt is constructed into a fixed output format with Json format. The original Prompt is: "Please classify the above paragraph." Modify it to: "Please give the category of the above sentence in Json format, the format is as follows: \n{"category":"candidate category"}". Then add candidate category information to the updated Prompt, that is, modify the updated Prompt to: Please give the category of the above sentence in Json format, the format is as follows: \n{"category":"candidate category"}", the selectable candidate categories are {'category label 1', 'category label 2',..., 'category label n'}. The Prompt with the added candidate category information gives the positive sample example information, and the Prompt with the added candidate category information is modified to the following category-limited text prompt:

[0096] {

[0097] [Paragraph 1]

[0098] Please give the category of the above paragraph in Json format. The format is as follows: {"category":"candidate category"}", and the selectable candidate categories are {'positive sentiment', 'negative sentiment', 'neutral sentiment'}.

[0099] Here is an example:

[0100] This movie is quite well made.

[0101] Please give the above sentence categories in Json format:

[0102] {“category”:”sentiment positive”}

[0103] }.

[0104] S302: Obtain a large text classification model for a target classification task.

[0105] In one possible implementation, the text classification model is trained in the following manner:

[0106] Obtain any sample text in the sample set and classification label data corresponding to the sample text; wherein the sample set includes sample text of at least one classification task, at least one classification task includes a target classification task, each classification task corresponds to a classification-restricted text prompt, and the classification label data is used to identify the standard classification to which the sample text belongs;

[0107] Determine the expected classification through the basic text classification model based on the sample text and the classification-limited text prompts corresponding to the classification task to which the sample text belongs;

[0108] Based on standard classification and expected classification, the basic text classification model is trained to obtain a trained text classification model.

[0109] In a possible implementation, the basic text classification big model is an untrained original big model, or a big model that has been pre-trained based on different text data and has natural language understanding capabilities.

[0110] S303: Obtain the encoding feature data corresponding to each text unit in the text to be classified through the encoding layer of the text classification model based on the text to be classified and the classification-limited text prompt.

[0111] S304: Determine the target hidden layer representation based on the encoded feature data through the transform decoding layer of the text classification model.

[0112] Among them, the target hidden layer represents the category features used to characterize the category of the text to be classified.

[0113] Among them, the transform decoding layer contains multiple decoder blocks, which are responsible for processing the decoding process of the current text unit. The multiple decoder blocks are logically processed in sequence according to the order of the text units. The multiple decoders share the same model parameters and run iteratively at each time step; at any decoding time step, the input of the current decoder block includes the encoded feature data of the current text unit and the hidden layer representation of the output of the decoder block at the previous time step.

[0114] S305: Through the category output layer of the text classification model, through the prefix tree, filter out each candidate category information from the category-limited text prompts; determine the category features corresponding to each candidate category information from the full category feature table; for each candidate category information, determine the distribution probability of the text to be classified on the candidate category information according to the target hidden layer representation and the category features corresponding to the candidate category information; determine the target category based on the distribution probabilities corresponding to each candidate category information.

[0115] S306: Based on the output specification and the target category, output the classification result according to the output specification.

[0116] Embodiment 4:

[0117] Based on the same inventive concept, the present application also provides a text classification device, Figure 4 A schematic diagram of the structure of a text classification device provided in an embodiment of the present application, the device comprising:

[0118] The acquisition unit 41 is used to acquire the to-be-classified text of the target classification task and the classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt the candidate category information to which the to-be-classified text may belong in the target classification task, and the output specification of the classification result;

[0119] The processing unit 42 is used to obtain encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of the pre-trained text classification model; wherein the text classification model supports the classification of the target classification task; through the transform decoding layer of the text classification model, based on the encoding feature data, determine the target hidden layer representation; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs; through the category output layer of the text classification model, based on the prefix tree corresponding to the target hidden layer representation and the classification-limiting text prompt, determine the target category from the candidate category information;

[0120] The output unit 43 is used to output the classification result according to the output specification based on the output specification and the target category.

[0121] The text classification device in this embodiment is presented in the form of a functional module, where the module refers to an application specific integrated circuit (ASIC), a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0122] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0123] Embodiment 5:

[0124] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present application, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.

[0125] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0126] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0127] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of a computer device based on the presentation of a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0128] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0129] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0130] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.

[0131] Embodiment 6:

[0132] On the basis of the above embodiments, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor implements the following steps when executing:

[0133] Acquire a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt information about candidate categories to which the text to be classified may belong in the target classification task, and output specifications of the classification results;

[0134] Obtaining encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of the pre-trained text classification model; wherein the text classification model supports the classification of the target classification task;

[0135] Determining a target hidden layer representation based on the encoded feature data through a transform decoding layer of the text classification model; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs;

[0136] Determine a target category from the candidate category information based on the target hidden layer representation and the prefix tree corresponding to the category-restricted text prompt through the category output layer of the text classification large model;

[0137] Based on the output specification and the target category, the classification result is output according to the output specification.

[0138] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the text classification method, the implementation of the above-mentioned computer-readable storage medium can refer to the embodiment of the method, and the repeated parts will not be repeated.

[0139] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A text classification method, characterized in that: The method comprises: Acquire a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt information about candidate categories to which the text to be classified may belong in the target classification task, and output specifications of the classification results; Obtaining encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of the pre-trained text classification model; wherein the text classification model supports the classification of the target classification task; Determining a target hidden layer representation based on the encoded feature data through a transform decoding layer of the text classification model; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs; Determine a target category from the candidate category information based on the target hidden layer representation and the prefix tree corresponding to the category-restricted text prompt through the category output layer of the text classification large model; Based on the output specification and the target category, the classification result is output according to the output specification.

2. The method according to claim 1, characterized in that The encoding layer of the pre-trained text classification model obtains encoding feature data based on the text to be classified and the classification-limited text prompt, including: Through the encoding layer, based on the text to be classified and the classification-limited text prompt, the encoding feature data corresponding to each text unit in the text to be classified is obtained.

3. The method according to claim 2, characterized in that The transform decoding layer includes multiple decoder blocks, which are responsible for processing the decoding process of the current text unit. The multiple decoder blocks are logically processed in sequence according to the order of the text units. The multiple decoders share the same model parameters and run iteratively at each time step. At any decoding time step, the input of the current decoder block includes the encoded feature data of the current text unit and the hidden layer representation of the output of the decoder block at the previous time step.

4. The method according to claim 1, characterized in that The step of determining the target category from the candidate category information through the category output layer of the text classification model based on the target hidden layer representation and the prefix tree corresponding to the category-limited text prompt comprises: Filtering each candidate category information from the category-restricted text prompt through the prefix tree; Determine the category features corresponding to each of the candidate category information from the full category feature table; For each candidate category information, determining the distribution probability of the to-be-classified text on the candidate category information according to the target hidden layer representation and the category feature corresponding to the candidate category information; The target category is determined based on the distribution probabilities respectively corresponding to each of the candidate category information.

5. The method according to claim 1, characterized in that The category-restricted text prompt includes at least one positive sample text corresponding to candidate category information.

6. The method according to claim 1, characterized in that The text classification model is trained in the following way: Obtain any sample text in a sample set and classification label data corresponding to the sample text; wherein the sample set includes sample text of at least one classification task, the at least one classification task includes the target classification task, each of the classification tasks corresponds to a classification-restricted text prompt, and the classification label data is used to identify the standard classification to which the sample text belongs; Determine the desired classification based on the sample text and the classification-limited text prompt corresponding to the classification task to which the sample text belongs, through the basic text classification model; Based on the standard classification and the expected classification, the basic text classification model is trained to obtain the trained text classification model.

7. The method according to claim 6, characterized in that The basic text classification model is an untrained original model, or a model that has been pre-trained based on different text data and has natural language understanding capabilities.

8. A text classification device, characterized in that: The device comprises: An acquisition unit, used to acquire a text to be classified of a target classification task and a classification-limited text prompt corresponding to the target classification task; wherein the classification-limited text prompt is used to prompt information about a candidate category to which the text to be classified may belong in the target classification task, and an output specification of a classification result; A processing unit is used to obtain encoding feature data based on the text to be classified and the classification-limiting text prompt through the encoding layer of a pre-trained text classification model; wherein the text classification model supports the classification of the target classification task; through the transform decoding layer of the text classification model, based on the encoding feature data, determine the target hidden layer representation; wherein the target hidden layer representation is used to characterize the category features to which the text to be classified belongs; through the category output layer of the text classification model, based on the prefix tree corresponding to the target hidden layer representation and the classification-limiting text prompt, determine the target category from the candidate category information; An output unit is used to output the classification result according to the output specification based on the output specification and the target category.

9. A computer device, characterized in that: The computer device comprises a processor, and the processor is used to implement the steps of the text classification method as described in any one of claims 1 to 7 when executing a computer program stored in a memory.

10. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device. When the program is run on the computer device, the computer device executes the steps of the text classification method as described in any one of claims 1 to 7.