A labeling method, system and storage medium thereof
The deep learning model is used to calculate the tag keywords and tag keyword matching times and scores of latent semantic texts, which solves the problem of existing technology being unable to find consistent latent semantic tags, and enables efficient tagging without changing the model logic code. Maintained business continuity.
Patent Information
- Application Number
- CN202210666638.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-14
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-06-14
AI Technical Summary
Existing labeling methods cannot discover potentially semantically consistent keywords and keywords, and when modifying the labeling system or rules, it is necessary to change the model logic code or retrain the classification model, which increases complexity and interrupts business coherence.
By preprocessing the semantic text, building a deep learning model, calculating the number of matches between tag keywords and tag keywords and the score of the deep learning model, and calculating the third score to decide whether to tag, it is possible to achieve this without changing the model logic. Discovering potentially semantically consistent tags in code contexts.
It realizes the discovery and marking of more potentially semantically consistent mark statements without changing the model logic code, reducing out-of-system operations and maintaining business continuity.
Smart Images

Figure CN115130438B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text labeling, and in particular to a labeling method, system and storage medium thereof. Background Art
[0002] The existing tagging methods are mainly based on keywords and key words. When the keywords and key words corresponding to the tagging rules appear in the text paragraph to be tagged, the corresponding tags are added to the text paragraph. However, this method is relatively mechanical and cannot find keywords and key words with consistent potential semantics for tagging.
[0003] The definition of label systems and rules is flexible and changeable in response to different business needs of users. Some current methods require changing the model logic code or retraining the classification model and then redeploying the model after modifying the label system or changing the rules, which increases the complexity and interrupts business continuity. How to find label keywords and label keywords (label keywords and label keywords are marked sentences) with consistent potential semantics without changing the model logic code and then label them is a difficult problem in existing technologies. Summary of the invention
[0004] The purpose of the present invention is to overcome the above-mentioned technical deficiencies and provide a labeling method, system and storage medium thereof to solve the technical problem of the prior art of how to discover label keywords and label keywords that are potentially semantically consistent and then label without changing the model logic code.
[0005] In order to achieve the above technical objectives, the technical solution of the present invention provides a labeling method, comprising the following steps:
[0006] S1, preprocessing the semantic text;
[0007] S2, building a deep learning model based on the preprocessed semantic text and using the training set data to train the model to obtain a trained model;
[0008] S3, obtaining the number of matches between the tag keyword and the tag keyword in the text to be marked by traversing or scanning the text to be marked, and calculating the first score of the tag keyword and the tag keyword according to the matching score, which is recorded as a; calculating the second score of the tag keyword and the tag keyword by the trained model through the text to be marked, which is recorded as b;
[0009] S4. derive a third score of the label corresponding to the text to be marked according to the first score and the second score, denoted as c, and decide whether to add a corresponding label to the text to be marked according to the third score.
[0010] Furthermore, in step S1, the preprocessing of the semantic text includes: segmenting the sentence to obtain a word segmentation list, dividing the word segmentation list into a training set, a validation set and a test set, and then training a word embedding model or a character embedding model to obtain a representation of the text, and the word segmentation list is used to count label keywords and label keywords.
[0011] Further, in step S3, the calculation method of the first score is as follows: if the number of matches between the tag keyword and the tag keyword is less than 3 times, the score is calculated according to the actual number of times; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 3 times and less than 5 times, it is calculated as 3 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 5 times and less than 10 times, it is calculated as 5 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 10 times, it is calculated as 10 points.
[0012] Further, in step S3, the second score is calculated by X max Indicates the maximum value of the calculation score of the deep learning model, X min represents the minimum value of the calculation score of the deep learning model, and X represents the actual calculation score of the deep learning model for the labeled text.
[0013] Further, in step S4, the calculation formula of the third score is: c=0.5*a+0.5*b.
[0014] Further, in step S4, when the third score c is greater than or equal to 6 points, the text to be marked is marked with the current label, otherwise, the text to be marked is not marked with the current label.
[0015] Furthermore, in step S1, the division ratio of the training set, the validation set and the test set is set to 3:1:1.
[0016] Furthermore, the method further comprises the step: S5, creating a dictionary, wherein the dictionary is used to store data with a third score greater than or equal to 8 points.
[0017] In addition, the present invention also provides a labeling system as described above, comprising:
[0018] A preprocessing module is used to preprocess the semantic text;
[0019] A training module is used to build a deep learning model based on the preprocessed semantic text and use the training set data to train the model to obtain a trained model;
[0020] A scoring module is used to obtain the tag keyword or the number of matches of the tag keyword in the text to be marked by traversing or scanning the text to be marked, and calculate the first score of the tag keyword and the tag keyword according to the matching score, which is recorded as a; and calculate the second score of the tag keyword or the tag keyword by the trained model through the text to be marked, which is recorded as b;
[0021] The labeling module is used to obtain a third score of the label corresponding to the text to be labeled according to the first score and the second score, denoted as c, and the third score determines whether to label the text to be labeled with a corresponding label.
[0022] In addition, the present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the labeling method as described above are implemented.
[0023] Compared with the prior art, the beneficial effects of the present invention include: preprocessing the semantic text; then building a deep learning model based on the preprocessed semantic text and using the training set data to train the model to obtain a trained model; then traversing or scanning the text to be labeled to obtain the number of matches of the label keywords or label keywords in the text to be labeled, and calculating the first score of the label keywords and the label keywords according to the matching score, recorded as a; calculating the second score of the label keywords or label keywords by the trained model through the text to be labeled, recorded as b; then obtaining the third score of the label corresponding to the text to be labeled according to the first score and the second score, recorded as c, the third score determines whether to label the text to be labeled with the corresponding label, and the third score of the label is obtained by combining the label keywords, label keywords and semantics. The method can discover or label more potentially semantically consistent label sentences. In addition, the entire process of label definition, training and labeling is operated in the system, which reduces operations outside the system and allows users to maintain consistency in use. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a flow chart of a labeling method according to a specific embodiment of the present invention;
[0025] Figure 2 It is a structural block diagram of a labeling system according to a specific embodiment of the present invention. DETAILED DESCRIPTION
[0026] Combination Figure 1 This specific implementation provides a labeling method, comprising the following steps:
[0027] S1. Preprocessing the semantic text; specifically, segmenting the sentences to obtain a word list, dividing the word list into a training set, a validation set and a test set, and then training a word embedding model or a character embedding model to obtain a representation of the text, wherein the word list is used to count label keywords and label keywords; further, the division ratio of the training set, the validation set and the test set is preferably set to 3:1:1;
[0028] S2, building a deep learning model based on the preprocessed semantic text and using the training set data to train the model to obtain a trained model;
[0029] S3. Obtain the number of matches between the tag keyword and the tag keyword in the text to be labeled by traversing or scanning the text to be labeled, and calculate the first score of the tag keyword and the tag keyword according to the matching score, which is recorded as a; calculate the second score of the tag keyword and the tag keyword by the trained model of the text to be labeled, which is recorded as b; the calculation method of the first score is that the number of matches between the tag keyword and the tag keyword is less than 3 times, and the score is calculated according to the actual number of times; the number of matches between the tag keyword and the tag keyword is greater than or equal to 3 times and less than 5 times, which is counted as 3 points; the number of matches between the tag keyword and the tag keyword is greater than or equal to 5 times and less than 10 times, which is counted as 5 points; the number of matches between the tag keyword and the tag keyword is greater than or equal to 10 times, which is counted as 10 points; the calculation method of the second score is X max Indicates the maximum value of the calculation score of the deep learning model, X min represents the minimum value of the calculation score of the deep learning model, and X represents the actual calculation score of the deep learning model for the labeled text;
[0030] S4. derive a third score of the label corresponding to the text to be marked according to the first score and the second score, denoted as c, and decide whether to label the text to be marked according to the third score; the calculation formula of the third score is: c=0.5*a+0.5*b; when the third score c is greater than or equal to 6 points, label the text to be marked with the current label, otherwise, do not label the text to be marked with the current label.
[0031] In some embodiments, the method further includes step S5, creating a dictionary to store data with a third score greater than or equal to 8 points; further, the method further includes calculating the number of each category of data in the dictionary, and automatically optimizing the model when more than half of the categories have more than 1,000 data in the list. At this time, the data of each category in the dictionary is merged with the data of each category in step 4, and steps S2-S4 are repeated. Otherwise, the task is completed.
[0032] Combination Figure 2This specific implementation also proposes a labeling system, including:
[0033] A preprocessing module is used to preprocess the semantic text;
[0034] A training module is used to build a deep learning model based on the preprocessed semantic text and use the training set data to train the model to obtain a trained model;
[0035] The scoring module obtains the tag keyword or the number of matches of the tag keyword in the text to be marked by traversing or scanning the text to be marked, and calculates the first score of the tag keyword and the tag keyword according to the matching score, which is recorded as a; and calculates the second score of the tag keyword or the tag keyword by the trained model through the text to be marked, which is recorded as b;
[0036] The labeling module is used to obtain a third score of the label corresponding to the text to be labeled according to the first score and the second score, denoted as c, and the third score determines whether to label the text to be labeled with a corresponding label.
[0037] In addition, this specific embodiment also proposes a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned labeling method are implemented.
[0038] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the labeling method of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0039] Example 1
[0040] This embodiment provides a labeling method, including the following steps:
[0041] S0. Before labeling, create a label and enter and upload the labeling basis; then enter the basic information of the label and the labeling basis. The basic information includes: label name, label type, label parent and other information. The labeling basis includes: label keywords, label keywords and semantic files. Among them, label keywords and label keywords are the word and phrase basis for manual labeling; semantic files are the texts that have been sorted and manually determined to be in this category;
[0042] Take the example of labeling the review text of a laptop computer product:
[0043] The labels are divided into "good review", "average review" and "bad review". The labeling basis of "good review" is:
[0044] Keywords: fast; smooth; comfortable; clear; convenient; thin and light; ...
[0045] The semantic files include:
[0046] This laptop really didn't disappoint me. It's exquisitely made, thin and light, and feels great in the hand. The screen resolution is very high, very clear, and the display effect is great, which can be described as delicate and stunning.
[0047] The computer runs extremely fast, has good heat dissipation performance, and is ultra-thin and easy to carry.
[0048] Unexpected heat dissipation effect, it does not get hot at all during use. It is equipped with a fast charging head and can work continuously for 8 hours without any problem on a full charge. The battery life exceeds expectations.
[0049] The machine is very good-looking, the operation is very smooth, and the screen display is especially delicate.
[0050] When traveling for work, you need a notebook that is thin, portable and has a long battery life.
[0051] S1. Preprocess the semantic text, including word segmentation, removal of stop words, data division and other tasks; specifically, the system background first loads the stop word list, then processes the uploaded semantic file sentence by sentence, uses the "word segmentation method based on sequence annotation" in the prior art to segment the sentence to obtain a word segmentation list, traverses the word segmentation list, checks each element in the word segmentation list, and if this element exists in the stop word list, removes this element from the word segmentation list, and finally returns the word segmentation list, divides the word segmentation list into a training set, a validation set and a test set, and then trains a word embedding model or a character embedding model to obtain a representation of the text, and the word segmentation list is used to count label keywords and label keywords; further, the division ratio of the training set, the validation set and the test set is set to 3:1:1; the model used in this embodiment is the TextCNN model in the prior art; the text to be scored is vectorized using a character embedding model or a word embedding model, and then the convolution is calculated through a convolution kernel, and then the score is obtained through pooling and softmax;
[0052] S2. Build a deep learning model based on the preprocessed semantic text and use the training set data to train the model to obtain the trained model; after the model training is completed, the label status of the label will be updated to "model training successful" or "model training failed". When the model training is successful, the system will generate a new training model. The system will use the test set to test the model performance. When the model performance is higher than the historical best version, the system will replace the labeled model with the new training model. Otherwise, the historical best version model will continue to be used. When the model training fails, the new training model will not be generated. The system will display the error information during the model training process for users to troubleshoot and solve the problem;
[0053] S3. Obtain the number of matches between the tag keyword and the tag keyword in the text to be labeled by traversing or scanning the text to be labeled, and calculate the first score of the tag keyword and the tag keyword according to the matching score, which is recorded as a; calculate the second score of the tag keyword and the tag keyword by the trained model of the text to be labeled, which is recorded as b, and the value of the second score b is standardized to the interval [0,10]; the calculation method of the first score is that the number of matches between the tag keyword and the tag keyword is less than 3 times, and the score is calculated according to the actual number of times. For example, if the number of matches is 1, the first score is 1 point. If the number of matches is 0, the first score is 0 point; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 3 times and less than 5 times, it is counted as 3 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 5 times and less than 10 times, it is counted as 5 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 10 times, it is counted as 10 points; the calculation method of the second score is X max Indicates the maximum value of the calculation score of the deep learning model, X min represents the minimum value of the calculation score of the deep learning model, and X represents the actual calculation score of the deep learning model for the labeled text;
[0054] It should be noted that the number of matches between the tag keyword and the tag keyword in the text to be tagged is obtained by traversing or scanning the text to be tagged, including: using the "sequence tagging-based word segmentation method" to segment the text to be tagged to obtain a word segmentation list, traversing the word segmentation list, checking each element in the word segmentation list, if the current element exists in the keyword and word list, the number of matches is increased by 1, and the operation is repeated until the traversal is completed;
[0055] S4. derive a third score of the label corresponding to the text to be marked according to the first score and the second score, denoted as c, and decide whether to label the text to be marked according to the third score; the calculation formula of the third score is: c=0.5*a+0.5*b; when the third score c is greater than or equal to 6 points, label the text to be marked with the current label, otherwise, do not label the text to be marked with the current label.
[0056] In this embodiment, a dictionary is also created to store data where the third score is greater than or equal to 8. The dictionary format is as follows:
[0057] dic = {'Classification 1': [data 1, data 2, data 3 ...], 'Classification 2': [data 4, data 5 ...], 'Classification 3': [data 6, data 7, data 8 ...], 'Classification 4': [ ...], ..., 'Classification n': [data p, data q, ...]}, when the third score of the text data to be marked is greater than or equal to 8 points, the data is stored in the list of the corresponding category. The number of categories can be n, and the value of n is set according to needs. The number of categories in this embodiment is 3.
[0058] Calculate the number of data in each category in the dictionary. When more than half of the categories have more than 1,000 data in the list, automatically optimize the model. At this time, merge the data of each category in the dictionary with the data of each category in step 4, and repeat steps S2-S4. Otherwise, the task is completed.
[0059] The labeling method proposed in the present invention combines label keywords, label key words and semantic methods in labeling, and can discover or label more label sentences that are potentially semantically consistent. The entire process of label definition, training and labeling is operated in the system, which reduces operations outside the system and allows users to maintain consistency in use.
[0060] The specific implementation of the present invention described above does not constitute a limitation on the protection scope of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A labeling method, It is characterized in that The following steps are involved: S1, preprocessing the semantic text; S2, building a deep learning model based on the preprocessed semantic text and using the training set data to train the model to obtain a trained model; S3, obtaining the number of matches between the tag keyword and the tag keyword in the text to be marked by traversing or scanning the text to be marked, and calculating the first score of the tag keyword and the tag keyword according to the number of matches, which is recorded as a; The trained model is used to calculate the text to be labeled to obtain the label keyword and the second score of the label keyword, which is recorded as b; The calculation method of the first score is that if the number of matches between the tag keyword and the tag keyword is less than 3 times, the score is calculated according to the actual number of times; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 3 times and less than 5 times, it is calculated as 3 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 5 times and less than 10 times, it is calculated as 5 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 10 times, it is calculated as 10 points; The second score is calculated as follows: , X max Indicates the maximum value of the calculation score of the deep learning model, X min represents the minimum value of the calculation score of the deep learning model, and X represents the actual calculation score of the deep learning model for the labeled text; S4. derive a third score of the label corresponding to the text to be marked according to the first score and the second score, denoted as c, and decide whether to mark the text to be marked with the corresponding label according to the third score; when the third score c is greater than or equal to 6 points, mark the text to be marked with the current label, otherwise, do not mark the current label; the calculation formula of the third score is: c=0.5*a+0.5*b.
2. The labeling method according to claim 1, It is characterized in that In step S1, the preprocessing of the semantic text includes: segmenting the sentence to obtain a word list, dividing the word list into a training set, a validation set and a test set, and then training a word embedding model or a character embedding model to obtain a representation of the text, and the word list is used to count label keywords and label keywords.
3. The labeling method according to claim 2, It is characterized in that In step S1, the division ratio of the training set, the validation set and the test set is set to 3:1:
1.
4. The labeling method according to claim 1, It is characterized in that The step also includes: S5, creating a dictionary, wherein the dictionary is used to store data whose third score is greater than or equal to 8 points.
5. A labeling system, It is characterized in that include: A preprocessing module is used to preprocess the semantic text; A training module is used to build a deep learning model based on the preprocessed semantic text and use the training set data to train the model to obtain a trained model; A scoring module, used for obtaining the tag keyword or the matching number of the tag keyword in the text to be marked by traversing or scanning the text to be marked, and calculating the first score of the tag keyword and the tag keyword according to the matching number, which is recorded as a; The trained model is used to calculate the text to be labeled to obtain a label keyword or a second score of the label keyword, which is recorded as b; The calculation method of the first score is that if the number of matches between the tag keyword and the tag keyword is less than 3 times, the score is calculated according to the actual number of times; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 3 times and less than 5 times, it is calculated as 3 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 5 times and less than 10 times, it is calculated as 5 points; if the number of matches between the tag keyword and the tag keyword is greater than or equal to 10 times, it is calculated as 10 points; The second score is calculated as follows: , X max Indicates the maximum value of the calculation score of the deep learning model, X min represents the minimum value of the calculation score of the deep learning model, and X represents the actual calculation score of the deep learning model for the labeled text; The labeling module is used to obtain a third score of the label corresponding to the text to be labeled according to the first score and the second score, denoted as c, and the third score determines whether to label the text to be labeled with the corresponding label; when the third score c is greater than or equal to 6 points, the text to be labeled is labeled with the current label, otherwise, the current label is not labeled; the calculation formula of the third score is: c=0.5*a+0.5*b.
6. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the labeling method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method and system for label automatic extraction
CN103177036A
A rapid fuzzy matching algorithm for strings in mass audio data
CN106528599A
Information processing method and relevant product
CN107562847A
Label display method and device, computer equipment and storage medium
CN109815479A
Cross-media retrieval method based on deep semantic space
US20210256365A1
