Text classification method and device, electronic equipment and medium
By combining text classification methods of direct keywords and indirect keywords, using neural networks and semantic databases to match preset texts, the problems of restricted use scenarios and incomplete semantic information capture in the classification of automotive complaint content are solved, and classification efficiency and accuracy are improved reduces the need for manual review.
Patent Information
- Application Number
- CN202411279732.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-20
AI Technical Summary
The prior art has problems such as restricted use scenarios and incomplete semantic information capture in the text classification of automobile complaint content, resulting in inefficient classification and prolonging the automobile iteration update cycle.
Using text classification method combining direct keywords and indirect keywords, keywords are determined through the encoder and decoder of the first neural network, and preset text is matched from the semantic library, and the control encoding and word marking enhancement model is used to enhance complex semantics. analytical ability.
It significantly improves the accuracy and processing efficiency of text classification, reduces the need for manual review, and can more comprehensively capture the semantic information in the complaint content and quickly respond to customer needs.
Smart Images

Figure CN119166816A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of text classification, and in particular to a text classification method, device, electronic device and medium. Background Art
[0002] With the continuous development of the automobile industry, consumers have higher and higher requirements for vehicles, not only limited to basic driving functions, but also including vehicle safety, comfort and technological innovation. In order to meet these needs, automakers must constantly collect and analyze customer feedback in order to continuously improve their products. In this process, customer complaints provide a valuable source of information. However, complaints may have problems such as repeated text, numerous opinions, wide range, and lengthy expressions, which will inevitably increase the cost of manual review, directly lead to reduced improvement efficiency, and extend the iteration and update cycle of automobiles. Therefore, it is particularly important to effectively classify and analyze these text data.
[0003] Related technologies have proposed that texts can be classified by using word frequency statistics, methods based on recurrent neural networks, or methods based on deep learning models. However, the text classification methods used in related technologies have the problems of limited usage scenarios and incomplete semantic information capture. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a text classification method, device, electronic device and medium. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a text classification method is provided, comprising:
[0006] Obtain key sentences in the complaint content data;
[0007] Inputting the key sentence into an encoder of a first neural network to determine direct keywords of the key sentence;
[0008] Inputting the key sentence into a decoder of the first neural network in combination with the control code and the word tag to determine indirect keywords of the key sentence;
[0009] determining the direct keyword and the indirect keyword as a keyword set;
[0010] A preset text matching the keyword set is determined from the semantic library, and the preset text is determined as the category of the complaint content data.
[0011] Optionally, obtaining key sentences in the complaint content data includes:
[0012] Acquire the complaint content data, and perform word embedding, character embedding, position embedding, and fragment embedding on the complaint content data to obtain an embedded text;
[0013] Mapping the embedded text into a vector space of a target dimension, and encoding the embedded text through the encoder to obtain a sentence set of the complaint content data;
[0014] Determining the saliency probability of each sentence in the sentence set by cascading max pooling and average pooling in combination with multi-layer batch normalization;
[0015] Inputting the significance probability into the activation function layer to obtain the prediction result of each sentence in the sentence set;
[0016] Based on the prediction result, key sentences of the complaint content data are determined.
[0017] Optionally, the key sentence is input into a decoder of the first neural network in combination with the control code and the word tag to determine the indirect keywords of the key sentence, including:
[0018] Combining the word tag and the plurality of control codes, a set of initial indirect keywords is obtained;
[0019] Inputting a plurality of the initial indirect keyword sets into the decoder, and decoding the initial indirect keyword sets by the decoder to obtain initial indirect keywords;
[0020] Determining a first label of the initial indirect keyword, wherein the first label represents a probability distribution of the initial indirect keyword in a vocabulary library;
[0021] determining a second label of the initial indirect keyword, wherein the second label represents a probability distribution of the initial indirect keyword in the key sentence;
[0022] The first tag and the second tag are added to the initial indirect keyword to obtain the indirect keyword of the key sentence.
[0023] Optionally, determining the first tag of the initial indirect keyword includes:
[0024] Determine the probability distribution of each of the initial indirect keywords in the vocabulary through a linear layer and an activation function to obtain a first label of the initial indirect keyword;
[0025] The step of determining the second tag of the initial indirect keyword includes:
[0026] By means of the copy attention mechanism, determining whether the initial indirect keyword is copied from the original text;
[0027] In the case where the initial indirect keywords are copied from the original text, deduplication of the initial indirect keywords is performed;
[0028] The probability distribution of the initial indirect keywords after duplication removal in the key sentence is determined to obtain a second label of the initial indirect keyword.
[0029] Optionally, the process of decoding the initial indirect keyword set by a decoder to obtain the initial indirect keyword includes:
[0030] determining a current time at which the initial set of indirect keywords is input;
[0031] According to the current moment, the attention weight of each layer in the decoder is adjusted so that the initial keyword set currently input occupies a larger proportion when calculating attention.
[0032] Optionally, inputting the key sentence into an encoder of the first neural network to determine direct keywords of the key sentence includes:
[0033] Inputting the key sentence into the encoder;
[0034] converting the key sentence into each initial direct keyword by the encoder;
[0035] Determine the part-of-speech tag of the initial direct keyword and add it to the initial direct keyword; the part-of-speech tag includes: a keyword head tag, a keyword middle part tag and a non-keyword tag;
[0036] The initial direct keyword after the part-of-speech tag is added is determined as the direct keyword of the key sentence.
[0037] Optionally, determining a preset text matching the keyword set from the semantic library, and determining the preset text as the category of the complaint content data, includes:
[0038] Get the preset text;
[0039] Inputting the preset text and the keyword set into a second neural network;
[0040] Determining, by the second neural network, the similarity between the keyword set and each of the preset texts;
[0041] When the similarity reaches a preset threshold, the corresponding preset text is determined as the target text;
[0042] The target text is determined as the category of the complaint content data, and the target text is output.
[0043] Optionally, it also includes:
[0044] Obtain precision, recall, and comprehensive indicators;
[0045] Evaluating the direct keywords and the indirect keywords by using the accuracy, the recall and the comprehensive index;
[0046] The category of the complaint content data is evaluated through the accuracy rate and the comprehensive index.
[0047] According to a second aspect of an embodiment of the present disclosure, a text classification device is provided, including:
[0048] An acquisition module is used to obtain key sentences in the complaint content data;
[0049] A first determination module, configured to input the key sentence into an encoder of a first neural network to determine direct keywords of the key sentence;
[0050] A second determination module is used to input the key sentence into a decoder of the first neural network in combination with the control code and the word tag to determine the indirect keywords of the key sentence;
[0051] A third determining module, configured to determine the direct keyword and the indirect keyword as a keyword set;
[0052] A matching module is used to determine a preset text matching the keyword set from a semantic library, and determine the preset text as the category of the complaint content data.
[0053] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the text classification method described in the first aspect are implemented.
[0054] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text classification method described in the first aspect are implemented.
[0055] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the text classification method described in the first aspect are implemented.
[0056] The present disclosure can capture the semantic information in the complaint content data more comprehensively by combining direct keywords and indirect keywords. The introduction of control codes and word tags as the input of the decoder enables the model to consider more contextual information and language rules when generating indirect keywords, so that the generated indirect keywords are more focused on inductive generation rather than original text acquisition, and enhance the model's ability to parse complex semantics. The automated text classification method significantly reduces the need for manual review, especially for large amounts of repeated complaint content. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments of the present disclosure will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0058] Figure 1 is a schematic diagram of steps of a text classification method shown in an embodiment of the present disclosure;
[0059] Figure 2 is a schematic diagram of a first neural network shown in an embodiment of the present disclosure;
[0060] Figure 3 is a flowchart of text classification shown in an embodiment of the present disclosure;
[0061] Figure 4 is a block diagram of a text classification device shown in an embodiment of the present disclosure;
[0062] Figure 5 It is a schematic diagram of an electronic device shown in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0064] The terms "first", "second", etc. in the specification and claims of the present disclosure are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present disclosure can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0065] With the continuous development of the automobile industry, consumers have higher and higher requirements for vehicles, not only limited to basic driving functions, but also including vehicle safety, comfort and technological innovation. In order to meet these needs, automakers must constantly collect and analyze customer feedback in order to continuously improve their products. Customer complaints provide a valuable source of information. However, complaints may have problems such as repeated text, numerous opinions, wide range, and lengthy expressions. If text classification is performed manually, it is bound to increase the cost of manual review, directly leading to reduced improvement efficiency and extending the iteration and update cycle of automobiles.
[0066] Therefore, some automatic text classification methods have been proposed in the related art. For example, keywords are extracted and word frequency statistics are performed to classify the text, but this method cannot capture contextual semantic information and is inaccurate for understanding the semantic meaning of the text. Another example is to classify text based on similarity models and multi-label texts, but this method has weak extraction capabilities, especially when the text is long, the starting point information of the text sequence will be forgotten, and there will be deviations in text understanding. For another example, a deep learning model method is used to classify the text, but this method cannot be applied to the text classification of complaints during vehicle driving.
[0067] Therefore, in order to address the problems of limited usage scenarios and incomplete capture of semantic information in the technology, the present invention proposes a text classification method, device, electronic device and medium. The method can better obtain the semantic information of the text, and the generated keywords are more focused on inductive generation rather than original text acquisition, which greatly improves the accuracy of text classification.
[0068] Figure 1 Schematic diagram of a text classification method according to an embodiment of the present disclosure. Figure 1 As shown, the text classification method may specifically include the following steps:
[0069] Step S11: Obtain key sentences in the complaint content data.
[0070] Export the application software complaint content data, clean and deduplicate the data, identify key sentences and keywords, and generate a complaint opinion text data set. The complaint opinion text data set includes each complaint content data. For any complaint content data, the key sentence corresponding to the complaint content data is obtained from the complaint content data through the encoder of the first neural network. There can be multiple determined key sentences, and the determined key sentences are combined into a new text so that the long text is reduced to a short text that can represent the key information.
[0071] Step S12: input the key sentence into the encoder of the first neural network to determine the direct keywords of the key sentence.
[0072] The first neural network is an encoder-decoder architecture network, where the encoder part is used to understand and extract the semantics of sentences. The encoder can analyze the semantics of the text and further determine direct keywords from the key sentences through the encoder. Specifically, through technical means such as the attention mechanism, direct keywords that directly describe the complaint content are automatically extracted. Direct keywords refer to important words that appear directly in the key sentences, such as nouns, verbs, or specific terms, which are directly related to the user's complaint points.
[0073] Step S13: Input the key sentence into the decoder of the first neural network in combination with the control code and the word tag to determine the indirect keywords of the key sentence.
[0074] Control coding is a technique used in natural language processing and neural networks to guide or control the output generated by the model. Control coding can be used to specify the type of keywords you want the model to extract, such as nouns, verbs, or proper nouns. Through control coding, you can also guide the model to prioritize the extraction of words related to a specific topic or field. For example, when analyzing the content of car complaints, you can extract keywords related to car quality or service.
[0075] Word tagging is the process of assigning a tag to each word in the text to indicate its part of speech, which helps to understand the function and role of the word in the sentence. Word tagging can help the model understand the linguistic function of each word, while control encoding can be used to specify specific attributes of keywords.
[0076] Controlling encoding combined with word tagging can help the model identify and extract key information from the text more accurately. By controlling encoding, the scope and diversity of extracted keywords can be specified, and combining word tagging can ensure the linguistic correctness and rationality of these keywords.
[0077] The key sentence is combined with control coding and word tagging to guide the decoder to generate indirect keywords. Indirect keywords do not appear directly in the original text, but can be inferred through logical reasoning or common sense.
[0078] Step S14: Determine the direct keywords and the indirect keywords as a keyword set.
[0079] Combining direct and indirect keywords to determine a comprehensive and accurate keyword set provides a comprehensive view of the complaint content data.
[0080] Step S15: Determine a preset text matching the keyword set from the semantic library, and determine the preset text as the category of the complaint content data.
[0081] A semantic library containing various types of complaints and their corresponding description texts is pre-established. These description texts are used as preset texts and are associated with specific complaint categories. The best matching preset text can be found by comparing the similarity between the keyword set and the preset text. The category corresponding to the matched preset text is determined as the category of the complaint content data.
[0082] By adopting the embodiments of the present disclosure, the automated classification of complaint content can significantly improve processing efficiency, reduce the need for manual classification, and quickly respond to customer needs. Determining the category of complaint content data based on key sentences in the complaint content data improves processing efficiency, quickly locates the core content of the complaint, can reduce the interference of non-critical information, and provide a more accurate data basis for subsequent analysis. By combining key sentences with control coding and word tags, the system's ability to understand complex semantic relationships can be enhanced, and deeper complaint information can be mined. Direct keywords and indirect keywords are used as a keyword set to comprehensively and accurately reflect complaint content data. By matching the keyword set with the preset text, automatic classification of complaint content is achieved, improving processing efficiency and accuracy.
[0083] Among them, in an optional embodiment, the obtaining of key sentences in the complaint content data includes: obtaining the complaint content data, and performing word embedding, character embedding, position embedding and fragment embedding on the complaint content data to obtain embedded text; mapping the embedded text to the vector space of the target dimension, and encoding the embedded text through the encoder to obtain a sentence set of the complaint content data; determining the significance probability of each sentence in the sentence set through cascading maximum pooling and average pooling, and combining multi-layer batch normalization; inputting the significance probability into the activation function layer to obtain the prediction results of each sentence in the sentence set; and determining the key sentences of the complaint content data based on the prediction results.
[0084] Word embedding converts each word in a text into a vector of fixed dimension that captures the semantic relationship between words. Character embedding captures character-level information, which helps to handle misspellings, abbreviations, and words that are not in the vocabulary. Position embedding captures the position of a word in a sentence, helping the model understand the contribution of words at different positions in a sentence to the overall semantics. Fragment embedding distinguishes text fragments from different sources and can be used to process pairs of sentences or paragraphs.
[0085] Word embedding, character embedding, position embedding, and fragment embedding of complaint content data can improve the model's ability to understand text semantics, capture more contextual information, improve model performance, and support more complex tasks.
[0086] The embedded text is a series of vectors. The embedded text is mapped to a vector space of a target dimension, and the results of various embeddings are merged into a unified vector representation. The vector representation is then further processed using the encoder of the first neural network to generate a set of sentences that can represent the semantics of the entire sentence or paragraph. Each item in the sentence set represents a sentence and is represented by a vector. For example, by encoding the embedded text, the encoded sequence vector in
[0087] Then, through cascaded maximum pooling and average pooling Combined with multi-layer batch normalization, the significance probability of each sentence in the sentence set is calculated, which can be calculated using softmax or sigmoid functions. Maximum pooling can select the largest value from the input feature and is usually used to extract the most significant part of the feature. Average pooling can calculate the average value of the input feature, aiming to retain the overall information of the feature. Cascading maximum pooling and average pooling can combine the results of maximum pooling and average pooling to form a new feature representation. Multi-layer batch normalization can standardize the input of each layer so that the mean of the input data is close to 0 and the variance is close to 1, thereby alleviating the problem of internal covariate shift.
[0088] The significance probability reflects the importance or prominence of each sentence in the overall text. The higher the significance probability, the more important the sentence is in the text. The sentence that meets the significance probability requirement is a key sentence.
[0089] By adopting the embodiments of the present disclosure, by combining different types of text embedding, the model can more comprehensively understand the semantics, grammar, and structure of the text; cascade pooling and batch normalization help the model to more effectively extract and utilize key features in text data; multi-level batch normalization reduces internal covariate shift, speeds up training, and improves the generalization ability of the model; and the comprehensive use of deep learning technology can significantly improve the accuracy of extracting key sentences from complaint content.
[0090] Among them, in an optional embodiment, the key sentence is combined with the control code and the word tag and input into the decoder of the first neural network to determine the indirect keywords of the key sentence, including: combining the word tag and multiple control codes to obtain a set of multiple initial indirect keywords; inputting multiple sets of the initial indirect keywords into the decoder, decoding the initial indirect keyword sets through the decoder to obtain initial indirect keywords; determining a first label of the initial indirect keyword, the first label represents the probability distribution of the initial indirect keyword in the vocabulary library; determining a second label of the initial indirect keyword, the second label represents the probability distribution of the initial indirect keyword in the key sentence; adding the first label and the second label to the initial indirect keyword to obtain the indirect keyword of the key sentence.
[0091] The key sentence obtained by the encoder of the first neural network is combined with the control code and the word tag. The word tag marks each word in the key sentence to ensure that each word is uniquely identified. The control code is used to guide the decoder to generate more accurate indirect keywords to obtain an initial indirect keyword set. The number of initial indirect keyword sets corresponds to the number of control codes. The initial indirect keyword sets obtained by each control code are input into the decoder of the first neural network together. The decoder of the first neural network decodes the initial indirect keyword set to generate initial indirect keywords.
[0092] After obtaining each indirect keyword, the first label and the second label corresponding to each indirect keyword are determined respectively. The first label represents the probability distribution of the initial indirect keyword in the vocabulary library. The second label represents the probability distribution of the initial indirect keyword in the key sentence.
[0093] In the field of text classification, the probability distribution of initial indirect keywords in the vocabulary reflects the prevalence and importance of the word in the overall corpus. It is used to accurately characterize the characteristics of the text, and can be used to screen out keywords that are useful for classification tasks, reduce the impact of noise on classification results, and improve the recognition ability of text classification models.
[0094] The second label reflects the probability distribution of the initial indirect keyword in the text, which can be used to evaluate the generation possibility of each possible initial indirect keyword in the current context.
[0095] The first tag and the second tag are added to the initial indirect keyword to form an indirect keyword containing rich information.
[0096] By adopting the embodiments of the present disclosure, by combining control coding and word tagging, and utilizing the decoding capability of a neural network, indirect keywords of key sentences can be extracted more accurately. Multiple initial indirect keyword sets are generated and processed by a decoder, which can cover a wider range of potential keywords and increase the diversity of keywords. By determining the probability distribution labels of keywords in the vocabulary and key sentences, rich context information and importance evaluation are provided for the keywords.
[0097] Among them, in an optional embodiment, determining the first label of the initial indirect keyword includes: determining the probability distribution of each of the initial indirect keywords in the vocabulary library through a linear layer and an activation function, and obtaining the first label of the initial indirect keyword; determining the second label of the initial indirect keyword includes: judging whether the initial indirect keyword is copied from the original text through the copy attention mechanism; when the initial indirect keyword is copied from the original text, deduplicating the initial indirect keyword; determining the probability distribution of the deduplicated initial indirect keyword in the key sentence, and obtaining the second label of the initial indirect keyword.
[0098] After the initial indirect keyword is obtained through the decoding layer of the first neural network, the probability distribution of the initial indirect keyword in the vocabulary is determined by splicing the linear layer and the activation function, thereby determining the first label of the initial indirect keyword. The probability distribution of the initial indirect keyword in the vocabulary can be specifically expressed by the formula:
[0099]
[0100] Calculate, where p is the probability distribution of the tth initial indirect keyword in the vocabulary, W is the weight, b is the constant parameter, is a decoded vector containing L masks.
[0101] Some initial indirect keywords may be directly copied from key sentences, so it is necessary to deduplicate such initial indirect keywords and remove the directly copied initial indirect keywords from the initial indirect keyword set. Specifically, the direct keywords and initial indirect keywords can be input into the copy attention module through the copy attention mechanism, and the relationship between each initial indirect keyword and each direct keyword can be determined to determine whether the initial indirect keyword is repeated with a direct keyword. If repeated, it means that the initial indirect keyword is copied from the original text, and then the initial indirect keyword is removed from the initial indirect keyword set to achieve deduplication of the initial indirect keywords.
[0102] Specifically, the context vector and the decoder layer vector can be used to perform binary classification to determine whether it is copied. The context vector is combined with the output vector of the decoder layer and the score is calculated, and then a binary classification judgment is performed. Specifically, a classifier can be used to output a probability value to indicate the possibility of copying, thereby determining whether the currently generated target keyword is copied from the original text. The context vector can be obtained by the formula:
[0103]
[0104] Determine, among which represents the context vector at time t, α ti is the probability that the target initial indirect keyword is in the original text sequence at time t, α ti The formula can be:
[0105]
[0106] After removing the initial indirect keywords, the probability distribution of the initial indirect keywords in the key sentences is calculated to determine the second label of the initial indirect keywords. The formula can be used for this:
[0107]
[0108] To determine, P(u t ) indicates that the initial indirect keyword is copied from the original text sequence, and the calculation formula is:
[0109] P(u t )=σ(W[h t ,c t ]+b)
[0110] where h t is the decoder layer vector, c t is the context vector and b is a constant.
[0111] After determining the first tag and the second tag corresponding to the initial indirect keyword, the first tag and the second tag are added to the initial indirect keyword to obtain a final indirect keyword.
[0112] By using the embodiments of the present disclosure, by calculating the probability distribution of the initial indirect keywords in the vocabulary library, those keywords that have important contributions to the text theme or category can be more accurately identified. Deduplication processing helps to reduce redundant information and noise interference in the labels, and improve the purity and accuracy of the labels. By considering the specific performance of the initial indirect keywords in the key sentences, a more specific and targeted second label can be generated. Combining the information of the first label and the second label, a more comprehensive and accurate text classification model can be constructed, improving the model's adaptability and robustness to different text types.
[0113] Among them, in an optional embodiment, in the process of decoding the initial indirect keyword set through a decoder to obtain the initial indirect keywords, it includes: determining the current moment of inputting the initial indirect keyword set; according to the current moment, adjusting the attention weight of each layer in the decoder so that the currently input initial keyword set occupies a larger proportion when calculating attention.
[0114] The initial indirect keyword set is used as the input of the decoder. The decoder works in a loop or recursive manner, iterating one initial indirect keyword each time. In each case where an initial indirect keyword is iterated out, the attention weight of each layer in the decoder corresponding to the initial indirect keyword is determined. The attention weight of each layer in the decoder is used to make the first neural network focus on the content at the current moment. Specifically, it can be expressed by the formula:
[0115]
[0116] OK. ti It is used to determine the correlation between the encoder hidden state and the decoder hidden state of the first neural network at the current moment. t is the initial indirect keyword corresponding to the current moment.
[0117] By adopting the embodiments of the present disclosure, the attention weight can be dynamically adjusted according to the current moment, and the decoder can more accurately focus on the input information most relevant to the current decoding task, thereby improving the accuracy and relevance of the decoding results. Allowing the model to adaptively adjust its behavior according to the temporal characteristics of the input data increases the flexibility and generalization ability of the model. In the attention mechanism, by increasing the weight of the current input data, the model can more efficiently utilize limited computing resources and prioritize the information that has the greatest impact on the output results.
[0118] Among them, in an optional embodiment, the key sentence is input into the encoder of the first neural network to determine the direct keywords of the key sentence, including: inputting the key sentence into the encoder; converting the key sentence into each initial direct keyword through the encoder; determining the part-of-speech tag of the initial direct keyword and adding it to the initial direct keyword; the part-of-speech tag includes: a keyword head tag, a keyword middle part tag and a non-keyword tag; and determining the initial direct keyword after adding the part-of-speech tag as the direct keyword of the key sentence.
[0119] The key sentence to be processed is used as input data and passed to the encoder part of the first neural network. After receiving the key sentence, the encoder captures the core information in the key sentence, encodes the key sentence, and converts it into a series of initial direct keywords. The initial direct keywords are a compressed representation of the information in the key sentence and represent the core content of the text.
[0120] The extractor is used as a three-way classifier to perform part-of-speech tagging on the initial direct keywords output by the encoder. Each initial direct keyword is classified into one of the following categories: keyword head tag, keyword middle part tag, or non-keyword tag.
[0121] According to the classification results of the extractor, add corresponding part-of-speech tags to each initial direct keyword. These tags include keyword head tags, keyword middle part tags, and non-keyword tags. According to the classification results of the part-of-speech tags, filter out the initial direct keywords with keyword head tags and / or keyword middle part tags and determine them as direct keywords of the key sentence.
[0122] The part of speech corresponding to each initial direct keyword can be obtained by the formula:
[0123]
[0124] Determine. Where W is the weight, b is the constant parameter, p j is the probability of which part-of-speech tag the jth initial direct keyword belongs to.
[0125] With the embodiments of the present disclosure, the extractor is used as a three-way classifier, which can accurately identify the part-of-speech features of keywords, thereby improving the accuracy and efficiency of keyword extraction. The addition of part-of-speech tags gives keywords richer semantic information, helps to distinguish the different parts of keywords, and improves the accuracy of keyword extraction. The determination of direct keywords provides an important reference for subsequent natural language processing tasks. The entire process does not require human intervention, and can automatically complete tasks such as key sentence input, encoding, part-of-speech tagging, and keyword extraction, greatly improving work efficiency. Through the powerful capabilities of the deep learning model, the encoder can capture key information in key sentences, and through the precise classification of the extractor, the accuracy of keyword extraction is improved.
[0126] Among them, in an optional embodiment, determining a preset text matching the keyword set from a semantic library and determining the preset text as a category of the complaint content data includes: obtaining the preset text; inputting the preset text and the keyword set into a second neural network; determining, through the second neural network, the similarity between the keyword set and each of the preset texts; when the similarity reaches a preset threshold, determining the corresponding preset text as a target text; determining the target text as a category of the complaint content data, and outputting the target text.
[0127] All preset texts are obtained from a pre-built semantic library, and the preset texts represent different complaint content categories.
[0128] The keyword set and each preset text in the semantic library are respectively input into the second neural network. The similarity between the keyword set and each preset text is calculated through the second neural network. The similarity calculation method may include cosine similarity, Jaccard similarity, edit distance, etc. Before the keyword set is input into the second neural network, keyword feature embedding is performed on the keyword set.
[0129] The similarity calculation results of all preset texts are traversed to determine the preset texts whose similarity reaches the preset threshold. The preset threshold is set according to the actual situation and classification requirements, and is used to determine whether the matching degree between the keyword set and the preset text is high enough.
[0130] The present disclosure can determine the similarity between a keyword set and a preset text by using an activation function according to the following formula:
[0131]
[0132] Where D represents each generated keyword, Q represents the keyword library sequence, γ is the smoothing factor of the activation function, and R(Q,D) represents the cosine similarity. The specific calculation formula of R(Q,D) is:
[0133]
[0134] Among them, y Q ,y D is the concept vector of keywords and sequences.
[0135] By using the embodiments of the present disclosure, the preset text can ensure a comprehensive and accurate set of preset texts, which is a reliable basis for classification tasks. By using deep learning technology and a preset similarity evaluation algorithm, the similarity between the keyword set and the preset text can be accurately evaluated, and the most matching preset text can be selected as the category of the complaint content data. By adjusting the preset threshold and the similarity evaluation algorithm, different classification requirements and scene changes can be adapted.
[0136] Among them, in an optional embodiment, it also includes: obtaining accuracy, recall rate and comprehensive indicators; evaluating the direct keywords and the indirect keywords through the accuracy, recall rate and comprehensive indicators; evaluating the category of the complaint content data through the accuracy and the comprehensive indicators.
[0137] Get the precision, recall and comprehensive indicators.
[0138] Accuracy is used to measure how much information should actually be extracted. Accuracy can be expressed by the following formula:
[0139]
[0140] Among them, TP (True Positives) is a true positive example, indicating that the result obtained by the model is correct; FP (False Positives) is a false positive example, indicating that the result obtained by the model is wrong.
[0141] The recall rate is used to measure whether all correct information has been extracted. The recall rate can be expressed by the following formula:
[0142]
[0143] Among them, FN (False Negatives) is a false negative example, which means that the model judges the correct information as incorrect.
[0144] The comprehensive index is the harmonic mean of precision and recall. The higher the comprehensive index score, the better the performance of the algorithm. The comprehensive index can be expressed by the following formula:
[0145]
[0146] Each keyword determined by the first neural network is evaluated by the accuracy, the recall rate and the comprehensive index.
[0147] The accuracy rate is used to evaluate each keyword, which is used to measure how many of the extracted keywords should be extracted. The recall rate is used to evaluate each keyword, which is used to measure the ability of the algorithm to extract all the real keywords in the text. When evaluating keywords through comprehensive indicators, the F1 score of the comprehensive indicators on the first 5 keywords returned is used to evaluate the accuracy of the "Top-N" in keyword extraction or recommendation systems.
[0148] The categories of complaint content data determined by the second neural network are evaluated through accuracy and comprehensive indicators.
[0149] When evaluating the category of complaint content data, the accuracy rate can be used to determine the correct proportion when judging that two objects are similar. The higher the accuracy rate, the better the performance of the second neural network module, and the higher the accuracy rate of the category of complaint content data determined by the second neural network.
[0150] The comprehensive indicator is the harmonic mean of precision and recall. When evaluating the categories of complaint content data, a balance can be found between precision and recall, thereby more comprehensively evaluating the performance of the algorithm.
[0151] By using the embodiments of the present disclosure, the effects of keyword extraction and complaint content classification are objectively evaluated through quantitative indicators such as accuracy, recall rate, and comprehensive index score, providing data support for optimizing the algorithm. Analyze the error cases and deficiencies in the evaluation results, identify the problems of the algorithm in the extraction and classification process, and provide a basis for optimizing the algorithm and improving the model. Through continuous evaluation and optimization, the accuracy and efficiency of keyword extraction and complaint content classification are improved, thereby improving the overall natural language processing effect and user experience.
[0152] Figure 2 is a schematic diagram of a first neural network shown in an embodiment of the present disclosure. Figure 2As shown, the input of the encoder of the first neural network needs to include additional inputs such as word embedding, character embedding, position embedding and fragment embedding to convert the complaint content data into a computer-recognizable form; the encoder includes multi-head attention, residual connection & normalization, feedforward network layer and residual connection & normalization, and the key sentence of the complaint content data is obtained through the encoder, and the key sentence is represented by a vector; then the initial direct keywords in the key sentence are obtained through the encoder; after the initial direct keywords in the key sentence are obtained through the encoder, the initial direct keywords are classified through the extractor to determine the part-of-speech tags corresponding to each initial direct keyword; word tags and control codes are introduced at the input end of the decoder of the first neural network, and the initial indirect keyword set corresponding to the control code is obtained in combination with the key sentence obtained by the encoder; the mask multi-head in the decoder Attention, residual connection & normalization, multi-head attention, residual connection & normalization, feedforward network layer and residual connection & normalization are used to decode the initial indirect keyword set to obtain the initial indirect keywords; after obtaining the initial indirect keywords through the decoder, the initial indirect keywords are successively passed through the linear layer and the activation function to determine the probability distribution of the initial indirect keywords in the vocabulary library, and the initial indirect keywords and direct keywords are passed through the replicated attention to determine the probability distribution of the initial indirect keywords in the key sentence, and the two probability distributions are added to the initial indirect keywords through the corresponding labels to obtain indirect keywords; according to the direct keywords and the indirect keywords, a keyword vector is obtained; keyword features are embedded in the keyword vector, and the embedded keyword vector is input into the deep semantic network to perform similarity calculation to determine the category to which the complaint content data belongs.
[0153] Figure 3 is a flowchart of text classification shown in an embodiment of the present disclosure. Figure 3 As shown, firstly, the complaint content data is obtained; the complaint content data is processed; the key sentences are extracted from the processed complaint content data, and the key sentences are spliced; the keyword classification is determined based on the layered coverage attention; direct keywords and indirect keywords are obtained; the keyword vector is obtained based on the direct keywords and the indirect keywords; based on the keyword vector, the similarity text probability is calculated through the deep semantic network; the similarity probability is output, and it is calculated whether the preset text is the similar text corresponding to the complaint content data.
[0154] Figure 4 is a block diagram of a text classification device shown in an embodiment of the present disclosure. Figure 4 As shown, the text classification device includes:
[0155] An acquisition module 410 is used to obtain key sentences in the complaint content data;
[0156] A first determination module 420, configured to input the key sentence into an encoder of a first neural network to determine direct keywords of the key sentence;
[0157] A second determination module 430 is used to input the key sentence in combination with the control code and the word tag into the decoder of the first neural network to determine the indirect keywords of the key sentence;
[0158] A third determining module 440 is used to determine the direct keyword and the indirect keyword as a keyword set;
[0159] The matching module 450 is used to determine a preset text matching the keyword set from the semantic library, and determine the preset text as the category of the complaint content data.
[0160] Optionally, the acquisition module is specifically used to execute:
[0161] Acquire the complaint content data, and perform word embedding, character embedding, position embedding, and fragment embedding on the complaint content data to obtain an embedded text;
[0162] Mapping the embedded text into a vector space of a target dimension, and encoding the embedded text through the encoder to obtain a sentence set of the complaint content data;
[0163] Determining the saliency probability of each sentence in the sentence set by cascading max pooling and average pooling in combination with multi-layer batch normalization;
[0164] Inputting the significance probability into the activation function layer to obtain the prediction result of each sentence in the sentence set;
[0165] Based on the prediction result, key sentences of the complaint content data are determined.
[0166] Optionally, the second determining module is specifically configured to execute:
[0167] Combining the word tag and the plurality of control codes, a set of initial indirect keywords is obtained;
[0168] Inputting a plurality of the initial indirect keyword sets into the decoder, and decoding the initial indirect keyword sets by the decoder to obtain initial indirect keywords;
[0169] Determining a first label of the initial indirect keyword, wherein the first label represents a probability distribution of the initial indirect keyword in a vocabulary library;
[0170] determining a second label of the initial indirect keyword, wherein the second label represents a probability distribution of the initial indirect keyword in the key sentence;
[0171] The first tag and the second tag are added to the initial indirect keyword to obtain the indirect keyword of the key sentence.
[0172] Optionally, the second determining module is specifically configured to execute:
[0173] Determine the probability distribution of each of the initial indirect keywords in the vocabulary through a linear layer and an activation function to obtain a first label of the initial indirect keyword;
[0174] By means of the copy attention mechanism, determining whether the initial indirect keyword is copied from the original text;
[0175] In the case where the initial indirect keywords are copied from the original text, deduplication of the initial indirect keywords is performed;
[0176] The probability distribution of the initial indirect keywords after duplication removal in the key sentence is determined to obtain a second label of the initial indirect keyword.
[0177] Optionally, the second determining module is specifically configured to execute:
[0178] determining a current time at which the initial set of indirect keywords is input;
[0179] According to the current moment, the attention weight of each layer in the decoder is adjusted so that the initial keyword set currently input occupies a larger proportion when calculating attention.
[0180] Optionally, the first determining module is specifically configured to execute:
[0181] Inputting the key sentence into the encoder;
[0182] converting the key sentence into each initial direct keyword by the encoder;
[0183] Determine the part-of-speech tag of the initial direct keyword and add it to the initial direct keyword; the part-of-speech tag includes: a keyword head tag, a keyword middle part tag and a non-keyword tag;
[0184] The initial direct keyword after the part-of-speech tag is added is determined as the direct keyword of the key sentence.
[0185] Optionally, the matching module is specifically configured to execute:
[0186] Get the preset text;
[0187] Inputting the preset text and the keyword set into a second neural network;
[0188] Determining, by the second neural network, the similarity between the keyword set and each of the preset texts;
[0189] When the similarity reaches a preset threshold, the corresponding preset text is determined as the target text;
[0190] The target text is determined as the category of the complaint content data, and the target text is output.
[0191] Optionally, the device further comprises:
[0192] The indicator acquisition module is used to obtain accuracy, recall rate and comprehensive indicators;
[0193] A first evaluation module, used for evaluating the direct keywords and the indirect keywords by using the accuracy, the recall rate and the comprehensive index;
[0194] The second evaluation module is used to evaluate the category of the complaint content data through the accuracy rate and the comprehensive index.
[0195] It should be noted that the device embodiment is similar to the method embodiment, so the description is relatively simple, and the relevant parts can be referred to the method embodiment.
[0196] The present disclosure also provides an electronic device, referring to Figure 5 , Figure 5 Schematic diagram of an electronic device shown in an embodiment of the present disclosure. Figure 5 As shown, the electronic device 500 includes: a memory 510 and a processor 520. The memory 510 and the processor 520 are connected via a bus communication. A computer program is stored in the memory 510. The computer program can be run on the processor 520 to implement the steps in the text classification method disclosed in the embodiment of the present disclosure.
[0197] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the text classification method disclosed in the embodiment of the present disclosure are implemented.
[0198] The embodiments of the present disclosure also provide a computer program product, including a computer program. When the computer program is executed by a processor, the steps in the text classification method disclosed in the embodiments of the present disclosure are implemented.
[0199] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0200] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices or computer program products. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0201] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks 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 terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal 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.
[0202] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including 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.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0204] Although some embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiment and all changes and modifications that fall within the scope of the present disclosure.
[0205] The above is a detailed introduction to a text classification method, device, electronic device and storage medium provided by the present disclosure. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea. At the same time, for those skilled in the art, according to the idea of the present disclosure, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A text classification method, characterized in that: include: Obtain key sentences in the complaint content data; Inputting the key sentence into an encoder of a first neural network to determine direct keywords of the key sentence; Inputting the key sentence into a decoder of the first neural network in combination with the control code and the word tag to determine indirect keywords of the key sentence; determining the direct keyword and the indirect keyword as a keyword set; A preset text matching the keyword set is determined from the semantic library, and the preset text is determined as the category of the complaint content data.
2. The method according to claim 1, characterized in that The key sentences in the complaint content data obtained include: Acquire the complaint content data, and perform word embedding, character embedding, position embedding, and fragment embedding on the complaint content data to obtain an embedded text; Mapping the embedded text into a vector space of a target dimension, and encoding the embedded text through the encoder to obtain a sentence set of the complaint content data; Determining the saliency probability of each sentence in the sentence set by cascading max pooling and average pooling in combination with multi-layer batch normalization; Inputting the significance probability into the activation function layer to obtain the prediction result of each sentence in the sentence set; Based on the prediction result, key sentences of the complaint content data are determined.
3. The method according to claim 1, characterized in that Inputting the key sentence into the decoder of the first neural network in combination with the control code and the word tag to determine the indirect keywords of the key sentence includes: Combining the word tag and the plurality of control codes, a set of initial indirect keywords is obtained; Inputting a plurality of the initial indirect keyword sets into the decoder, and decoding the initial indirect keyword sets by the decoder to obtain initial indirect keywords; Determining a first label of the initial indirect keyword, wherein the first label represents a probability distribution of the initial indirect keyword in a vocabulary library; determining a second label of the initial indirect keyword, wherein the second label represents a probability distribution of the initial indirect keyword in the key sentence; The first tag and the second tag are added to the initial indirect keyword to obtain the indirect keyword of the key sentence.
4. The method according to claim 3, characterized in that The step of determining the first tag of the initial indirect keyword includes: Determine the probability distribution of each of the initial indirect keywords in the vocabulary through a linear layer and an activation function to obtain a first label of the initial indirect keyword; The step of determining the second tag of the initial indirect keyword includes: By means of the copy attention mechanism, determining whether the initial indirect keyword is copied from the original text; In the case where the initial indirect keywords are copied from the original text, deduplication of the initial indirect keywords is performed; The probability distribution of the initial indirect keywords after duplication removal in the key sentence is determined to obtain a second label of the initial indirect keyword.
5. The method according to claim 3, characterized in that: The process of decoding the initial indirect keyword set by a decoder to obtain the initial indirect keyword includes: determining a current time at which the initial set of indirect keywords is input; According to the current moment, the attention weight of each layer in the decoder is adjusted so that the initial keyword set currently input occupies a larger proportion when calculating attention.
6. The method according to claim 1, characterized in that Inputting the key sentence into the encoder of the first neural network, and determining direct keywords of the key sentence, including: Inputting the key sentence into the encoder; converting the key sentence into each initial direct keyword by the encoder; Determine the part-of-speech tag of the initial direct keyword and add it to the initial direct keyword; the part-of-speech tag includes: a keyword head tag, a keyword middle part tag and a non-keyword tag; The initial direct keyword after the part-of-speech tag is added is determined as the direct keyword of the key sentence.
7. The method according to claim 1, characterized in that The step of determining a preset text matching the keyword set from the semantic library and determining the preset text as the category of the complaint content data includes: Get the preset text; Inputting the preset text and the keyword set into a second neural network; Determining, by the second neural network, the similarity between the keyword set and each of the preset texts; When the similarity reaches a preset threshold, the corresponding preset text is determined as the target text; The target text is determined as the category of the complaint content data, and the target text is output.
8. The method according to claim 1, characterized in that Also includes: Obtain precision, recall, and comprehensive indicators; Evaluating the direct keywords and the indirect keywords by using the accuracy, the recall and the comprehensive index; The category of the complaint content data is evaluated through the accuracy rate and the comprehensive index.
9. A text classification device, characterized in that: include: An acquisition module is used to obtain key sentences in the complaint content data; A first determination module, configured to input the key sentence into an encoder of a first neural network to determine direct keywords of the key sentence; A second determination module is used to input the key sentence into a decoder of the first neural network in combination with the control code and the word tag to determine the indirect keywords of the key sentence; A third determining module, configured to determine the direct keyword and the indirect keyword as a keyword set; A matching module is used to determine a preset text matching the keyword set from a semantic library, and determine the preset text as the category of the complaint content data.
10. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the text classification method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the text classification method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Text content analysis method and system combining theme and context
CN119514537A
