Text classification method and device, computing equipment and storage medium

The text classification method enhances multi-label classification accuracy by using a large language model with annotated sample sets and closed-loop optimization, addressing the inefficiencies of traditional algorithms in handling complex and diverse classification tasks.

CN119149744APending Publication Date: 2024-12-17SHANGHAI 100 METERS NETWORK TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411245148.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Existing multi-label text classification algorithms are time-consuming, labor-intensive, and struggle to handle complex and diverse classification requirements, especially when utilizing large language models.

Method used

A text classification method utilizing a large language model with a first annotated sample set covering all classification labels and a second annotated sample set with high similarity to the text data, enhancing accuracy through prompt words and closed-loop optimization.

Benefits of technology

Improves the accuracy of multi-label text classification by leveraging the large language model's context understanding and generation capabilities, while ensuring high similarity and diverse sample sets for better learning, leading to accurate label generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149744A_ABST
    Figure CN119149744A_ABST
Patent Text Reader

Abstract

The invention provides a text classification method and device, computing equipment and a storage medium. The method comprises the steps of obtaining to-be-classified text data; selecting a first labeled sample set from a plurality of classified samples of the historical data set; wherein the classification labels corresponding to the plurality of classified samples in the first labeling sample set cover preset classification labels; selecting a plurality of classified samples from the historical data set, wherein the similarity between the classified samples and the to-be-classified text data is greater than a first threshold value, and taking the selected samples as a second labeled sample set; inputting the to-be-classified text data, the first annotation sample set and the second annotation sample set into a large language model as cue words, and determining a classification label corresponding to the to-be-classified text data according to an output result of the large language model; wherein the to-be-classified text data is subjected to text classification to serve as tasks in cue words; and taking the first annotation sample set and the second annotation sample set as examples in the cue word. According to the scheme, the multi-label text classification problem can be effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text classification method, apparatus, computing device and storage medium. Background Art

[0002] With the explosive growth of Internet content and the diversification of information classification needs, a single text data may contain multiple classification labels.

[0003] Most traditional multi-label text classification algorithms try to use a large number of training samples to train different neural network models, and then compare the classification accuracy between different neural network models, so as to select the neural network model with higher accuracy for application in actual scenarios. This method requires collecting a large number of training samples, and different neural network models need to be selected for different scenarios. It is not only time-consuming and labor-intensive, but also difficult to cope with complex and diverse classification requirements.

[0004] Large language models have powerful context understanding and generation capabilities, but how to apply them to multi-label text classification problems remains to be solved. Summary of the invention

[0005] The present application provides a text classification method, apparatus, computing device and storage medium, which can effectively handle multi-label text classification problems.

[0006] In the first aspect, the embodiment of the present application provides a text classification method, which can be executed by a text classification device, and the text classification device can be a terminal device or a module for a terminal device, or a server or a module for a server. The present application does not limit the execution subject of the method. The method includes: obtaining text data to be classified; selecting a first annotated sample set from multiple classified samples of a historical data set; wherein each classified sample corresponds to at least one classification label, and the classification labels corresponding to the multiple classified samples in the first annotated sample set cover the preset classification labels; selecting multiple classified samples whose similarity with the text data to be classified is greater than a first threshold from the historical data set as a second annotated sample set; inputting the text data to be classified, the first annotated sample set and the second annotated sample set as prompt words into a large language model, and determining the classification label corresponding to the text data to be classified according to the output result of the large language model; wherein, text classification of the text data to be classified is used as a task in the prompt word; and the first annotated sample set and the second annotated sample set are used as examples in the prompt word.

[0007] In the above scheme, on the one hand, a large language model is used to classify the text data to be classified. Since the large language model has powerful context understanding and generation capabilities, it has relative advantages in processing complex text data and multi-label systems, so it can automatically generate multiple labels suitable for text data, thereby realizing accurate multi-label classification of text data; on the other hand, the prompt words of the large language model include a first labeled sample set and a second labeled sample set. The first labeled sample set covers all classification labels, so that the large language model can understand all classification labels; the second labeled sample set has a high similarity with the text data to be classified, so that the large language model can obtain the classification label of the text data to be classified based on the classified text data that has a high similarity with the text data to be classified, thereby improving the accuracy of text classification.

