Data intelligent analysis method and system combining knowledge graph and rule constraints
By combining knowledge graphs and rule constraints, the technical lack of multimodal data analysis in government affairs processing technology is solved, the accurate identification and extraction of key entities and relationships of government affairs texts is achieved, and a knowledge graph with rich semantic information is constructed , improves the accuracy and consistency of knowledge representation, discovers implicit inter-entities relationships, and expands the government analysis vision.
Patent Information
- Application Number
- CN202411082733.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-08
AI Technical Summary
In the multimodal government big data analysis, existing government affairs processing technologies have technical shortcomings in entity extraction, relationship extraction, knowledge embedding, knowledge integration, etc., and it is difficult to effectively process and utilize complex government affairs data.
Using a data intelligent analysis method combining knowledge graph and rule constraints, entities are identified through BERT model, entity relationships are extracted by BiLSTM-CRF model, TransE model is used to embed knowledge graphs, and Markov logical network fusion rule constraints are used to map mining and Inference techniques mine potential relationships between entities.
It realizes the accurate identification and extraction of key entities and relationships in government affairs texts, builds a knowledge graph with rich semantic information, improves the accuracy and consistency of knowledge representation, discovers implicit inter-entities relationships, and expands government affairs. Workers’ analytical vision.
Smart Images

