Method, apparatus, and device for extracting causal keywords

The method uses a machine learning model to concatenate and extract cause and effect keywords from sentences, addressing inefficiencies in existing technologies and enhancing extraction efficiency and generalization.

CN114840678BActive Publication Date: 2025-07-15JINGDONG TECH HLDG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110145041.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-02
Publication Date
2025-07-15
Estimated Expiration
2041-02-02

AI Technical Summary

Technical Problem

The prior art cannot extract multiple pairs of causal keywords in the same sentence at the same time, resulting in low efficiency in causal keyword extraction.

Method used

By splicing the set cause text and the original sentences of the causal keywords to be extracted, a trained machine learning model is used to extract keywords, including the BERT model, graph convolutional neural network layer and attention layer, and the cause keywords and result keywords are extracted.

Benefits of technology

It improves the efficiency of causal keyword extraction, reduces manual consumption, and improves the generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114840678B_ABST
    Figure CN114840678B_ABST
Patent Text Reader

Abstract

The present application provides a method, an apparatus, and a computer device for extracting causal keywords. The method includes: splicing a set cause text and an original sentence from which causal keywords are to be extracted to generate a first input text, using a trained machine learning model to extract keywords from the first input text, and taking the keywords extracted by the machine learning model as cause keywords, splicing the cause keywords, a set result text, and the original sentence to generate a second input text corresponding to the cause keywords, and using the machine learning model to extract keywords from the second input text corresponding to the cause keywords, and taking the keywords extracted by the machine learning model as result keywords corresponding to the cause keywords. Thus, the machine learning model is used to automatically extract cause keywords and corresponding result keywords in the text, which not only reduces manual consumption but also improves the generalization ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of deep learning technology, and in particular, to a method, apparatus, and device for extracting causal keywords. Background Art

[0002] Causality is the relationship between "cause" and "result", which is a relationship of causation. As an important type of relationship, causality plays an important role in many tasks, such as event prediction, scenario generation, question answering, and text entailment. In causality extraction, the most important thing is the extraction of causal keywords, which mark whether the event in the sentence is a cause or an effect. It can be said that causality extraction is the extraction of causal keywords.

[0003] In the prior art, when extracting causal keywords from text, it is impossible to extract multiple pairs of causal keywords in the same sentence at the same time. For example, for the sentence "Student Xiaoming usually studies hard, so he achieved excellent grades in the final exam", the existing causal keyword extraction methods cannot extract multiple pairs of causal keywords "hard - excellent" and "study - grades" in the sentence at the same time, resulting in low extraction efficiency of the existing causal keyword extraction methods. Summary of the Invention

[0004] This application aims to solve at least one of the technical problems in the related art to some extent.

[0005] To this end, this application proposes a method for extracting causal keywords to achieve extracting all causal keywords in the text using a machine learning model, which is beneficial to improving the extraction efficiency of causal keywords.

[0006] The first aspect embodiment of this application proposes a method for extracting causal keywords, including:

[0007] Concatenate the set cause text and the original sentence to be extracted with causal keywords to generate a first input text;

[0008] Use the trained machine learning model to extract keywords from the first input text, and take the keywords extracted by the machine learning model as cause keywords;

[0009] Concatenate the cause keywords, the set result text, and the original sentence to generate a second input text corresponding to the cause keywords;

[0010] Use the machine learning model to extract keywords from the second input text corresponding to the cause keywords, and take the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords.

[0011] Optionally, using the trained machine learning model to extract keywords from the first input text, and using the keywords extracted by the machine learning model as cause keywords, includes:

[0012] Inputting the first input text into the feature extraction layer of the machine learning model to obtain word vectors of each character in the first input text output by the feature extraction layer;

[0013] Inputting the word vectors of each character in the first input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the first input text;

[0014] Inputting the semantic vector into the attention layer of the machine learning model to predict attention weights for each character in the first input text according to the semantic vector, and obtaining the attention weights of each character;

[0015] Inputting the attention weights of each character into the output layer of the machine learning model, so that the output layer outputs the cause keywords according to the attention weights of each character.

[0016] Optionally, using the machine learning model to extract keywords from the second input text corresponding to the cause keywords, and using the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords, includes:

[0017] Inputting the second input text corresponding to the cause keywords into the feature extraction layer of the machine learning model to obtain word vectors of each character in the second input text output by the feature extraction layer;

[0018] Inputting the word vectors of each character in the second input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the second input text;

[0019] Inputting the semantic vector into the attention layer of the machine learning model to predict attention weights for each character in the second input text according to the semantic vector, and obtaining the attention weights of each character in the second input text;

[0020] Inputting the attention weights of each character in the second input text into the output layer of the machine learning model, so that the output layer outputs the result keywords corresponding to the cause keywords according to the attention weights of each character.

[0021] Optionally, the method further includes:

[0022] Obtaining a predicted cause keyword obtained by the machine learning model for causal keyword extraction from a training sample, and a predicted result keyword corresponding to the predicted cause keyword;

[0023] Determine first loss information according to the difference between the predicted cause keyword and the standard cause keyword labeled in the training sample;

[0024] Determine second loss information according to the difference between the predicted result keyword corresponding to the predicted cause keyword and the standard result keyword labeled in the training sample;