[0008] In a possible implementation method, for any classified sample in the historical data set, if the degree of matching between the text data and the classification label in the classified sample is greater than a second threshold, the classified sample is selected into the first labeled sample set.

[0009] In the above scheme, in the first annotated sample set, the matching degree between the text data and the classification labels in the classified samples is relatively high, so that the large language model can better learn the relationship between the text data and the classification labels, thereby improving the accuracy of text classification.

[0010] In a possible implementation method, a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold and are not in the first annotated sample set are selected from the historical data set as the second annotated sample set.

[0011] The above scheme ensures that the text data in the second labeled sample is different from that in the first labeled sample, thereby increasing the number of classified samples input into the large language model, so that the large language model can better learn the relationship between text data and classification labels based on more samples, thereby improving the accuracy of text classification.

[0012] In a possible implementation method, the text data to be classified is segmented to obtain multiple words; the multiple words are converted into corresponding word vectors, and a first text vector corresponding to the text data to be classified is obtained based on the word vector; for any classified sample in the historical data set, a classified sample corresponding to a second text vector whose similarity with the first text vector is greater than a first threshold is selected as the second labeled sample set; the second text vector is composed of the word vectors corresponding to the classified sample.

[0013] The above scheme uses text vectors to improve the accuracy of text similarity comparison, so that the similarity between the classified samples in the second labeled sample set and the text data to be classified is higher. Further, the large language model can better learn the relationship between text data and classification labels, thereby improving the accuracy of text classification.

[0014] In a possible implementation method, the text data to be classified and the text data of multiple classified samples in the historical data set are clustered to obtain clustering results; from the clustering results with the same clustering category as the text data to be classified, multiple classified samples whose similarity with the text data to be classified is greater than a first threshold are selected as the second labeled sample set.

[0015] The above scheme first performs clustering processing, and then selects multiple classified samples whose similarity with the text data to be classified is greater than a first threshold from the clustering results of the same clustering category as the text data to be classified as the second labeled sample set, which can improve the accuracy of text similarity comparison, so that the classified samples in the second labeled sample set have a higher similarity with the text data to be classified. Further, the large language model can better learn the relationship between text data and classification labels, thereby improving the accuracy of text classification.

[0016] In a possible implementation method, incorrectly classified text data output by a large language model is collected, and the classification labels corresponding to the incorrectly classified text data are corrected; the incorrectly classified text data and the corrected classification labels are added to the historical data set.

[0017] The above solution automatically generates text classification labels for production data, and continuously optimizes prompt words and the large language model by collecting and analyzing misclassified text data output by the large language model, forming a closed-loop optimization process, which can gradually improve the accuracy of text classification of the large language model.

[0018] In a second aspect, an embodiment of the present application provides a text classification device, including: an acquisition unit, a selection unit, and a determination unit. The acquisition unit is used to acquire text data to be classified; the selection unit is used to select a first annotated sample set from multiple classified samples in a historical data set; wherein each classified sample corresponds to at least one classification label, and the classification labels corresponding to multiple classified samples in the first annotated sample set cover preset classification labels; multiple classified samples whose similarity to the text data to be classified is greater than a first threshold are selected from the historical data set as a second annotated sample set; the determination unit is used to input the text data to be classified, the first annotated sample set, and the second annotated sample set as prompt words into a large language model, and determine the classification label corresponding to the text data to be classified according to the output result of the large language model; wherein text classification of the text data to be classified is used as a task in the prompt word; and the first annotated sample set and the second annotated sample set are used as examples in the prompt word.

[0019] In a possible implementation method, the selection unit is specifically used to select any classified sample in the historical data set into the first labeled sample set if the degree of matching between the text data and the classification label in the classified sample is greater than a second threshold.

[0020] In a possible implementation method, the selection unit is specifically configured to select, from the historical data set, a plurality of classified samples whose similarity to the text data to be classified is greater than a first threshold and which are not in the first annotated sample set, as the second annotated sample set.

