Text data classification and grading method and device
By combining the word frequency-inverse file frequency algorithm and natural language model to extract features, the classification and grading of text data is solved, and the problem of poor performance of existing technology in complex contexts is improved, and the reliability and security of classification and grading is achieved. Accurate classification and grading of complex data.
Patent Information
- Application Number
- CN202411222491.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-06
AI Technical Summary
Existing text data classification and grading methods perform poorly when dealing with complex contexts and fail to make full use of overall context information, resulting in insufficient reliability and security of classification and grading.
Using a method based on word frequency-inverse file frequency algorithm and natural language model (such as BERT), position features, weighted features and semantic features are extracted, and comprehensive feature representations are generated through feature fusion processing, which is used to improve the classification and hierarchy accuracy of text data.
It improves the reliability and security of classification and grading of text data, enhances the accuracy of classification and grading of sensitive information for complex format data, reduces the probability of missed reports and false alarms, and can better adapt to data classification and grading in complex contexts.
Smart Images

Figure CN119088969A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology and can also be used in the financial field, and in particular to a method and device for classifying and grading text data. Background Art
[0002] Data classification and grading plays an important role in information security management throughout the entire data life cycle. It provides a foundation and guidance for enterprises, helps to formulate correct security strategies, take effective data protection measures, and continuously improve data security levels to achieve comprehensive compliance governance. With the continuous increase in the amount of data in the financial industry, data security issues are becoming increasingly prominent. The current classification and grading methods for text data used to achieve text data security management and control mainly adopt a combination of rule matching and manual recognition. The main process is as follows: the user defines the data matching rules in advance, and then matches the target text data. After the matching is completed, the matching results are usually screened manually to determine the classification and grading results of the target text data.
[0003] This method combines rule matching with manual recognition. Existing rule matching methods only apply static matching rules and cannot utilize overall contextual information, resulting in poor performance in processing data in complex contexts and affecting the reliability of classification and grading of text data.
[0004] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section. Summary of the invention
[0005] In response to at least one problem in the prior art, the present application proposes a method and device for classifying and grading text data.
[0006] In order to solve the above technical problems, this application provides the following technical solutions:
[0007] An embodiment of the present invention provides a text data classification and grading method for improving the reliability of text data classification and grading, thereby improving the security of text data. The method includes:
[0008] Get target text data;
[0009] According to the preset matching rules and the target text data, a first keyword and its corresponding position feature vector are obtained; the target text data is processed based on a word frequency-inverse file frequency algorithm to obtain a weighted feature vector; a natural language model is applied to perform deep feature extraction on the target text data to obtain a semantic feature vector;
[0010] Performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation;
[0011] According to the preset classification and grading model and the comprehensive feature representation, the classification and grading results of the target text data are obtained.
[0012] In one embodiment, obtaining the first keyword and its corresponding position feature vector according to the preset matching rule and the target text data includes:
[0013] Obtaining a first keyword according to a preset matching rule and the target text data;
[0014] The position feature vector is determined according to the starting position and the ending position of the first keyword in the target text data and the total length of the target text data.
[0015] In one embodiment, the target text data is processed based on the word frequency-inverse document frequency algorithm to obtain a weighted feature vector, including:
[0016] Acquire a second keyword in the target text data;
[0017] Determining a word frequency-inverse document frequency value of the second keyword according to the number of times the second keyword appears in the target text data, the total number of pre-acquired texts, and the number of texts containing the second keyword;
[0018] A weighted feature vector is obtained according to the word frequency-inverse document frequency value of the second keyword.
[0019] In one embodiment, the performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation includes:
[0020] The position feature vector, the weighted feature vector and the semantic feature vector are subjected to weighted summation processing to obtain the comprehensive feature representation.
[0021] In one embodiment, the text data classification and grading method further includes:
[0022] Collecting a training sample set, the training sample set includes: batch historical text data and their corresponding actual classification and grading results;
[0023] The classification algorithm is trained using the training sample set to obtain the preset classification and grading model.
[0024] In one embodiment, the applying the training sample set to train the classification algorithm to obtain the preset classification and grading model includes:
[0025] Applying the training sample set to train the weight coefficients and classification algorithms corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, to obtain the optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, and the preset classification and grading model;
[0026] Correspondingly, the weighted summing of the position feature vector, the weighted feature vector and the semantic feature vector to obtain the comprehensive feature representation includes:
[0027] The optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector are applied to perform weighted summation processing on the position feature vector, the weighted feature vector, and the semantic feature vector to obtain the comprehensive feature representation.
[0028] In one embodiment, the performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation includes:
[0029] The position feature vector, the weighted feature vector and the semantic feature vector are concatenated to obtain a comprehensive feature representation.
[0030] In one embodiment, the classification algorithm includes at least one of a recurrent neural network, a long short-term memory network, a gated recurrent unit, a natural language algorithm, and a self-attention mechanism algorithm.
[0031] The embodiment of the present invention further provides a text data classification and grading device, which is used to improve the reliability of text data classification and grading, and further improve the security of text data, including:
[0032] An acquisition module, used to acquire target text data;
[0033] A feature extraction module is used to obtain a first keyword and its corresponding position feature vector according to a preset matching rule and the target text data; process the target text data based on a word frequency-inverse file frequency algorithm to obtain a weighted feature vector; and perform deep feature extraction on the target text data using a natural language model to obtain a semantic feature vector;
[0034] A feature fusion module, used for performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation;
[0035] The classification and grading module is used to obtain the classification and grading results of the target text data according to a preset classification and grading model and the comprehensive feature representation.
[0036] In one embodiment, the feature extraction module includes:
[0037] A matching unit, configured to obtain a first keyword according to a preset matching rule and the target text data;
[0038] The first determining unit is used to determine the position feature vector according to the starting position and the ending position of the first keyword in the target text data and the total length of the target text data.
[0039] In one embodiment, the feature extraction module includes:
[0040] An acquisition unit, configured to acquire a second keyword from the target text data;
[0041] a second determining unit, configured to determine a word frequency-inverse document frequency value of the second keyword according to the number of times the second keyword appears in the target text data, the total number of pre-acquired texts, and the number of texts containing the second keyword;
[0042] A weighting unit is used to obtain a weighted feature vector according to the word frequency-inverse document frequency value of the second keyword.
[0043] In one embodiment, the feature fusion module includes:
[0044] The weighted summation unit is used to perform weighted summation processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain the comprehensive feature representation.
[0045] In one embodiment, the text data classification and grading device further includes:
[0046] A collection module is used to collect a training sample set, wherein the training sample set includes: batch historical text data and their corresponding actual classification and grading results;
[0047] The training module is used to train the classification algorithm using the training sample set to obtain the preset classification and grading model.
[0048] In one embodiment, the training module is used to:
[0049] Applying the training sample set to train the weight coefficients and classification algorithms corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, to obtain the optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, and the preset classification and grading model;
[0050] Correspondingly, the weighted summation unit is used for:
[0051] The optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector are applied to perform weighted summation processing on the position feature vector, the weighted feature vector, and the semantic feature vector to obtain the comprehensive feature representation.
[0052] In one embodiment, the feature fusion module includes:
[0053] The concatenation unit is used to concatenate the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation.
[0054] In one embodiment, the classification algorithm includes at least one of a recurrent neural network, a long short-term memory network, a gated recurrent unit, a natural language algorithm, and a self-attention mechanism algorithm.
[0055] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text data classification and grading method when executing the computer program.
[0056] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the text data classification and grading method is implemented.
[0057] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the text data classification and grading method is implemented.
[0058] It can be seen from the above technical scheme that the present application provides a method and device for classifying and grading text data. The method includes: obtaining target text data; obtaining a first keyword and its corresponding position feature vector according to a preset matching rule and the target text data; processing the target text data based on a word frequency-inverse file frequency algorithm to obtain a weighted feature vector; applying a natural language model to perform deep feature extraction on the target text data to obtain a semantic feature vector; performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation; obtaining the classification and grading results of the target text data according to a preset classification and grading model and the comprehensive feature representation, which can improve the reliability of the classification and grading of text data, and thus improve the security of text data; can improve the adaptability to changes in the format of sensitive information, reduce the probability of missed reports and false reports, make full use of the overall contextual semantic information, improve the accuracy and adaptability of matching, and even in the face of data in complex contexts, can accurately classify and grade text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 It is a first flow chart of the method for classifying and grading text data in an embodiment of the present application;
[0061] Figure 2 is a second flow chart of the text data classification and grading method in the embodiment of the present application;
[0062] Figure 3 3 is a schematic diagram of a third flow chart of the text data classification and grading method in the embodiment of the present application;
[0063] Figure 4 is a fourth flow chart of the text data classification and grading method in the embodiment of the present application;
[0064] Figure 5 is a fifth flow chart of the text data classification and grading method in the embodiment of the present application;
[0065] Figure 6 is a schematic diagram of the structure of a text data classification and grading device in an embodiment of the present application;
[0066] Figure 7 A schematic block diagram of the system structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0067] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0068] At present, rule matching is a static matching method, which is difficult to accurately match data with complex formats, especially when the format of sensitive information changes greatly, it is easy to have missed or false positives. Existing rule matching methods only have static matching rules and cannot utilize the overall context information, resulting in poor performance in processing data with complex contexts.
[0069] In order to solve the problems existing in the above-mentioned prior art, the embodiment of the present application provides a classification and grading method and device for text data. By integrating the traditional matching model and the natural language model BERT, it can make full use of the prior knowledge of the rules, and at the same time learn more complex semantics and contextual information from the data; this fusion method can overcome the rigidity of rule matching and the problem of difficulty in adapting to changes while retaining the high accuracy of rule matching. The classification and grading model provided by this scheme is also scalable and sustainable. It can add labels to the classification and grading system through manual review feedback information to achieve the scalability of the classification and grading model; in addition, the feedback result information can also be fed back to the classification and grading model to achieve the sustainability of the classification and grading model; by integrating the deep learning method with rule matching, it can improve the accurate classification and grading of sensitive information in complex format data. Complex format data, such as a mixture of structured data, semi-structured and unstructured data (such as Excel documents, HTML web page content and user comments), multilingual data (multilingual data from different countries or regions) and heterogeneous data sources (such as data from different system platforms).
[0070] Traditional rule matching also has limitations in the sentiment analysis task of product evaluation. When traditional matching rules are applied to sentiment analysis of product evaluation, they may focus on some first keywords such as "good", "bad", "satisfied", "disappointed", etc. to judge the user's attitude towards the product. However, such static rules may not cover all situations, especially when the user uses polysemous words or complex sentences when expressing emotions. The text data classification method and device provided by this scheme can be applied to the classification and classification scenarios of text data, and can also be applied to the sentiment analysis scenarios of text data. By integrating deep learning methods, pre-trained language models (such as BERT) can be introduced for sentiment analysis. This method can not only capture the first keyword, but also understand the context of the entire sentence, and better understand the user's emotional tendency. For example, a comment may contain: "Although the price of this product is slightly higher, the quality is satisfactory and it is worth buying." Traditional rule matching may only focus on the two first keywords "high price" and "satisfactory quality", while deep learning methods can understand the context of the entire comment and accurately grasp the user's comprehensive evaluation of the product. This comprehensive method can more comprehensively consider the complexity of user expression of emotions and improve the accuracy and depth of sentiment analysis.
[0071] In order to facilitate the understanding of this solution, the technical terms related to this solution are explained below.
[0072] Metadata: Data that describes data, that is, information that explains, describes or manages the data.
[0073] BERT, the full name of which is Bidirectional Encoder Representations from Transformers, is a transformer-based machine learning technology used for natural language processing pre-training.
[0074] TF-IDF, the full name of which is Term Frequency-Inverse Document Frequency, is a commonly used weighting technique for information retrieval and text mining. It is used to evaluate the importance of a word to a document in a document set or corpus.
[0075] Word segmentation technology is a basic task in natural language processing (NLP). Its goal is to split a continuous text sequence (such as sentences or documents) into a sequence of words or subwords.
[0076] PCA, the full name of which is Principal Component Analysis, is a commonly used dimensionality reduction technique that aims to convert high-dimensional data into low-dimensional data while retaining the main information in the original data.
[0077] Normalization is a data processing method that aims to map the values of different features or variables to a uniform scale or range to eliminate the bias caused by different scales or units.
[0078] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0079] The information collected in the technical solution of this application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with the relevant laws, regulations and standards of relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0080] The acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0081] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0082] The details are described through the following embodiments.
[0083] In order to improve the reliability of text data classification and grading, and further improve the security of text data, this embodiment provides a text data classification and grading method in which the execution subject is a text data classification and grading device, and the text data classification and grading device includes but is not limited to a server, such as Figure 1 As shown, the method specifically includes the following contents:
[0084] Step 101: Obtain target text data.
[0085] Specifically, the target text data may be financial text data that has security control requirements, such as contract texts, financial reports, and personal account information documents.
[0086] Step 102: According to the preset matching rules and the target text data, obtain the first keyword and its corresponding position feature vector; process the target text data based on the word frequency-inverse file frequency algorithm to obtain a weighted feature vector; apply the natural language model to perform deep feature extraction on the target text data to obtain a semantic feature vector.
[0087] Specifically, a natural language model, i.e., a pre-trained BERT model, can be used to convert target text data into an embedded vector representation, and a fixed-dimensional semantic representation can be obtained through a pooling operation as the semantic feature vector.
[0088] Step 103: performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation.
[0089] Step 104: Obtain classification and grading results of the target text data according to a preset classification and grading model and the comprehensive feature representation.
[0090] Specifically, the classification and grading results can be used to evaluate the security classification and security level of the target text data; for example, the classification can be divided into public data, personal information, legal person data, etc.; the classification can be divided into 5 levels: non-confidential level (level 1), secret level (level 2), confidential level (level 3), top secret level (level 4); based on the classification and grading results of the target text data, the security policy can be implemented on the target text data. The corresponding relationship between the category, level and security policy can be pre-set according to the actual situation, so as to facilitate the corresponding security management and control of text data of different categories and levels.
[0091] Before step 400, the comprehensive feature representation may be normalized or standardized to ensure that the overall scale of the comprehensive feature representation is consistent, so as to avoid excessive or insufficient influence of different features on the classification and grading model; the principal component analysis method may be used to perform dimensionality reduction on the normalized or standardized comprehensive feature representation. The preset classification and grading model may be obtained by pre-training the classification algorithm based on batch historical text data and their corresponding actual classification and grading results.
[0092] In order to capture the location context information, the relationship between the matching results and the surrounding text is provided to provide a more comprehensive contextual understanding, such as Figure 2 As shown, in one embodiment, the step 102 of obtaining the first keyword and its corresponding position feature vector according to the preset matching rule and the target text data includes:
[0093] Step 201: Obtain a first keyword according to a preset matching rule and the target text data.
[0094] Specifically, the first keyword may represent a keyword extracted from the target text data by applying a preset matching rule.
[0095] In this embodiment, a preset regular expression can be applied to extract the first keyword in the target text data; the preset regular expression can be set according to actual conditions, and this application does not limit this. A preset first keyword table can also be applied to extract the first keyword in the target text data; the preset first keyword table contains a batch of first keywords, which can be set according to actual conditions, and this application does not limit this.
[0096] Step 202: Determine the position feature vector according to the starting position and ending position of the first keyword in the target text data and the total length of the target text data.
[0097] Specifically, the starting position ratio = starting position / total length of the target text data, the ending position ratio = ending position / total length of the target text data, and the position feature vector = [starting position / total length of the target text data ending position / total length of the target text data]. For example, assuming that the target text data includes: "Company A's net profit increased by 10% this quarter, mainly due to the launch of new products", the total length of the text is 100 characters, the first keyword is "net profit", the starting position of the first keyword in the target text data is the 7th character in the text, and the ending position of the first keyword in the target text data is the 9th character in the text, then it can be determined that the position feature vector = [7 / 100 9 / 100].
[0098] Specifically, position features can reflect the relationship between keywords and other parts of the text, such as sentence structure, paragraph structure, etc., which can facilitate a more accurate understanding of the semantics of the text; position features can facilitate accurate identification of specific patterns in text data, which can be grammatical structures, semantic relationships, or specific expressions, etc. For example, in Chinese, adjectives usually come before the nouns they modify; position features can help understand the contextual relationship between words. For example, a word may represent the topic at the beginning of a sentence and the conclusion at the end.
[0099] In order to pay more attention to keywords with special significance in the financial field and improve the reliability of the subsequent classification and grading of text data, such as Figure 3 As shown, in one embodiment, the target text data is processed based on the word frequency-inverse document frequency algorithm described in step 102 to obtain a weighted feature vector, including:
[0100] Step 301: Acquire a second keyword in the target text data.
[0101] Specifically, all non-repeating entries in the target text data can be extracted as the second keyword; for example, assuming that the target text data includes: "Application of deep learning in artificial intelligence", then it can be determined that the second keywords include: deep, learning, in, artificial intelligence, in, application.
[0102] Step 302: Determine the word frequency-inverse document frequency value of the second keyword according to the number of times the second keyword appears in the target text data, the total number of pre-acquired texts, and the number of texts containing the second keyword.
[0103] Specifically, the term frequency-inverse document frequency value TF-IDF of the second keyword i i =TF i ×IDF i , TF i is the frequency of the second keyword i in the target text data, IDF i =log(total number of documents / number of documents containing the second keyword i).
[0104] Step 303: Obtain a weighted feature vector according to the word frequency-inverse document frequency value of the second keyword.
[0105] Specifically, assuming that there are multiple second keywords in the target text data, the weighted feature vector can be composed of the word frequency-inverse document frequency values of each second keyword in the target text data. For example, assuming that the second keywords include: depth, learning, in, artificial intelligence, in, of, application, then the weighted feature vector of the target text data, i.e., the TF-IDF vector, can be determined as: [TF-IDF("depth"), TF-IDF("learning"), TF-IDF("in"), TF-IDF("artificial intelligence"), TF-IDF("in"), TF-IDF("of"), TF-IDF("application")].
[0106] In order to effectively combine the feature vectors obtained in different ways and achieve a more comprehensive understanding of text data, thereby improving the reliability of text data classification and grading, such as Figure 4 As shown, in one embodiment, step 103 includes:
[0107] Step 401: Perform weighted sum processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain the comprehensive feature representation.
[0108] Specifically, w is a weight vector, whose elements are weight w1 corresponding to the position feature vector, weight w2 corresponding to the weighted feature vector, and weight w3 corresponding to the semantic feature vector. As a preference, w1 to w3 can be defaulted to 0.3, 0.3, and 0.4 respectively; f r is the position eigenvector. k is a weighted feature vector (e.g., using TF-IDF score). b is the semantic feature vector. The weight vector w and each feature vector can be expressed as:
[0109]
[0110] Where n is the number of first keywords, m is the number of second keywords, and p is the dimension of the semantic feature vector. The weighted fusion comprehensive feature vector f combined It can be expressed in matrix form:
[0111] f combined =wΘ[f r f k f b ]
[0112] Here, Θ represents the Hadamard (element-wise) product, which is the multiplication of corresponding elements. If n, m, and p are the same, the calculation process is as follows:
[0113]
[0114] If n, m, and p have different values, the number of elements in the comprehensive eigenvector can be the maximum value among n, m, and p. If the maximum value among n, m, and p is n, then f k and f b The elements that do not exist in f combined The default is zero, for example:
[0115]
[0116] In practical applications, f r , f k and f b It may be necessary to convert to a vector of the same dimension through an appropriate mapping function for weighted fusion. In addition, the weights w1, w2, and w3 need to be adjusted according to the importance of the features and experimental results.
[0117] In order to improve the reliability of classification and grading model training, and then apply reliable classification and grading models to improve the accuracy of classification and grading of text data, such as Figure 5 As shown, in one embodiment, the text data classification and grading method further includes:
[0118] Step 501: Collect a training sample set, which includes: batch historical text data and their corresponding actual classification and grading results.
[0119] Specifically, in order to ensure the consistency of the input of the classification and grading model, the number of the batch of historical text data can be the same as the total number of the above texts, and the number of texts containing the second keyword can be equal to the number of historical text data containing the second keyword in the batch of historical text data. The actual classification and grading result of each historical text data can include the real category and level of the historical text data.
[0120] Step 502: Apply the training sample set to train the classification algorithm to obtain the preset classification and grading model.
[0121] Specifically, the classification algorithm may include: at least one of a recurrent neural network, a long short-term memory network, a gated recurrent unit, a natural language algorithm, and a self-attention mechanism algorithm.
[0122] In order to improve the reliability of determining the weight coefficient of the feature vector, consider the importance of each feature vector, better integrate multi-source features, and improve the reliability of the subsequent classification and grading of text data, in one embodiment, step 502 includes:
[0123] The training sample set is used to train the weight coefficients and classification algorithms corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, to obtain the optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, and the preset classification and grading model; correspondingly, step 401 includes:
[0124] The optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector are applied to perform weighted summation processing on the position feature vector, the weighted feature vector, and the semantic feature vector to obtain the comprehensive feature representation.
[0125] Specifically, the weight coefficient can be a learnable weight parameter, and the initial values of the weight coefficients corresponding to the position feature vector, weighted feature vector, and semantic feature vector can be set. During the training process, the value of the weight coefficient can be adjusted until the value of the cross entropy loss function of the classification and grading model is minimized, and the current classification and grading model is determined as the trained classification and grading model, and the current weight coefficient is determined as the optimal weight coefficient.
[0126] In order to improve the efficiency of obtaining a comprehensive feature representation while ensuring the integrity of the position feature vector, the weighted feature vector and the semantic feature vector, in one embodiment, step 103 includes: concatenating the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation.
[0127] For example, each eigenvector can be expressed as: The comprehensive feature obtained by splicing is expressed as: f combined =[f r1 ,f r2 ,...,f rn ,f k1 ,f k2 ,f k3 ,...,f km ,f b1 ,f b2 ,f b3 ,...,f bp ].
[0128] In order to further illustrate this solution, this application provides an application example, which is specifically described as follows:
[0129] Step 1: Establish a basic corpus, including:
[0130] Step 11: Establish a classification and grading label system. It is necessary to sort out and form a unified data classification and grading label system based on laws, regulations and financial industry standards, combined with actual conditions. For example, the classification can be divided into public data, personal information, legal person data, etc.; the classification can be divided into 5 levels: non-confidential level (level 1), secret level (level 2), confidential level (level 3), top secret level (level 4).
[0131] Step 12: Manual labeling: classify and label important or sensitive data according to the classification and grading labeling system.
[0132] Step 2: Model training, which includes:
[0133] Step 21: Data preprocessing: Divide the basic corpus into data sets, which are divided into training sets, validation sets, and test sets. Use word segmentation technology to perform word segmentation and standardization on the data sets to improve the quality of the data sets.
[0134] Step 22: Data feature extraction, including:
[0135] 1) Rule matching: For the features of rule matching results, the starting and ending position information of the matching results can be extracted and converted into position features. Position features allow the model to understand the relative position of the rule matching results in the text. This helps capture contextual information, that is, the relationship between the matching results and the surrounding text, and provides a more comprehensive contextual understanding.
[0136] For example, in the financial industry, to identify transaction risk texts, you can identify texts that may involve risks based on specific keywords and classify them.
[0137] For example, the text data records: "This contract stipulates the risk disclosure terms that both parties must comply with when trading financial products to assess and control possible market fluctuations...", and the confidentiality agreement mentioned is identified and classified. Matching result: "Risk Disclosure", starting position: 27th character in the text data, end position: 30th character in the text data. The following are the steps to convert to position features:
[0138] 1. Determine the text length: Determine the length of the entire text to standardize position features.
[0139] 2. Calculate the position ratio: Convert the starting and ending positions of the matching results into a ratio relative to the length of the entire text, that is,
[0140] 3. Create a position feature vector: The position feature can be a two-dimensional vector representing the ratio of the start and end positions.
[0141] If the total length of the text data "This contract stipulates the risk disclosure terms that both parties must comply with when trading financial products in order to assess and control possible market fluctuations..." is 100 characters, then the position feature vector can be expressed as:
[0142]
[0143] 4. Standardization: In order to eliminate the influence of text length on position features, the position ratio can be further standardized to the [0,1] interval.
[0144] 5. Combine with other features: Position features can be combined with other features to form a comprehensive feature vector, which is then provided as input data to the classification and grading model.
[0145] 6. Apply to the model: Combine this position feature vector with other features (such as word embedding of text content or BERT embedding, etc.) as the input of the classification and grading model.
[0146] 2) Keyword recognition: For the features of keyword recognition results, use word frequency or TF-IDF and other methods to weight them, so that the keyword information is more distinguishable. Suppose there is a document of personal account information, and its keyword recognition results include: "account information", "transaction record" and "identity authentication". Although the ranking of "account information" may appear less frequently in the entire document, it is very important in the current text. Through TF-IDF feature processing, the subsequent classification and grading model can pay more attention to these keywords that have special significance in the financial field.
[0147] 3) BERT feature extraction: Use the pre-trained BERT model to convert the text sequence into an embedded vector representation. Perform a pooling operation on the output data of the BERT model, for example, average pooling or CLS tag pooling, to obtain a fixed-dimensional semantic representation.
[0148] Among them, 1) the input data of rule matching is text data and a set of predefined rules or patterns. 2) The input data of keyword recognition is text data and a possible keyword list or dictionary. 3) The input data of BERT feature extraction is text data. The relationship between these three methods is complementary: rule matching can provide accurate recognition of specific patterns in text. Keyword recognition can help highlight key concepts or entities in the text. BERT feature extraction can provide a deep understanding of the overall semantics of the text.
[0149] Step 23: Feature fusion: Concatenate or weighted sum the position features of rule matching, the TF-IDF weighted features of the first keyword recognition, and the semantic features extracted by BERT to obtain the final comprehensive feature representation. The weighted fusion method can be used by default. Normalize or standardize the fused features to ensure that the scale of the overall features is consistent and to avoid different features from having too much or too little impact on the classification and grading model. If the fused feature dimension is too high, PCA can also be used for dimensionality reduction to reduce redundant information and speed up the model training process.
[0150] The initialization weights of rule matching, keyword recognition, and BERT features are set to 0.3, 0.3, and 0.4, respectively, and the final weights can be fine-tuned based on training.
[0151] w is a weight vector, whose elements are the weight w1 of the rule matching feature, the weight w2 of the keyword recognition feature, and the weight w3 of the BERT feature, which are 0.3, 0.3, and 0.4 by default, respectively. r is the vector of rule matching features, which can be equivalent to the above position feature vector. k is a vector of keyword identification features (for example, using TF-IDF scores), which can be equivalent to the weighted feature vector mentioned above. b is the vector of BERT features, which is equivalent to the above semantic feature vector. The weight vector w and each feature vector can be expressed as:
[0152]
[0153] Among them, n is the number of rule matching features, which can be equivalent to the number of the first keywords mentioned above, m is the number of keywords, which can be equivalent to the number of the second keywords mentioned above, and p is the dimension of the BERT model output, which can be equivalent to the dimension of the semantic feature vector mentioned above.
[0154] Comprehensive feature vector f combined It can be expressed in matrix form: combined =wΘ[f r f k f b ].
[0155] Here, Θ represents the Hadamard (element-wise) product, that is, the corresponding elements are multiplied. Specifically, if we only consider the fusion of keyword recognition features and BERT features, the calculation process is as follows:
[0156]
[0157] Step 24: Model training: Select a suitable deep learning model and use the training set to train the selected model. In this process, the model will learn the relationship between features and classification and grading labels. The model can use the cross entropy loss function, the goal is to make the classification and grading results predicted by the model as close as possible to the actual category and level. In addition, it is necessary to adjust the model parameters to fit the training data to the greatest extent to improve the performance and generalization ability of the model. You can select at least one of the following deep learning models for model training:
[0158] (1) Recurrent Neural Network (RNN) and its variants (such as LSTM and GRU): If the fused features contain sequence information, RNN and its variants can handle sequence dependencies.
[0159] (2) BERT and its variants (such as RoBERTa, ALBERT, ELECTRA): These models have been pre-trained on a large amount of text data and can capture language nuances and contextual information well.
[0160] (3) Transformer model: In addition to BERT, other Transformer-based models can also be used for classification tasks, especially when the model is required to capture long-distance dependencies.
[0161] Step 3: Closed-loop learning. Specifically includes:
[0162] Step 31: When both the training set and the validation set can achieve a high accuracy rate, a basic model is obtained. This basic model can be used to automatically classify and grade the existing data.
[0163] Step 32: Manual review of the classification and grading results output by the model becomes an important link. In this process, if it is found that the classification result should belong to the new data label classification, this information can be fed back to step 1 to update the data security label system and realize dynamic labeling of incremental data. This dynamic labeling mechanism can flexibly respond to changes in data security labels and the introduction of new classifications. At the same time, if errors are found in the classification and grading results during manual review, manual corrections can be made and the correction information can be fed back to step 2. This link is a closed-loop mechanism that allows the model to gradually improve its understanding of misjudged data by introducing manual corrections, thereby improving the overall recognition accuracy. Such a continuous feedback loop helps the model gradually adapt to and correct complex situations encountered in practical applications, and improves the robustness and accuracy of the model.
[0164] Step 33: For those verified correct classification and grading results, they can be directly put on the shelf for display. The entire process can achieve dynamic and accurate data classification and grading by combining the strategy of AI model automatic classification and manual review.
[0165] From the above description, it can be seen that this application example can introduce a natural language model, namely the BERT model, to improve adaptability to changes in sensitive information formats and reduce the probability of missed reports and false positives by learning the dynamic patterns of data. Traditional matching rules can be integrated with natural language models to make full use of the overall contextual semantic information, which can improve the accuracy and adaptability of matching, and even when facing data in complex contexts, the data can be correctly classified and graded.
[0166] The present invention also provides a text data classification and grading device, as described in the following embodiments. Since the principle of the device to solve the problem is similar to the text data classification and grading method, the implementation of the device can refer to the implementation of the text data classification and grading method, and the repeated parts will not be repeated.
[0167] like Figure 6 As shown, in one embodiment, the text data classification and grading device includes:
[0168] The acquisition module 61 is used to acquire target text data.
[0169] The feature extraction module 62 is used to obtain the first keyword and its corresponding position feature vector according to the preset matching rules and the target text data; process the target text data based on the word frequency-inverse file frequency algorithm to obtain a weighted feature vector; and apply the natural language model to perform deep feature extraction on the target text data to obtain a semantic feature vector.
[0170] The feature fusion module 63 is used to perform feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation.
[0171] The classification and grading module 64 is used to obtain the classification and grading results of the target text data according to a preset classification and grading model and the comprehensive feature representation.
[0172] In one embodiment, the feature extraction module includes:
[0173] A matching unit, configured to obtain a first keyword according to a preset matching rule and the target text data;
[0174] The first determining unit is used to determine the position feature vector according to the starting position and the ending position of the first keyword in the target text data and the total length of the target text data.
[0175] In one embodiment, the feature extraction module includes:
[0176] An acquisition unit, configured to acquire a second keyword from the target text data;
[0177] a second determining unit, configured to determine a word frequency-inverse document frequency value of the second keyword according to the number of times the second keyword appears in the target text data, the total number of pre-acquired texts, and the number of texts containing the second keyword;
[0178] A weighting unit is used to obtain a weighted feature vector according to the word frequency-inverse document frequency value of the second keyword.
[0179] In one embodiment, the feature fusion module includes:
[0180] The weighted summation unit is used to perform weighted summation processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain the comprehensive feature representation.
[0181] In one embodiment, the text data classification and grading device further includes:
[0182] A collection module is used to collect a training sample set, wherein the training sample set includes: batch historical text data and their corresponding actual classification and grading results;
[0183] The training module is used to train the classification algorithm using the training sample set to obtain the preset classification and grading model.
[0184] In one embodiment, the training module is used to:
[0185] Applying the training sample set to train the weight coefficients and classification algorithms corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, to obtain the optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, and the preset classification and grading model;
[0186] Correspondingly, the weighted summation unit is used for:
[0187] The optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector are applied to perform weighted summation processing on the position feature vector, the weighted feature vector, and the semantic feature vector to obtain the comprehensive feature representation.
[0188] In one embodiment, the feature fusion module includes:
[0189] The concatenation unit is used to concatenate the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation.
[0190] In one embodiment, the classification algorithm includes at least one of a recurrent neural network, a long short-term memory network, a gated recurrent unit, a natural language algorithm, and a self-attention mechanism algorithm.
[0191] The embodiment of the text data classification and grading device provided in this specification can be specifically used to execute the processing flow of the embodiment of the above-mentioned text data classification and grading method. Its functions are not repeated here, and reference can be made to the detailed description of the embodiment of the above-mentioned text data classification and grading method.
[0192] Figure 7 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as Figure 7 As shown, the electronic device includes: a processor (processor) 701, a memory (memory) 702 and a bus 703.
[0193] The processor 701 and the memory 702 communicate with each other via a bus 703 .
[0194] The processor 701 is used to call the program instructions in the memory 702 to execute the text data classification and grading methods provided by the above-mentioned method embodiments.
[0195] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned text data classification and grading method is implemented.
[0196] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned text data classification and grading method is implemented.
[0197] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention 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.
[0198] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of 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 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.
[0199] 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.
[0200] 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.
[0201] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for classifying and grading text data, characterized in that: include: Get target text data; According to the preset matching rules and the target text data, a first keyword and its corresponding position feature vector are obtained; the target text data is processed based on a word frequency-inverse file frequency algorithm to obtain a weighted feature vector; a natural language model is applied to perform deep feature extraction on the target text data to obtain a semantic feature vector; Performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation; According to the preset classification and grading model and the comprehensive feature representation, the classification and grading results of the target text data are obtained.
2. The text data classification and grading method according to claim 1, characterized in that: The step of obtaining the first keyword and its corresponding position feature vector according to the preset matching rule and the target text data includes: Obtaining a first keyword according to a preset matching rule and the target text data; The position feature vector is determined according to the starting position and the ending position of the first keyword in the target text data and the total length of the target text data.
3. The text data classification and grading method according to claim 1, characterized in that: The target text data is processed based on the word frequency-inverse file frequency algorithm to obtain a weighted feature vector, including: Acquire a second keyword in the target text data; Determining a word frequency-inverse document frequency value of the second keyword according to the number of times the second keyword appears in the target text data, the total number of pre-acquired texts, and the number of texts containing the second keyword; A weighted feature vector is obtained according to the word frequency-inverse document frequency value of the second keyword.
4. The text data classification and grading method according to claim 1, characterized in that: The step of performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation includes: The position feature vector, the weighted feature vector and the semantic feature vector are subjected to weighted summation processing to obtain the comprehensive feature representation.
5. The text data classification and grading method according to claim 4, characterized in that: Also includes: Collecting a training sample set, the training sample set includes: batch historical text data and their corresponding actual classification and grading results; The classification algorithm is trained using the training sample set to obtain the preset classification and grading model.
6. The text data classification and grading method according to claim 5, characterized in that: The applying the training sample set to train the classification algorithm to obtain the preset classification and grading model includes: Applying the training sample set to train the weight coefficients and classification algorithms corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, to obtain the optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector, respectively, and the preset classification and grading model; Correspondingly, the weighted summing of the position feature vector, the weighted feature vector and the semantic feature vector to obtain the comprehensive feature representation includes: The optimal weight coefficients corresponding to the position feature vector, the weighted feature vector, and the semantic feature vector are applied to perform weighted summation processing on the position feature vector, the weighted feature vector, and the semantic feature vector to obtain the comprehensive feature representation.
7. The text data classification and grading method according to claim 1, characterized in that: The step of performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation includes: The position feature vector, the weighted feature vector and the semantic feature vector are concatenated to obtain a comprehensive feature representation.
8. The text data classification and grading method according to claim 5 or 6, characterized in that: The classification algorithm includes: at least one of a recurrent neural network, a long short-term memory network, a gated recurrent unit, a natural language algorithm and a self-attention mechanism algorithm.
9. A text data classification and grading device, characterized in that: include: An acquisition module, used to acquire target text data; A feature extraction module is used to obtain a first keyword and its corresponding position feature vector according to a preset matching rule and the target text data; process the target text data based on a word frequency-inverse file frequency algorithm to obtain a weighted feature vector; and perform deep feature extraction on the target text data using a natural language model to obtain a semantic feature vector; A feature fusion module, used for performing feature fusion processing on the position feature vector, the weighted feature vector and the semantic feature vector to obtain a comprehensive feature representation; The classification and grading module is used to obtain the classification and grading results of the target text data according to a preset classification and grading model and the comprehensive feature representation.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for classifying and grading text data as described in any one of claims 1 to 8 is 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 method for classifying and grading text data according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method for classifying and grading text data according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
BERT-A-BiLSTM-based multi-feature patent automatic classification algorithm
CN113011527A
Text clustering method based on artificial intelligence, related equipment and storage medium
CN113392209A
Text recognition method based on position information and related device
CN113590832A
Text classification method and device based on word right statistics and pre-training model
CN118535743A
Text clustering method, electronic device and storage medium
WO2022126944A1
Cited By
Data resource classification method and device based on rule and semantic approximation in combination with AI
CN121456535A