[0025] Adjust the model parameters of the machine learning model according to the first loss information and the second loss information.

[0026] Optionally, obtaining a predicted cause keyword extracted from the training sample by the machine learning model includes:

[0027] If there are multiple predicted cause keywords extracted from the training sample by using the machine learning model, randomly select the one predicted cause keyword from the multiple predicted cause keywords.

[0028] Optionally, the set cause text includes words or sentences representing cause semantics;

[0029] The set result text includes words or sentences representing result semantics.

[0030] Optionally, sequentially append each character of the original sentence after the last character in the set cause text to obtain the first input text.

[0031] Optionally, splicing the cause keyword, the set result text, and the original sentence to generate a second input text corresponding to the cause keyword includes:

[0032] Sequentially append each character of the set result text after the last character in the cause keyword to obtain an intermediate text;

[0033] Sequentially append each character of the original sentence after the last character in the intermediate text to obtain the second input text.

[0034] The method for extracting causal keywords according to the embodiments of the present application generates a first input text by splicing a set cause text and the original sentence from which the causal keywords are to be extracted, and uses a trained machine learning model to extract keywords from the first input text, taking the keywords extracted by the machine learning model as cause keywords. Then, the cause keywords, the set result text, and the original sentence are spliced to generate a second input text corresponding to the cause keywords, and the machine learning model is used to extract keywords from the second input text corresponding to the cause keywords, taking the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords. Thus, the machine learning model is used to automatically extract cause keywords and corresponding result keywords from the text, which not only reduces manual consumption but also improves the generalization ability.

[0035] The embodiments of the second aspect of the present application propose an apparatus for extracting causal keywords, including:

[0036] A first splicing module, configured to splice a set cause text and the original sentence from which the causal keywords are to be extracted to generate a first input text;

[0037] A first extraction module, configured to use a trained machine learning model to extract keywords from the first input text, taking the keywords extracted by the machine learning model as cause keywords;

[0038] A second splicing module, configured to splice the cause keywords, the set result text, and the original sentence to generate a second input text corresponding to the cause keywords;

[0039] A second extraction module, configured to use the machine learning model to extract keywords from the second input text corresponding to the cause keywords, taking the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords.

[0040] The apparatus for extracting causal keywords according to the embodiments of the present application generates a first input text by splicing a set cause text and the original sentence from which the causal keywords are to be extracted, and uses a trained machine learning model to extract keywords from the first input text, taking the keywords extracted by the machine learning model as cause keywords. Then, the cause keywords, the set result text, and the original sentence are spliced to generate a second input text corresponding to the cause keywords, and the machine learning model is used to extract keywords from the second input text corresponding to the cause keywords, taking the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords. Thus, the machine learning model is used to automatically extract cause keywords and corresponding result keywords from the text, which not only reduces manual consumption but also improves the generalization ability.

[0041] A third - aspect embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method for extracting causal keywords as described in the above - mentioned embodiment is implemented.

[0042] A fourth - aspect embodiment of the present application provides a non - transitory computer - readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method for extracting causal keywords as described in the above - mentioned embodiment is implemented.

[0043] A fifth - aspect embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor, the method for extracting causal keywords as described in the above - mentioned embodiment is executed.

[0044] Additional aspects and advantages of the present application will be given in part in the following description, will become apparent in part from the following description, or will be understood through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The above - mentioned and / or additional aspects and advantages of the present application will become apparent and be readily understood from the following description of the embodiments in conjunction with the drawings, where:

[0046] Figure 1 is a schematic flowchart of a method for extracting causal keywords provided by an embodiment of the present application;

[0047] Figure 2 is an example diagram of keywords of a machine - learning model provided by an embodiment of the present application;

[0048] Figure 3 is a schematic flowchart of a method for training a machine - learning model provided by an embodiment of the present application;

[0049] Figure 4 is a schematic structural diagram of an apparatus for extracting causal keywords provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0050] The embodiments of the present application will be described in detail below. The examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are intended to explain the present application, and should not be construed as limiting the present application.

[0051] The method, apparatus, and device for extracting causal keywords according to the embodiments of the present application will be described below with reference to the drawings.

[0052] Figure 1 is a schematic flowchart of a method for extracting causal keywords provided by an embodiment of the present application.

[0053] As Figure 1 shown, the method for extracting causal keywords includes the following steps:

[0054] Step 101, splice the set cause text and the original sentence from which causal keywords are to be extracted to generate a first input text.

[0055] Among them, the set cause text may include words or sentences representing cause semantics. For example, the set cause text may be "cause", "cause keyword", or may be a question related to the cause, such as "What is the cause keyword", etc.

[0056] In the embodiments of the present application, the original sentence from which causal keywords are to be extracted may be a sentence input by a user, a sentence downloaded from a web page, or a sentence obtained from a database, which is not limited herein.

[0057] For example, the original sentence from which causal keywords are to be extracted is "Student Xiaoming usually studies hard, so he got excellent grades in the final exam."

[0058] It should be explained that the above original sentence is only for exemplary description, and the original sentence from which causal keywords are to be extracted may also be any other sentence containing causal keywords, which is not limited herein.