[0021] In a possible implementation method, the selection unit is specifically used to perform word segmentation on the text data to be classified to obtain multiple words; convert the multiple words into corresponding word vectors, and obtain a first text vector corresponding to the text data to be classified based on the word vectors; for any classified sample in the historical data set, select a classified sample corresponding to a second text vector whose similarity with the first text vector is greater than a first threshold as the second labeled sample set; the second text vector is composed of the word vectors corresponding to the classified sample.

[0022] In a possible implementation method, the selection unit is specifically used to cluster the text data to be classified and the text data of multiple classified samples in the historical data set to obtain a clustering result; from the clustering results with the same clustering category as the text data to be classified, select multiple classified samples whose similarity with the text data to be classified is greater than a first threshold as the second labeled sample set.

[0023] In a possible implementation method, the above-mentioned device also includes an updating unit, which is used to collect incorrectly classified text data output by the large language model and correct the classification labels corresponding to the incorrectly classified text data; and add the incorrectly classified text data and the corrected classification labels to the historical data set.

[0024] In a third aspect, an embodiment of the present application further provides a computing device, including:

[0025] A memory for storing program instructions;

[0026] The processor is used to call the program instructions stored in the memory, and execute any method of implementing the above-mentioned first aspect according to the obtained program instructions.

[0027] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which computer-readable instructions are stored. When a computer reads and executes the computer-readable instructions, any method of the above-mentioned first aspect is implemented.

[0028] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising a computer program executable by a computer device, wherein when the program is run on the computer device, the computer device executes any method for implementing the above-mentioned first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A flowchart of a text classification method provided in an embodiment of the present application;

[0030] Figure 2 A flowchart of a text classification method provided in an embodiment of the present application;

[0031] Figure 3 A flowchart of a text classification method provided in an embodiment of the present application;

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

[0033] Figure 5 A schematic diagram of the structure of a text classification device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] Figure 1 A flowchart of a text classification method provided in an embodiment of the present application, the method can be executed by a text classification device, the text classification device can be a terminal device or a module for a terminal device, or a server or a module for a server. The present application does not limit the execution subject of the method.

[0035] The method comprises the following steps:

[0036] Step 101, obtaining text data to be classified.

[0037] Step 102: Select a first labeled sample set from a plurality of classified samples in the historical data set.

[0038] Each classified sample corresponds to at least one classification label, and the classification labels corresponding to the multiple classified samples in the first labeled sample set cover the preset classification labels.

[0039] In a possible implementation method, the historical data set is text data in an actual application scenario acquired in real time, or text data designed artificially according to certain rules. This application does not limit this.

[0040] In a possible implementation method, for any classified sample in the historical data set, if the degree of match between the text data and the classification label in the classified sample is greater than a second threshold, the classified sample is selected into the first annotated sample set. The second threshold is not limited in this application. In this solution, in the first annotated sample set, the degree of match between the text data and the classification label in the classified sample is relatively high, so that the large language model can better learn the relationship between the text data and the classification label, thereby improving the accuracy of text classification.

[0041] In a possible implementation method, the number of samples N in the first labeled sample set is determined, and the classified samples are sorted according to the degree of match between the text data and the classification labels, and the top N classified samples with the highest matching degree are selected into the first labeled sample set, where N is a positive integer.

[0042] In one possible implementation method, the degree of match between the text data in the classified sample and the classification label is determined according to a machine learning algorithm. The present application does not limit the machine learning algorithm for determining the degree of match between the text data in the classified sample and the classification label. For example, it can be a convolutional neural network (CNN), a deep neural network (DNN), etc.

[0043] In one possible implementation method, the degree of match between the text data in the classified sample and the classification label is determined according to a preset rule. The preset rule is a rule artificially formulated or a rule obtained by a statistical analysis algorithm based on historical data. This application does not limit the setting of the preset rule.

[0044] Step 103: input the text data to be classified and the first annotated sample set as prompt words into a large language model, and determine the classification label corresponding to the text data to be classified according to the output result of the large language model.

