Keyword extraction method, device, equipment and storage medium based on text pairs
By constructing similar and dissimilar text pairs, calculating keyword word frequency and generating comprehensive feature scores, the problems of low accuracy and recall in the prior art are solved, and a more efficient keyword extraction effect is achieved.
Patent Information
- Application Number
- CN202010042447.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-15
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2040-01-15
AI Technical Summary
The existing keyword extraction technology ignores document correlation characteristics when dealing with non-independent and homogeneous document sets, resulting in low accuracy and recall of keyword extraction, especially in vertical business scenarios, high-frequency words are difficult to be recalled.
By constructing similar text pairs and dissimilar text pairs, the word frequency of keywords in similar text pairs and dissimilar text pairs is calculated, and the comprehensive feature scores of each word pair are generated, thereby improving the keyword recall and extraction accuracy.
It improves the recall rate and extraction accuracy of keywords, enhances the comprehensive score of keywords, and is suitable for keyword extraction in different business scenarios.
Smart Images

Figure CN111259660B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a keyword extraction method, device, equipment and storage medium based on text pairs. Background Art
[0002] Keyword extraction technology is a very important basic technology in the field of natural language processing (NLP). It is widely used in various NLP projects due to its advantages such as strong interpretability, wide adaptability, and easy scalability. Therefore, the accuracy and recall rate of keyword extraction affect the effectiveness of NLP project strategies to a certain extent.
[0003] The commonly used keyword extraction technology is to process each document independently, and then sort and extract based on the term frequency-inverse document frequency (TF-IDF) feature. This method has the following two main shortcomings: 1) The document set may not be independent and identically distributed, and the correlation features between documents (such as document similarity) are discarded, which further weakens the correlation between words in the related document set, thus affecting the accuracy of keyword extraction. 2) For different projects and different business scenarios, in vertical business scenarios, some key high-frequency words will appear in many document sets. For example, in the corpus of Ping An Life Insurance's question-and-answer knowledge base system, "insurance" and "claims" will appear in many questions, which will result in a small IDF value, which will further result in a small TF-IDF feature value, making it difficult to recall, thus affecting the recall rate of keywords. As a result, the existing solution has a low accuracy rate in keyword extraction. Summary of the invention
[0004] The present invention provides a keyword extraction method, device, equipment and storage medium based on text pairs, which are used to construct similar text pairs and dissimilar text pairs, calculate the word frequencies of keywords in similar text pairs and dissimilar text pairs respectively, thereby improving the recall rate of keywords, improving the comprehensive score of each keyword, and improving the accuracy of keyword extraction.
[0005] A first aspect of an embodiment of the present invention provides a keyword extraction method based on text pairs, comprising: obtaining an original question statement, and generating an original corpus data set based on the original question statement, wherein the original question statement is used to instruct a customer service system to search for a corresponding answer to the question; constructing a text pair data set based on the original corpus data set, wherein the text pair data set includes similar text pairs and dissimilar text pairs; in the text pair data set, performing word segmentation operations on two sub-texts in each text pair respectively, and generating multiple word pairs corresponding to each text pair, wherein each word pair includes a candidate word in each sub-text; calculating the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair; calculating the comprehensive feature score of each word pair based on the forward word frequency and the reverse word frequency of each word pair; sorting the comprehensive feature scores of all word pairs to generate a keyword set; and screening the keyword set in combination with business scenarios to generate target keywords.
[0006] Optionally, in a first implementation method of the first aspect of the embodiment of the present invention, a text pair dataset is constructed based on the original corpus dataset, and the text pair dataset includes similar text pairs and dissimilar text pairs, including: determining questions with semantics similar to the original question sentence in the original corpus dataset, and generating a plurality of similar question sentences; combining the plurality of similar question sentences in pairs to generate similar text pairs; determining questions with semantics dissimilar to the original question sentence in the original corpus dataset, and generating a plurality of dissimilar question sentences; combining the plurality of dissimilar question sentences in pairs to generate dissimilar text pairs; and merging a first preset number of similar text pairs and a second preset number of dissimilar text pairs according to a preset ratio to generate a text pair dataset.
[0007] Optionally, in a second implementation manner of the first aspect of the embodiment of the present invention, in the text pair dataset, word segmentation operations are performed on the two sub-texts in each text pair respectively, and multiple word pairs corresponding to each text pair are generated, and each word pair includes a candidate word in each sub-text, including: in the text pair dataset, word segmentation operations are performed on the first sub-text and the second sub-text in each text pair respectively to obtain a first word segmentation result of the first sub-text and a second word segmentation result of the second sub-text; and a candidate word is extracted from the first word segmentation result and the second word segmentation result respectively using a preset model algorithm to generate multiple word pairs for each text pair.
[0008] Optionally, in a third implementation manner of the first aspect of the embodiment of the present invention, in the text pair data set, performing word segmentation operations on the first subtext and the second subtext in each text pair respectively to obtain a first word segmentation result of the first subtext and a second word segmentation result of the second subtext, includes: randomly selecting a text pair in the text pair data set as a target text pair; obtaining the first subtext and the second subtext in the target text pair, and performing word segmentation on the first subtext and the second subtext respectively; generating a first word segmentation result corresponding to the first subtext and a second word segmentation result corresponding to the second subtext, the first word segmentation result including each candidate word in the first subtext, and the second word segmentation result including each candidate word in the second subtext.
[0009] Optionally, in a fourth implementation manner of the first aspect of the embodiment of the present invention, the method of using a preset model algorithm to extract a candidate word from the first word segmentation result and the second word segmentation result respectively to generate multiple word pairs for each text pair includes: using a preset bigram model 2-gram algorithm to select a candidate word from the first sub-text in each text pair, and selecting another candidate word from the second sub-text; and forming a word pair from the two respectively extracted candidate words to generate multiple word pairs for each text pair.
[0010] Optionally, in a fifth implementation manner of the first aspect of the embodiment of the present invention, the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair are calculated respectively according to the multiple word pairs of each text pair, including: selecting a word pair as a target word pair from the multiple word pairs of each text pair; counting the number of occurrences x1 of the target word pair in the similar text pair and the number of occurrences x2 of the target word pair in the dissimilar text pair; determining the total number N1 of word pairs in the similar text pairs and the total number N2 of word pairs in the dissimilar text pairs; generating the forward word frequency x1 / N1 of the target word pair in the similar text pairs and the reverse word frequency x2 / N2 in the dissimilar text pairs; and generating the forward word frequency and reverse word frequency of each word pair in turn.
[0011] Optionally, in a sixth implementation manner of the first aspect of the embodiment of the present invention, the comprehensive feature scores of all word pairs are sorted to generate a keyword set, including: sorting the comprehensive feature scores of all word pairs in order from large to small; comparing whether the comprehensive feature score of each word pair is greater than a threshold; determining the word pairs with a comprehensive feature score greater than the threshold as candidate word pairs; and grouping all the generated candidate word pairs to generate a keyword set.
[0012] A second aspect of an embodiment of the present invention provides a keyword extraction device based on text pairs, comprising: an acquisition unit, used to acquire an original question statement, and generate an original corpus data set based on the original question statement, wherein the original question statement is used to instruct a customer service system to find a corresponding answer to the question; a construction unit, used to construct a text pair data set based on the original corpus data set, wherein the text pair data set includes similar text pairs and dissimilar text pairs; a word segmentation unit, used to perform word segmentation operations on two sub-texts in each text pair in the text pair data set, and generate multiple word pairs corresponding to each text pair, wherein each word pair includes a candidate word in each sub-text; a first calculation unit, used to calculate the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair; a second calculation unit, used to calculate the comprehensive feature score of each word pair based on the forward word frequency and the reverse word frequency of each word pair; a sorting unit, used to sort the comprehensive feature scores of all word pairs to generate a keyword set; a generation unit, used to screen the keyword set in combination with a business scenario to generate a target keyword.
[0013] Optionally, in a first implementation method of the second aspect of the embodiment of the present invention, the construction unit is specifically used to: determine questions that are semantically similar to the original question sentence in the original corpus dataset, and generate multiple similar question sentences; combine the multiple similar question sentences in pairs to generate similar text pairs; determine questions that are semantically dissimilar to the original question sentence in the original corpus dataset, and generate multiple dissimilar question sentences; combine the multiple dissimilar question sentences in pairs to generate dissimilar text pairs; and merge a first preset number of similar text pairs and a second preset number of dissimilar text pairs according to a preset ratio to generate a text pair dataset.
[0014] Optionally, in a second implementation manner of the second aspect of the embodiment of the present invention, the word segmentation unit includes: a word segmentation module, used to perform word segmentation operations on the first sub-text and the second sub-text in each text pair in the text pair data set, respectively, to obtain a first word segmentation result of the first sub-text and a second word segmentation result of the second sub-text; an extraction module, used to use a preset model algorithm to extract a candidate word from the first word segmentation result and the second word segmentation result respectively, to generate multiple word pairs for each text pair.
[0015] Optionally, in a third implementation manner of the second aspect of the embodiment of the present invention, the word segmentation module is specifically used to: randomly select a text pair in a text pair data set as a target text pair; obtain a first subtext and a second subtext in the target text pair, and perform word segmentation on the first subtext and the second subtext, respectively; generate a first word segmentation result corresponding to the first subtext and a second word segmentation result corresponding to the second subtext, the first word segmentation result including each candidate word in the first subtext, and the second word segmentation result including each candidate word in the second subtext.
[0016] Optionally, in a fourth implementation of the second aspect of the embodiment of the present invention, the extraction module is specifically used to: use a preset bigram model 2-gram algorithm to select a candidate word from the first sub-text in each text pair, and select another candidate word from the second sub-text; form a word pair by the two candidate words extracted respectively, and generate multiple word pairs for each text pair.
[0017] Optionally, in a fifth implementation manner of the second aspect of the embodiment of the present invention, the first computing unit is specifically used to: select a word pair from multiple word pairs in each text pair as a target word pair; count the number of occurrences x1 of the target word pair in the similar text pairs and the number of occurrences x2 of the target word pair in the dissimilar text pairs; determine the total number of word pairs N1 in the similar text pairs and the total number of word pairs N2 in the dissimilar text pairs; generate a forward word frequency x1 / N1 of the target word pair in the similar text pairs and a reverse word frequency x2 / N2 in the dissimilar text pairs; and generate the forward word frequency and reverse word frequency of each word pair in turn.
[0018] Optionally, in a sixth implementation of the second aspect of the embodiment of the present invention, the sorting unit is specifically used to: sort the comprehensive feature scores of all word pairs in descending order; compare whether the comprehensive feature score of each word pair is greater than a threshold; determine the word pairs with comprehensive feature scores greater than the threshold as candidate word pairs; and group all the generated candidate word pairs to generate a keyword set.
[0019] A third aspect of an embodiment of the present invention provides a text pair-based keyword extraction device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text pair-based keyword extraction method described in any one of the above-mentioned embodiments when executing the computer program.
[0020] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the keyword extraction method based on text pairs described in any of the above embodiments are implemented.
[0021] In the technical solution provided by the embodiment of the present invention, the original question statement is obtained, and the original corpus data set is generated based on the original question statement, and the original question statement is used to instruct the customer service system to find the corresponding answer to the question; a text pair data set is constructed according to the original corpus data set, and the text pair data set includes similar text pairs and dissimilar text pairs; in the text pair data set, the two subtexts in each text pair are respectively segmented, and multiple word pairs corresponding to each text pair are generated, and each word pair includes a candidate word in each subtext; the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair are respectively calculated according to the multiple word pairs of each text pair; based on the forward word frequency and the reverse word frequency of each word pair, the comprehensive feature score of each word pair is calculated; the comprehensive feature scores of all word pairs are sorted to generate a keyword set; the keyword set is screened in combination with the business scenario to generate the target keyword. In the embodiment of the present invention, by constructing similar text pairs and dissimilar text pairs, the word frequencies of keywords in similar text pairs and dissimilar text pairs are calculated, the recall rate of keywords is improved, and then the comprehensive score of each keyword is improved, and the accuracy of keyword extraction is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 Schematic diagram of an embodiment of a keyword extraction method based on text pairs in an embodiment of the present invention;
[0023] Figure 2 Schematic diagram of another embodiment of the keyword extraction method based on text pairs in an embodiment of the present invention;
[0024] Figure 3 Schematic diagram of an embodiment of a keyword extraction device based on text pairs in an embodiment of the present invention;
[0025] Figure 4 Schematic diagram of another embodiment of a keyword extraction device based on text pairs in an embodiment of the present invention;
[0026] Figure 5 The figure is a schematic diagram of an embodiment of a keyword extraction device based on text pairs in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The present invention provides a keyword extraction method, device, equipment and storage medium based on text pairs, which are used to construct similar text pairs and dissimilar text pairs, calculate the word frequencies of keywords in similar text pairs and dissimilar text pairs respectively, thereby improving the recall rate of keywords, improving the comprehensive score of each keyword, and improving the accuracy of keyword extraction.
[0028] In order to enable those skilled in the art to better understand the solutions of the present invention, the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0029] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned 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 data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] See also Figure 1 , a flowchart of a keyword extraction method based on text pairs provided by an embodiment of the present invention specifically includes:
[0031] 101. Obtain an original question statement, and generate an original corpus data set based on the original question statement. The original question statement is used to instruct the customer service system to find the corresponding answer to the question.
[0032] The server obtains the original question statement and generates an original corpus data set based on the original question statement, and the original question statement is used to instruct the customer service system to find the corresponding answer to the question. The original corpus data set includes standard question statements and similar question statements.
[0033] It should be noted that the same question may be expressed in different ways. For example, the standard question statement is: "What are the key points of pre-job training?", and similar question statements of this statement are: "The key content of pre-job training" or "What are the key points of pre-job training?". For another example, the standard question statement is: "Insurance for gastroenteritis", and similar question statements of this statement are: "Can gastroenteritis be insured?" or "Insurance for acute gastroenteritis" or "Can acute gastroenteritis be insured?".
[0034] It is understandable that the execution subject of the present invention may be a keyword extraction device based on text pairs, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0035] 102. A text pair dataset is constructed based on the original corpus dataset, and the text pair dataset includes similar text pairs and dissimilar text pairs.
[0036] The server constructs a text pair dataset based on the original corpus dataset, and the text pair dataset includes similar text pairs and dissimilar text pairs, wherein the similar text pairs and dissimilar text pairs are determined according to a preset similarity standard.
[0037] It should be noted that the original corpus dataset (pre-set question-and-answer knowledge base) generally contains semantically similar texts. If it does not contain similar texts, similar texts can be automatically annotated. For the sampling of dissimilar questions, there are different sampling rules and sampling quantities for different business scenarios. For example, the sampling rules can generally be random sampling / stratified sampling / text similarity sampling, etc. The sampling quantity can generally be sampled based on the ratio of similar text pairs to dissimilar text pairs of 1:1 / 1:2 / 1:3.
[0038] For example, similar text pair datasets include:
[0039] "Ping An Fu is insured, I want to buy Ping An Fu", "Ping An Fu is insured, I want to insure Ping An Fu", "I want to buy Ping An Fu, I want to insure Ping An Fu", "Can cancer be insured with Love Full Marks, can cancer be insured with Love Full Marks".
[0040] Assuming that the positive and negative samples are sampled in a 1:1 ratio, the dissimilar text pair dataset includes:
[0041] "I have insured Ping An Fu, can cancer be insured with Full Love Score", "I want to buy Ping An Fu, can cancer be insured with Full Love Score", "I want to insure Ping An Fu, can cancer be insured with Full Love Score", "Can cancer be insured with Full Love Score, I want to buy Ping An Fu".
[0042] 103. In the text pair data set, two sub-texts in each text pair are segmented respectively, and multiple word pairs corresponding to each text pair are generated, each word pair including a candidate word in each sub-text.
[0043] In the text pair data set, the server performs word segmentation operations on the two sub-texts in each text pair, where each sub-text corresponds to a candidate word set, and each text pair corresponds to two candidate word sets. For a text pair, a candidate word is selected from two different candidate word sets each time to obtain a word pair for the text pair.
[0044] It should be noted that the candidate word set includes multiple candidate words, so each text pair may correspond to multiple word pairs, and each word pair is different.
[0045] 104. Calculate the positive word frequency of each word pair in the similar text pair and the negative word frequency of each word pair in the dissimilar text pair according to the multiple word pairs of each text pair.
[0046] The server calculates the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair. Specifically, the server first selects a word pair, calculates the forward word frequency of the word pair in the similar text pair, and calculates the reverse word frequency of the word pair in the dissimilar text pair, and then calculates the forward word frequency and reverse word frequency corresponding to other word pairs.
[0047] Among them, word frequency is to count how many times this word pair appears. For example, in similar text pairs, a total of 50,000 word pairs were extracted, among which the word pair (pre-job, training) appeared 1,000 times, so the frequency x1 of this word pair is 1,000, N1=50,000. After normalization, the positive word frequency of this word pair is x1 / N1=1,000 / 50,000=0.02. Similarly, in non-similar text pairs, a total of 100,000 word pairs were extracted, among which the word pair (pre-job, training) only appeared 10 times, so the frequency x2 is 10, N2=100,000, and the reverse word frequency is x2 / N2=10 / 100,000=0.0001.
[0048] 105. Based on the forward word frequency and reverse word frequency of each word pair, calculate the comprehensive feature score of each word pair.
[0049] The server calculates the comprehensive feature score of each word pair based on the positive word frequency and negative word frequency of each word pair. Specifically, the server calculates the comprehensive feature score of each word pair based on the positive word frequency, negative word frequency and preset calculation formula of each word pair, wherein the preset calculation formula is specifically score=freq_positive / freq_negative=(x / N1) / (x2 / N2). The higher the frequency of the word pair in similar text pairs, the higher the criticality of the word pair; the lower the frequency of the word pair in dissimilar text pairs, the higher the criticality of the word pair and the higher the score.
[0050] For example, for the word pair (buy insurance, take out insurance), the semantics of these two words are the same. Therefore, they appear more frequently in similar text pairs, that is, the positive word frequency (freq_positve) is larger. However, they appear less frequently in dissimilar text pairs, that is, the negative word frequency (freq_negative) is smaller. Therefore, the overall score is larger, and this word pair is very likely to be a keyword. Another example is the word pair (ba, ma). These two words are pause words and filler words, and they appear more frequently in similar text pairs, that is, freq_positve is larger, and they also appear frequently in dissimilar text pairs, that is, freq_negative is larger. Therefore, the overall score is smaller, and this word pair is less likely to be a keyword. Another example is the word pair (take out insurance, training). These two words have no relation to each other. They appear less frequently in similar text pairs, that is, freq_positve is smaller, and they appear moderately frequently in dissimilar text pairs, that is, freq_negative is average. However, the overall score may also be on the small side, and this word pair is less likely to be a keyword. For example, the positive word frequency freq_positve of (pre-job, training) mentioned above is 0.02, and the negative word frequency freq_negative is 0.0001, then the comprehensive feature score is 0.02 / 0.0001 = 200.
[0051] It should be noted that the preset calculation formula can also be in other forms. For example, the preset calculation formula can be: score = freq_positve - freq_negative; or the preset calculation formula can be: score = w1 * freq_positve + w2 * (1 - freq_negative), and it can also be in other forms, which are not limited here.
[0052] 106. Sort the comprehensive feature scores of all word pairs to generate a keyword set.
[0053] The server sorts the comprehensive feature scores of all word pairs in descending order; the server compares whether the comprehensive feature score of each word pair is greater than the threshold; the server determines the word pairs with comprehensive feature scores greater than the threshold as candidate word pairs; the server combines all the generated candidate word pairs to generate a keyword set.
[0054] 107. Screen the keyword set in combination with the business scenario to generate target keywords.
[0055] The server screens the keyword set in combination with the business scenario to generate target keywords.
[0056] It should be noted that different business scenarios require different keywords. For example, for the auto insurance underwriting scenario, the keywords may be: car model, car brand, insurance amount, etc. For the medical insurance underwriting scenario, the keywords may be: medical history, diagnosis report, health status, etc. There is no specific limitation here.
[0057] The embodiment of the present invention improves the recall rate of keywords, improves the comprehensive score of each keyword, and improves the accuracy of keyword extraction by constructing similar text pairs and dissimilar text pairs and calculating the word frequencies of keywords in the similar text pairs and dissimilar text pairs respectively.
[0058] See also Figure 2 , another flow chart of the keyword extraction method based on text pairs provided by an embodiment of the present invention, specifically comprising:
[0059] 201. Obtain an original question statement, and generate an original corpus data set based on the original question statement, where the original question statement is used to instruct the customer service system to find a corresponding answer to the question.
[0060] The server obtains the original question statement and generates an original corpus data set based on the original question statement, and the original question statement is used to instruct the customer service system to find the corresponding answer to the question. The original corpus data set includes standard question statements and similar question statements.
[0061] It should be noted that the same question may be expressed in different ways. For example, the standard question statement is: "What are the key points of pre-job training?", and similar question statements of this statement are: "The key content of pre-job training" or "What are the key points of pre-job training?". For another example, the standard question statement is: "Insurance for gastroenteritis", and similar question statements of this statement are: "Can gastroenteritis be insured?" or "Insurance for acute gastroenteritis" or "Can acute gastroenteritis be insured?".
[0062] It is understandable that the execution subject of the present invention may be a keyword extraction device based on text pairs, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0063] 202. A text pair dataset is constructed based on the original corpus dataset, where the text pair dataset includes similar text pairs and dissimilar text pairs.
[0064] Specifically, (1) the server determines questions in the original corpus dataset that are semantically similar to the original question sentence and generates multiple similar question sentences.
[0065] (2) The server combines multiple similar question statements in pairs to generate similar text pairs.
[0066] For example, in the original corpus data set, there are two types of semantically similar question data, one is the standard question sentence, and the other is the similar question sentence. The similar question sentence is an extension of the standard question sentence, and there are generally multiple similar question sentences, while the standard question sentence is unique. For example, for the original question sentence "Insurance for gastroenteritis", similar question sentences include "Can gastroenteritis be insured?", "Acute gastroenteritis", "Acute gastroenteritis insurance", etc., and the standard question sentence is "Gastroenteritis insurance". Select any two similar question sentences from the similar question sentences and the standard question sentences as similar text pairs. It can be obtained that the similar text pairs: "Gastroenteritis insurance, can gastroenteritis be insured?", similar text pairs: "Gastroenteritis insurance, insurance for gastroenteritis".
[0067] (3) The server determines questions in the original corpus dataset that are semantically dissimilar to the original question sentence and generates multiple dissimilar question sentences.
[0068] (4) The server combines multiple dissimilar question statements in pairs to generate dissimilar text pairs.
[0069] For another example, in the original corpus data set, there are two types of semantically similar question data, one is the standard question sentence, and the other is the similar question sentence. The similar question sentence is an extension of the standard question sentence, and there are generally multiple similar question sentences, while the standard question sentence is unique (if there are multiple standard questions with the same semantics, they can be merged in theory). Therefore, different standard question sentences are selected as dissimilar texts. For example, for the original question sentence "Insurance for gastroenteritis", similar question sentences include "Can gastroenteritis be insured?", "Acute gastroenteritis" and "Gastroenteritis", etc., and standard question sentences include "Insurance for gastroenteritis". Semantically dissimilar standard questions include "What are the key points of pre-job training" and "What is the insurance limit of accident insurance". Select any two standard question sentences as dissimilar text pairs, and get the dissimilar text pair: "Insurance for gastroenteritis, what are the key points of pre-job training?".
[0070] It should be noted that if the data noise is relatively large, you can first use the BM25 algorithm to calculate the similarity of the two texts, and then use the threshold to determine whether they can be considered dissimilar texts.
[0071] (5) The server fuses a first preset number of similar text pairs and a second preset number of dissimilar text pairs according to a preset ratio to generate a text pair data set.
[0072] 203. In the text pair data set, perform word segmentation operations on the first subtext and the second subtext in each text pair respectively to obtain a first word segmentation result of the first subtext and a second word segmentation result of the second subtext.
[0073] Specifically, the server randomly selects a text pair in the text pair data set as a target text pair; the server obtains a first subtext and a second subtext in the target text pair, and performs word segmentation on the first subtext and the second subtext respectively; the server generates a first word segmentation result corresponding to the first subtext and a second word segmentation result corresponding to the second subtext, the first word segmentation result includes each candidate word in the first subtext, and the second word segmentation result includes each candidate word in the second subtext.
[0074] For example, if the selected text pair is a similar text pair, and the specific content is "What are the key points of pre-job training? The key content of pre-job training", the first sub-text is "What are the key points of pre-job training", and the second sub-text is "The key content of pre-job training", then the word segmentation results for this text are as follows:
[0075] "What are the key points of pre-job training?"
[0076] "What are the key points and contents of pre-job training?"
[0077] 204. A preset model algorithm is used to extract a candidate word from the first word segmentation result and the second word segmentation result respectively, to generate multiple word pairs for each text pair.
[0078] Specifically, the server uses a preset bigram model 2-gram algorithm to select a candidate word from the first subtext in each text pair and another candidate word from the second subtext; the server combines the two extracted candidate words into word pairs to generate multiple word pairs for each text pair.
[0079] For example, for “What are the key points of pre-job training?”, based on 2-gram extraction of word pairs, the words of the first sentence are combined with the words of the second sentence to form word pairs, and the extraction results are: (pre-job, pre-job), (pre-job, training), (pre-job, of), (pre-job, key points), (pre-job, content), (training, pre-job), (training, training), (training, of), (training, key points), (training, content), …, (pre-job training, pre-job), (pre-job, pre-job training), etc. 2-gram means that on the basis of word segmentation, any two adjacent words are also paired to form new words.
[0080] 205. Calculate the positive word frequency of each word pair in the similar text pair and the negative word frequency of each word pair in the dissimilar text pair according to the multiple word pairs of each text pair.
[0081] 206. Based on the forward word frequency and the reverse word frequency of each word pair, calculate the comprehensive feature score of each word pair.
[0082] 207. Sort the comprehensive feature scores of all word pairs to generate a keyword set.
[0083] 208. Screen the keyword set in combination with the business scenario to generate target keywords.
[0084] Steps 205-208 are similar to steps 104-107, and will not be described in detail here.
[0085] The embodiment of the present invention improves the recall rate of keywords, improves the comprehensive score of each keyword, and improves the accuracy of keyword extraction by constructing similar text pairs and dissimilar text pairs and calculating the word frequencies of keywords in the similar text pairs and dissimilar text pairs respectively.
[0086] The above describes the keyword extraction method based on text pairs in the embodiment of the present invention. The following describes the keyword extraction device based on text pairs in the embodiment of the present invention. Figure 3 , an embodiment of a keyword extraction device based on text pairs in an embodiment of the present invention includes:
[0087] An acquisition unit 301 is used to acquire an original question statement and generate an original corpus data set based on the original question statement, wherein the original question statement is used to instruct the customer service system to search for a corresponding answer to the question;
[0088] A construction unit 302 is used to construct a text pair dataset based on the original corpus dataset, wherein the text pair dataset includes similar text pairs and dissimilar text pairs;
[0089] A word segmentation unit 303 is used to perform word segmentation operations on two sub-texts in each text pair in the text pair data set, and generate multiple word pairs corresponding to each text pair, each word pair including a candidate word in each sub-text;
[0090] A first calculation unit 304 is used to calculate the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair;
[0091] A second calculation unit 305, for calculating a comprehensive feature score of each word pair based on the forward word frequency and the reverse word frequency of each word pair;
[0092] A sorting unit 306 is used to sort the comprehensive feature scores of all word pairs to generate a keyword set;
[0093] The generating unit 307 is used to filter the keyword set in combination with the business scenario to generate target keywords.
[0094] The embodiment of the present invention improves the recall rate of keywords, improves the comprehensive score of each keyword, and improves the accuracy of keyword extraction by constructing similar text pairs and dissimilar text pairs and calculating the word frequencies of keywords in the similar text pairs and dissimilar text pairs respectively.
[0095] See also Figure 4 Another embodiment of the keyword extraction device based on text pairs in the embodiment of the present invention includes:
[0096] An acquisition unit 301 is used to acquire an original question statement and generate an original corpus data set based on the original question statement, wherein the original question statement is used to instruct the customer service system to search for a corresponding answer to the question;
[0097] A construction unit 302 is used to construct a text pair dataset based on the original corpus dataset, wherein the text pair dataset includes similar text pairs and dissimilar text pairs;
[0098] A word segmentation unit 303 is used to perform word segmentation operations on two sub-texts in each text pair in the text pair data set, and generate multiple word pairs corresponding to each text pair, each word pair including a candidate word in each sub-text;
[0099] A first calculation unit 304 is used to calculate the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair;
[0100] A second calculation unit 305, for calculating a comprehensive feature score of each word pair based on the forward word frequency and the reverse word frequency of each word pair;
[0101] A sorting unit 306 is used to sort the comprehensive feature scores of all word pairs to generate a keyword set;
[0102] The generating unit 307 is used to filter the keyword set in combination with the business scenario to generate target keywords.
[0103] Optionally, the construction unit 302 is specifically used for:
[0104] Determine questions that are semantically similar to an original question sentence in an original corpus data set, and generate a plurality of similar question sentences; combine the plurality of similar question sentences in pairs to generate similar text pairs; determine questions that are semantically dissimilar to the original question sentence in the original corpus data set, and generate a plurality of dissimilar question sentences; combine the plurality of dissimilar question sentences in pairs to generate dissimilar text pairs; merge a first preset number of similar text pairs and a second preset number of dissimilar text pairs according to a preset ratio to generate a text pair data set.
[0105] Optionally, the word segmentation unit 303 includes:
[0106] The word segmentation module 3031 is used to perform word segmentation operations on the first subtext and the second subtext in each text pair in the text pair data set, respectively, to obtain a first word segmentation result of the first subtext and a second word segmentation result of the second subtext;
[0107] The extraction module 3032 is used to extract a candidate word from the first word segmentation result and the second word segmentation result respectively by using a preset model algorithm to generate multiple word pairs for each text pair.
[0108] Optionally, the word segmentation module 3031 is specifically used for:
[0109] A text pair is randomly selected in a text pair data set as a target text pair; a first subtext and a second subtext in the target text pair are obtained, and the first subtext and the second subtext are segmented respectively; a first segmentation result corresponding to the first subtext and a second segmentation result corresponding to the second subtext are generated, wherein the first segmentation result includes each candidate word in the first subtext, and the second segmentation result includes each candidate word in the second subtext.
[0110] Optionally, the extraction module 3032 is specifically used for:
[0111] A preset bigram model 2-gram algorithm is used to select a candidate word from the first subtext in each text pair, and another candidate word from the second subtext; the two candidate words extracted are combined into a word pair to generate multiple word pairs for each text pair.
[0112] Optionally, the first calculating unit 304 is specifically configured to:
[0113] Select one word pair from multiple word pairs in each text pair as the target word pair; count the number of occurrences x1 of the target word pair in the similar text pair and the number of occurrences x2 of the target word pair in the dissimilar text pair; determine the total number N1 of word pairs in the similar text pair and the total number N2 of word pairs in the dissimilar text pair; generate the forward word frequency x1 / N1 of the target word pair in the similar text pair and the reverse word frequency x2 / N2 in the dissimilar text pair; and generate the forward word frequency and reverse word frequency of each word pair in turn.
[0114] Optionally, the sorting unit 306 is specifically configured to:
[0115] The comprehensive feature scores of all word pairs are sorted in descending order; the comprehensive feature score of each word pair is compared to see whether it is greater than a threshold; the word pairs with a comprehensive feature score greater than the threshold are determined as candidate word pairs; all the generated candidate word pairs are grouped together to generate a keyword set.
[0116] In the technical solution provided by the embodiment of the present invention, an original question statement is obtained, and an original corpus data set is generated based on the original question statement, the original question statement is used to instruct the customer service system to find the corresponding answer to the question; a text pair data set is constructed according to the original corpus data set, and the text pair data set includes similar text pairs and dissimilar text pairs; in the text pair data set, a first subtext and a second subtext in each text pair are respectively segmented to obtain a first segmentation result of the first subtext and a second segmentation result of the second subtext; a candidate word is respectively extracted from the first segmentation result and the second segmentation result using a preset model algorithm to generate multiple word pairs for each text pair; the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair are respectively calculated according to the multiple word pairs of each text pair; based on the forward word frequency and the reverse word frequency of each word pair, a comprehensive feature score of each word pair is calculated; the comprehensive feature scores of all word pairs are sorted to generate a keyword set; the keyword set is screened in combination with the business scenario to generate a target keyword. The embodiment of the present invention improves the recall rate of keywords, improves the comprehensive score of each keyword, and improves the accuracy of keyword extraction by constructing similar text pairs and dissimilar text pairs and calculating the word frequencies of keywords in the similar text pairs and dissimilar text pairs respectively.
[0117] above Figure 3 to Figure 4 The text pair-based keyword extraction device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The text pair-based keyword extraction device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0118] Figure 5 1 is a schematic diagram of the structure of a text-pair-based keyword extraction device provided by an embodiment of the present invention. The text-pair-based keyword extraction device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 501 (for example, one or more processors) and a memory 509, and one or more storage media 508 (for example, one or more massive storage devices) storing application programs 507 or data 506. Among them, the memory 509 and the storage medium 508 may be short-term storage or permanent storage. The program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the text-pair-based keyword extraction device. Furthermore, the processor 501 may be configured to communicate with the storage medium 508 to execute a series of instruction operations in the storage medium 508 on the text-pair-based keyword extraction device 500.
[0119] The keyword extraction device 500 based on text pairs may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and / or one or more operating systems 505, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 5 The structure of the text pair-based keyword extraction device shown in the figure does not constitute a limitation on the text pair-based keyword extraction device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. The processor 501 can perform the functions of the acquisition unit 301, the construction unit 302, the word segmentation unit 303, the first calculation unit 304, the second calculation unit 305, the sorting unit 306 and the generation unit 307 in the above-mentioned embodiment.
[0120] Combine the following Figure 5 A detailed introduction to the various components of the text pair-based keyword extraction device:
[0121] The processor 501 is the control center of the keyword extraction device based on text pairs, and can process according to the set keyword extraction method based on text pairs. The processor 501 uses various interfaces and lines to connect the various parts of the entire keyword extraction device based on text pairs, and executes various functions and processes data of the keyword extraction device based on text pairs by running or executing software programs and / or modules stored in the memory 509, and calling data stored in the memory 509, thereby improving the recall rate of keywords, improving the comprehensive score of each keyword, and improving the accuracy of keyword extraction. The storage medium 508 and the memory 509 are both carriers for storing data. In the embodiment of the present invention, the storage medium 508 can refer to an internal memory with a small storage capacity but a fast speed, and the memory 509 can be an external memory with a large storage capacity but a slow storage speed.
[0122] The memory 509 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing of the text pair-based keyword extraction device 500 by running the software programs and modules stored in the memory 509. The memory 509 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as constructing a text pair data set based on the original corpus data set, and the text pair data set includes similar text pairs and dissimilar text pairs), etc.; the data storage area can store data created according to the use of the text pair-based keyword extraction device (such as a keyword set or a target keyword, etc.), etc. In addition, the memory 509 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. The text pair-based keyword extraction method program and the received data stream provided in the embodiment of the present invention are stored in the memory, and when needed, the processor 501 calls from the memory 509.
[0123] When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, twisted pair) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., an optical disk), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0124] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0125] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A keyword extraction method based on text pairs, characterized in that: include: Obtaining an original question statement, and generating an original corpus data set based on the original question statement, wherein the original question statement is used to instruct the customer service system to search for a corresponding answer to the question; Constructing a text pair dataset according to the original corpus dataset, wherein the text pair dataset includes similar text pairs and dissimilar text pairs; In the text pair data set, two sub-texts in each text pair are respectively segmented, and a plurality of word pairs corresponding to each text pair are generated, each word pair including a candidate word in each sub-text; According to the multiple word pairs of each text pair, respectively calculate the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair; Based on the forward word frequency and reverse word frequency of each word pair, calculate the comprehensive feature score of each word pair; Sort the comprehensive feature scores of all word pairs to generate a keyword set; The keyword set is screened in combination with business scenarios to generate target keywords; The step of respectively calculating the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs in each text pair comprises: selecting a word pair from the multiple word pairs in each text pair as a target word pair; Count the number of times x1 that the target word pair appears in the similar text pair and the number of times x2 that the target word pair appears in the dissimilar text pair; determine the total number N1 of word pairs in the similar text pair and the total number N2 of word pairs in the dissimilar text pair; generate the forward word frequency x1 / N1 of the target word pair in the similar text pair and the reverse word frequency x2 / N2 in the dissimilar text pair; and generate the forward word frequency and reverse word frequency of each word pair in turn.
2. The keyword extraction method based on text pairs according to claim 1 is characterized in that: The step of constructing a text pair dataset based on the original corpus dataset, wherein the text pair dataset includes similar text pairs and dissimilar text pairs, includes: Determine questions with semantic similarity to the original question sentence in the original corpus data set, and generate multiple similar question sentences; Combining the multiple similar question sentences in pairs to generate similar text pairs; Determining questions in the original corpus data set that are semantically dissimilar to the original question sentence, and generating a plurality of dissimilar question sentences; Combining the plurality of dissimilar question sentences in pairs to generate dissimilar text pairs; A first preset number of similar text pairs and a second preset number of dissimilar text pairs are fused according to a preset ratio to generate a text pair data set.
3. The keyword extraction method based on text pairs according to claim 1, characterized in that: In the text pair data set, two sub-texts in each text pair are respectively segmented, and a plurality of word pairs corresponding to each text pair are generated, each word pair including a candidate word in each sub-text, including: In the text pair data set, a first subtext and a second subtext in each text pair are respectively segmented to obtain a first segmentation result of the first subtext and a second segmentation result of the second subtext; A preset model algorithm is used to extract a candidate word from each of the first word segmentation result and the second word segmentation result to generate multiple word pairs for each text pair.
4. The keyword extraction method based on text pairs according to claim 3 is characterized in that: In the text pair data set, the first subtext and the second subtext in each text pair are respectively subjected to word segmentation operations to obtain a first word segmentation result of the first subtext and a second word segmentation result of the second subtext, including: Randomly select a text pair in the text pair dataset as the target text pair; Acquire a first subtext and a second subtext in the target text pair, and perform word segmentation on the first subtext and the second subtext respectively; A first word segmentation result corresponding to the first subtext and a second word segmentation result corresponding to the second subtext are generated, wherein the first word segmentation result includes each candidate word in the first subtext, and the second word segmentation result includes each candidate word in the second subtext.
5. The keyword extraction method based on text pairs according to claim 3 is characterized in that: The method of using a preset model algorithm to extract a candidate word from each of the first word segmentation result and the second word segmentation result to generate multiple word pairs for each text pair includes: Select one candidate word from the first subtext of each text pair and another candidate word from the second subtext using a preset bigram model 2-gram algorithm; The two candidate words extracted respectively are combined into word pairs to generate multiple word pairs for each text pair.
6. The keyword extraction method based on text pairs according to any one of claims 1 to 5, characterized in that: The comprehensive feature scores of all word pairs are sorted to generate a keyword set, including: Sort the comprehensive feature scores of all word pairs from largest to smallest; Compare whether the comprehensive feature score of each word pair is greater than the threshold; Determine the word pairs whose comprehensive feature scores are greater than the threshold as candidate word pairs; All generated candidate word pairs are collected to generate a keyword set.
7. A keyword extraction device based on text pairs, characterized in that: include: An acquisition unit, used to acquire an original question statement and generate an original corpus data set based on the original question statement, wherein the original question statement is used to instruct the customer service system to search for a corresponding answer to the question; A construction unit, configured to construct a text pair dataset based on the original corpus dataset, wherein the text pair dataset includes similar text pairs and dissimilar text pairs; A word segmentation unit is used to perform word segmentation operations on two sub-texts in each text pair in the text pair data set, and generate multiple word pairs corresponding to each text pair, each word pair including a candidate word in each sub-text; A first calculation unit, for respectively calculating the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs of each text pair; A second calculation unit, used to calculate a comprehensive feature score of each word pair based on the forward word frequency and the reverse word frequency of each word pair; A sorting unit is used to sort the comprehensive feature scores of all word pairs to generate a keyword set; A generating unit, configured to screen the keyword set in combination with a business scenario to generate a target keyword; The step of respectively calculating the forward word frequency of each word pair in the similar text pair and the reverse word frequency in the dissimilar text pair according to the multiple word pairs in each text pair comprises: selecting a word pair from the multiple word pairs in each text pair as a target word pair; Count the number of times x1 that the target word pair appears in the similar text pair and the number of times x2 that the target word pair appears in the dissimilar text pair; determine the total number N1 of word pairs in the similar text pair and the total number N2 of word pairs in the dissimilar text pair; generate the forward word frequency x1 / N1 of the target word pair in the similar text pair and the reverse word frequency x2 / N2 in the dissimilar text pair; and generate the forward word frequency and reverse word frequency of each word pair in turn.
8. A keyword extraction device based on text pairs, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for extracting keywords based on text pairs as described in any one of claims 1 to 6 is implemented.
9. 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 text pair-based keyword extraction method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Heat development apparatus
US20020135661A1
Method and device for automatically extracting Chinese text keyword
CN110362678A
Intelligent test method, device and equipment and readable storage medium
CN110502432A