[0059] In the embodiments of the present application, after obtaining the original sentence from which causal keywords are to be extracted, the set cause text and the original sentence from which causal keywords are to be extracted may be spliced to generate a first input text.

[0060] In a possible case, each character of the original sentence may be sequentially continued after the last character in the set cause text to obtain the first input text.

[0061] As an example, assuming that the set cause text is "cause" and the original sentence is "Student Xiaoming usually studies hard, so he got excellent grades in the final exam", splicing the set cause text and the original sentence from which causal keywords are to be extracted, the first input text "causeStudent Xiaoming usually studies hard, so he got excellent grades in the final exam" can be obtained.

[0062] In another possible case, each character of the set cause text may also be sequentially continued after the last character in the original sentence to obtain the first input text.

[0063] As an example, assume that the set reason text is "reason", and the original sentence is "Student Xiaoming usually studies hard, so he achieved excellent results in the final exam". By concatenating the set reason text and the original sentence for which causal keywords are to be extracted, the first input text "Student Xiaoming usually studies hard, so he achieved excellent results in the final exam reason" can also be obtained. It should be noted that in this application, the concatenation order of the set reason text and the original sentence is not limited. The set reason text can be concatenated in front of the original sentence, or the set reason text can be concatenated behind the original sentence, which is not limited here.

[0064] Step 102, use the trained machine learning model to extract keywords from the first input text, and use the keywords extracted by the machine learning model as the reason keywords.

[0065] In this application, the machine learning model can be a trained BERT model (Bidirectional Encoder Representations from Transformer, bidirectional encoding representation based on machine translation).

[0066] Optionally, as Figure 2 shown, the machine learning model can include a feature extraction layer, a graph convolutional neural network layer (Graph Convolutional Network, GCN), an attention layer, and an output layer. Among them, the feature extraction layer is used to extract features from the input text to obtain the word vectors of each character in the input text; the graph convolutional neural network layer is also a feature extractor, which is used to obtain the semantic vectors of the input text; the attention layer is used to predict the attention weights of each character in the input text to obtain the attention weights of each character; the output layer is used to output the reason keywords according to the attention weights of each character. As a possible implementation, when using the machine learning model to extract keywords from the first input text, first input the first input text into the feature extraction layer of the machine learning model, and the feature extraction layer extracts features from each character in the input first input text to output the word vectors of each character in the first input text. Thus, by extracting the reason keywords and result keywords in units of word vectors, the extracted result keywords and reason keywords are made to match.

[0067] Continue with Figure 2The example in is explained. Assume that the set cause text is "cause", and the original sentence is "Student Xiaoming usually studies hard, so he achieved excellent results in the final exam". Assume that the set cause text and the original sentence for which causal keywords are to be extracted are concatenated to obtain the first input text: "cause Student Xiaoming usually studies hard, so he achieved excellent results in the final exam". The first input text can be input into the feature extraction layer of the machine learning model. The feature extraction layer extracts features from each character in the first input text to output the word vectors of each character in the first input text.

[0068] Further, the word vectors of each character in the first input text are input into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the first input text.

[0069] In the embodiment of the present application, after the graph convolutional neural network layer of the machine learning model performs semantic encoding on the word vectors of each character in the first input text to obtain the semantic vector of the first input text, the semantic vector can be input into the attention layer of the machine learning model, so that the attention layer predicts the attention weights of each character in the first input text according to the semantic vector to obtain the attention weights of each character. Further, the attention weights of each character are input into the output layer of the machine learning model, so that the output layer outputs the cause keyword according to the attention weights of each character.

[0070] Continue to explain with the example in Figure 2 After the graph convolutional neural network layer in performs semantic encoding on the word vectors of each character in the first input text to obtain the corresponding semantic vector, the semantic vector is passed into the attention layer to obtain the attention weights of each character. The attention weights of each character are input into the output layer of the machine learning model and activated by the sigmoid function to obtain Figure 2 the sequences of the start position and the end position of the cause keyword shown in Figure 2

[0071] As can be seen from Figure 2 when using the machine learning model to extract the cause keyword, the number "1" in the sequence of the start position output by the output layer indicates the start position of the cause keyword, and the number "1" in the sequence of the end position indicates the end position of the cause keyword.

[0072] For example, Figure 2The sequence at the start position is [0100000000100100000001000000], and the sequence at the end position is [0010010010000000101000001000]. There are 4 '1's in the sequence at the start position. The machine learning model extracts 4 cause keywords. The start position of each cause keyword in the original sentence is the position corresponding to the '1' in the sequence at the start position, and the end position of each cause keyword in the original sentence is the position corresponding to the '1' in the sequence at the end position that is closest to the start position of the cause keyword.

[0073] For example, Figure 2 The start position of the first cause keyword in is the position corresponding to the first '1' in the sequence at the start position, and the end position is the position corresponding to the first '1' in the sequence at the end position that is closest to the position corresponding to the first '1' in the sequence at the start position. The start position of the second cause keyword is the position corresponding to the second '1' in the sequence at the start position, and the end position is the position corresponding to the fourth '1' in the sequence at the end position; among them, the second and third '1's in the sequence at the end position are invalid because the first '1' in the sequence at the end position is closest to the position corresponding to the first '1' in the sequence at the start position, and the second and third '1's in the sequence at the end position are farther from the position corresponding to the first '1' in the sequence at the start position, so the second and third '1's in the sequence at the end position are invalid. The start position of the third cause keyword is the position corresponding to the third '1' in the sequence at the start position, and the end position is the position corresponding to the fourth '1' in the sequence at the end position. It can be seen that the second and third cause keywords can have repeated words. The start position of the fourth cause keyword is the position corresponding to the fourth '1' in the sequence at the start position, and the end position is the position corresponding to the sixth '1' in the sequence at the end position.