[0045] Herein, text classification of the text data to be classified is used as a task in the prompt word; and the first annotated sample set is used as an example in the prompt word.

[0046] The Big Language Model is an artificial intelligence technology based on deep learning. Its core is to use large-scale data sets to train the model so that it can understand and generate natural language text. These models learn and simulate the complex laws of human language through a stacked neural network structure, achieving text generation capabilities close to human levels.

[0047] In a possible implementation method, text classification of the text data to be classified is used as a task in the prompt word; the first annotated sample set is used as an example in the prompt word, the prompt word is input into a language model, and the classification label corresponding to the text data to be classified is determined according to the output result of the large language model.

[0048] In the above scheme, on the one hand, a large language model is used to classify the text data to be classified. Since the large language model has powerful context understanding and generation capabilities, it has relative advantages in processing complex text data and multi-label systems. Therefore, it can automatically generate multiple labels suitable for text data, thereby realizing accurate multi-label classification of text data; on the other hand, the prompt words of the large language model include a first labeled sample set, and the first labeled sample set covers all classification labels, so that the large language model can understand all classification labels, thereby improving the accuracy of text classification.

[0049] The present application provides another embodiment. The difference between this embodiment and the above embodiment is that this embodiment introduces a second labeled sample set. The specific implementation process of this embodiment is as follows: Figure 2 As shown, the method comprises the following steps:

[0050] Step 201, obtaining text data to be classified.

[0051] Step 202: Select a first labeled sample set from a plurality of classified samples in the historical data set.

[0052] Each classified sample corresponds to at least one classification label, and the classification labels corresponding to the multiple classified samples in the first labeled sample set cover the preset classification labels.

[0053] Step 203 : Selecting a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold from the historical data set as a second annotated sample set.

[0054] In one possible implementation method, the number of samples M in the second labeled sample set is determined, and the text data in the classified samples and the text data to be classified are sorted according to the similarity, and the top M classified samples with the highest similarity are selected into the second labeled sample set, where M is a positive integer. The present application does not limit the method for determining the similarity between the text data in the classified samples and the text data to be classified, which can be a neural network algorithm or a sorting algorithm.

[0055] Step 204: input the text data to be classified, the first annotated sample set, and the second annotated sample set as prompt words into a large language model, and determine a classification label corresponding to the text data to be classified according to an output result of the large language model.

[0056] The text classification of the to-be-classified text data is used as a task in the prompt word; and the first annotated sample set and the second annotated sample set are used as examples in the prompt word.

[0057] In the above scheme, on the one hand, a large language model is used to classify the text data to be classified. Since the large language model has powerful context understanding and generation capabilities, it has relative advantages in processing complex text data and multi-label systems, so it can automatically generate multiple labels suitable for text data, thereby realizing accurate multi-label classification of text data; on the other hand, the prompt words of the large language model include a first labeled sample set and a second labeled sample set. The first labeled sample set covers all classification labels, so that the large language model can understand all classification labels; the second labeled sample set has a high similarity with the text data to be classified, so that the large language model can obtain the classification label of the text data to be classified based on the classified text data that has a high similarity with the text data to be classified, thereby improving the accuracy of text classification.

[0058] In a possible implementation method, the above step 203 also includes: selecting from the historical data set a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold and which are not in the first annotated sample set, as the second annotated sample set. That is, samples that are identical to the classified samples in the first annotated sample set are eliminated from the second annotated sample set. This solution ensures that the text data in the second annotated sample is different from that in the first annotated sample, thereby increasing the number of classified samples input into the large language model, so that the large language model can better learn the relationship between text data and classification labels based on more samples, thereby improving the accuracy of text classification.