Figure CN118606440B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of government affairs processing technology, and specifically to a data intelligent analysis method and system that combines knowledge graphs with rule constraints. Background Art
[0002] With the continuous advancement of government informationization, government data presents the characteristics of multi-source heterogeneity, large data volume, and complex semantics. Traditional structured data analysis methods are difficult to effectively process and utilize. As a structured knowledge representation and reasoning method, knowledge graph technology can organize complex government data into a concise entity-relationship network and discover implicit association patterns through graph reasoning. It has been applied in smart cities, decision support and other fields.
[0003] In terms of knowledge graph construction, mainstream methods include rule-based, probability-statistics-based, and deep learning-based methods. Rule-based methods use predefined templates and rules to extract entities and their relationships from text, such as regular expression matching, syntactic dependency analysis, etc.; probability-statistics-based methods use joint probability models to characterize the co-occurrence patterns of entities and their relationships, such as conditional random fields, topic models, etc.; deep learning-based methods use neural networks to automatically learn text features and complete entity recognition and relationship extraction tasks end-to-end, such as convolutional neural networks CNN, long short-term memory networks LSTM, etc. In recent years, pre-trained language models such as BERT have achieved remarkable results in multiple NLP tasks, bringing new breakthroughs to knowledge extraction tasks.
[0004] Existing government processing technologies have major technical deficiencies in terms of entity extraction, relationship extraction, knowledge embedding, knowledge fusion, and knowledge reasoning in response to many technical challenges faced by multimodal government big data analysis.
[0005] In view of this, the present invention proposes a data intelligent analysis method and system that combines knowledge graphs with rule constraints. Summary of the invention
[0006] To achieve the above purpose, the present invention provides the following technical solution: a data intelligent analysis method combining knowledge graph and rule constraints, comprising:
[0007] Collect multimodal data, including text, images and audio, perform the same structured processing on the multimodal data, and obtain the text in the multimodal data;
[0008] Using text as the data source, the BERT model is used to identify entities, and the BiLSTM-CRF model, a relationship extraction technology, is constructed to extract entity relationships in the text;
[0009] Based on the entities and entity relationships identified and extracted in the text, the TransE model is used to embed the knowledge graph, map the entities and entity relationships into the vector space, and construct the knowledge graph;
[0010] Define rule constraints, convert them into first-order logic expressions, build a Markov logic network, and fuse the knowledge graph and rule constraints in the vector space based on the Markov logic network;
[0011] Based on the fused knowledge graph, graph mining and reasoning techniques are used to mine the potential relationships between entities and analyze the mined entity relationships.
[0012] Preferably, the multimodal data collected includes text, images and audio, and the multimodal data is subjected to the same structured processing, and the text in the multimodal data is obtained, including: obtaining the multimodal data, cleaning the obtained multimodal data, removing HTML tags, special characters and repeated content, and extracting the text content in the multimodal data; converting the cleaned data into a unified format to obtain the text to be recognized.
[0013] Preferably, the method of using text as a data source, using a BERT model to identify entities, and constructing a BiLSTM-CRF model using a relationship extraction technology to extract entity relationships in the text includes: using entity recognition technology to identify entities in various types of text data, and using a deep learning method of a BERT model to perform NER named entity recognition;
[0014] After identifying entities in the text, generate a text sequence with the entities highlighted ,in represents the nth entity, represents the cth text word;
[0015] The relationship between entities in the text is extracted through the BiLSTM-CRF model, which is a bidirectional long short-term memory network BiLSTM model combined with the conditional random field CRF model for relationship extraction;
[0016] Use the BiLSTM layer to encode the text sequence to obtain the entity hidden state sequence , represents the hidden state vector of the cth text word, Represents the hidden state vector of the nth entity, the BiLSTM model includes a forward LSTM model and the reverse LSTM model ,in:
[0017] ;
[0018] ;
[0019] ;
[0020] Among them, k is the hidden state dimension of the LSTM model; the output of the BiLSTM layer is used as the input of the fully connected layer, which is used to convert the output of the BiLSTM into a specific number of categories, corresponding to the type of relationship between entities: ,in and b are the weight matrix and bias vector of the fully connected layer, yes The output vector of represents the score of each entity relationship type, represents the vector representation of the nth entity, R represents the total number of entity relationship types, Indicates the hidden state at the previous moment, Represents the hidden state at the next moment.
[0021] Preferably, the CRF model is used to capture the dependencies between the output entity relationship labels, ensure that the output label sequence conforms to the legal mode, the CRF layer calculates the score of the entire label sequence, and finds the optimal entity relationship label sequence through a dynamic programming algorithm;
[0022] The formula for calculating the entity relationship label sequence score is:
[0023] ;
[0024] Among them, y is the entity relationship label sequence, It is The score of the corresponding label of each entity, A is the state transfer matrix, Indicates Entity and entities; n is the total number of entities; i≤n;
[0025] Construct entity relationship label probability function:
[0026] ;
[0027] The probability function of entity relationship labels is constructed according to the entity relationship label sequence score to determine the specific relationship labels between entities. is the predicted entity relationship label, is the sequence of all relation labels, It represents the score of outputting label sequence y' given input sequence x.
[0028] Preferably, based on the entities and entity relationships identified and extracted from the text, the TransE model is used to embed the knowledge graph, map the entities and entity relationships into the vector space, and construct the knowledge graph, including:
[0029] Construct triples of entities identified in the text and extracted entity relations ,in is the head entity, For entity relationships, is the tail entity; through the TransE model, entities and entity relationships are mapped to the same vector space, entities are represented by low-dimensional real-valued vectors, and entity relationships are represented by translation vectors;
[0030] The TransE model training process is as follows: for each triple , the TransE model learns the embedding vectors of entities and entity relations so that ;
[0031] The energy function of the TransE model is defined as: ,in and Represents the vector norm. The L1 norm and L2 norm are used to calculate the distance between entity embedding vectors. The L1 norm represents the Manhattan distance and the L2 norm represents the Euclidean distance.
[0032] Generate negative sample triplets using negative sampling strategy ,in and Randomly replace with any entity; define the loss function of the TransE model as:
[0033] ;
[0034] in, is the set of positive sample triplets, is the set of negative sample triplets, is a hyperparameter that controls the interval between positive and negative samples;
[0035] Use the stochastic gradient descent (SGD) algorithm to minimize the TransE model loss function, update the embedding vectors of entities and entity relationships, and stop training when the loss function converges;
[0036] Use the trained TransE model to map the entities and entity relationships identified in the text into the vector space to build a knowledge graph , where E is the entity set, R represents the total number of entity relationship types, and entity nodes The feature vector of is the corresponding embedding vector , relationship edge The feature vector of is the corresponding embedding vector ; Use the TransE model to calculate the semantic similarity of entity nodes and relationship edge embedding vectors to construct the topological structure of the knowledge graph.
[0037] Preferably, the step of defining rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and the rule constraints in a vector space based on the Markov logic network includes:
[0038] Define constraint rules ,in Indicates rule constraints, each rule constraint It is composed of a plurality of first-order logic formulas, wherein the first-order logic formulas are used to express constraint conditions of entity types and relationships between entities;
[0039] Each constraint rule Transformed into a first-order logic formula , construct logical formulas using predicates, constants, variables, and logical connectives ,
[0040] ;
[0041] in, Represents a constant, Represents a variable, Represents predicates and logical connectives.
[0042] Preferably, the method of defining rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and the rule constraints in a vector space based on the Markov logic network also includes:
[0043] Construct a Markov logic network, define a Markov logic network ,in Represents the first-order logic formula of the mth Markov logic network, assigning a weight to each first-order logic formula , represents the confidence of the formula;
[0044] Based on the Markov logic network, the knowledge graph and rule constraints are integrated in the vector space; the first-order logic formula in the Markov logic network is applied to the knowledge graph embedding, and the satisfaction degree of each first-order logic formula on the knowledge graph is calculated;
[0045] For every first-order logic formula , use the embedding vector to calculate the satisfaction degree:
[0046] ;
[0047] in, And express the formula The weight vector of represents the concatenation of entity and relation embedding vectors, Represents the sigmoid activation function; is the transpose of the mth weight vector;
[0048] The TransE model embedding vector is used as the observed variable in the Markov logic network, the weight vector in the MLN is used as the parameter to be learned, and the knowledge graph and Markov logic network are embedded and fused.
[0049] Preferably, the method uses graph mining and reasoning technology based on the fused knowledge graph to mine potential relationships between entities and analyze the mined entity relationships, including:
[0050] Using the path information between entities in the knowledge graph, we can infer the potential relationship between entities. We define the path in the knowledge graph based on the Markov logic network. We use the depth-first search (DFS) algorithm to find the entity relationship path that conforms to the definition of the Markov logic network in the fused knowledge graph. We score the found path, evaluate the credibility and importance of the path through the score, and calculate the path score using the path length and entity relationship type:
[0051] set up represents a path of length N, where represents the nth entity, Represents the g-th entity relationship and defines the scoring function of the path:
[0052] ;
[0053] in, Representing entity relationships The weight of Indicates the path length, calculates the score for all found paths, and sets the path score threshold ,when When , the path is established, the entities on the path have entity logical relationships, and are output as language text according to the entities and entity relationships in the path; the entities and entity relationships mined from the text are inserted at the end of the original text according to the path scores for subsequent analysis of the text.
[0054] A data intelligent analysis system combining knowledge graph and rule constraints, which is used to implement the data intelligent analysis method combining knowledge graph and rule constraints, including: a data acquisition and processing module, an entity recognition module, a knowledge graph module, a rule constraint module, a fusion module, and a mining and analysis module;
[0055] The data acquisition and processing module is used to acquire multimodal data, including text, images and audio, perform uniform structured processing on the multimodal data, and obtain text in the multimodal data;
[0056] The entity recognition module uses text as a data source, adopts the BERT model to recognize entities, and constructs a BiLSTM-CRF model using relationship extraction technology to extract the relationship between entities;
[0057] The knowledge graph module uses the TransE model to embed the entities and entity relationships identified and extracted from the text, maps the entities and entity relationships into the vector space, and constructs the knowledge graph.
[0058] The rule constraint module defines rule constraints and converts rule constraints into first-order logic expressions;
[0059] The fusion module is used to construct a Markov logic network, and fuse the knowledge graph and rule constraints in the vector space based on the Markov logic network;
[0060] The mining and analysis module uses graph mining and reasoning technology based on the fused knowledge graph to mine potential relationships between entities and analyze the mined entity relationships.
[0061] An electronic device comprises: a processor and a memory, wherein the memory stores a computer program that can be called by the processor;
[0062] The processor executes the data intelligent analysis method combining the knowledge graph with rule constraints by calling the computer program stored in the memory.
[0063] A computer-readable storage medium includes: instructions stored therein, which, when executed on a computer, enable the computer to execute the data intelligent analysis method combining the knowledge graph with rule constraints.
[0064] Beneficial effects: The present invention can accurately identify key entities and relationships, use the advanced deep learning model BERT for named entity recognition, and efficiently and accurately extract key entities in government texts such as names of people, places, and institutions. By using sequence annotation models such as BiLSTM-CRF for relationship extraction, multiple semantic associations between entities can be discovered, and an entity relationship network can be constructed.
[0065] The present invention uses knowledge representation learning methods such as TransE to represent entity relationship networks as low-dimensional dense vectors to form a government knowledge graph. The entity nodes and relationship edges in the graph contain rich semantic information, reflecting the structural associations between government elements, and facilitating knowledge reasoning and intelligent search.
[0066] The present invention introduces rule constraints based on first-order logic and realizes the fusion of graph embedding and rule constraints through Markov logic network, which can improve the accuracy and consistency of knowledge representation; the addition of domain rules makes the graph more in line with common sense and the generated new knowledge is more credible.
[0067] The present invention performs reasoning and mining based on the fused knowledge graph, which can discover some implicit relationships between entities and supplement the existing government cognition; applying the new knowledge obtained by reasoning to the original government scenarios can expand the horizons of government workers and provide a new analytical perspective. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 A schematic diagram of the process flow of the data intelligent analysis method combining knowledge graph and rule constraints of the present invention;
[0069] Figure 2 It is a schematic diagram of the structure of the data intelligent analysis system combining the knowledge graph and rule constraints of the present invention;
[0070] Figure 3 It is a schematic diagram of the structure of an electronic device provided by the present invention;
[0071] Figure 4 It is a schematic diagram of the structure of the computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0072] In order to better understand the present application, a more detailed description will be made of various aspects of the present application with reference to the accompanying drawings. It should be understood that these detailed descriptions are only descriptions of exemplary embodiments of the present application, and are not intended to limit the scope of the present application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.
[0073] In the accompanying drawings, the size, dimensions and shapes of the elements have been slightly adjusted for ease of illustration. The drawings are for illustration only and are not strictly drawn to scale. As used herein, the terms "substantially", "approximately" and similar terms are used as terms of approximation, not as terms of degree, and are intended to illustrate the inherent deviations in measurements or calculations that will be recognized by those of ordinary skill in the art. In addition, in this application, the order in which the steps are described does not necessarily represent the order in which these processes occur in actual operation, unless otherwise specified or can be derived from the context.
[0074] It should also be understood that expressions such as "include", "including", "have", "contain" and / or "comprising" are open rather than closed expressions in this specification, which indicate the presence of the stated features, elements and / or components, but do not exclude the presence of one or more other features, elements, components and / or combinations thereof. In addition, when expressions such as "at least one of..." appear after a list of listed features, they modify the entire list of features rather than just the individual elements in the list. In addition, when describing embodiments of the present application, "may" is used to mean "one or more embodiments of the present application". And, the term "exemplary" is intended to refer to an example or illustration.
[0075] Unless otherwise defined, all words (including engineering terms and scientific and technological terms) used in this article have the same meaning as those commonly understood by ordinary technicians in the field to which this application belongs. It should also be understood that unless there is a clear explanation in this application, words defined in commonly used dictionaries should be interpreted as having the same meaning as their meaning in the context of the relevant technology, and should not be interpreted in an idealized or overly formal sense.
[0076] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0077] Example 1
[0078] This embodiment discloses a data intelligent analysis method that combines knowledge graphs with rule constraints, see Figure 1 The method includes: collecting multimodal government data, including but not limited to text, images and audio, performing the same structural processing on the multimodal government data, and obtaining government text in the government data.
[0079] Acquire multimodal government data from government websites, policy documents, government announcements, and public service information, wherein the government data includes policy documents, service guides, and news announcements; clean the acquired government data, remove HTML tags, special characters, and repeated content, and extract text content from the government data; convert the cleaned data into a unified format to obtain the government text to be identified.
[0080] The entities include government agency names, job titles, personal names, administrative region names, and policy and regulation names, and the entity relationships include entity subordination relationships and process relationships.
[0081] By defining the key entities and relationship types in the government field, we can clarify the construction goals of the knowledge graph and provide a clear direction for intelligent analysis.
[0082] Taking government text as the data source, the BERT model is adopted to identify entities, and the relationship extraction technology BiLSTM-CRF model is constructed to extract the relationship between government entities.
[0083] Use entity recognition technology to identify entities in various government-related text data, and use the deep learning method of the BERT model to perform NER named entity recognition.
[0084] Exemplary, the code for NER named entity recognition using the BERT model is as follows:
[0085] from transformers import BertTokenizer, BertForTokenClassification
[0086] import torch
[0087] # Load the pre-trained BERT tokenizer
[0088] tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
[0089] #Load the pre-trained BERT model for named entity recognition tasks
[0090] model = BertForTokenClassification.from_pretrained('bert-base-chinese')
[0091] def entity_recognition(text):
[0092] #Convert the input text into a format acceptable to the BERT model
[0093] inputs = tokenizer(text, return_tensors="pt")
[0094] #Use the BERT model for forward pass to obtain the predicted logits for each token
[0095] outputs = model(**inputs).logits
[0096] #Perform argmax operation on the prediction results to obtain the predicted label of each token
[0097] predictions = torch.argmax(outputs, dim=2)
[0098] entities = []
[0099] #Traverse the input token and the corresponding predicted label
[0100] for token, prediction in zip(inputs.tokens(), predictions[0]):
[0101] #If the predicted label is greater than 0, it means that the token belongs to a named entity
[0102] if prediction.item() > 0:
[0103] entities.append(token)
[0104] #Return the list of recognized named entities
[0105] return entities
[0106] After identifying entities in government text, generate a sequence of government text with entities highlighted ,in represents the nth entity, represents the cth text word;
[0107] The relationship between entities in government texts is extracted through the relationship extraction technology BiLSTM-CRF model, that is, the bidirectional long short-term memory network BiLSTM is combined with the conditional random field CRF for relationship extraction.
[0108] Use the BiLSTM layer to encode the text sequence to obtain the entity hidden state sequence , represents the hidden state vector of the nth entity, Represents the hidden state vector of the nth text word, the BiLSTM model includes a forward LSTM model and the reverse LSTM model ,in:
[0109] ;
[0110] ;
[0111] ;
[0112] Among them, k is the hidden state dimension of the LSTM model; the output of the BiLSTM layer is used as the input of the fully connected layer, which is used to convert the output of the BiLSTM into a specific number of categories, corresponding to the type of relationship between entities: ,in and b are the weight matrix and bias vector of the fully connected layer, yes The output vector of represents the score of each entity relationship type, represents the vector representation of the nth entity, Represents the total number of entity relationship types, Indicates the hidden state at the previous moment, Represents the hidden state at the next moment.
[0113] The CRF model is used to capture the dependency between the output entity relations and entity relation labels, ensuring that the output label sequence conforms to the legal mode. The CRF layer calculates the score of the entire label sequence and finds the optimal entity relation label sequence through a dynamic programming algorithm.
[0114] The formula for calculating the entity relationship label sequence score is:
[0115] ;
[0116] Among them, y is the entity relationship label sequence, It is The score of the corresponding label of each entity, A is the state transfer matrix, Indicates Entity and The transfer score of an entity; n is the total number of entities; i≤n.
[0117] Construct entity relationship label probability function:
[0118] ;
[0119] The probability function of entity relationship labels is constructed according to the entity relationship label sequence score to determine the specific relationship labels between entities. is the predicted entity relationship label, is the sequence of all relation labels, It represents the score of outputting label sequence y' given input sequence x.
[0120] Using the pre-trained Chinese BERT model to perform named entity recognition on government texts can efficiently and accurately extract key entity information such as names of people, places, and institutions mentioned in the text. At the same time, the BiLSTM-CRF model is used to extract the relationship between entities, making full use of the semantic information of entities in the context, and can discover multiple associations such as subordination and processes between entities. After this step, the core entities and their semantic relationships in the government texts are fully mined, forming the elements for building the knowledge graph.
[0121] Based on the entities and entity relationships identified and extracted from government texts, the TransE model is used to embed knowledge graphs, map entities and entity relationships into vector space, and construct a knowledge graph.
[0122] Construct triples of entities identified in government documents and extracted entity relationships ,in is the head entity, For entity relationships, is the tail entity; through the TransE model, entities and relationships are mapped to the same vector space, entities are represented by low-dimensional real-valued vectors, and entity relationships are represented by translation vectors.
[0123] The TransE model training process is as follows: for each triple , the TransE model learns the embedding vectors of entities and entity relations so that .
[0124] The energy function of the TransE model is defined as: ,in and Represents the vector norm. The L1 norm and L2 norm are used to calculate the distance between entity embedding vectors. The L1 norm represents the Manhattan distance and the L2 norm represents the Euclidean distance.
[0125] Generate negative sample triplets using negative sampling strategy ,in and Randomly replace with any entity; define the loss function of the TransE model as:
[0126]
[0127] in, is the set of positive sample triplets, is the set of negative sample triplets, is a hyperparameter that controls the interval between positive and negative samples.
[0128] Use the stochastic gradient descent SGD algorithm to minimize the TransE model loss function, update the embedding vectors of entities and relations, and stop training when the loss function converges.
[0129] Use the trained TransE model to map the entities and entity relationships identified in the text into the vector space to build a knowledge graph , where E is the entity set, R represents the total number of entity relationship types, and entity nodes The feature vector of is the corresponding embedding vector , relationship edge The feature vector of is the corresponding embedding vector ; Use the TransE model to calculate the semantic similarity of entity nodes and relationship edge embedding vectors to construct the topological structure of the knowledge graph.
[0130] The extracted entity relationship triples are used for knowledge representation learning through the TransE model, which can map discrete, symbolic knowledge into continuous low-dimensional vectors.
[0131] TransE embeds entities and relations into the same semantic space through a translation mechanism, so that h+r≈t is satisfied in this space. This geometric representation can well reveal the potential semantic similarity between entities and relations, facilitating subsequent knowledge reasoning.
[0132] At the same time, TransE also uses strategies such as negative sampling for optimization training to obtain more robust and effective knowledge representation. Ultimately, government knowledge is organized into a multi-relational heterogeneous network, with both entity nodes and relationship edges having rich semantic information, laying the foundation for mining implicit knowledge.
[0133] Define government rule constraints, convert the rule constraints into first-order logic expressions, build a Markov logic network, and integrate the knowledge graph and rule constraints in the vector space based on the Markov logic network.
[0134] Define constraint rules ,in Indicates rule constraints, each rule constraint It consists of multiple first-order logic formulas, which are used to express the constraints of entity types and relationships between entities.
[0135] Each constraint rule Transformed into a first-order logic formula , construct logical formulas using predicates, constants, variables, and logical connectives :
[0136] ;
[0137] in, Represents a constant, Represents a variable, Represents predicates and logical connectives.
[0138] Construct a Markov logic network, define a Markov logic network ,in Represents the first-order logic formula of the mth Markov logic network, assigning a weight to each first-order logic formula , represents the confidence of the formula;
[0139] Based on the Markov logic network, the knowledge graph and rule constraints are integrated in the vector space; the first-order logic formula in the Markov logic network is applied to the knowledge graph embedding, and the satisfaction degree of each first-order logic formula on the knowledge graph is calculated.
[0140] For every first-order logic formula , use the embedding vector to calculate the satisfaction degree:
[0141] ;
[0142] in, Representation formula The weight vector of represents the concatenation of entity and relation embedding vectors, Represents the sigmoid activation function; is the transpose of the mth weight vector.
[0143] The TransE model embedding vector is used as the observed variable in the Markov logic network, the weight vector in the MLN is used as the parameter to be learned, and the knowledge graph and Markov logic network are embedded and fused.
[0144] By using Markov logic networks to fuse knowledge graph embedding and rule constraints, we can achieve joint modeling of factual knowledge and logical knowledge under a unified framework. The first-order logic formulas in MLN are weighted and combined to act on the knowledge graph, so that triples that meet the rules have a higher probability, while the probability of triples that violate the rules is reduced. At the same time, the weight parameters in MLN can be learned from data through probabilistic inference. This fusion mechanism enables the final knowledge representation to satisfy rule constraints while retaining the graph structure information, and has stronger semantic consistency. The introduction of rules enhances the interpretability of knowledge graph representation.
[0145] Based on the fused knowledge graph, graph mining and reasoning techniques are used to mine the potential relationships between entities and analyze the mined entity relationships.
[0146] The path information between entities in the knowledge graph is used to infer the potential relationships between entities. The paths in the knowledge graph are defined according to the Markov logic network. The depth-first search DFS algorithm is used to find the entity relationship paths that conform to the definition of the Markov logic network in the fused knowledge graph. The found paths are scored, and the credibility and importance of the paths are evaluated through the scoring. The path score is calculated using the path length and entity relationship type.
[0147] set up represents a path of length N, where represents the nth entity, Represents the g-th entity relationship and defines the scoring function of the path:
[0148] ;
[0149] in, Representing entity relationships The weight of Indicates the path length, calculates the score for all found paths, and sets the path score threshold ,when When , the path is established, the entities on the path have entity logical relationships, and are output as language text according to the entities and entity relationships in the path; the entities and entity relationships mined from the text are inserted at the end of the original text according to the path scores for subsequent analysis of the text.
[0150] Using path-based reasoning methods on the fused knowledge graph can discover some implicit entity relationships. By searching for relationship paths that meet rule constraints through depth-first search and using features such as length and relationship type to evaluate the quality of the paths, we can screen out reasoning results with high importance and credibility. Organizing the newly discovered entity relationships into natural language texts and supplementing them to the original government information can greatly enrich the amount of information in the government texts, reveal some hidden meanings, and provide new perspectives and entry points for government analysis. The re-injection of knowledge also makes the entire method form a closed loop, highlighting the advantages of knowledge-driven analysis.
[0151] Example 2
[0152] Reference Figure 2 The second embodiment of the present invention provides a data intelligent analysis system that combines knowledge graphs with rule constraints.
[0153] The system includes a data collection and processing module, an entity recognition module, a knowledge graph module, a government rules constraint and fusion module, and a mining and analysis module.
[0154] The data collection and processing module is used to collect multimodal government data, including text, images and audio, perform the same structured processing on the multimodal government data, and obtain the government text in the government data.
[0155] The entity recognition module uses government text as a data source, adopts the BERT model to identify entities, and constructs a relationship extraction technology BiLSTM-CRF model to extract the relationship between government entities.
[0156] The knowledge graph module uses the TransE model to embed the knowledge graph based on the entities and entity relationships identified and extracted from the government text, maps the entities and entity relationships to the vector space, and constructs the knowledge graph.
[0157] The rule constraint module defines rule constraints and converts rule constraints into first-order logic expressions.
[0158] The fusion module is used to construct a Markov logic network, and fuse the knowledge graph and rule constraints in the vector space based on the Markov logic network.
[0159] The mining and analysis module uses graph mining and reasoning technology based on the fused knowledge graph to mine potential relationships between entities and analyze the mined entity relationships.
[0160] Example 3
[0161] Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 3 As shown in the figure, the electronic device 500 may include one or more processors and one or more memories. The memories store computer-readable codes, which, when executed by one or more processors, can execute the data intelligent analysis method combining the knowledge graph with rule constraints as described above.
[0162] The method or system according to the embodiment of the present invention can also be used by Figure 3 The architecture of the electronic device shown is implemented.
[0163] like Figure 3 As shown, the electronic device 500 may include a bus 501, one or more CPUs 502, a read-only memory (ROM) 503, a random access memory (RAM) 504, a communication port 505 connected to a network, an input / output component 506, a hard disk 507, and the like.
[0164] The storage device in the electronic device 500, such as ROM 503 or hard disk 507, can store the data intelligent analysis method combining the knowledge graph and rule constraints provided by the present invention.
[0165] The data intelligent analysis method combining knowledge graph with rule constraints includes: collecting multimodal government data, including text, image and audio, performing the same structured processing on the multimodal government data, and obtaining the government text in the government data; using the government text as the data source, adopting the BERT model to identify entities, and constructing the relationship extraction technology BiLSTM-CRF model to extract the relationship between government entities; based on the entities and entity relationships identified and extracted in the government text, using the TransE model to embed the knowledge graph, mapping the entities and entity relationships to the vector space, and constructing the knowledge graph; defining government rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and rule constraints in the vector space based on the Markov logic network; based on the fused knowledge graph, using graph mining and reasoning technology to mine the potential relationships between entities, and analyzing the mined entity relationships.
[0166] Furthermore, the electronic device 500 may also include a user interface 508. Figure 3 The architecture shown is only exemplary and can be omitted according to actual needs when implementing different devices. Figure 3 One or more components of an electronic device are shown.
[0167] Example 4
[0168] Figure 4 It is a schematic diagram of the structure of a computer-readable storage medium provided by an embodiment of the present invention.
[0169] like Figure 4 As shown, the storage medium 600 stores instructions.
[0170] When the instructions are executed by the processor, the data intelligent analysis method combining the knowledge graph and rule constraints according to the embodiment of the present invention described with reference to the above drawings can be executed.
[0171] The storage medium 600 includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. In addition, according to an embodiment of the present invention, the process described above with reference to the flowchart may be implemented as a computer software program.
[0172] For example, the present invention provides a non-temporary machine-readable storage medium, which stores machine-readable instructions, and the machine-readable instructions can be executed by a processor to execute instructions corresponding to the method steps provided by the present invention, for example: collecting multimodal government data, including text, images and audio, performing the same structured processing on the multimodal government data, and obtaining government text in the government data; using government text as a data source, using the BERT model to identify entities, and constructing a relationship extraction technology BiLSTM-CRF model to extract relationships between government entities; based on the entities and entity relationships identified and extracted in the government text, using the TransE model to embed knowledge graphs, mapping entities and entity relationships to vector space, and constructing a knowledge graph; defining government rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and rule constraints in the vector space based on the Markov logic network; based on the fused knowledge graph, using graph mining and reasoning technology to mine potential relationships between entities, and analyzing the mined entity relationships.
[0173] When the computer program is executed by the central processing unit (CPU), the above functions defined in the method of the present invention are performed. The method, apparatus, and device of the present invention may be implemented in many ways. For example, the method, apparatus, and device of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware.
[0174] The above sequence for the steps of the method is for illustration only, and the steps of the method of the present invention are not limited to the sequence specifically described above unless otherwise specifically stated.
[0175] In addition, in some embodiments, the present invention can also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Therefore, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
[0176] In addition, the parts of the above technical solutions provided in the embodiments of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive redundancy.
[0177] The specific implementation modes as described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation mode of the present invention and is not intended to limit the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data intelligent analysis method combining knowledge graph and rule constraints, characterized in that: include: Collect multimodal data, including text, images and audio, perform the same structured processing on the multimodal data, and obtain the text in the multimodal data; Using text as the data source, the BERT model is used to identify entities, and the BiLSTM-CRF model, a relationship extraction technology, is constructed to extract entity relationships in the text; Based on the entities and entity relationships identified and extracted from the text, the TransE model is used to embed the knowledge graph, map the entities and entity relationships into the vector space, and construct the knowledge graph; Define rule constraints, convert them into first-order logic expressions, build a Markov logic network, and fuse the knowledge graph and rule constraints in the vector space based on the Markov logic network; Based on the fused knowledge graph, graph mining and reasoning techniques are used to mine potential relationships between entities and analyze the mined entity relationships. The method of using text as a data source, using the BERT model to identify entities, and constructing a BiLSTM-CRF model for extracting entity relationships in text includes: using entity recognition technology to identify entities in various types of text data, and using the deep learning method of the BERT model to perform NER named entity recognition; After identifying entities in the text, generate a text sequence with the entities highlighted ,in represents the nth entity, represents the cth text word; The relationship between entities in the text is extracted through the BiLSTM-CRF model, which is a bidirectional long short-term memory network BiLSTM model combined with the conditional random field CRF model for relationship extraction; Use the BiLSTM layer to encode the text sequence to obtain the entity hidden state sequence , represents the hidden state vector of the cth text word, Represents the hidden state vector of the nth entity, the bidirectional long short-term memory network BiLSTM model includes a forward LSTM model and the reverse LSTM model ,in: ; ; ; Among them, k is the hidden state dimension of the forward / reverse LSTM model; the output of the BiLSTM layer is used as the input of the fully connected layer, which is used to convert the output of the bidirectional long short-term memory network BiLSTM model into a specific number of categories, which correspond to the type of relationship between entities: ,in and b are the weight matrix and bias vector of the fully connected layer, yes The output vector of represents the score of each entity relationship type, represents the vector representation of the nth entity, R represents the total number of entity relationship types, Indicates the hidden state at the previous moment, Indicates the hidden state at the next moment; Based on the entities and entity relationships identified and extracted from the text, the TransE model is used to embed the knowledge graph, map the entities and entity relationships into the vector space, and construct the knowledge graph, including: Construct triples of entities identified in the text and extracted entity relations ,in is the head entity, For entity relationships, is the tail entity; through the TransE model, entities and entity relationships are mapped to the same vector space, entities are represented by low-dimensional real-valued vectors, and entity relationships are represented by translation vectors; The TransE model training process is as follows: for each triple , the TransE model learns the embedding vectors of entities and entity relations so that ; The energy function of the TransE model is defined as: ,in and Represents the vector norm. The L1 norm and L2 norm are used to calculate the distance between entity embedding vectors. The L1 norm represents the Manhattan distance, and the L2 norm represents the Euclidean distance. Generate negative sample triplets using negative sampling strategy ,in and Randomly replace with any entity; define the loss function of the TransE model as: ; in, is the set of positive sample triplets, is the set of negative sample triplets, is a hyperparameter that controls the interval between positive and negative samples; Use the stochastic gradient descent (SGD) algorithm to minimize the TransE model loss function, update the embedding vectors of entities and entity relationships, and stop training when the loss function converges; Use the trained TransE model to map the entities and entity relationships identified in the text into the vector space to build a knowledge graph , where E is the entity set, entity node The feature vector of is the corresponding embedding vector , relationship edge The feature vector of is the corresponding embedding vector ; Use the TransE model to calculate the semantic similarity of entity nodes and relationship edge embedding vectors to construct the topological structure of the knowledge graph; The method of defining rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and the rule constraints in the vector space based on the Markov logic network includes: Define constraint rules ,in Indicates rule constraints, each rule constraint It is composed of a plurality of first-order logic formulas, wherein the first-order logic formulas are used to express constraint conditions of entity types and entity relationships; Each constraint rule Transformed into a first-order logic formula , construct logical formulas using predicates, constants, variables, and logical connectives , ; in, Represents a constant, Represents a variable, Represents predicates and logical connectives; The method of defining rule constraints, converting the rule constraints into first-order logic expressions, constructing a Markov logic network, and fusing the knowledge graph and the rule constraints in the vector space based on the Markov logic network also includes: Construct a Markov logic network, define a Markov logic network ,in Represents the first-order logic formula of the mth Markov logic network, assigning a weight to each first-order logic formula , represents the confidence of the first-order logic formula; Based on the Markov logic network, the knowledge graph and rule constraints are integrated in the vector space; the first-order logic formula in the Markov logic network is applied to the knowledge graph embedding, and the satisfaction degree of each first-order logic formula on the knowledge graph is calculated; For every first-order logic formula , use the embedding vector to calculate the satisfaction degree: ; in, Represents a first-order logic formula The weight vector of represents the concatenation of entity and relation embedding vectors, Represents the sigmoid activation function; is the transpose of the mth weight vector; The TransE model embedding vector is used as the observed variable in the Markov logic network, and the weight vector in the Markov logic network is used as the parameter to be learned. The knowledge graph and the Markov logic network are embedded and fused.
2. The data intelligent analysis method combining knowledge graph and rule constraints according to claim 1 is characterized in that: The multimodal data is collected, including text, images and audio, and the multimodal data is subjected to the same structured processing, and the text in the multimodal data is obtained, including: obtaining the multimodal data, cleaning the obtained multimodal data, removing HTML tags, special characters and repeated content, and extracting the text content in the multimodal data; converting the cleaned data into a unified format to obtain the text to be recognized.
3. The data intelligent analysis method combining knowledge graph and rule constraints according to claim 2 is characterized in that: The CRF model is used to capture the dependencies between the output entity relationship labels and ensure that the output label sequence conforms to the legal mode. The CRF layer calculates the score of the entire label sequence and finds the optimal entity relationship label sequence through a dynamic programming algorithm. The formula for calculating the entity relationship label sequence score is: ; Among them, y is the entity relationship label sequence, It is The score of the corresponding label of each entity, A is the state transfer matrix, Indicates Entity and The transfer score of an entity; n is the total number of entities; i≤n; Construct entity relationship label probability function: ; The probability function of entity relationship labels is constructed according to the entity relationship label sequence score to determine the specific relationship labels between entities. is the predicted entity relationship label, is the sequence of all relation labels, It represents the score of outputting label sequence y' given input sequence x.
4. The data intelligent analysis method combining knowledge graph and rule constraints according to claim 3 is characterized in that: Based on the fused knowledge graph, graph mining and reasoning techniques are used to mine potential relationships between entities and analyze the mined entity relationships, including: Using the path information between entities in the knowledge graph, we can infer the potential relationship between entities. We define the path in the knowledge graph based on the Markov logic network. We use the depth-first search (DFS) algorithm to find the entity relationship path that conforms to the definition of the Markov logic network in the fused knowledge graph. We score the found path, evaluate the credibility and importance of the path through the score, and calculate the path score using the path length and entity relationship type: set up represents a path of length N, where represents the nth entity, Represents the g-th entity relationship and defines the scoring function of the path: ; in, Representing entity relationships The weight of Indicates the path length, calculates the score for all found paths, and sets the path score threshold ,when When , the path is established, the entities on the path have entity relationships, and the entities and entity relationships in the path are output as language text; the entities and entity relationships mined from the text are inserted at the end of the original text according to the path scores for subsequent analysis of the text.
5. A data intelligent analysis system combining knowledge graph and rule constraints, which is used to implement the data intelligent analysis method combining knowledge graph and rule constraints as described in any one of claims 1 to 4, characterized in that: include: Data collection and processing module, entity recognition module, knowledge graph module, rule constraint module, fusion module, and mining and analysis module; The data acquisition and processing module is used to acquire multimodal data, including text, images and audio, perform uniform structured processing on the multimodal data, and obtain text in the multimodal data; The entity recognition module uses text as a data source, adopts the BERT model to recognize entities, and constructs a BiLSTM-CRF model using relationship extraction technology to extract the relationship between entities; The knowledge graph module uses the TransE model to embed the entities and entity relationships identified and extracted from the text, maps the entities and entity relationships to the vector space, and constructs the knowledge graph; The rule constraint module defines rule constraints and converts rule constraints into first-order logic expressions; The fusion module is used to construct a Markov logic network, and fuse the knowledge graph and rule constraints in the vector space based on the Markov logic network; The mining and analysis module uses graph mining and reasoning technology based on the fused knowledge graph to mine potential relationships between entities and analyze the mined entity relationships.
6. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores a computer program that can be called by the processor; The processor executes the data intelligent analysis method combining the knowledge graph and rule constraints as described in any one of claims 1 to 4 by calling the computer program stored in the memory.
7. A computer-readable storage medium, characterized in that: include: Instructions are stored, and when the instructions are executed on a computer, the computer executes the data intelligent analysis method combining the knowledge graph with rule constraints as described in any one of claims 1 to 4.