[0074] It should be noted that, Figure 2 The process of extracting cause keywords using the machine learning model in is only for exemplary description, and the specific extraction results correspond to the original sentence of the causal keywords to be extracted as input.

[0075] In the embodiments of the present application, when extracting cause keywords from the first input text using a trained machine learning model, the extracted cause keywords are not limited to one, but can also be multiple.

[0076] Step 103, splice the cause keyword, the set result text, and the original sentence to generate the second input text corresponding to the cause keyword.

[0077] Among them, the set result text includes words or sentences representing the result semantics. For example, the set result text can be "result", "result keywords", "what is the result", and so on.

[0078] In the embodiments of the present application, after the machine learning model extracts the cause keywords, the cause keywords, the set result text, and the original sentence can be concatenated to generate the second input text corresponding to the cause keywords.

[0079] In a possible case, assuming that the machine learning model performs keyword extraction on the first input text and extracts a cause keyword, the cause keyword, the set result text, and the original sentence can be concatenated to generate the second input text corresponding to the cause keyword.

[0080] In another possible case, assuming that the machine learning model performs keyword extraction on the first input text and extracts multiple cause keywords, one cause keyword can be selected from the multiple cause keywords, and the selected cause keyword, the set result text, and the original sentence can be concatenated to generate the second input text corresponding to the cause keyword.

[0081] It should be noted that when the machine learning model extracts multiple cause keywords, one cause keyword can be randomly selected from the multiple cause keywords, or one cause keyword can be selected according to the order of each keyword in the multiple cause keywords. For example, the cause keyword with the earlier order can be selected from the multiple cause keywords and concatenated with the set result text and the original sentence. This application does not limit this.

[0082] For example, the second input text can be "cause keyword set result text original sentence", or "cause keyword original sentence set result text", or "original sentence set result text cause keyword", and so on.

[0083] As a possible case of the embodiments of the present application, when concatenating the cause keyword, the set result text, and the original sentence, the characters of the set result text can be sequentially continued after the last character of the cause keyword to obtain an intermediate text. Then, the characters of the original sentence can be sequentially continued after the last character of the intermediate text to obtain the second input text.

[0084] As an example, assume that the cause keyword is "study hard", the set result text is "What is the result", and the original sentence is "Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam". The second text obtained by splicing the cause keyword, the set result text, and the original sentence can be "Study hard What is the result Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam".

[0085] As another possible case of the embodiment of the present application, the characters of the original sentence can be sequentially continued after the last character of the cause keyword to obtain an intermediate text, and then the characters of the set result text can be sequentially continued after the last character of the intermediate text to obtain a second input text.

[0086] As an example, assume that the cause keyword is "study hard", the set result text is "What is the result", and the original sentence is "Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam". The second input text obtained by splicing the cause keyword, the set result text, and the original sentence can also be "Study hard Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam What is the result".

[0087] As another possible case of the embodiment of the present application, the characters of the cause keyword can also be sequentially continued after the last character of the set result text to obtain an intermediate text. Further, the characters of the original sentence can be sequentially continued after the last character of the intermediate text to obtain a second input text.

[0088] As an example, assume that the cause keyword is "study hard", the set result text is "What is the result", and the original sentence is "Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam". The second input text obtained by splicing the cause keyword, the set result text, and the original sentence can also be "What is the result Study hard Because classmate Xiaoming usually studies hard, he achieved excellent results in the final exam".

[0089] It should be noted that when splicing the cause keyword, the set result text, and the original sentence in the present application, the order of arrangement of the characters of the cause keyword, the set result text, and the original sentence is not limited. Other splicing orders can also be used to splice the cause keyword, the set result text, and the original sentence. The above several splicing methods are only used as exemplary descriptions.

[0090] Step 104, use a machine learning model to extract keywords from the second input text corresponding to the cause keyword, and use the keywords extracted by the machine learning model as the result keywords corresponding to the cause keyword.

[0091] In the embodiments of the present application, after generating the second input text corresponding to the cause keyword, a machine learning model can be used to extract keywords from the second input text corresponding to the cause keyword, and the keywords extracted by the machine learning model are used as the result keywords corresponding to the cause keyword.

[0092] It should be noted that the number of result keywords extracted by the machine learning model can be one or more, and there is no limitation in the present application.

[0093] As an example, such as Figure 2 shown, the machine learning model for extracting result keywords may include a feature extraction layer, a graph convolutional neural network layer, an attention layer, and an output layer.

[0094] From Figure 2 it can be seen that the second input text corresponding to the cause keyword is input into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the second input text output by the feature extraction layer. Furthermore, the word vectors of each character in the second input text are input into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the second input text. The semantic vector is input into the attention layer of the machine learning model to predict the attention weights of each character in the second input text according to the semantic vector, and the attention weights of each character in the second input text are obtained. The attention weights of each character in the second input text are input into the output layer of the machine learning model, so that the output layer outputs the result keywords corresponding to the cause keyword according to the attention weights of each character. Figure 2 The sequences output in Figure 2 represent the start position and end position of the result keywords corresponding to the cause keyword.