[0059] In a possible implementation method, the above step 203 specifically includes: performing word segmentation processing on the text data to be classified to obtain multiple words; converting the multiple words into corresponding word vectors, and obtaining the first text vector corresponding to the text data to be classified according to the word vector; for any classified sample in the historical data set, selecting the classified sample corresponding to the second text vector whose similarity with the first text vector is greater than the first threshold as the second labeled sample set; the second text vector is composed of the word vectors corresponding to the classified sample. Among them, the method for converting the multiple words into corresponding word vectors can be a Word2Vec model, including but not limited to a CBOW (Continuous Bag-of-Words) model and a Skip-gram model. This application does not limit the method for converting to word vectors. This solution uses text vectors to improve the accuracy of text similarity comparison, so that the classified samples in the second labeled sample set have a higher similarity with the text data to be classified, and further, the large language model can better learn the relationship between text data and classification labels, thereby improving the accuracy of text classification.

[0060] In a possible implementation method, the above step 203 specifically includes: clustering the text data to be classified and the text data of multiple classified samples in the historical data set to obtain a clustering result; from the clustering results with the same clustering category as the text data to be classified, select multiple classified samples with a similarity greater than a first threshold to the text data to be classified as the second labeled sample set. Wherein, the clustering algorithm includes but is not limited to the K-means algorithm (K-means clustering algorithm) and the K-nearest neighbor algorithm (K-Nearest Neighbor clustering algorithm). The present application does not limit the clustering algorithm. This scheme first performs clustering processing, and then selects multiple classified samples with a similarity greater than a first threshold to the text data to be classified from the clustering results with the same clustering category as the text data to be classified as the second labeled sample set, which can improve the accuracy of text similarity comparison, so that the classified samples in the second labeled sample set have a higher similarity with the text data to be classified, and further, enables the large language model to better learn the relationship between text data and classification labels, and improve the accuracy of text classification.

[0061] In a possible implementation method, the above-mentioned step 203 specifically includes: performing word segmentation processing on the text data to be classified to obtain multiple words; converting the multiple words into corresponding word vectors, and obtaining a first text vector corresponding to the text data to be classified based on the word vector; clustering the first text vector and the second text vector in the historical data set to obtain a clustering result; from the clustering results with the same clustering category as the text data to be classified, selecting a classified sample corresponding to the second text vector whose similarity with the first text vector is greater than a first threshold as the second labeled sample set.

[0062] The above steps 201 to 204 are described in detail below using a specific example.

[0063] Background: Labeling of fulfillment (sorting and delivery) evaluations, with 10 classification labels: inappropriate delivery location / inappropriate notification time / product quality issues / delivery timeout / inappropriate order packaging / poor rider attitude / not reading notes / missing products / early delivery / thank you evaluations. That is, the text data to be classified and the text data in the historical data set are all sorting and delivery evaluations.

[0064] Assume that the historical data set includes 500 text data and their corresponding classification labels. The text classification method provided in the embodiment of the present application is as follows: Figure 3 As shown, the following steps are included:

[0065] Step 301: Select N text data and their corresponding classification labels from the historical data set as the first annotated sample set.

[0066] In a possible implementation method, according to the matching degree between the text data in the historical data set and its corresponding classification label, the top N text data with the highest matching degree are selected as the first annotated sample set. For example, N is equal to 8, and the first annotated sample set is shown in Table 1 below.

[0067] Table 1

[0068]

[0069] Step 302: Select M pieces of text data and their corresponding classification labels from the historical data set as a second annotated sample set.

[0070] In a possible implementation method, based on the similarity between the text data in the historical data set and the text data to be classified, the first M text data with the highest similarity are selected as the second annotated sample set. For example, M is equal to 3, and the second annotated sample set is shown in Table 2 below.

[0071] Table 2

[0072]

[0073] Step 303: determining prompt words according to the text data to be classified, the first annotated sample set, and the second annotated sample set.

[0074] In a possible implementation method, text classification of the text data to be classified is used as a task in the prompt word; the first annotated sample set and the second annotated sample set are used as examples in the prompt word; the classification label is used as the classification label in the prompt word, and the definition of each classification label is written into the prompt word. The definition of the classification label helps the large language model to analyze and understand the meaning of each classification label and improve the accuracy of text classification. For example, the prompt word is as follows, where <content>The content in is the text data to be classified. <tag>The content is the category label and the definition of the category label.

