A method, system and computer-readable storage medium for extracting causal relationship groups based on massive data
By using massive data and the BERT+CRF model to annotate events and causal relationships, form triples and perform clustering and reduction processing, the problem of insufficient accuracy and redundancy in causal relationship extraction is solved and achieved Extracting causal event groups with high accuracy and low redundancy.
Patent Information
- Application Number
- CN202210103217.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-27
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-01-27
AI Technical Summary
The existing technology lacks the accuracy optimization of causal relationships in causal event extraction, cannot effectively discover hidden causal relationships, and has problems with redundant and noisy data.
Using a method based on massive data, we obtain network text and store it by time period, perform uniform sampling and pre-annotation, use the BERT+CRF model to annotate events and causal relationships, form triples and perform quantitative coding, and use cosine distance clustering , combined with the Mini Batch K-means algorithm to extract and reduce causality groups.
It improves the accuracy of causality extraction, reduces noise and redundant data, enhances the reliability and time characteristics of the extraction results, and ensures high reliability and low redundancy of the extraction results.
Smart Images

Figure CN114676840B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of cause-and-effect graphs in artificial intelligence natural language processing, and more specifically, to a method, system and computer-readable storage medium for extracting causal cause-and-effect groups based on massive data. Background Art
[0002] Traditional causal reasoning extraction schemes usually focus on extracting events containing causal relationships, but do not pay much attention to optimizing the accuracy and redundancy of the extracted causal relationships. Existing rule-based or statistical methods usually need to discover causal relationships based on causal relationship words and cannot well discover hidden causal relationships. The cascaded conditional random field-based method cannot discover most implicit causal relationships that require certain reasoning because it does not use prior knowledge. The deep learning-based method adopted in this scheme uses the language model BERT pre-trained on a large-scale corpus, so it can, to a certain extent, mine causal relationships from semantic and contextual reasoning.
[0003] The prior art discloses a method, device, computer equipment and storage medium for constructing a causal reasoning graph, including: obtaining a target text pre-stored in a database; parsing the target text to obtain a short-term event text set and a long-term event text set; determining the event relationship between the short-term event text set and the long-term event text set to obtain an initial causal event pair; preprocessing the initial causal event pair to obtain a target causal event pair; and constructing a causal reasoning graph based on the target causal event pair. The prior art does not specifically optimize and improve the accuracy and redundancy of causal relationships. The present application is based on a premise: there are many different expressions of the same or very similar causal reasons in the text obtained in the same time period. Combining the advantages of massive data and the causal reasoning selection and reduction method proposed in this scheme, the causal reasons within the time period can be extracted more accurately, and these extracted causal reasons are supported by more samples, so the extraction results are more reliable and less redundant, and also have certain time characteristics. Summary of the invention
[0004] In order to overcome the defect of the above-mentioned prior art in extracting causal relationships that there is a lack of optimization of the accuracy of causal relationships, the present invention provides a method, system and computer-readable storage medium for extracting causal relationship groups based on massive data.
[0005] The primary purpose of the present invention is to solve the above technical problems. The technical solution of the present invention is as follows:
[0006] The first aspect of the present invention provides a method for extracting causal event groups based on massive data, comprising the following steps:
[0007] S1: Obtain online text and store it by time period;
[0008] S2: uniformly sample the acquired network texts to obtain a sample set and pre-label the sample set;
[0009] S3: Define events and causal relationships, and annotate the pre-annotated text set with events and causal relationships in BIO format;
[0010] S4: Use the data annotated in step S3 to train the BERT+CRF model and obtain a trained BERT+CRF model;
[0011] S5: Use the trained BERT+CRF model to extract causal information from the stored network text and form triples in a preset format;
[0012] S6: Quantize and encode the cause and effect events in the obtained triples to obtain the semantic vector of the cause and effect event, use the semantic vector to calculate the cosine distance between the triples, and cluster the triples using the cosine distance as an indicator through a clustering algorithm to obtain a cause and effect event group;
[0013] S7: Select and reduce the obtained causal event groups, and save the reduced causal event groups.
[0014] Furthermore, the sample set is pre-labeled, that is, each sample is labeled whether it contains a causal relationship by using keywords and regular matching.
[0015] Furthermore, the event annotation and causal relationship annotation in BIO format are performed on the pre-annotated text set, that is, the events are annotated in a phrase manner, and the phrases include: subject-predicate phrases, verb-object phrases, and subject-predicate-object phrases.
[0016] Furthermore, multi-task training is used when training the BERT+CRF model, and the multi-tasks include: identifying all events in the sample and identifying causal relationships in the sample.
[0017] Furthermore, the format of the triple in the preset format is: ("cause" event, causality coefficient, "effect" event), where the causality coefficient is a probability value between 0 and 1, indicating the strength of the causal relationship between the "cause" event and the "effect" event.
[0018] The causal events and effect events in the obtained triples are further quantified and encoded to obtain the semantic vector of the causal event. The cosine distance between the triples is calculated using the semantic vector. The cosine distance is used as an indicator to cluster the triples through the clustering algorithm to obtain the causal event group. The specific steps are as follows:
[0019] S601: quantizing and encoding the cause event and the effect event in the obtained triple to obtain a semantic vector of the cause-effect event;
[0020] S602: Calculate the cosine similarity of the triple semantic vectors in the same time period using the cosine similarity formula, and calculate the cosine distance using the cosine similarity;
[0021] S603: Clustering the triples using a clustering algorithm with cosine distance as a metric to obtain causal reasoning groups.
[0022] Furthermore, the clustering algorithm is a Mini Batch K-means algorithm.
[0023] Furthermore, the obtained causal reasoning groups are selected and reduced, and the specific process of preserving the reduced causal reasoning groups is as follows:
[0024] S701: Determine the number of triples in the causal relationship group, and if the number of triples is less than a preset value or only one triple is included, discard the current causal relationship group;
[0025] S702: If the number of triplets is greater than or equal to a preset value, the triplet with the largest causal coefficient in the causal group is taken to represent the current causal group, and the causal coefficient of the triplet is updated to the average of the causal coefficients in the current causal group, and the obtained causal group is saved.
[0026] A second aspect of the present invention provides a causal reasoning group extraction system based on massive data, the system comprising: a memory and a processor, the memory comprising a causal reasoning group extraction method program based on massive data, the causal reasoning group extraction method program based on massive data, when executed by the processor, implements the steps of the causal reasoning group extraction method based on massive data.
[0027] The third aspect of the present invention provides a computer-readable storage medium, which includes a causal graph extraction method program based on massive data. When the causal graph extraction method program based on massive data is executed by a processor, the steps of the causal group extraction method based on massive data are implemented.
[0028] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0029] The present invention first annotates the data twice, and then uses the annotated data to extract events, identify causal relationships, and judge similar causal relationships through the BERT+CRF model. It incorporates the model's prior knowledge and a certain degree of semantic understanding. Compared with the existing causal relationship extraction, it improves the accuracy of causal relationship extraction, reduces noise data, redundant data, and isolated data in the extraction results, and has higher reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 The present invention is a flowchart of a method for extracting causal event groups based on massive data according to an embodiment of the present invention.
[0031] Figure 2 The flowchart of an embodiment of the present invention is to process triples to obtain causal event groups.
[0032] Figure 3 The present invention is a flowchart of processing a causal event group according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0034] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0035] Example 1
[0036] like Figure 1 As shown, the first aspect of the present invention provides a method for extracting causal event groups based on massive data, comprising the following steps:
[0037] S1: Obtain online text and store it by time period;
[0038] It should be noted that the network text obtained in the embodiments of the present application is public content on the Internet. In the specific implementation process, it can be collected in multiple periods and distributedly stored according to different time periods, for example, it can be stored in the Hadoop distributed storage system HDFS.
[0039] S2: uniformly sample the acquired network texts to obtain a sample set and pre-label the sample set;
[0040] The obtained Internet samples are uniformly sampled to obtain a sample set. It should be noted that the number of samples in the sample set should not be too small. In the specific implementation, the number of samples can be about 10,000. Then the sample set is pre-labeled, which is to use keywords and regular matching to make the first labeling of whether each sample contains a causal relationship. For example, regular matching causal relationship words: "because", "so", "due to", "cause", "cause", etc.
[0041] S3: Define events and causal relationships, and annotate the pre-annotated text set with events and causal relationships in BIO format;
[0042] After pre-marking, the present invention continues to define events and causal relationships, that is, the pre-marked text set is marked with events and causal relationships in BIO format; the present invention uses phrases to mark events, mainly using subject-predicate phrases, verb-object phrases, and subject-predicate-object phrases, such as the phrases "cold wave is coming" and "down jacket sales are rising", so that the events marked in this way have relatively complete semantics and are also relatively concise.
[0043] S4: Use the data annotated in step S3 to train the BERT+CRF model and obtain a trained BERT+CRF model;
[0044] The present invention adopts the existing BERT+CRF model and trains the model using the data annotated in step S3, wherein the training process is multi-task training, wherein task one is to identify all events in the sample, and task two is to identify the causal relationship of events in the sample. It should be noted that during the training of the model, the loss value of the model can be monitored to determine whether the training is stopped. If the loss value does not decrease after one epoch of training, the training is stopped, which can effectively prevent the model from overfitting.
[0045] S5: Use the trained BERT+CRF model to extract causal information from the stored network text and form triples in a preset format;
[0046] The BERT+CRF model obtained through the above training is used to extract causal relationships from the stored network text and combine them into triplets. The format of the triplets is: ("cause" event, causal relationship coefficient, "effect" event), where the causal relationship coefficient is a probability value between 0 and 1, indicating the strength of the causal relationship between the "cause" event and the "effect" event. In a specific embodiment, only triplets with a causal relationship coefficient greater than 0.5 are retained.
[0047] S6: Quantize and encode the cause and effect events in the obtained triples to obtain the semantic vector of the cause and effect event, use the semantic vector to calculate the cosine distance between the triples, and cluster the triples using the cosine distance as an indicator through a clustering algorithm to obtain a cause and effect event group;
[0048] like Figure 2 As shown, the specific process of step S6 in the present invention is:
[0049] S601: quantizing and encoding the cause event and the effect event in the obtained triple to obtain a semantic vector of the cause-effect event;
[0050] S602: Calculate the cosine similarity of the triple semantic vectors in the same time period using the cosine similarity formula, and calculate the cosine distance using the cosine similarity; wherein the cosine distance = 1 - cosine similarity, and the cosine similarity is obtained using the existing cosine similarity calculation formula.
[0051] S603: Clustering the triples using a clustering algorithm with cosine distance as a metric to obtain causal reasoning groups.
[0052] Furthermore, the clustering algorithm is the Mini Batch K-means algorithm. It should be noted that when the Mini Batch K-means algorithm is used for triple clustering, an algorithm such as kmeans++ can be used to optimize the initial cluster center.
[0053] S7: Select and reduce the obtained causal event groups, and save the reduced causal event groups.
[0054] like Figure 3 As shown, the specific process of step S7 in the present invention is:
[0055] S701: Determine the number of triples in the causal relationship group, and if the number of triples is less than a preset value or only one triple is included, discard the current causal relationship group;
[0056] S702: If the number of triplets is greater than or equal to a preset value, the triplet with the largest causal coefficient in the causal group is taken to represent the current causal group, and the causal coefficient of the triplet is updated to the average of the causal coefficients in the current causal group, and the obtained causal group is saved.
[0057] It should be noted that, in a specific implementation process, the preset value may be set to u-nσ, where u represents the mean of the number of triplets, n is a positive integer, and σ is the standard deviation of the number of triplets.
[0058] Example 2
[0059] A second aspect of the present invention provides a system for extracting causal reasoning groups based on massive data, the system comprising: a memory and a processor, the memory comprising a causal reasoning group extraction method program based on massive data, the causal reasoning group extraction method program based on massive data when executed by the processor implements the following steps:
[0060] S1: Obtain online text and store it by time period;
[0061] It should be noted that the network text obtained in the embodiments of the present application is public content on the Internet. In the specific implementation process, it can be collected in multiple periods and distributedly stored according to different time periods, for example, it can be stored in the Hadoop distributed storage system HDFS.
[0062] S2: uniformly sample the acquired network texts to obtain a sample set and pre-label the sample set;
[0063] The obtained Internet samples are uniformly sampled to obtain a sample set. It should be noted that the number of samples in the sample set should not be too small. In the specific implementation, the number of samples can be about 10,000. Then the sample set is pre-labeled, which is to use keywords and regular matching to make the first labeling of whether each sample contains a causal relationship. For example, regular matching causal relationship words: "because", "so", "due to", "cause", "cause", etc.
[0064] S3: Define events and causal relationships, and annotate the pre-annotated text set with events and causal relationships in BIO format;
[0065] After pre-marking, the present invention continues to define events and causal relationships, that is, the pre-marked text set is marked with events and causal relationships in BIO format; the present invention uses phrases to mark events, mainly using subject-predicate phrases, verb-object phrases, and subject-predicate-object phrases, such as the phrases "cold wave is coming" and "down jacket sales are rising", so that the events marked in this way have relatively complete semantics and are also relatively concise.
[0066] S4: Use the data annotated in step S3 to train the BERT+CRF model and obtain a trained BERT+CRF model;
[0067] The present invention adopts the existing BERT+CRF model and uses the data annotated in step S3 to train the model, wherein the training process is multi-task training, wherein task one is to identify all events in the sample, and task two is to identify the causal relationship of events in the sample.
[0068] It should be noted that during the model training process, you can determine whether to stop training by monitoring the model's loss value. If the loss value does not decrease after one epoch of training, stop training. This can effectively prevent the model from overfitting.
[0069] S5: Use the trained BERT+CRF model to extract causal information from the stored network text and form triples in a preset format;
[0070] The BERT+CRF model obtained through the above training is used to extract causal relationships from the stored network text and combine them into triplets. The format of the triplets is: ("cause" event, causal relationship coefficient, "effect" event), where the causal relationship coefficient is a probability value between 0 and 1, indicating the strength of the causal relationship between the "cause" event and the "effect" event. In a specific embodiment, only triplets with a causal relationship coefficient greater than 0.5 are retained.
[0071] S6: Quantize and encode the cause and effect events in the obtained triples to obtain the semantic vector of the cause and effect event, use the semantic vector to calculate the cosine distance between the triples, and cluster the triples using the cosine distance as an indicator through a clustering algorithm to obtain a cause and effect event group;
[0072] The specific process of step S6 in the present invention is:
[0073] S601: quantizing and encoding the cause event and the effect event in the obtained triple to obtain a semantic vector of the cause-effect event;
[0074] S602: Calculate the cosine similarity of the triple semantic vectors in the same time period using the cosine similarity formula, and calculate the cosine distance using the cosine similarity; wherein the cosine distance = 1 - cosine similarity, and the cosine similarity is obtained using the existing cosine similarity calculation formula.
[0075] S603: Clustering the triples using a clustering algorithm with cosine distance as a metric to obtain causal reasoning groups.
[0076] Furthermore, the clustering algorithm is the Mini Batch K-means algorithm. It should be noted that when the Mini Batch K-means algorithm is used for triple clustering, an algorithm such as kmeans++ can be used to optimize the initial cluster center.
[0077] S7: Select and reduce the obtained causal event groups, and save the reduced causal event groups.
[0078] The specific process of step S7 in the present invention is:
[0079] S701: Determine the number of triples in the causal relationship group, and if the number of triples is less than a preset value or only one triple is included, discard the current causal relationship group;
[0080] S702: If the number of triplets is greater than or equal to a preset value, the triplet with the largest causal coefficient in the causal group is taken to represent the current causal group, and the causal coefficient of the triplet is updated to the average of the causal coefficients in the current causal group, and the obtained causal group is saved.
[0081] It should be noted that, in a specific implementation process, the preset value may be set to u-nσ, where u represents the mean of the number of triplets, n is a positive integer, and σ is the standard deviation of the number of triplets.
[0082] The third aspect of the present invention provides a computer-readable storage medium, which includes a causal reasoning group extraction method program based on massive data. When the causal reasoning group extraction method program based on massive data is executed by a processor, the steps of the causal reasoning group extraction method based on massive data are implemented.
[0083] Example 3
[0084] This embodiment illustrates the method of the present invention by processing specific triples. For example, in a specific embodiment, the BERT+CRF model is used to extract causal relationships from network text to obtain the following triples:
[0085] [("The temperature dropped by 5 degrees today", 0.55,"It will rain tomorrow"),("Cold wave is coming", 0.9,"Down jacket sales are rising"),("Wire short circuit", 0.7,"Fire breaks out"),("Double Eleven is coming", 0.65,"Down jackets are out of stock at the manufacturer"),("Cable short circuit", 0.55,"Causes fire"),("Cold air is moving south", 0.85,"Down jackets are selling well"),("Temperature drops sharply", 0.55,"Down jackets are in short supply"),("Lines are aging", 0.9,"Fire hazard"),("Down jackets are in short supply", 0.55,"Temperature drops sharply")]
[0086] Calculate the semantic vector of the above triples, use the semantic vector to calculate the cosine distance, use the cosine distance (cosine distance = 1-cosine similarity) as a metric to cluster the triples through the Mini Batch K-means algorithm (kmeans++ and other algorithms can be used to optimize the initial clustering center during clustering) to form causal groups as follows:
[0087] Group A: [("Cold wave is coming", 0.9,"Down jacket sales are rising"), ("Double 11 is coming", 0.65,"Down jackets are out of stock at manufacturers"), ("Cold air is moving south", 0.85,"Down jackets are selling well"), ("Temperature drops sharply", 0.55,"Down jackets are in short supply"), ("Down jackets are in short supply", 0.55,"Temperature drops sharply")]
[0088] Group B: [("Wire short circuit", 0.7,"Fire"), ("Line aging", 0.9,"Fire hazard"), ("Cable short circuit", 0.55,"Cause fire")]
[0089] Group C: [("The temperature dropped by 5 degrees today", 0.55,"It will rain tomorrow")]
[0090] In the specific selection process, for group C, because there is only one triple in the group and the number of samples supporting the causal event is too small, it is directly discarded. This can filter out more isolated events, so that the final causal events have more sample support. After abandoning group C, groups A and B are reduced. For group A, there are more similar causal triplets in the group. The triplet with the largest causal coefficient is extracted to represent the causal event after reduction of group A. The mean of the causal coefficient in the group is taken as the reduced causal coefficient. It can be seen that a large number of causal triplets with the same meaning are obviously eliminated, and triplets with inverted causality are eliminated to a certain extent (generally speaking, the causal coefficient of the correct causal event predicted by the model should be greater than the causal coefficient of the inverted causal event); for group B, the reduced result is relatively more accurate, and redundancy is removed, and finally the reduced causal event group is preserved. Through experiments, it was found that the accuracy of the causal relationship groups finally saved was above 90%, and the ratio of repeated causal relationship groups (here, the cosine distance less than 0.25 is considered repeated) was less than 5%, which effectively verified the feasibility and effectiveness of this scheme.
[0091] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for extracting causal event groups based on massive data, characterized in that: The following steps are involved: S1: Obtain online text and store it according to time periods; S2: uniformly sample the acquired network texts to obtain a sample set and pre-label the sample set; The sample set is pre-labeled, i.e., each sample is labeled whether it contains a causal relationship by using keywords and regular matching; S3: Perform event annotation and causal relationship annotation in BIO format on the pre-annotated text set; S4: Use the data annotated in step S3 to train the BERT+CRF model and obtain a trained BERT+CRF model; S5: Use the trained BERT+CRF model to extract causal information from the stored network text and form triples in a preset format; The format of the triplet in the preset format is: ("cause" event, causal relationship coefficient, "effect" event), where the causal relationship coefficient is a probability value between 0 and 1, indicating the strength of the causal relationship between the "cause" event and the "effect" event; S6: Quantize and encode the cause and effect events in the obtained triples to obtain the semantic vector of the cause and effect event, use the semantic vector to calculate the cosine distance between the triples, and cluster the triples using the cosine distance as an indicator through a clustering algorithm to obtain a cause and effect event group; S7: selecting and reducing the obtained causal reasoning groups, and saving the reduced causal reasoning groups; The obtained causal reasoning group is selected and reduced, and the specific process of saving the reduced causal reasoning group is as follows: S701: Determine the number of triples in the causal relationship group, and if the number of triples is less than a preset value or only one triple is included, discard the current causal relationship group; S702: If the number of triplets is greater than or equal to a preset value, the triplet with the largest causal coefficient in the causal group is taken to represent the current causal group, and the causal coefficient of the triplet is updated to the average of the causal coefficients in the current causal group, and the obtained causal group is saved.
2. A method for extracting causal event groups based on massive data according to claim 1, characterized in that: The event annotation and causal relationship annotation in BIO format for the pre-annotated text set is to use phrases to annotate events, and the phrases include: subject-predicate phrases, verb-object phrases, and subject-predicate-object phrases.
3. The method for extracting causal event groups based on massive data according to claim 1 is characterized in that: Multi-task training is used when training the BERT+CRF model, and the multi-task includes: identifying all events in the sample and identifying causal relationships in the sample.
4. The method for extracting causal event groups based on massive data according to claim 1 is characterized in that: The causal events and effect events in the obtained triples are quantized and encoded to obtain the semantic vector of the causal event. The cosine distance between the triplets is calculated using the semantic vector. The triplets are clustered using the cosine distance as an indicator through a clustering algorithm to obtain the causal event group. The specific steps are as follows: S601: quantizing and encoding the cause event and the effect event in the obtained triple to obtain a semantic vector of the cause-effect event; S602: Calculate the cosine similarity of the triple semantic vectors in the same time period using the cosine similarity formula, and calculate the cosine distance using the cosine similarity; S603: Clustering the triples using a clustering algorithm with cosine distance as a metric to obtain causal reasoning groups.
5. A method for extracting causal event groups based on massive data according to claim 4, characterized in that: The clustering algorithm is the Mini Batch K-means algorithm.
6. A causal event group extraction system based on massive data, characterized in that: The system includes: a memory and a processor, wherein the memory includes a causal event group extraction method program based on massive data, and when the causal event group extraction method program based on massive data is executed by the processor, the method steps described in any one of claims 1-5 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a causal reason group extraction method program based on massive data. When the causal reason graph extraction method program based on massive data is executed by a processor, the steps of a causal reason group extraction method based on massive data as described in any one of claims 1 to 5 are implemented.