[0095] From Figure 2 it can be seen that when using the machine learning model to extract result keywords, the number "1" in the sequence of the start position output by the output layer represents the start position of the result keyword, and the number "1" in the sequence of the end position represents the end position of the result keyword.

[0096] For example, Figure 2 in Figure 2 , the sequence of the start position is [0100010000100010000001000000], and the sequence of the end position is [0001000010001010101000000100]. There are 5 numbers "1" in the sequence of the start position. The machine learning model extracts 5 result keywords. The start position of each result keyword in the original sentence is the position corresponding to the number "1" in the sequence of the start position, and the end position of each result keyword in the original sentence is the position corresponding to the number "1" closest to the start position of the result keyword in the sequence of the end position.

[0097] For example, Figure 2The starting position of the first result keyword in the sequence of the starting position is the position corresponding to the first digit '1' in the sequence of the starting position, and the ending position is the position corresponding to the first digit '1' in the sequence of the ending position. The starting position of the second result keyword is the position corresponding to the second digit '1' in the sequence of the starting position, and the ending position is the position corresponding to the second digit '1' in the sequence of the ending position. The starting position of the third result keyword is the position corresponding to the third digit '1' in the sequence of the starting position, and the ending position is the position corresponding to the third digit '1' in the sequence of the ending position. The starting position of the fourth result keyword is the position corresponding to the fourth digit '1' in the sequence of the starting position, and the ending position is the position corresponding to the fourth digit '1' in the sequence of the ending position. The starting position of the fifth result keyword is the position corresponding to the fifth digit '1' in the sequence of the starting position, and the ending position is the position corresponding to the seventh digit '1' in the sequence of the ending position. Among them, the fifth and sixth digits '1' in the sequence of the ending position are invalid.

[0098] It should be explained that when there are multiple cause keywords extracted by the machine learning model, the machine learning model needs to be used to extract keywords from the second input text corresponding to each cause keyword to obtain the result keywords corresponding to each cause keyword.

[0099] Such as Figure 2 As shown, assuming there are N cause keywords, the machine learning model is looped N times to extract keywords from the second input text corresponding to the cause keywords to obtain the result keywords corresponding to each cause keyword. Thus, the machine learning model can extract all the cause keywords in the original sentence and the result keywords corresponding to the cause keywords, thereby improving the extraction efficiency of causal keywords.

[0100] The method for extracting causal keywords in the embodiments of the present application splices the set cause text and the original sentence to be extracted with causal keywords to generate the first input text, uses the trained machine learning model to extract keywords from the first input text, takes the keywords extracted by the machine learning model as cause keywords, splices the cause keywords, the set result text and the original sentence to generate the second input text corresponding to the cause keywords, and uses the machine learning model to extract keywords from the second input text corresponding to the cause keywords to take the keywords extracted by the machine learning model as the result keywords corresponding to the cause keywords. Thus, using the machine learning model to automatically extract cause keywords and corresponding result keywords in the text not only reduces manual consumption but also improves the generalization ability.

[0101] The machine learning model in the embodiments of the present application is a trained model. The following combines Figure 3A detailed introduction to the model training process is provided. Figure 3 It is a schematic flowchart of the training method for the machine learning model provided by the embodiments of this application.

[0102] As Figure 3 shown, the method may include the following steps:

[0103] Step 201: Obtain a predicted cause keyword extracted by the machine learning model from the training sample, and a predicted result keyword corresponding to the predicted cause keyword.

[0104] Among them, the training sample can be text downloaded from the server, or text input by the user, etc., which is not limited here. It should be noted that the training sample is marked with standard cause keywords and standard result keywords.

[0105] In the embodiments of this application, after obtaining the training sample, the machine learning model can be used to extract causal keywords from the training sample to obtain a predicted cause keyword and a predicted result keyword corresponding to the predicted cause keyword.

[0106] In a possible case, if there are multiple predicted cause keywords extracted by the machine learning model from the training sample, one predicted cause keyword can be randomly selected from the multiple predicted cause keywords.

[0107] For example, assume that the machine learning model extracts 4 predicted cause keywords from the training sample, then one predicted cause keyword can be randomly selected from these 4 predicted cause keywords.

[0108] Step 202: Determine the first loss information according to the difference between the predicted cause keyword and the standard cause keyword marked in the training sample.

[0109] Step 203: Determine the second loss information according to the difference between the predicted result keyword corresponding to the predicted cause keyword and the standard result keyword marked in the training sample.

[0110] For the convenience of distinction, in this application, the difference between the predicted cause keyword and the standard cause keyword marked in the training sample is determined as the first loss information, and the difference between the predicted result keyword and the standard result keyword marked in the training sample is determined as the second loss information.

[0111] In the embodiments of this application, after determining the predicted cause keyword and the predicted result keyword corresponding to the predicted cause keyword, the predicted cause keyword can be compared with the standard cause keyword marked in the training sample to determine the difference between the predicted cause keyword and the standard cause keyword, and this difference is determined as the first loss information.