[0075] "Your mission is to give <content>Label each user review in the . Each user review can have one or more labels (no more than three). <tag>The set of tags and the definition of each tag are given in . <example>Several examples are given in the comments. Make sure you label the question accurately and only answer the label without repeating the comment.

[0076] <tag>

[0077] Tag collection: inappropriate delivery location / inappropriate notification time / product quality problem / delivery timeout / inappropriate order packaging / poor rider attitude / not reading notes / missing products / early delivery / thank you for the review / missed;

[0078] Tag definition:

[0079] Thanks for the review: a positive review, be careful not to take sarcasm as a compliment;

[0080] The order packaging is not appropriate: the packaged items should not be put together or not enough ice is added or the insulated box is missing, etc.;

[0081] Product quality issues: Product deterioration, expiration, staleness, spoilage, rot, damage, fresh product death, etc.;

[0082] Delivery timeout: delivery time exceeds the promised time and delivery is too slow;

[0083] Improper notification time: The delivery person fails to notify the customer in time when placing the goods directly at the door or other places (no phone call / no knock / no text message / no doorbell);

[0084] Not reading notes: Ignoring order notes and not acting according to the user's requirements;

[0085] Missing goods: some goods were not delivered, less or missed;

[0086] Poor attitude of the rider: The deliveryman has a poor communication attitude, etc.

[0087] Early delivery: The delivery time is too early, for example, the scheduled delivery time is 10:00, but it is delivered at 9:00;

[0088] Inappropriate delivery location: The goods are placed in a place that is inconvenient for users to pick up, ignoring user needs and convenience;

[0089] Missed: None of the above labels apply. Please give a "missed" label.

[0090] < / tag>

[0091] <example>

[0092] 1. Deliver in advance and place directly on the ground at the door. Just take a photo on DingDong. No phone call or doorbell is made. When the food is found, it has been outside the door for more than half an hour.

[0093] 2. I ordered the vegetables I bought today and asked you to deliver them between 8 and 8:30 tomorrow morning, but they were delivered at around 6 pm today. They will not be fresh tomorrow. The delivery staff should see this carefully! Last time, I also ordered one day in advance and it was delivered the next day, which was great!

[0094] 3. The order arrived late, the delivery was delayed by half an hour, and there was no phone contact;

[0095] 4. There was no phone call or knocking on the door when the product was delivered. The product was left at the door for an afternoon and the frozen food melted. I am not satisfied.

[0096] 5. I left it directly at the door, and there was no knock on the door, no text messages or phone calls;

[0097] 6. I wrote to put it at the door but he insisted to put it downstairs;

[0098] 7. No door-to-door delivery. I repeatedly stated that door-to-door delivery was required, so the deliveryman left it at the front desk downstairs;

[0099] 8. Delivered to the wrong place, ended up going back to get it myself;

[0100] 9. No door-to-door delivery;

[0101] 10. I told you to call me when it was delivered, but I didn’t call and just left it at the door;

[0102] 11. The rider has a bad attitude and leaves the car at the door and leaves;

[0103] 1. The advance delivery / notification time is inappropriate;

[0104] 2. Deliver in advance;

[0105] 3. Delivery timeout / inappropriate notification time;

[0106] 4. Product quality issues / inappropriate notification time;

[0107] 5. The notification time is inappropriate;

[0108] 6. Not reading the notes / inappropriate delivery location;

[0109] 7. The delivery location is not suitable;

[0110] 8. The delivery location is not suitable;

[0111] 9. The delivery location is not suitable;

[0112] 10. Not reading the notes / inappropriate delivery location;

[0113] 11. The rider has a bad attitude / the delivery location is not suitable;

[0114] < / example>

[0115] <content>”

[0116] Step 304: input the prompt word into the large language model, and determine the classification label corresponding to the text data to be classified according to the output result of the large language model.

[0117] Exemplarily, if the output result of the large language model is "inappropriate delivery location", then the classification label corresponding to the text data to be classified is determined to be "inappropriate delivery location".

