A method for constructing police situation knowledge graph based on joint learning
Through joint learning methods, a knowledge graph is constructed, the complexity and format of data in the public security field is solved, the automatic extraction and analysis of police information is realized, and the police data is improved. Utilization efficiency.
Patent Information
- Application Number
- CN202010413365.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-15
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-05-15
AI Technical Summary
The complexity of data and messy data formats in the public security field have led to the inadequate structured data being able to build an effective police knowledge graph, making it difficult to play the role of text data, and limiting the technological development in the public security field.
Using joint learning-based method, data annotation and training are performed on police texts, part-of-speech and sentence annotation are used using Transformer model and BiLSTM model, knowledge graph is constructed, and results are stored in the graph database to analyze case correlation and personnel relationships. .
It realizes the construction of automated police knowledge graphs, simplifies police analysis work, improves the accuracy of case text information extraction and entity identification, and enhances the structure and correlation analysis capabilities of public security data.
Smart Images

Figure CN111737484B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to natural language processing, knowledge graphs, and deep learning, and in particular to a method for constructing a police knowledge graph based on joint learning. Background Art
[0002] In 2012, Google formally proposed the concept of knowledge graph, aiming to solve problems in automatic question answering, personalized recommendations, and intelligent information retrieval. Since then, artificial intelligence has begun to expand from conventional structured and unstructured data to knowledge concepts in the objective world, enabling computers to process complex data similar to human cognition.
[0003] At present, knowledge graph technology has been widely used in many fields, from the early general knowledge graphs of encyclopedias such as Google and Baidu to knowledge graphs in industries such as government, education, medical care, and finance, and has achieved remarkable results. However, in the public security field, due to the complexity of its internal departmental composition, the data integrity of each department varies, the data format is messy, and a large amount of data is stored in the form of text such as case summaries and case closing reports. Existing structured data alone is not enough to provide further development and breakthroughs.
[0004] In this case, how to give full play to the role of internal public security texts and automatically construct knowledge graphs through deep learning methods becomes the key to the problem. Summary of the invention
[0005] In order to obtain information from complex police texts and automatically construct a knowledge graph, the present invention proposes a police knowledge graph construction method based on joint learning, which annotates the police texts within the public security department and sends them to the joint learning model for training, and then sends the output results into the graph database with a designed structure.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] A method for constructing a police situation knowledge graph based on joint learning, the method comprising the following steps:
[0008] 1) Obtain all the short text data of the case briefs, and annotate the word list data. The annotated content mainly includes four types of entities: type, time, place name, person name, and organization name. Among them, time, place name, person name, and organization name are annotated in units of words using the BIO annotation method, with a total of 9 types of labels. Type is annotated in units of sentence text. The number of labels is determined by the number of case categories, denoted as N;
[0009] 2) Use the WordPiece tool to perform word segmentation and insert the separator [CLS] used to separate samples and the separator [SEP] used to separate different sentences in the sample. Each sentence corresponds to a matrix X = (x1, x2, L, x t ), where x i They all represent the word vector of the i-th word, that is, the row vector, with a dimension of d and a sentence length of t;
[0010] 3) Use the Transformer model as an encoder to learn the context of the sentence and update the word embedding results. The Transformer steps are as follows:
[0011] 3.1) In order to obtain the influence of the word order in the input sequence on the sentence, a position vector with the same dimension as the word vector is calculated based on the above matrix X. The position vector can determine the position of the current word, or the distance between different words in a sentence. The calculation formula is as follows:
[0012]
[0013] Where pos refers to the position of the current word in the sentence, and i refers to the index of each value in the vector. It can be seen that sine encoding is used at even positions, and cosine encoding is used at odd positions;
[0014] 3.2) Sum the position vector and word vector and use it as the final input vector;
[0015] 3.3) The input vector is input through three different linear transformations to obtain the query vector Q, key vector K and value vector V. The dimension of the query vector and key vector is d k , the dimension of the value vector is d v , use the attention function to interpret it. The attention function formula is shown in (2):
[0016]
[0017] 3.4) The actual model uses a multi-head attention function, that is, multiple sets of Q, K, V matrices are calculated based on h different parameter matrices, and all transformation results are concatenated to obtain the multi-head attention value. The formula of the multi-head attention function is shown in (3):
[0018] MultiHead(Q,K,V)=Concat(head1,head2,L,head h )W O (3)
[0019] Among them, W O is a parameter matrix, headi is the calculation result of the attention function of the i-th group, and the formula is as follows:
[0020] head i =Attention(QW i Q ,KW i K ,VW i V ) (4)
[0021] In the formula, the parameter matrix
[0022] 3.5) Input the above output into a fully connected feedforward network, and perform layer normalization on the input result, as shown in formula (5):
[0023]
[0024] Where x is the function input value, o is the coding layer output matrix, W1, b1, W2 and b2 are the weight matrix and bias matrix respectively;
[0025] 4) Joint training includes two major tasks: part-of-speech tagging and sentence tagging. The output of the above Transformer model is o = {o1,o2,o3,L,o t} is split into o1 and {o2,o3,L,o t} two parts, the former is used as the input data of the classification task, and the latter is used as the input data of the entity recognition task. The probability functions are calculated separately. The process is as follows:
[0026] 4.1) For the entity recognition task, the BiLSTM model is used as the training model of the neural network to read the context. The pre-trained word vector is input into the BiLSTM model to obtain the hidden state matrix, as shown in formula (6):
[0027] h=BiLSTM(x) (6)
[0028] For each feature vector h of the output i , add a fully connected neural network with an input dimension of d and an output dimension of 9 word labels, and use the softmax function to calculate the label probability y for each word i , as shown in formula (7):
[0029] y i =softmax(W 9×d h i +b 9×d ) (7)
[0030] 4.2) For the classification task, take the sentence feature vector o1 as the input value x, add a fully connected neural network with an input dimension of d and an output dimension of the number of word labels N, and use the softmax function to calculate the label probability y of each word seq , as shown in formula (8):
[0031] y seq =softmax(W N×d x+b N×d ) (8)
[0032] 5) Use the cross entropy function for the two label probabilities, p i and p seq are the one-hot representations of the positive sample labels, and finally the loss function of joint training is obtained by summing them up. Finally, the model is trained, as shown in formula (9):
[0033]
[0034] 6) After training, the model is used to extract all case text data to obtain relevant entity data for each case for subsequent construction work; since there may be multiple nouns of the same type in each text, according to the text specification, only the time of the first appearance is taken as the entity of the case, and for place names, personal names, and institution names, all entities are removed after duplication and are regarded as case-related entities;
[0035] 7) A graph database is a database used to store multiple relationship graphs. Each node in the graph represents an entity, the edges between nodes represent relationships, and time is an attribute of the entity or edge. In this way, the defined data can be stored in the graph database in a node-edge-node manner.
[0036] Furthermore, the method further comprises the following steps:
[0037] 8) After the graph database is built, the correlation between different cases can be analyzed through various related algorithms. For example, the number of secondary connected paths between two cases can be checked. The more paths there are, the greater the correlation between the two cases. In addition, the graph can also be used as a supplement to public security structured data, integrating it with personnel relationships, and using graph algorithms to count and analyze the probability of people committing crimes.
[0038] The beneficial effects of the present invention are: learning and training are performed on annotated corpus using a joint learning algorithm, and the trained model automatically extracts important entity information from case texts, constructs a knowledge graph, and simplifies police analysis work. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1It is a method for constructing police knowledge graph based on joint learning; DETAILED DESCRIPTION
[0040] The present invention will be further described below in conjunction with the accompanying drawings.
[0041] Reference Figure 1 , a method for constructing a police situation knowledge graph based on joint learning, the method comprising the following steps:
[0042] 1) Obtain all the short text data of the case briefs, and annotate the word list data. The annotated content mainly includes four types of entities: type, time, place name, person name, and organization name. Among them, time, place name, person name, and organization name are annotated in units of words using the BIO annotation method, with a total of 9 types of labels. Type is annotated in units of sentence text. The number of labels is determined by the number of case categories, denoted as N;
[0043] 2) Use the WordPiece tool to perform word segmentation and insert the separator [CLS] used to separate samples and the separator [SEP] used to separate different sentences in the sample. Each sentence corresponds to a matrix X = (x1, x2, L, x t ), where x i They all represent the word vector of the i-th word, that is, the row vector, with a dimension of d and a sentence length of t;
[0044] 3) Use the Transformer model as the encoder to learn the context of the sentence and update the word embedding results.
[0045] The Transformer steps are as follows:
[0046] 3.1) In order to obtain the influence of the word order in the input sequence on the sentence, a position vector with the same dimension as the word vector is calculated based on the above matrix X. The position vector can determine the position of the current word, or the distance between different words in a sentence. The calculation formula is as follows:
[0047]
[0048] Where pos refers to the position of the current word in the sentence, and i refers to the index of each value in the vector. It can be seen that sine encoding is used at even positions, and cosine encoding is used at odd positions;
[0049] 3.2) Sum the position vector and word vector and use it as the final input vector;
[0050] 3.3) The input vector is input through three different linear transformations to obtain the query vector Q, key vector K and value vector V. The dimension of the query vector and key vector is d k , the dimension of the value vector is dv , use the attention function to interpret it. The attention function formula is shown in (2):
[0051]
[0052] 3.4) The actual model uses a multi-head attention function, that is, multiple sets of Q, K, V matrices are calculated based on h different parameter matrices, and all transformation results are concatenated to obtain the multi-head attention value. The formula of the multi-head attention function is shown in (3):
[0053] MultiHead(Q,K,V)=Concat(head1,head2,L,head h )W O (3)
[0054] Among them, W O is a parameter matrix, head i is the calculation result of the attention function of the i-th group, and the formula is as follows:
[0055] head i =Attention(QW i Q ,KW i K ,VW i V ) (4)
[0056] In the formula, the parameter matrix
[0057] 3.5) Input the above output into a fully connected feedforward network, and perform layer normalization on the input result, as shown in formula (5):
[0058]
[0059] Where x is the function input value, o is the coding layer output matrix, W1, b1, W2 and b2 are the weight matrix and bias matrix respectively;
[0060] 4) Joint training includes two major tasks: part-of-speech tagging and sentence tagging. The output of the above Transformer model is o = {o1,o2,o3,L,o t} is split into o1 and {o2,o3,L,o t} two parts, the former is used as the input data of the classification task, and the latter is used as the input data of the entity recognition task. The probability functions are calculated separately. The process is as follows:
[0061] 4.1) For the entity recognition task, the BiLSTM model is used as the training model of the neural network to read the context. The pre-trained word vector is input into the BiLSTM model to obtain the hidden state matrix, as shown in formula (6):
[0062] h=BiLSTM(x) (6)
[0063] For each feature vector h of the output i , add a fully connected neural network with an input dimension of d and an output dimension of 9 word labels, and use the softmax function to calculate the label probability y for each word i , as shown in formula (7):
[0064] y i =softmax(W 9×d h i +b 9×d ) (7)
[0065] 4.2) For the classification task, take the sentence feature vector o1 as input x, add a fully connected neural network with input dimension d and output dimension N as the number of word labels, and use the softmax function to calculate the label probability y for each word seq , as shown in formula (8):
[0066] y seq =softmax(W N×d x+b N×d ) (8)
[0067] 5) Use the cross entropy function for the two label probabilities, p i and p seq are the one-hot representations of the positive sample labels, and finally the loss function of joint training is obtained by summing them up. Finally, the model is trained, as shown in formula (9):
[0068]
[0069] 6) After training, the model is used to extract all case text data to obtain relevant entity data for each case for subsequent construction work; since there may be multiple nouns of the same type in each text, according to the text specification, only the time of the first appearance is taken as the entity of the case, and for place names, personal names, and institution names, all entities are removed after duplication and are regarded as case-related entities;
[0070] 7) A graph database is a database used to store various relationship graphs. Each node in the graph represents an entity, the edge between nodes represents the relationship, and time is an attribute of the entity or edge. In this way, the defined data can be stored in the graph database in a node-edge-node manner.
[0071] The method further comprises the following steps:
[0072] 8) After the graph database is built, the correlation between different cases can be analyzed through various related algorithms. For example, the number of secondary connected paths between two cases can be checked. The more paths there are, the greater the correlation between the two cases. In addition, the graph can also be used as a supplement to public security structured data, integrating it with personnel relationships, and using graph algorithms to count and analyze the probability of people committing crimes.
[0073] An embodiment of the present invention provides a method for constructing a police situation knowledge graph based on joint learning. The instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0074] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0075] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for constructing a police situation knowledge graph based on joint learning, characterized in that: The method comprises the following steps: 1) Obtain all the short text data of the case briefs, and annotate the word list data. The annotation content includes four major entities: type, time, place name, person name, and organization name. Time, place name, person name, and organization name are annotated in units of words using the BIO annotation method, with a total of 9 types of labels. Type is annotated in units of sentence text. The number of labels is determined by the number of case categories, denoted as N; 2) Use the WordPiece tool to perform word segmentation and insert the separator [CLS] used to separate samples and the separator [SEP] used to separate different sentences in the sample. Each sentence corresponds to a matrix X = (x1, x2, ..., x t ), where x i They all represent the word vector of the i-th word, that is, the row vector, with a dimension of d. The length of the sentence is t; 3) Use the Transformer model as an encoder to learn the context of the sentence and update the word embedding results. The Transformer steps are as follows: 3.1) In order to obtain the influence of the word order in the input sequence on the sentence, a position vector with the same dimension as the word vector is calculated based on the above matrix X. The position vector can determine the position of the current word, or the distance between different words in a sentence. The calculation formula is as follows: Where pos refers to the position of the current word in the sentence, i refers to the index of each value in the vector, sine encoding is used for even positions, and cosine encoding is used for odd positions; 3.2) Sum the position vector and word vector and use it as the final input vector; 3.3) The input vector is input through three different linear transformations to obtain the query vector Q, key vector K and value vector V. The dimension of the query vector and key vector is d k , the dimension of the value vector is d v , use the attention function to interpret it. The attention function formula is shown in (2): 3.4) The actual model uses a multi-head attention function, that is, multiple sets of Q, K, V matrices are calculated based on h different parameter matrices, and all transformation results are concatenated to obtain the multi-head attention value. The formula of the multi-head attention function is shown in (3): MultiHead(Q,K,V)=Concat(head1,head2,…,head h )W O (3) Among them, W O is a parameter matrix, head i is the calculation result of the attention function of the i-th group, and the formula is as follows: In the formula, the parameter matrix 3.5) Input the multi-head attention value outputted above into a fully connected feedforward network, and perform layer normalization on the input result, as shown in formula (5): Where x is the function input value, o is the coding layer output matrix, W1, b1, W2 and b2 are the weight matrix and bias matrix respectively; 4) Joint training includes two major tasks: part-of-speech tagging and sentence tagging. The output of the above Transformer model is o = {o1, o2, o3, …, o t } is split into o1 and {o2,o3,…,o t } two parts, the former is used as the input data of the classification task, and the latter is used as the input data of the entity recognition task. The probability functions are calculated separately. The process is as follows: 4.1) For the entity recognition task, the BiLSTM model is used as the training model of the neural network to read the context. The pre-trained word vector is input into the BiLSTM model to obtain the hidden state matrix, as shown in formula (6): h=BiLSTM(x) (6) For each feature vector h of the output i , add a fully connected neural network with an input dimension of d and an output dimension of 9 word labels, and use the softmax function to calculate the label probability y for each word i , as shown in formula (7): y i =softmax(W 9×d h i +b 9×d ) (7) 4.2) For the classification task, take the sentence feature vector o1 as input x, add a fully connected neural network with input dimension d and output dimension N as the number of word labels, and use the softmax function to calculate the label probability y for each word seq , as shown in formula (8): y seq =softmax(W N×d x+b N×d ) (8) 5) Use the cross entropy function for the two label probabilities, p i and p seq are the one-hot representations of the positive sample labels, and finally the loss function of joint training is obtained by summing them up. Finally, the model is trained, as shown in formula (9): 6) After training, the model is used to extract all case text data to obtain relevant entity data for each case for subsequent construction work; since there may be multiple nouns of the same type in each text, according to the text specification, only the time of the first appearance is taken as the entity of the case, and for place names, personal names, and institution names, all entities are removed after duplication and are regarded as case-related entities; 7) A graph database is a database used to store multiple relationship graphs. Each node in the graph represents an entity, the edges between nodes represent relationships, and time is an attribute of the entity or edge. The defined data is stored in the graph database in a node-edge-node manner.
2. A method for constructing a police situation knowledge graph based on joint learning as claimed in claim 1, characterized in that: The method further comprises the following steps: 8) After the graph database is built, the correlation between different cases is analyzed through relevant algorithms. The graph is used as a supplement to the public security structured data, and the knowledge is integrated with the personnel relationship. The probability of a person committing a crime is counted and analyzed through the graph algorithm.