[0112] In a possible case, the difference between the predicted cause keyword and the standard cause keyword labeled in the training sample can be the reciprocal of the semantic similarity between the semantic vectors corresponding to the predicted cause keyword and the standard cause keyword, so as to determine the reciprocal of the semantic similarity as the first loss information.

[0113] It should be noted that the semantic similarity between the semantic vectors mentioned in the embodiments of the present application can be the Euclidean distance between the semantic vector corresponding to the predicted cause keyword and the semantic vector corresponding to the standard cause keyword.

[0114] As an example, assume that the predicted cause keyword is A1 and the standard cause keyword is A2. The semantic vectors corresponding to the predicted cause keyword A1 and the standard cause keyword A2 obtained by semantic extraction are vector B1 and vector B2 respectively. The reciprocal of the semantic similarity between vector B1 and vector B2 can be determined as the difference between the predicted cause keyword A1 and the standard cause keyword A2. Correspondingly, compare the predicted result keyword corresponding to the predicted cause keyword with the standard result keyword labeled in the training sample to determine the difference between the predicted result keyword and the standard result keyword, and determine the difference as the second loss information.

[0115] In a possible case, the difference between the predicted result keyword and the standard result keyword labeled in the training sample can also be the reciprocal of the semantic similarity between the semantic vectors corresponding to the predicted result keyword and the standard result keyword, so as to determine the reciprocal of the semantic similarity as the second loss information.

[0116] It should be noted that the semantic similarity between the semantic vectors mentioned in the embodiments of the present application can be the Euclidean distance between the semantic vector corresponding to the predicted result keyword and the semantic vector corresponding to the standard result keyword.

[0117] As an example, assume that the predicted result keyword is C1 and the standard result keyword is C2. The semantic vectors corresponding to the predicted result keyword C1 and the standard result keyword C2 obtained by semantic extraction are vector D1 and vector D2 respectively. The reciprocal of the semantic similarity between vector D1 and vector D2 can be determined as the difference between the predicted result keyword C1 and the standard result keyword C2. Step 204, adjust the model parameters of the machine learning model according to the first loss information and the second loss information.

[0118] In the embodiments of the present application, since the first loss information represents the accuracy of the predicted cause keywords and the second loss information represents the accuracy of the predicted result keywords. Therefore, after determining the first loss information and the second loss information, the machine learning model can be trained according to the differences between the predicted cause keywords and the standard cause keywords annotated in the training samples and the differences between the predicted result keywords and the standard result keywords annotated in the training samples, so that the machine learning model can learn the mapping relationship between the cause keywords and the result keywords. During the model training process, the model parameters are adjusted so that when the trained machine learning model extracts causal keywords, the difference between the extracted predicted cause keywords and the standard cause keywords is minimized, and the difference between the extracted predicted result keywords and the standard result keywords is minimized.

[0119] In the embodiments of the present application, after obtaining a predicted cause keyword extracted by the machine learning model from the training samples and the predicted result keyword corresponding to the predicted cause keyword, the first loss information is determined according to the difference between the predicted cause keyword and the standard cause keyword annotated in the training samples, and the second loss information is determined according to the difference between the predicted result keyword corresponding to the predicted cause keyword and the standard result keyword annotated in the training samples. The model parameters of the machine learning model are adjusted according to the first loss information and the second loss information. Thus, by adjusting the model parameters of the machine learning model, the trained machine learning model can more accurately extract the cause keywords and the corresponding result keywords in the text, thereby improving the extraction efficiency of the machine learning model.

[0120] To implement the above embodiments, the present application also proposes an extraction device for causal keywords.

[0121] Figure 4 It is a schematic structural diagram of an extraction device for causal keywords provided by the embodiments of the present application.

[0122] As Figure 4 shown, the extraction device 300 for causal keywords may include: a first splicing module 310, a first extraction module 320, a second splicing module 330, and a second extraction module 340.

[0123] Among them, the first splicing module 310 is used to splice the set cause text and the original sentence to be extracted with causal keywords to generate a first input text.

[0124] The first extraction module 320 is used to extract keywords from the first input text by using the trained machine learning model, and use the keywords extracted by the machine learning model as cause keywords.

[0125] The second splicing module 330 is used to splice the cause keyword, the set result text, and the original sentence to generate the second input text corresponding to the cause keyword.

[0126] The second extraction module 340 is used to extract keywords from the second input text corresponding to the cause keyword by using a machine learning model, and use the keywords extracted by the machine learning model as the result keywords corresponding to the cause keyword.

[0127] As a possible case, the first extraction module 320 can also be used to:

[0128] Input the first input text into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the first input text output by the feature extraction layer; input the word vectors of each character in the first input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the first input text; input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the first input text according to the semantic vector, and obtain the attention weights of each character; input the attention weights of each character into the output layer of the machine learning model, so that the output layer outputs the cause keyword according to the attention weights of each character.

[0129] As another possible case, the second extraction module 340 can also be used to:

[0130] Input the second input text corresponding to the cause keyword into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the second input text output by the feature extraction layer; input the word vectors of each character in the second input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the second input text; input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the second input text according to the semantic vector, and obtain the attention weights of each character in the second input text; input the attention weights of each character in the second input text into the output layer of the machine learning model, so that the output layer outputs the result keyword corresponding to the cause keyword according to the attention weights of each character.