[0118] In another embodiment, misclassified text data output by the large language model is collected, and the classification labels corresponding to the misclassified text data are corrected; the misclassified text data and the corrected classification labels are added to the historical data set. Specifically, production data label generation: in actual applications, the optimized large language model is used to automatically generate classification labels for production data. Collect feedback and error samples: collect misclassified samples from user feedback, especially classification labels with higher error rates, and conduct statistical analysis. Optimize prompt words: based on user feedback data, for classification labels with high error rates, after correcting the classification labels corresponding to the misclassified text data, further optimize the prompt words and the large language model to form a closed-loop optimization process to continuously improve the accuracy of text classification.

[0119] Based on the same technical concept, Figure 4 A text classification device 400 provided in an embodiment of the present application is exemplarily shown. Figure 4 As shown, it includes: an acquisition unit 401, a selection unit 402 and a determination unit 403. The acquisition unit 401 is used to acquire the text data to be classified; the selection unit 402 is used to select a first annotated sample set from multiple classified samples in the historical data set; wherein each classified sample corresponds to at least one classification label, and the classification labels corresponding to the multiple classified samples in the first annotated sample set cover the preset classification labels; multiple classified samples whose similarity with the text data to be classified is greater than a first threshold are selected from the historical data set as the second annotated sample set; the determination unit 403 is used to input the text data to be classified, the first annotated sample set and the second annotated sample set as prompt words into the large language model, and determine the classification label corresponding to the text data to be classified according to the output result of the large language model; wherein text classification of the text data to be classified is used as a task in the prompt word; and the first annotated sample set and the second annotated sample set are used as examples in the prompt word.

[0120] In a possible implementation method, the selection unit 402 is specifically used to select any classified sample in the historical data set into the first labeled sample set if the matching degree between the text data and the classification label in the classified sample is greater than a second threshold.

[0121] In a possible implementation method, the selection unit 402 is specifically configured to select, from the historical data set, a plurality of classified samples whose similarity to the text data to be classified is greater than a first threshold and which are not in the first annotated sample set, as the second annotated sample set.

[0122] In a possible implementation method, the selection unit 402 is specifically used to perform word segmentation on the text data to be classified to obtain multiple words; convert the multiple words into corresponding word vectors, and obtain a first text vector corresponding to the text data to be classified based on the word vectors; for any classified sample in the historical data set, select a classified sample corresponding to a second text vector whose similarity with the first text vector is greater than a first threshold as the second labeled sample set; the second text vector is composed of the word vectors corresponding to the classified sample.

[0123] In a possible implementation method, the selection unit 402 is specifically used to cluster the text data to be classified and the text data of multiple classified samples in the historical data set to obtain a clustering result; from the clustering results with the same clustering category as the text data to be classified, select multiple classified samples whose similarity with the text data to be classified is greater than a first threshold as the second labeled sample set.

[0124] In a possible implementation method, the above-mentioned device also includes an updating unit 404, which is used to collect misclassified text data output by the large language model and correct the classification labels corresponding to the misclassified text data; and add the misclassified text data and the corrected classification labels to the historical data set.

[0125] Based on the same technical concept, the present application embodiment provides a text classification device 500, which can be a computing device, for example. Figure 5 As shown, a text classification device 500 includes at least one processor 501 and a memory 502 connected to the at least one processor. The specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of the present application. Figure 5 For example, the processor 501 and the memory 502 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.

[0126] In the embodiment of the present application, the memory 502 stores instructions that can be executed by at least one processor 501, and the at least one processor 501 can execute the above-mentioned text classification method by executing the instructions stored in the memory 502.

[0127] Among them, the processor 501 is a control center of the text classification device 500, which can use various interfaces and lines to connect various parts of the computer equipment, and perform resource settings by running or executing instructions stored in the memory 502 and calling data stored in the memory 502. Optionally, the processor 501 may include one or more determination units, and the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 501. In some embodiments, the processor 501 and the memory 502 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.

[0128] The processor 501 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0129] The memory 502 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 502 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 502 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 502 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0130] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer-executable program. The computer-executable program is used to enable a computer to execute a text classification method listed in any of the above methods.

