Model effect verification method and device
By using collaborative filtering and keyword extraction technology in the encoding model to construct similar text pairs and evaluate their semantic consistency, the efficiency problem of online effect verification of the encoding model is solved, and efficient text semantic evaluation and similar text recall are achieved.
Patent Information
- Application Number
- CN202210665280.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-06-13
AI Technical Summary
In the existing technology, the optimized coding model lacks an effective verification method when simulating the online effect. As a result, manual selection of similar text pairs takes a long time, and similar text pairs cannot be efficiently constructed, which affects the efficiency of content management and secondary creation.
By obtaining the text information after data cleaning, extracting keywords as tags, using collaborative filtering to construct similar text pairs, and combining the original and trained encoding models to calculate similarity scores, judge the semantic consistency of the encoding representation, and achieve unsupervised text keywords Extraction and similar text recall.
It saves a lot of time in manual selection of similar evaluation text pairs, improves the efficiency of online effect evaluation of coding models, and ensures text semantic accuracy.
Smart Images

Figure CN115017264B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a model effect verification method, apparatus, computer equipment and storage medium. Background Art
[0002] With the rapid expansion of the marketing field and the transformation of the business layout of emerging communication media, more and more merchants in the fast-moving consumer goods industry have begun to shift advertising marketing from traditional TV media broadcasts to content distribution in public domains such as Douyin / Xiaohongshu and private domains such as WeChat Moments. By relying on influencers and studios to produce, manage and operate public and private domain content, they can achieve consumer traffic and product sales conversion. In this process, more and more content advertising and copywriting materials have accumulated and settled. How to achieve these connections and manage these copywriting contents to facilitate downstream search and secondary creation has become a problem that needs to be solved.
[0003] When users use the content management platform, they will collect and return various marketing advertising copy from various marketing platforms and put them into the content pool; when performing secondary creation, they will search in the content pool and select useful and satisfactory copy information for secondary creation. In this process, multiple retrieval behaviors will occur before a batch of marketing copy that meets the requirements can be collected. If the copy in these content pools can be associated, when the user finds the first article that meets the requirements, we will push more copy of the same type to them, which will greatly reduce the user's search time and improve the efficiency of their secondary creation of content to meet the content flow and distribution of users on different platforms. In real scenarios, the original encoding model BERT in the existing technology will make it difficult to recommend similar texts and inaccurate recommendation results due to inconsistencies in content specifications on multiple platforms and missing copy tags.
[0004] But even after optimizing the original encoding model, there is still the problem of how to select the appropriate verification method to simulate the online launch effect. Specifically: manually selecting sentence pairs, how to determine in advance whether two sentences are related, and thus construct a model evaluation set before going online. This process is very labor-intensive, because we cannot select and construct similar sample pairs one by one from thousands of marketing copy. How to construct similar text pairs directly in these corpora by machine is also a problem that needs to be considered and solved.
[0005] Regarding the problem of how to select a suitable verification method in the related technology to simulate the online effect of the optimized encoding model, thereby saving the time of manually selecting similar evaluation text pairs, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present invention provide a model effect verification method, apparatus, computer equipment and storage medium to solve the problem of how to select a suitable verification method to simulate the online effect of an optimized coding model in the related art.
[0007] In order to achieve the above object, a first aspect of an embodiment of the present invention provides a model effect verification method, comprising:
[0008] Get text information after data cleaning;
[0009] Extracting keywords from the text in the text information, and using the keywords as tags for the text;
[0010] Randomly selecting a plurality of first texts from the text information, using the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and constructing similar text pairs based on the first texts and the second texts;
[0011] Encoding the similar text pair according to the original encoding model to obtain a first similarity score, and calculating the first similarity score and the manual similarity score to obtain a first correlation score, wherein the manual similarity score refers to the similar text pair calculated by manual annotation;
[0012] Encoding the similar text pair according to the trained encoding model to obtain a second similarity score, and calculating the second similarity score and the manual similarity score to obtain a second relevance score;
[0013] Based on the first relevance score and the second relevance score, determine whether the encoding representation of the text by the trained encoding model conforms to the semantics of the text.
[0014] Optionally, in a possible implementation manner of the first aspect, extracting keywords from the text in the text information includes:
[0015] Setting word frequency and word length, performing word segmentation processing on the text in the text information by calculating information entropy, and obtaining multiple word segmentation results;
[0016] Using the TF-IDF calculation method, at least one keyword is extracted from the multiple word segmentation results to serve as a label for the text.
[0017] Optionally, in a possible implementation manner of the first aspect, calculating the first similarity score and the manual similarity score to obtain a first relevance score includes:
[0018] The relevance score is calculated using the following formula:
[0019]
[0020] Among them, d i represents the difference in the rank values of the i-th data pair, n represents the total number of samples, and r represents the correlation score between two columns of data. The closer the r value is to 1, the more correlated the two columns of data are; the closer it is to 0, the less relevant the two columns of scores are.
[0021] Optionally, in a possible implementation manner of the first aspect, before obtaining the text information after data cleaning, it includes:
[0022] Obtain marketing copy information from different channels;
[0023] Perform first data cleaning and second data cleaning on the marketing copy information;
[0024] The first data cleaning includes: filtering out meaningless special symbols, uniformly replacing meaningful special symbols with text commas, and replacing all non-comma Chinese and English symbols with text commas;
[0025] The second data cleaning includes: calculating the information entropy of the marketing copy information after the first data cleaning, and filtering out meaningless and repeatedly occurring long text phrases according to word frequency and word length to obtain the text information after data cleaning.
[0026] Optionally, in a possible implementation manner of the first aspect, the calculating the information entropy of the marketing copy information after the first data cleaning and filtering out meaningless and repeatedly occurring long text phrases according to word frequency and word length includes:
[0027] Set the word frequency and word length, and filter out meaningless and repeatedly occurring long text phrases by calculating the information entropy. The information entropy calculation formula includes:
[0028]
[0029] Among them, w represents the phrase for which the information entropy is to be calculated, len(w)<m means the length of this word is to be limited within m, freq(w)>k means the occurrence frequency of this word is greater than k, and P(i|W) represents the probability situation of all words surrounding the word w.
[0030] Optionally, in a possible implementation manner of the first aspect, randomly select multiple first texts from the text information, use the labels of the first texts, and roughly recall the same number of second texts in a collaborative filtering manner, and construct similar text pairs according to the first texts and the second texts, including:
[0031] Step 1: Randomly select a preset number of statements from the corpus as the first statement group, and identify the keyword labels and the number of labels of each statement;
[0032] Step 2: Randomly select a sentence from the first sentence group as the first sentence;
[0033] Step 3: Identify the keyword tags and tag quantities of the sentences in the corpus except the first sentence group;
[0034] Step 4: Determine the result of the number of overlapping labels between the first sentence and other sentences / the square root of the total number of labels of the first sentence and the square root of the total number of labels of other sentences, sort the results from small to large, and randomly recall a sentence from other sentences ranked within a preset range as the second sentence; construct a sentence pair based on the first sentence and the second sentence;
[0035] Step 5: According to the collaborative filtering method in the above steps 1-4, all the sentences in the first sentence group are roughly recalled to have the same number of sentences, and sentence pairs are constructed.
[0036] A second aspect of an embodiment of the present invention provides a model effect verification device, comprising:
[0037] A text information acquisition module is used to acquire text information that has undergone data cleaning;
[0038] A keyword extraction module, used to extract keywords from the text in the text information and use the keywords as labels for the text;
[0039] A similar text pair construction module is used to randomly select a plurality of first texts from the text information, use the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and construct similar text pairs based on the first texts and the second texts;
[0040] A first correlation score calculation module, configured to encode the similar text pair according to the original encoding model to obtain a first similarity score, and calculate the first similarity score and the manual similarity score to obtain a first correlation score, wherein the manual similarity score refers to the score calculated by using manual annotation for the similar text pair;
[0041] A second correlation score calculation module, configured to encode the similar text pair according to a trained encoding model to obtain a second similarity score, and calculate the second similarity score with an artificial similarity score to obtain a second correlation score;
[0042] A judgment module is used to judge whether the encoding representation of the text by the trained encoding model conforms to the text semantics according to the first relevance score and the second relevance score.
[0043] Optionally, in a possible implementation manner of the second aspect, the keyword extraction module includes:
[0044] A word segmentation processing unit, used to set word frequency and word length, and perform word segmentation processing on the text in the text information by calculating information entropy to obtain multiple word segmentation results;
[0045] The keyword extraction unit is used to extract at least one keyword from the multiple word segmentation results by using a TF-IDF calculation method to serve as a label of the text.
[0046] Optionally, in a possible implementation manner of the second aspect, the first correlation score calculation module or the second correlation score calculation module is further configured to perform the following steps:
[0047] The relevance score is calculated using the following formula:
[0048]
[0049] Among them, di represents the difference in the rank values of the i-th data pair, n represents the total number of samples, and r represents the correlation score of the two columns of data. The closer the r value is to 1, the more correlated the two columns of data are, and the closer it is to 0, the more unrelated the two columns of scores are.
[0050] According to a third aspect of an embodiment of the present invention, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0051] According to a fourth aspect of an embodiment of the present invention, a readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the steps of the method of the first aspect of the present invention and various possible designs of the first aspect.
[0052] The model effect verification method, device, computer equipment and storage medium provided by the present invention obtain text information that has been cleaned by data; extract keywords from the text in the text information and use the keywords as labels of the text; randomly select multiple first texts from the text information, use the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and construct similar text pairs based on the first texts and the second texts; encode the similar text pairs according to the original encoding model to obtain a first similarity score, and calculate the first similarity score and the artificial similarity score to obtain a first relevance score, wherein the artificial similarity score refers to the similar text pair calculated by using an artificial annotation method; encode the similar text pair according to the trained encoding model to obtain a second similarity score, and calculate the second similarity score and the artificial similarity score to obtain a second relevance score; based on the first relevance score and the second relevance score, judge whether the encoding representation of the text by the trained encoding model conforms to the text semantics. The present invention can simulate the online effect of the optimized coding model, extract keywords from all texts through an unsupervised text keyword extraction method, and then use the idea of collaborative filtering to recall and extract relatively close text pairs from massive unlabeled text pairs without human intervention, saving a lot of time for manual selection of similar evaluation text pairs. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 , 2 A schematic diagram of a flow chart of a model effect verification method according to an embodiment of the present application;
[0054] Figure 3 A schematic diagram of the process of filtering useless interference information using different cleaning rules;
[0055] Figure 4 A schematic diagram of the structure of a model effect verification device according to an embodiment of the present application;
[0056] Figure 5 , 6 A flowchart of a model training method according to an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein.
[0059] It should be understood that in various embodiments of the present invention, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0060] It should be understood that in the present invention, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0061] It should be understood that in the present invention, "plurality" refers to two or more than two. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.
[0062] It should be understood that in the present invention, "B corresponding to A", "B corresponding to A", "A corresponds to B" or "B corresponds to A" means that B is associated with A and B can be determined based on A. Determining B based on A does not mean determining B based only on A, but B can also be determined based on A and / or other information. A and B match when the similarity between A and B is greater than or equal to a preset threshold.
[0063] Depending on the context, "if" as used herein may be interpreted as "when" or "when" or "in response to determining" or "in response to detecting."
[0064] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0065] Embodiment 1:
[0066] The present invention provides a method for verifying the model effect. As shown in the flowchart Figure 1 , 2 shown below, it includes:
[0067] Step S110: Obtain the text information that has undergone data cleaning.
[0068] In this step, the text information includes copywriting information from different channels. For example, collect the marketing copywriting returned from the placements of a customer (such as a fast-moving consumer goods brand) on various platforms, and the platforms include marketing copywriting on Xiaohongshu, Douyin, WeChat Moments, etc. Data cleaning and processing refers to dividing the marketing copywriting information from different channels (the content specifications of multiple platforms are inconsistent), and using different cleaning rules to clean and filter out useless interference information.
[0069] Step S120: Extract keywords from the text in the text information, and use the keywords as labels for the text.
[0070] In step S120, the text information refers to a corpus set aggregated from multi-platform marketing copywriting;
[0071] When extracting keywords from the text, it is necessary to first set the word frequency and word length, perform word segmentation processing on the text in the text information by calculating the information entropy, and obtain multiple word segmentation results; then use the TF-IDF calculation method to extract at least one keyword from the multiple word segmentation results as the label for the text. The information entropy calculation formula is as follows:
[0072]
[0073] where w represents the phrase for which the information entropy is to be calculated, len(w) < m means that the length of this word is restricted within m, freq(w) > k means that the occurrence frequency of this word is greater than k, and P(i|W) represents the probability situation of all words around the word w. The greater the information entropy, the more chaotic the surrounding words are, indicating that there are many words around the word w itself, and this word is probably considered to be a piece of information that can be fixed because it can be combined with multiple words; the less the information entropy, the purer the surrounding words are, indicating that there are few adjacent words around the word w itself, then this word is very likely to be combined with the surrounding words to form a new phrase, and then it will be judged whether a phrase can be constructed under the condition of adding 1 to the ngram.
[0074] Specifically, when setting the word frequency and word length and performing word segmentation processing on the text in the text information by calculating the information entropy, according to the word granularity ngram, the word formation conditions for 1 character, 2 characters, 3 characters to m characters are constructed, and the combined words that meet the word formation conditions will construct a custom word segmentation dictionary.
[0075] For example, when m is set to 5, k is set to 3, and ngram=2, the word "vitamin" meets the conditions of m and k, with the number of characters within 5 and the frequency of occurrence above 3. At this time, we start to count the information entropy of the words around the word "vitamin". We find that the information entropy of the words adjacent to the left of "vitamin" is very high, while the information entropy of some words adjacent to the right of "vitamin" is very low, such as "aldehyde", "alcohol", and "acid". In this case, it is very likely that new words "retinal", "retinal alcohol", and "retinal alcohol" will be constructed.
[0076] After all sentences in the corpus are segmented one by one according to the above method and the segmentation vocabulary is constructed, the tfidf (term frequency-inverse document frequency) calculation method will be used to extract at least one keyword from the multiple segmentations obtained by the sentence segmentation processing as the label of the sentence.
[0077] Step S130: randomly select multiple first texts from the text information, use the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and construct similar text pairs based on the first texts and the second texts.
[0078] In this step, the first text and the second text refer to sentences in the corpus of marketing copywriting on multiple platforms. By using the keywords extracted in step S120 as labels for sentences, randomly selecting sentences, and recalling the labels through collaborative filtering, similar text pairs to be evaluated are constructed. For example, there are 5,000 sentences in the corpus of marketing copywriting, and 100 sentences are randomly sampled. How to select texts that are close to the 100 sentences we sampled from these 5,000 sentences? This process does not require manual browsing of 5,000 sentences, but through collaborative filtering, 100 close sentences are roughly recalled to construct 100 sentence pairs.
[0079] The calculation method of collaborative filtering includes:
[0080] 1. Randomly select a preset number of sentences from the corpus as the first sentence group, and identify the keyword tag and the number of tags of each sentence in the first sentence group;
[0081] 2. Randomly select a sentence from the first sentence group as the first sentence;
[0082] 3. Identify the keyword tags and the number of tags of the sentences in the corpus except the first sentence group;
[0083] 4. Determine the result of (the number of overlapping labels between the first sentence and other sentences) / (the square root of the total number of labels in the first sentence and the square root of the total number of labels in other sentences), sort the results from small to large, and randomly recall a sentence from other sentences ranked within a preset range (for example, top 30) as the second sentence; construct a sentence pair based on the first sentence and the second sentence;
[0084] 5. According to the collaborative filtering method in steps 1-3 above, roughly recall the same number of sentences from all the sentences in the first sentence group to construct sentence pairs.
[0085] For the above 4, you can also judge the result of (the number of overlapping labels between the first sentence and other sentences) / (the square root of the total number of labels of the first sentence and the square root of the total number of labels of other sentences) to determine whether the result is greater than a preset threshold (for example: 0.5, 0.6, 0.75, etc.). If it is greater than or equal to the threshold, randomly recall a sentence from multiple sentences greater than the preset threshold as the second sentence.
[0086] Or take other methods, as follows:
[0087] 1. Randomly select a sentence from the corpus as the first sentence, and identify the keyword tags and the number of tags of the first sentence; 2. Then identify the keyword tags and the number of tags of other sentences in the corpus except the first sentence; 3. Determine the result of (the number of overlapping tags of the first sentence and the other sentences) / (the square root of the total number of tags of the first sentence and the square root of the total number of tags of other sentences), sort the results from small to large, and randomly recall a sentence from other sentences ranked within a preset range (for example, top30) as the second sentence; construct a sentence pair based on the first sentence and the second sentence; 4. According to the collaborative filtering method in the above steps 1-3, roughly recall a preset number of sentences to construct a sentence pair.
[0088] An example is given for the collaborative filtering method described above: the threshold is pre-set to 0.5, sentence 1, the extracted keyword tags are "shampoo", "anti-dandruff", "anti-itching", "fragrance", and "long-lasting", sentence 2, the extracted keywords are "shampoo", "smooth", "anti-dandruff", "oil control", and "long-lasting", then the collaborative filtering score = (the number of overlapping labels between sentence 1 and sentence 2) / (the square root of the total number of labels in sentence 1 x the square root of the total number of labels in sentence 2), and the result is 3 / 5 = 0.6.
[0089] Step S140, encoding the similar text pair according to the original encoding model to obtain a first similarity score, and calculating the first similarity score and the manual similarity score to obtain a first correlation score, wherein the manual similarity score refers to the score calculated by manually annotating the similar text pair.
[0090] Step S150: Encode the similar text pair according to the trained encoding model to obtain a second similarity score, and calculate the second similarity score and the manual similarity score to obtain a second relevance score.
[0091] Step S160: Determine, based on the first relevance score and the second relevance score, whether the encoding representation of the text by the trained encoding model conforms to the semantics of the text.
[0092] In steps S140-S160, the first correlation score or the second correlation score is calculated using the following formula:
[0093]
[0094] Among them, di represents the difference in the rank values of the i-th data pair, n represents the total number of samples, and r represents the correlation score of the two columns of data. The closer the r value is to 1, the more correlated the two columns of data are, and the closer it is to 0, the more unrelated the two columns of scores are.
[0095] Specifically, for the above steps S140-S160, an example is used to illustrate: according to the 100 sentence pairs constructed in the above step S130, the vector encoding of the text pairs output by the original BERT model and the trained BERT model is respectively performed, and the first similarity scores of the 100 sentence pairs scored by the original BERT model and the second similarity scores of the 100 sentence pairs scored by the trained BERT model are obtained, and then the similarity scores of the 100 sentence pairs are manually annotated (in the range of 1-10 points), and finally the first correlation score Spearman Correlation between the first similarity score of the original BERT model and the manual similarity score is calculated, and the result is 0.65, and the second correlation score Spearman Correlation between the second similarity score of the trained BERT model and the manual similarity score is 0.83. The second correlation score (0.83) is closer to 1 than the first correlation score (0.65), indicating that the scores of the trained BERT model are consistent with the manual scores, and the models that are considered similar by the manual are also considered similar, and the models that are considered dissimilar by the manual are also considered dissimilar. In this way, it is measured whether the trend of the model for the text pairs is related to the trend of the manual annotation scores.
[0096] Therefore, through Spearman Correaltion, we can know that the fine-tuned BERT model has a higher score for similar texts, is more relevant to human scores, and the encoding representation of the text is more consistent with the text semantics, and the calculated similarity score is more accurate. Therefore, the trained BERT model is determined to be the final text encoding model for online use.
[0097] In one embodiment, before obtaining the text information after data cleaning, the process includes:
[0098] Obtain marketing copy information from different channels;
[0099] Performing a first data cleaning and a second data cleaning on the marketing copy information;
[0100] The first data cleaning includes: filtering meaningless special symbols, uniformly replacing meaningful special symbols with text commas, and replacing all non-comma Chinese and English symbols with text commas;
[0101] The second data cleaning includes: calculating information entropy of the marketing copy information after the first data cleaning, filtering out meaningless repetitive long text phrases according to word frequency and word length, and obtaining text information after data cleaning.
[0102] In this step, if Figure 3 As shown, the marketing copy information of different channels is divided (the content standards of multiple platforms are inconsistent), and different cleaning rules are used to clean and filter out useless interference information.
[0103] First, considering that Xiaohongshu's marketing copywriting is characterized by long articles, fixed language, and contains a large number of emoji expressions, it is necessary to filter out meaningless emoji expressions, and replace meaningful emoji expressions, such as check marks and crosses that describe efficacy, exclamation marks and question marks that indicate mood, with text commas that have a pause function; at the same time, all non-comma Chinese and English symbols are replaced with text commas.
[0104] Secondly, the marketing copywriting in WeChat Moments is short and contains a lot of meaningless text information. Therefore, it is necessary to calculate the information entropy of this type of marketing copywriting information, and filter out meaningless repetitive long text phrases based on word frequency and word length. The information entropy calculation formula is shown in step S120. When m is set to 25 and k is set to 10, some high-frequency meaningless long texts can be obtained through information entropy. For example, in WeChat Moments materials, meaningless long texts such as "Add WeChat to get discount codes and get the latest product information" can be obtained. However, these long texts appear in a large number of copies and are not helpful for distinguishing texts, so they need to be eliminated.
[0105] The model effect verification method provided by the present invention obtains text information that has been cleaned by data; extracts keywords from the text information, and uses the keywords as labels of the text; randomly selects multiple first texts from the text information, uses the labels of the first texts, and roughly recalls the same number of second texts by collaborative filtering, and constructs similar text pairs according to the first text and the second text; encodes the similar text pairs according to the original encoding model to obtain a first similarity score, and calculates the first similarity score and the artificial similarity score to obtain a first correlation score; encodes the similar text pairs according to the trained encoding model to obtain a second similarity score, and calculates the second similarity score and the artificial similarity score to obtain a second correlation score; according to the first correlation score and the second correlation score, it is judged whether the encoding representation of the text by the trained encoding model conforms to the text semantics. The present invention can simulate the online effect of the optimized encoding model, extract keywords from all texts by the keyword extraction method of unsupervised text, and after extraction, use the idea of collaborative filtering to recall and extract relatively close text pairs from a large number of unlabeled text pairs without manual participation, saving a lot of time for manually selecting similar evaluation text pairs. In addition, the present invention manually scores the similar text pairs constructed by coarse recall, scores the original BERT model, and scores the fine-tuned BERT model. Finally, the Spearman Correlation scores of the original BERT model and the manual scores, and the Spearman Correlation scores of the fine-tuned BERT model and the manual scores are calculated, which are verified on the data of our users. After the fine-tuning training of this solution, the encoding representation of the text by the model is more consistent with the text semantics, and the calculated similarity score is also more accurate.
[0106] Embodiment 2:
[0107] The embodiment of the present invention also provides a model effect verification device, such as Figure 4 As shown, including:
[0108] A text information acquisition module is used to acquire text information that has undergone data cleaning;
[0109] A keyword extraction module, used to extract keywords from the text in the text information and use the keywords as labels for the text;
[0110] A similar text pair construction module is used to randomly select a plurality of first texts from the text information, use the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and construct similar text pairs based on the first texts and the second texts;
[0111] A first correlation score calculation module, configured to encode the similar text pair according to the original encoding model to obtain a first similarity score, and calculate the first similarity score and the manual similarity score to obtain a first correlation score, wherein the manual similarity score refers to the score calculated by using manual annotation for the similar text pair;
[0112] A second correlation score calculation module, configured to encode the similar text pair according to a trained encoding model to obtain a second similarity score, and calculate the second similarity score with an artificial similarity score to obtain a second correlation score;
[0113] A judgment module is used to judge whether the encoding representation of the text by the trained encoding model conforms to the text semantics according to the first relevance score and the second relevance score.
[0114] In one embodiment, the keyword extraction module includes:
[0115] A word segmentation processing unit, used to set word frequency and word length, and perform word segmentation processing on the text in the text information by calculating information entropy to obtain multiple word segmentation results;
[0116] The keyword extraction unit is used to extract at least one keyword from the multiple word segmentation results by using a TF-IDF calculation method to serve as a label of the text.
[0117] In one embodiment, the first correlation score calculation module or the second correlation score calculation module is further configured to perform the following steps:
[0118] The relevance score is calculated using the following formula:
[0119]
[0120] Among them, d i It represents the difference in the rank value of the i-th data pair, n represents the total number of samples, and r represents the correlation score of the two columns of data. The closer the r value is to 1, the more correlated the two columns of data are, and the closer it is to 0, the less related the two columns of scores are.
[0121] Embodiment 3:
[0122] The embodiment of the present invention also provides a model training method, such as Figure 5 , 6 As shown, including:
[0123] Step 1: Obtain the normalized text information to be trained.
[0124] In this step, the text information to be trained includes the copywriting information to be trained from different channels, such as collecting the marketing copywriting that customers (such as a fast-moving consumer goods brand) put back on various platforms, including Xiaohongshu, Douyin, WeChat Moments and other marketing copywriting.
[0125] Normalization processing refers to dividing the marketing copy information of different channels (the content standards of multiple platforms are inconsistent) and using different cleaning rules to clean and filter out useless interference information.
[0126] First, considering that Xiaohongshu's marketing copywriting is characterized by long articles, fixed language, and contains a large number of emoji expressions, it is necessary to filter out meaningless emoji expressions, and replace meaningful emoji expressions, such as check marks and crosses that describe efficacy, exclamation marks and question marks that indicate mood, with text commas that have a pause function; at the same time, all non-comma Chinese and English symbols are replaced with text commas.
[0127] Secondly, the marketing copywriting in WeChat Moments is short and contains a lot of meaningless text information. Therefore, it is necessary to calculate the information entropy of this type of marketing copywriting information and filter out meaningless repetitive long text phrases based on word frequency and word length.
[0128] Step 2: randomly select a sentence from the text information to be trained as a first sample, perform data enhancement processing on the first sample to obtain a second sample, and use another sentence in the text information to be trained except the first sample as a third sample.
[0129] In step 2,
[0130] First, a sentence is randomly selected from the normalized text information to be trained as the first sample a, and another sentence is randomly selected as the third sample b;
[0131] Secondly, the first sample a is subjected to data enhancement, that is, the adjectives in the first sample a are randomly replaced by synonyms / synonyms (50% are randomly replaced, and 50% are not replaced) to obtain the second sample a'.
[0132] Step 3: Encode the first sample, the second sample, and the third sample respectively through the original coding model to obtain a first coding result, a second coding result, and a third coding result, and randomly shuffle the second coding result in the character position dimension and the character coding dimension to obtain a fourth coding result.
[0133] In step 3, samples A, A', B are encoded by the original BERT coding model to obtain encoding results A1, A1', B1. The encoding result of A1' is randomly shuffled in the token dimension (word position dimension) and the embedding dimension (word encoding dimension) to obtain A2.
[0134] Specifically, the "randomly shuffling the word position dimension and the autoencoder dimension" in the above step 3 is illustrated as follows:
[0135] The test sentence "Anti-dandruff and anti-itching shampoo" is a sentence of 7 words, which is encoded into a three-dimensional vector of (1, 7, 768). The first dimension indicates how many sentences there are here, here is 1 sentence; the second dimension indicates how many words there are in the corresponding sentence, here is 7 words; the third dimension indicates how many numbers are used to represent each word, here 768 digital features are used to represent each word.
[0136] Random shuffling in the word position dimension means random shuffling in the second dimension. For example, after shuffling, the sentence may become "Shampoo to relieve itching and dandruff"; shuffling in the word encoding dimension means shuffling in the third dimension. For example, we originally used 768 numbers to represent the word "go" [0.32, 0.98, 0.12, 0.55, 0.86, 0.77........0.32, 0.65]. There are 768 numbers here. After shuffling, the encoding of the 768 numbers representing the word "go" may become [0.98, 0.32, 0.12, 0.65, 0.86, 0.77........0.32, 0.55].
[0137] Step 4: construct the first encoding result and the third encoding result into a negative sample pair, and construct the first encoding result and the fourth encoding result into a positive sample pair.
[0138] Step 5: Perform steps 2-4 on all sentences in the text information to be trained to obtain all positive and negative sample pairs.
[0139] In step 4-5, a1 and b1 are constructed as a negative sample pair, and a1 and a2 are constructed as a positive sample pair. The above operation is performed on the N text pairs in the text information to be trained to obtain all sample pairs.
[0140] Step 6: According to the positive and negative sample pairs, the loss is calculated using a contrastive learning method to optimize the original encoding model.
[0141] In step 6, the following formula is used for calculation in contrastive learning loss:
[0142]
[0143] Among them, ri, rj represent positive samples, ri, rk represent negative sample pairs, sim(ri, rj) represents the calculation of vector cosine similarity, and t is the temperature normalization factor;
[0144] By shortening the distance between positive sample pairs and increasing the distance between negative sample pairs, the loss is reduced and the original encoding model is optimized. The loss calculation uses contrastive learning loss to fine-tune the BERT model.
[0145] Among them, the readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The computer storage medium can be any available medium that can be accessed by a general or special-purpose computer. For example, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application-specific integrated circuit (ASIC). In addition, the ASIC can be located in a user device. Of course, the processor and the readable storage medium can also exist in a communication device as discrete components. The readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0146] The present invention also provides a program product, which includes an execution instruction, which is stored in a readable storage medium. At least one processor of a device can read the execution instruction from the readable storage medium, and at least one processor executes the execution instruction so that the device implements the methods provided in the above various embodiments.
[0147] In the above-mentioned terminal or server embodiment, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the present invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A model effect verification method, characterized in that: Including: Obtain text information that has undergone data cleaning; Extract keywords from the text in the text information, and use the keywords as labels for the text; Randomly select multiple first texts from the text information, use the labels of the first texts, and roughly recall the same number of second texts in a collaborative filtering manner, and construct similar text pairs based on the first texts and the second texts; Encode the similar text pairs according to the original encoding model to obtain a first similarity score, and calculate the first correlation score by calculating the first similarity score and the manual similarity score, where the manual similarity score is obtained by calculating the similar text pairs in a manually annotated manner; Encode the similar text pairs according to the trained encoding model to obtain a second similarity score, and calculate the second correlation score by calculating the second similarity score and the manual similarity score; Among them, the first correlation score or the second correlation score is calculated using the following formula: Among them, d i It represents the difference in the rank value of the i-th data pair, n represents the total number of samples, and r represents the correlation score of the two columns of data. The closer the r value is to 1, the more correlated the two columns of data are, and the closer it is to 0, the less related the two columns of scores are. Judge whether the encoding representation of the text by the trained encoding model conforms to the text semantics according to the first correlation score and the second correlation score.
2. The model effect verification method according to claim 1, characterized in that: The extraction of keywords from the text in the text information includes: Set the word frequency and word length, and perform word segmentation on the text in the text information by calculating the information entropy to obtain multiple word segmentation results; Adopt the TF-IDF calculation method to extract at least one keyword from multiple word segmentation results as the label of the text.
3. The model effect verification method according to claim 1, characterized in that: Before obtaining the text information that has undergone data cleaning, it includes: Obtain marketing copy information from different channels; Perform the first data cleaning and the second data cleaning on the marketing copy information; The first data cleaning includes: filtering out meaningless special symbols, uniformly replacing meaningful special symbols with text commas, and replacing all non-comma Chinese and English symbols with text commas; The second data cleaning includes: calculating the information entropy of the marketing copy information after the first data cleaning, and filtering out meaningless and repeatedly appearing long text phrases according to the word frequency and word length to obtain the text information that has undergone data cleaning.
4. The model effect verification method according to claim 3, characterized in that: The calculation of the information entropy of the marketing copy information after the first data cleaning, and filtering out meaningless and repeatedly appearing long text phrases according to the word frequency and word length includes: Set the word frequency and word length, and filter out meaningless and repeatedly appearing long text phrases by calculating the information entropy, where the information entropy calculation formula includes: Among them, w represents the phrase for which the information entropy is to be calculated, len(w)<m means that the length of this word is to be limited within m, freq(w)>k means that the occurrence frequency of this word is to be greater than k, and P(i|W) represents the probability situation of all words surrounding the word w.
5. The model effect verification method according to claim 1, characterized in that: Randomly select multiple first texts from the text information, use the labels of the first texts, and roughly recall the same number of second texts in a collaborative filtering manner, and construct similar text pairs based on the first texts and the second texts, including: Step 1: Randomly select a preset number of sentences from the corpus as the first sentence group, and identify the first sentence group; the keyword tag and the number of tags for each sentence; Step 2: Randomly select a sentence from the first sentence group as the first sentence; Step 3: Identify the keyword tags and tag quantities of the sentences in the corpus except the first sentence group; Step 4: Determine the result of (the number of overlapping labels between the first sentence and other sentences) / (the square root of the total number of labels of the first sentence x the square root of the total number of labels of other sentences), sort the results from small to large, and randomly recall a sentence from other sentences ranked within a preset range as the second sentence; construct a sentence pair based on the first sentence and the second sentence; Step 5: According to the collaborative filtering method in the above steps 1-4, all the sentences in the first sentence group are roughly recalled to have the same number of sentences, and sentence pairs are constructed.
6. A model effect verification device, characterized in that: include: A text information acquisition module is used to acquire text information that has undergone data cleaning; A keyword extraction module, used to extract keywords from the text in the text information and use the keywords as labels for the text; A similar text pair construction module is used to randomly select a plurality of first texts from the text information, use the labels of the first texts to roughly recall the same number of second texts by collaborative filtering, and construct similar text pairs based on the first texts and the second texts; A first correlation score calculation module, configured to encode the similar text pair according to the original encoding model to obtain a first similarity score, and calculate the first similarity score and the manual similarity score to obtain a first correlation score, wherein the manual similarity score refers to the score calculated by using manual annotation for the similar text pair; A second correlation score calculation module, configured to encode the similar text pair according to a trained encoding model to obtain a second similarity score, and calculate the second similarity score with an artificial similarity score to obtain a second correlation score; The first correlation score or the second correlation score is calculated using the following formula: Among them, d i It represents the difference in the rank value of the i-th data pair, n represents the total number of samples, and r represents the correlation score of the two columns of data. The closer the r value is to 1, the more correlated the two columns of data are, and the closer it is to 0, the less related the two columns of scores are. A judgment module is used to judge whether the encoding representation of the text by the trained encoding model conforms to the text semantics according to the first relevance score and the second relevance score.
7. The model effect verification device according to claim 6, characterized in that: The keyword extraction module comprises: A word segmentation processing unit, used to set word frequency and word length, and perform word segmentation processing on the text in the text information by calculating information entropy to obtain multiple word segmentation results; The keyword extraction unit is used to extract at least one keyword from the multiple word segmentation results by using a TF-IDF calculation method to serve as a label of the text.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the computer program, the steps of the model effect verification method described in any one of claims 1 to 4 are implemented.