[0131] As another possible case, the causal keyword extraction device 300 may further include:

[0132] An acquisition module, which is used to acquire a predicted cause keyword obtained by the machine learning model for causal keyword extraction from the training sample, and a predicted result keyword corresponding to the predicted cause keyword.

[0133] A first determination module, which is used to determine the first loss information according to the difference between the predicted cause keyword and the standard cause keyword marked in the training sample.

[0134] A second determination module, configured to determine second loss information according to the difference between the predicted result keywords corresponding to the predicted cause keywords and the standard result keywords labeled in the training samples.

[0135] An adjustment module, configured to adjust the model parameters of the machine learning model according to the first loss information and the second loss information.

[0136] As another possible case, the acquisition module may also be used for:

[0137] If multiple predicted cause keywords are extracted from the training samples by using the machine learning model, randomly select one predicted cause keyword from the multiple predicted cause keywords.

[0138] As another possible case, the set cause text includes words or sentences representing cause semantics;

[0139] The set result text includes words or sentences representing result semantics.

[0140] As another possible case, the first splicing module 310 may also be used for:

[0141] Sequentially continue the characters of the original sentence after the last character in the set cause text to obtain the first input text.

[0142] As another possible case, the second splicing module 330 may also be used for:

[0143] Sequentially continue the characters of the set result text after the last character in the cause keyword to obtain an intermediate text; sequentially continue the characters of the original sentence after the last character in the intermediate text to obtain the second input text.

[0144] It should be noted that the foregoing explanation of the embodiments of the method for extracting causal keywords also applies to the device for extracting causal keywords in this embodiment, and will not be elaborated here.

[0145] The causal keyword extraction device according to the embodiment of the present application splices a set cause text and an original sentence for which causal keywords are to be extracted to generate a first input text, uses a trained machine learning model to extract keywords from the first input text, takes the keywords extracted by the machine learning model as cause keywords, splices the cause keywords, a set result text, and the original sentence to generate a second input text corresponding to the cause keywords, and uses the machine learning model to extract keywords from the second input text corresponding to the cause keywords, taking the keywords extracted by the machine learning model as result keywords corresponding to the cause keywords. Thus, the machine learning model is used to automatically extract cause keywords and corresponding result keywords in the text, which not only reduces manual consumption but also improves the generalization ability.

[0146] To implement the above embodiment, the present application also proposes a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the causal keyword extraction method described in the above embodiment is implemented.

[0147] To implement the above embodiment, the present application also proposes a non-transitory computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the causal keyword extraction method described in the above embodiment is implemented.

[0148] To implement the above embodiment, the present application also proposes a computer program product. When the instructions in the computer program product are executed by a processor, the causal keyword extraction method described in the above embodiment is executed.

[0149] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples.

[0150] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the technical features indicated. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0151] Any process or method description represented in a flowchart or described otherwise herein may be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a customized logical function or process. The scope of the preferred embodiments of this application includes additional implementations, where functions may be executed in a manner substantially simultaneous with or in a reverse order according to the involved functions, rather than in the order shown or discussed, which should be understood by those skilled in the technical field to which the embodiments of this application pertain.

[0152] Logic and / or steps represented in a flowchart or described otherwise herein, for example, may be considered as an ordered list of executable instructions for implementing a logical function, and may be specifically implemented in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device. For the purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium may even be paper or other suitable media on which the program can be printed, as the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other appropriate processing as necessary, and then stored in a computer memory.

[0153] It should be understood that each part of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one of the following techniques known in the art or a combination thereof can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application specific integrated circuits with appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0154] Those of ordinary skill in the art can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0155] In addition, in each embodiment of the present application, each functional unit can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. When the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0156] The storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.

Claims

1. A method for extracting causal keywords, characterized in that, Including the following steps: Concatenate the set reason text and the original sentence for which causal keywords are to be extracted to generate a first input text, where the set reason text includes words or sentences representing the semantic meaning of the reason; Use a trained machine learning model to extract keywords from the first input text, and use the keywords extracted by the machine learning model as the reason keywords; Concatenate the reason keywords, the set result text, and the original sentence to generate a second input text corresponding to the reason keywords, where the set result text includes words or sentences representing the semantic meaning of the result; Use the machine learning model to extract keywords from the second input text corresponding to the reason keywords, and use the keywords extracted by the machine learning model as the result keywords corresponding to the reason keywords.

2. The extraction method according to claim 1, characterized in that The using a trained machine learning model to extract keywords from the first input text and using the keywords extracted by the machine learning model as the reason keywords includes: Input the first input text into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the first input text output by the feature extraction layer; Input the word vectors of each character in the first input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the first input text; Input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the first input text based on the semantic vector, and obtain the attention weights of each character; Input the attention weights of each character into the output layer of the machine learning model, so that the output layer outputs the reason keywords according to the attention weights of each character.