[0131] An embodiment of the present application provides a computer program product, including a computer program executable by a computer device. When the program is run on the computer device, the computer device executes a text classification method listed in any of the above-mentioned ways.

[0132] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0133] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0134] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0135] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0136] 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.< / content> < / example> < / tag> < / content> < / tag> < / content>

Claims

1. A text classification method, characterized in that: include: Obtain the text data to be classified; Selecting a first labeled sample set from multiple classified samples in the historical data set; wherein each classified sample corresponds to at least one classification label, and the classification labels corresponding to the multiple classified samples in the first labeled sample set cover preset classification labels; Selecting, from the historical data set, a plurality of classified samples whose similarity to the text data to be classified is greater than a first threshold as a second annotated sample set; The text data to be classified, the first annotated sample set and the second annotated sample set are used as prompt words and input into a large language model, and the classification label corresponding to the text data to be classified is determined according to the output result of the large language model; wherein text classification of the text data to be classified is used as a task in the prompt words; and the first annotated sample set and the second annotated sample set are used as examples in the prompt words.

2. The method according to claim 1, characterized in that The step of selecting a first labeled sample set from a plurality of classified samples in the historical data set includes: For any classified sample in the historical data set, if the matching degree between the text data in the classified sample and the classification label is greater than a second threshold, the classified sample is selected into the first labeled sample set.

3. The method according to claim 1, characterized in that Selecting a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold from the historical data set as a second annotated sample set, including: A plurality of classified samples whose similarity with the to-be-classified text data is greater than a first threshold and are not in the first annotated sample set are selected from the historical data set as the second annotated sample set.

4. The method according to claim 1, characterized in that The step of selecting, from the historical data set, a plurality of classified samples whose similarity to the text data to be classified is greater than a first threshold as a second annotated sample set includes: Perform word segmentation on the text data to be classified to obtain multiple words; Convert the multiple words into corresponding word vectors, and obtain a first text vector corresponding to the text data to be classified according to the word vectors; For any classified sample in the historical data set, a classified sample corresponding to a second text vector whose similarity to the first text vector is greater than a first threshold is selected as the second labeled sample set; the second text vector is composed of word vectors corresponding to the classified sample.

5. The method according to claim 1, characterized in that The step of selecting, from the historical data set, a plurality of classified samples whose similarity to the text data to be classified is greater than a first threshold as a second annotated sample set includes: Clustering the text data to be classified and the text data of multiple classified samples in the historical data set to obtain a clustering result; From the clustering results of the same clustering category as the text data to be classified, a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold value are selected as the second labeled sample set.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Collecting misclassified text data output by the large language model, and correcting classification labels corresponding to the misclassified text data; The misclassified text data and the corrected classification labels are added to the historical data set.

7. A text classification device, characterized in that: It includes acquisition unit, selection unit and determination unit: The acquisition unit is used to acquire the text data to be classified; The selection unit is used to select a first annotated sample set from a plurality of classified samples in a historical data set; wherein each classified sample corresponds to at least one classification label, and the classification labels corresponding to the plurality of classified samples in the first annotated sample set cover preset classification labels; and select a plurality of classified samples whose similarity with the text data to be classified is greater than a first threshold from the historical data set as a second annotated sample set; The determination unit is used to input the text data to be classified, the first annotated sample set and the second annotated sample set as prompt words into a large language model, and determine the classification label corresponding to the text data to be classified according to the output result of the large language model; wherein text classification of the text data to be classified is used as a task in the prompt word; and the first annotated sample set and the second annotated sample set are used as examples in the prompt word.

8. A computing device, characterized in that include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 6 according to the obtained program instructions.

9. A computer-readable storage medium, characterized in that: The method comprises computer-readable instructions, and when a computer reads and executes the computer-readable instructions, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that The invention comprises a computer program executable by a computer device, and when the program is run on the computer device, the computer device is caused to execute the steps of the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Text processing method, system and device based on large language model multi-round decision

    CN120910272A