3. The extraction method according to claim 1, wherein The using the machine learning model to extract keywords from the second input text corresponding to the reason keywords and using the keywords extracted by the machine learning model as the result keywords corresponding to the reason keywords includes: Input the second input text corresponding to the reason keywords into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the second input text output by the feature extraction layer; Input the word vectors of each character in the second input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the second input text; Input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the second input text based on the semantic vector, and obtain the attention weights of each character in the second input text; Input the attention weights of each character in the second input text into the output layer of the machine learning model, so that the output layer outputs the result keywords corresponding to the reason keywords according to the attention weights of each character.

4. The extraction method according to any one of claims 1-3, characterized in that, The method further includes: Obtain a predicted reason keyword obtained by the machine learning model through causal keyword extraction for the training sample, and the predicted result keyword corresponding to the predicted reason keyword; Determine the first loss information according to the difference between the predicted cause keyword and the standard cause keyword annotated in the training sample; Determine the second loss information according to the difference between the predicted result keyword corresponding to the predicted cause keyword and the standard result keyword annotated in the training sample; Adjust the model parameters of the machine learning model according to the first loss information and the second loss information.

5. The extraction method according to claim 4, wherein The obtaining of a predicted cause keyword obtained by the machine learning model through causal keyword extraction from the training sample includes: If there are multiple predicted cause keywords extracted by using the machine learning model from the training sample, randomly extract the one predicted cause keyword from the multiple predicted cause keywords.

6. The extraction method according to any one of claims 1-3, characterized in that The splicing of the set cause text and the original sentence from which the causal keyword is to be extracted to generate the first input text includes: Sequentially connect the characters of the original sentence after the last character in the set cause text to obtain the first input text.

7. The extraction method according to any one of claims 1-3, characterized in that, The splicing of the cause keyword, the set result text and the original sentence to generate the second input text corresponding to the cause keyword includes: Sequentially connect the characters of the set result text after the last character in the cause keyword to obtain an intermediate text; Sequentially connect the characters of the original sentence after the last character in the intermediate text to obtain the second input text.

8. An extraction device for causal keywords, characterized in that, Includes: A first splicing module for splicing the set cause text and the original sentence from which the causal keyword is to be extracted to generate the first input text, where the set cause text includes words or sentences representing the cause semantics; A first extraction module for performing keyword extraction on the first input text by using a trained machine learning model, and using the keyword extracted by the machine learning model as the cause keyword; A second splicing module for splicing the cause keyword, the set result text and the original sentence to generate the second input text corresponding to the cause keyword, where the set result text includes words or sentences representing the result semantics; A second extraction module for performing keyword extraction on the second input text corresponding to the cause keyword by using the machine learning model, and using the keyword extracted by the machine learning model as the result keyword corresponding to the cause keyword.

9. The extraction device according to claim 8, characterized in that, The first extraction module is further configured to: Input the first input text into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the first input text output by the feature extraction layer; Input the word vectors of each character in the first input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the first input text; Input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the first input text according to the semantic vector, and obtain the attention weights of each character; Input the attention weights of each character into the output layer of the machine learning model, so that the output layer outputs the cause keyword according to the attention weights of each character.

10. The extraction device according to claim 8, wherein, The second extraction module is further configured to: Input the second input text corresponding to the cause keyword into the feature extraction layer of the machine learning model to obtain the word vectors of each character in the second input text output by the feature extraction layer; Input the word vectors of each character in the second input text into the graph convolutional neural network layer of the machine learning model to obtain the semantic vector of the second input text; Input the semantic vector into the attention layer of the machine learning model to predict the attention weights of each character in the second input text according to the semantic vector, and obtain the attention weights of each character in the second input text; Input the attention weights of each character in the second input text into the output layer of the machine learning model, so that the output layer outputs the result keyword corresponding to the cause keyword according to the attention weights of each character.

11. The extraction device according to any one of claims 8-10, characterized in that, The device further includes: An acquisition module, configured to acquire a predicted cause keyword obtained by the machine learning model for causal keyword extraction from a training sample, and a predicted result keyword corresponding to the predicted cause keyword; A first determination module, configured to determine first loss information according to the difference between the predicted cause keyword and the standard cause keyword labeled in the training sample; A second determination module, configured to determine second loss information according to the difference between the predicted result keyword corresponding to the predicted cause keyword and the standard result keyword labeled in the training sample; An adjustment module, configured to adjust the model parameters of the machine learning model according to the first loss information and the second loss information.

12. The extraction device according to claim 11, wherein The acquisition module is further configured to: If there are multiple predicted cause keywords extracted from the training sample by using the machine learning model, randomly select the one predicted cause keyword from the multiple predicted cause keywords.

13. The extraction device according to any one of claims 8-10, characterized in that, The first splicing module is further configured to: Sequentially continue the characters of the original sentence after the last character in the set cause text to obtain the first input text.

14. The extraction device according to any one of claims 8-10, characterized in that, The second splicing module is further configured to: Sequentially continue the characters of the set result text after the last character in the cause keyword to obtain an intermediate text; Sequentially continue the characters of the original sentence after the last character in the intermediate text to obtain the second input text.

15. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the causal keyword extraction method according to any one of claims 1-7.

16. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the causal keyword extraction method according to any one of claims 1-7.

17. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor, it executes the causal keyword extraction method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Text Information Extraction Methods and Systems

    CN102298642A

  • Emotion reason mining method based on dependency syntax and generalized causal network

    CN110781369A