Event multi-label classification method and device based on knowledge graph, equipment and medium
By constructing an event knowledge graph based on a knowledge graph method and utilizing an event classification model, the problem of inaccurate event classification in existing technologies is solved, and more efficient semantic information mining and event classification are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-12-13
- Publication Date
- 2026-07-24
Smart Images

Figure CN115905538B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a method, apparatus, device and medium for multi-label event classification based on knowledge graphs. Background Technology
[0002] In recent years, with the rapid development of information technology, the construction of online platforms in various regions has steadily progressed, ushering in a new model of public services in the information age. Classifying public service text data on online platforms by event is beneficial for relevant staff to carry out more effective public service work, and also facilitates better classification, management, and storage of public service text data.
[0003] With the development of natural language processing (NLP) technology, some research has begun to focus on applying these technologies to mine potential information in text data for text data analysis. Existing event classification methods employ techniques such as word vectors and keywords. However, the problem is that shallow word vectors and keywords have limited ability to mine potential semantic information in text data, and for issues involving polysemy, it is difficult to guarantee the accuracy of semantic information mining, thus compromising the accuracy of event classification. Summary of the Invention
[0004] This application provides a method, apparatus, device, and medium for multi-label event classification based on knowledge graphs, which addresses the problem that existing solutions have limited ability to mine semantic information in text data and cannot guarantee the accuracy of event classification.
[0005] This application provides a knowledge graph-based multi-label event classification method, the method comprising: Obtain text data, and determine the entities contained in the text data, the attributes of the entities, and the attribute values; Attribute triples and relation triples are determined based on each entity, the attributes of each entity, and the attribute values. Based on the attribute triples and relation triples, construct the event knowledge graph corresponding to the text data; The event knowledge graph is input into a pre-trained event classification model, and the event category corresponding to the text data is determined based on the event classification model.
[0006] Further, determining the entities contained in the text data, the attributes of the entities, and the attribute values includes: The text data is converted into a first embedding vector, and the first embedding vector is input into the bidirectional encoder BERT model for encoding to obtain the encoded second embedding vector. The second embedding vector is decoded by segment enumeration to obtain the representation vector corresponding to each segment. Each representation vector is input into a trained semantic recognition model, and the entity, entity attributes, and attribute values corresponding to each representation vector are determined based on the semantic recognition model.
[0007] Further, determining the attribute triples based on the respective entities, the attributes of the respective entities, and the attribute values includes: For each entity, determine the entity's type and the attribute values of its main attributes; The attribute value of the entity's main attribute and the attribute value of any attribute belonging to the entity type in the text data are input into a pre-trained attribute triplet extraction model. Based on the attribute triplet extraction model, it is determined whether the attribute value of any attribute describes the entity. Based on the description of each attribute of the entity and its corresponding attribute value, determine each attribute triplet of the entity.
[0008] Furthermore, the method also includes: If multiple identical attribute values of a subject exist in the text data, the attribute value of the subject attribute that is closest to the attribute value to be judged is selected to construct the input of the attribute triple extraction model to obtain the prediction result.
[0009] Furthermore, determining the relation triples based on each entity, the attributes of each entity, and the attribute values includes: Determine the main attributes of each entity; input the attribute values of any two main attributes into a pre-trained relation triplet extraction model, and determine the relationship between the entities to which the two main attributes belong based on the relation triplet extraction model; Each relation triple is determined based on the entities and the relationships between any two entities.
[0010] Furthermore, the method also includes: If the text data contains multiple attribute values of the same main attribute, when judging the relationship between any two entities, the attribute value that is closest to the main attribute value of the two entities is selected to construct the input of the relationship triple extraction model to obtain the prediction result.
[0011] Furthermore, constructing the event knowledge graph corresponding to the text data based on the attribute triples and relation triples includes: Create event entities, connect each entity including the event entity according to the attribute triples, relation triples and the pre-defined connection relationships of the event entities, and populate the attributes and attribute values of each entity, as well as the relationships between the entities, to obtain the event knowledge graph corresponding to the text data.
[0012] Furthermore, the step of inputting the event knowledge graph into a pre-trained event classification model, and determining the event category corresponding to the text data based on the event classification model, includes: The event knowledge graph is converted into an undirected graph, which is then expanded or pruned while maintaining a fixed size. The adjacency matrix of the undirected graph is determined. The representation vectors of each entity in the event knowledge graph are determined, and the feature matrix is determined based on the representation vectors of each entity. The adjacency matrix and the feature matrix are input into a pre-trained event classification model. Based on the event classification model, a category representation matrix is determined, and features are extracted from the category representation matrix to obtain the event category corresponding to the text data.
[0013] Furthermore, determining the representation vector of each entity in the event knowledge graph includes: For each entity other than the event entity, the representation vector of each entity is determined based on the attribute value of the main attribute of each entity. For the event entity, the representation vector of the event entity is determined based on the representation vectors of each entity connected to the event entity.
[0014] On the other hand, this application provides a knowledge graph-based event multi-label classification device, the device comprising: The first determining module is used to acquire text data and determine each entity contained in the text data, the attributes of each entity, and the attribute values; The second determining module is used to determine attribute triples and relation triples based on each entity, the attributes of each entity, and the attribute values. The construction module is used to construct an event knowledge graph corresponding to the text data based on the attribute triples and relation triples. The classification module is used to input the event knowledge graph into a pre-trained event classification model and determine the event category corresponding to the text data based on the event classification model.
[0015] The first determining module is specifically used to convert the text data into a first embedding vector, input the first embedding vector into a bidirectional encoder BERT model for encoding to obtain an encoded second embedding vector; decode the second embedding vector by segment enumeration to obtain the representation vector corresponding to each segment; input each representation vector into a trained semantic recognition model, and determine the entity, entity attributes, and attribute values corresponding to each representation vector based on the semantic recognition model.
[0016] The second determining module is specifically used to determine the type and attribute value of the main attribute of each entity; input the attribute value of the main attribute of the entity and the attribute value of any attribute belonging to the entity type in the text data into a pre-trained attribute triple extraction model, and determine whether the attribute value of any attribute describes the entity based on the attribute triple extraction model; and determine each attribute triple of the entity according to each attribute describing the entity and its corresponding attribute value.
[0017] The second determining module is further configured to, if there are multiple identical attribute values of the same subject attribute in the text data, select the attribute value of the subject attribute that is closest to the attribute value to be judged to construct the input of the attribute triple extraction model and obtain the prediction result.
[0018] The second determining module is specifically used to determine the subject attributes of each entity; input the attribute values of any two subject attributes into a pre-trained relation triplet extraction model, and determine the relationship between the entities to which the two subject attributes belong based on the relation triplet extraction model; and determine each relation triplet based on each entity and the relationship between any two entities.
[0019] The second determining module is also used to select the most adjacent attribute value representing the main attribute value of the two entities to construct the input of the relationship triple extraction model when judging the relationship between any two entities if there are multiple attribute values of the same main attribute in the text data, so as to obtain the prediction result.
[0020] The construction module is specifically used to create event entities. Based on the attribute triples, relation triples and the pre-defined connection relationships of event entities, it connects each entity, including the event entity, and fills in the attributes and attribute values of each entity, as well as the relationships between each entity, to obtain the event knowledge graph corresponding to the text data.
[0021] The construction module is specifically used to convert the event knowledge graph into an undirected graph, expand or prune the undirected graph, and fix the size of the input graph; determine the adjacency matrix of the undirected graph; determine the representation vector of each entity in the event knowledge graph, and determine the feature matrix based on the representation vector of each entity; input the adjacency matrix and the feature matrix into a pre-trained event classification model, determine the category representation matrix based on the event classification model, and perform feature extraction on the category representation matrix to obtain the event category corresponding to the text data.
[0022] The construction module is specifically used to determine the representation vector of each entity other than the event entity based on the attribute value of the main attribute of each entity; and to determine the representation vector of the event entity based on the representation vectors of each entity connected to the event entity.
[0023] On the other hand, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the steps of the method described in any of the preceding statements.
[0024] In another aspect, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described in any of the above claims.
[0025] This application provides a method, apparatus, device, and medium for multi-label event classification based on knowledge graphs. The method includes: acquiring text data; determining each entity contained in the text data, the attributes of each entity, and the attribute values; determining attribute triples and relation triples based on each entity, the attributes of each entity, and the attribute values; constructing an event knowledge graph corresponding to the text data based on the attribute triples and relation triples; inputting the event knowledge graph into a pre-trained event classification model; and determining the event category corresponding to the text data based on the event classification model.
[0026] The above technical solution has the following advantages or beneficial effects: In this application, text data is acquired, and the entities, attributes, and attribute values of each entity are identified, thereby determining attribute triples and relation triples. Attribute triples and relation triples can contain more potential semantic information from the text data. Therefore, based on the attribute triples and relation triples, an event knowledge graph corresponding to the text data is constructed. Then, based on an event classification model, the event category corresponding to the text data is determined, enabling the extraction of more semantic information and achieving accurate event classification. Compared to event classification solutions based on word vectors, keywords, and other techniques, this method improves the accuracy of event classification. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 A schematic diagram of the event classification process provided in this application; Figure 2 Example diagram of input for relation triple extraction provided in this application; Figure 3 A schematic diagram of the event knowledge graph provided in this application; Figure 4 A schematic diagram of the event classification device provided in this application; Figure 5 A schematic diagram of the electronic device structure provided in this application. Detailed Implementation
[0029] To make the objectives and implementation methods of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the exemplary embodiments described are only some embodiments of this application, and not all embodiments.
[0030] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0031] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.
[0032] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.
[0033] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0034] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0035] For ease of explanation, the above description has been provided in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Various modifications and variations can be obtained based on the above teachings. The selection and description of the above embodiments are for the purpose of better explaining the principles and practical applications, thereby enabling those skilled in the art to better utilize the described embodiments and various different variations of embodiments suitable for specific use considerations.
[0036] Figure 1 The diagram illustrating the knowledge graph-based multi-label event classification process provided in this application includes the following steps: S101: Obtain text data and determine the entities contained in the text data, the attributes of the entities, and the attribute values.
[0037] S102: Determine attribute triples and relation triples based on each entity, the attributes of each entity, and the attribute values.
[0038] S103: Construct an event knowledge graph corresponding to the text data based on the attribute triples and relation triples.
[0039] S104: Input the event knowledge graph into the pre-trained event classification model, and determine the event category corresponding to the text data based on the event classification model.
[0040] The event classification method provided in this application is applied to electronic devices, which may be PCs, tablets, or servers.
[0041] The electronic device first acquires text data, which can be input by the user. Examples of text data include those related to public services, education, and healthcare. After acquiring the text data, the electronic device identifies the entities contained within it, their attributes, and attribute values. Based on this information, it determines attribute triples and relation triples, thereby constructing an event knowledge graph. Finally, it uses the knowledge graph to complete the final event classification.
[0042] Constructing an event knowledge graph first requires predefining the entities, attributes, and relationships it contains. Optionally, entities include events, people, time, location, items, and organizations. The event entity is the entity created in this application and does not have entity attributes. Meanwhile, entities other than event entities may contain multiple attributes describing that entity. For example, an entity named "People" might contain attributes such as name, gender, age, and personnel category; an entity named "Item" might contain attributes such as item name, item size, and item value; and an entity named "Organization" might contain attributes such as organization name and organization leader. Attribute values are the specific content of the attribute. For example, the attribute value for "Gender" includes "Male" or "Female," the attribute value for "Name" includes "Zhang San" or "Li Si," and the attribute value for "Age" includes "18 years old" or "20 years old."
[0043] In addition, this application predefines the subject attributes of each entity. An entity's subject attribute refers to the attribute that best characterizes the entity, such as the name of a person (for an entity-person) or the name of an item (for an entity-item). Another important component of the event knowledge graph structure is the relationships between entities. Optionally, the examples given in this application include the association between events and people, the affiliation between people and organizations, and the social relationships between people. Table 1 provides examples of entity types and subject attributes provided in this application, and Table 2 provides examples of relationship types between entities provided in this application. It should be noted that Tables 1 and 2 are merely illustrative examples of this application, and this application does not limit the specific entity types or relationship types.
[0044]
[0045] Table 1
[0046] Table 2
[0047] Electronic devices predefine the entities, attributes, and relationships contained in the event knowledge graph. During event classification, after acquiring text data, the entities, attributes, and attribute values within the text data are determined. This can be achieved using a BERT model combined with Span enumeration.
[0048] After identifying each entity, its attributes, and attribute values in the text data, we determine the attribute triples and relation triples. Attribute triples consist of an entity, its attribute, and its attribute value, while relation triples consist of entity 1, entity 2, and the relationship between them.
[0049] When determining the attribute triples for each entity, first, determine the entity's type, such as "person" or "item." Then, identify the attributes in the text data that belong to that entity type. Taking "person" as an example, attributes belonging to that entity type include name, gender, age, and person category. Next, it's necessary to determine whether the attribute values in the text data describe the same entity. For example, if the text data contains two person entities, Zhang San and Li Si, and includes gender and age attributes, it's necessary to determine which attribute value describes Zhang San and which describes Li Si.
[0050] This involves pre-training an attribute triple extraction model to determine which attribute values describe the same entity. During training, a first training set is saved, containing the attribute values of each sample attribute and the label information of the entity described by that attribute value. This label information indicates which specific entity the sample attribute value describes. The attribute triple extraction model is then trained based on the attribute values and label information of each sample attribute in the first training set.
[0051] When determining relation triples for each entity, for any two entities, firstly, the main attributes of each entity are selected. Then, these main attributes are input into a pre-trained relation triple extraction model. Based on the relation triple extraction model, the relationship between the two entities is determined. Finally, relation triples are constructed based on each entity and the relationships between them.
[0052] When training the relation triple extraction model, a second training set can be saved. This second training set includes each sample attribute and the label information indicating the relationship between the entities to which each sample attribute belongs. Based on the sample attributes and label information in the second training set, the relation triple extraction model is trained.
[0053] After identifying the attribute triples and relation triples, an event knowledge graph corresponding to the text data is constructed based on these triples. The event knowledge graph includes each entity, the attributes and attribute values of each entity, and the relationships between the entities.
[0054] The event knowledge graph is input into a pre-trained event classification model, which then determines the event category corresponding to the text data. Event categories could include, for example, urban management or conflicts and disputes.
[0055] When training the event classification model, the electronic device saves a third training set, which includes the event knowledge graph of each sample and its corresponding event category label information. The event knowledge graph of each sample and its corresponding event category label information are input into the event classification model to complete the training of the event classification model.
[0056] In this application, text data is acquired, and the entities, attributes, and attribute values of each entity are identified, thereby determining attribute triples and relation triples. Attribute triples and relation triples can contain more potential semantic information from the text data. Therefore, based on the attribute triples and relation triples, an event knowledge graph corresponding to the text data is constructed. Then, based on an event classification model, the event category corresponding to the text data is determined, enabling the extraction of more semantic information and achieving accurate event classification. Compared to event classification solutions based on word vectors, keywords, and other techniques, this method improves the accuracy of event classification.
[0057] To more accurately determine the entities, attributes, and attribute values contained in the text data, this application includes the following steps for determining the entities, attributes, and attribute values contained in the text data: The text data is converted into a first embedding vector, and the first embedding vector is input into the bidirectional encoder BERT model for encoding to obtain the encoded second embedding vector. The second embedding vector is decoded by segment enumeration to obtain the representation vector corresponding to each segment. Each representation vector is input into a trained semantic recognition model, and the entity, entity attributes, and attribute values corresponding to each representation vector are determined based on the semantic recognition model.
[0058] In this application, the text data is first converted into a first embedding vector to construct the input of the bidirectional encoder BERT model. The formula is constructed as follows: ; in, The word embedding vector is obtained by encoding the text data using the word2vec model, which is used to generate word vectors. Represents the fragment embedding vector. This represents the location embedding vector, which is encoded by the location of each token.
[0059] The first embedding vector The input is encoded into the BERT model to obtain the second embedding vector. A deep BERT model is then applied. Encoding yields a second embedding vector with richer semantic information and stronger representational power.
[0060] Then, the second embedding vector is decoded by segment enumeration to obtain the representation vector corresponding to each segment. After determining the representation vector corresponding to each segment, each representation vector is input into the trained semantic recognition model. Based on the semantic recognition model, the entity, the attribute of the entity, and the attribute value corresponding to each representation vector are determined.
[0061] For example, the maximum segment length `max_span_length` can be set to 15, a value that can be customized. Segment enumeration involves listing all possible segments in the text data and classifying these segments. For segment `i`, its final representation vector... The embedding vector of its starting token The embedding vector of the end token And concatenation of embedding vectors of fragment lengths learned by the model. And thus: ; Representation vector After passing through a fully connected layer and then activated by the softmax function, the final category of the fragment is obtained, i.e. Where W is the weight coefficient matrix. The final category includes any one of the instance type and the entity's attributes and attribute values. It should be noted that some segments may not have a category, meaning that the segment's recognition result is not within the pre-defined range of subject type, attributes, and attribute values.
[0062] To make the determination of attribute triples more accurate, in this application, the determination of attribute triples based on the entities, the attributes of the entities, and the attribute values includes: For each entity, determine the entity's type and the attribute values of its main attributes; The attribute value of the entity's main attribute and the attribute value of any attribute belonging to the entity type in the text data are input into a pre-trained attribute triplet extraction model. Based on the attribute triplet extraction model, it is determined whether the attribute value of any attribute describes the entity. Based on the description of each attribute of the entity and its corresponding attribute value, determine each attribute triplet of the entity.
[0063] In this application, for attribute triple extraction, the attribute value of the main attribute represents a certain entity, and is combined with the attribute values of other attributes of the same entity in pairs. Position labels are added and text truncation is performed to construct the model input. The model is treated as a binary classification problem, which only distinguishes whether the two combined attribute values describe the same entity.
[0064] It should be noted that if there are multiple identical attribute values for the same subject attribute in the text data, the attribute value of the subject attribute that is closest to the attribute value to be judged is selected to construct the input of the attribute triple extraction model to obtain the prediction result.
[0065] For example, the text data is " 18 years old Zhang San The text data contains two identical subject attribute values for "Zhang San". The attribute value to be judged is "18 years old". The attribute value of the subject attribute closest to the attribute value to be judged is the first Zhang San. The "18 years old" and the first Zhang San are used as inputs to the attribute triple extraction model. Based on the attribute triple extraction model, it is determined whether "18 years old" describes Zhang San.
[0066] To make the determination of relation triples more accurate, in this application, the determination of relation triples based on the entities, the attributes of the entities, and the attribute values includes: Determine the main attributes of each entity; input the attribute values of any two main attributes into a pre-trained relation triplet extraction model, and determine the relationship between the entities to which the two main attributes belong based on the relation triplet extraction model; Each relation triple is determined based on the entities and the relationships between any two entities.
[0067] For relation triple extraction, the attribute value of the subject attribute represents a certain entity. These subject attributes are combined in pairs, and position labels and text truncation are also added to construct the model input. Since there are multiple relationships between entities, it is regarded as a multi-classification problem.
[0068] Taking relation triple extraction as an example, its construction method is as follows: Given the event text data "At 12:30 PM on April 7, 2022, a large truck with license plate number XXX driven by Li was parked illegally on XX Road, causing traffic congestion.", the entity recognition result contains the attribute value of the subject attribute `personName` of an entity represented by "Li". This can be combined with the attribute value of the subject attribute `thingName` of an entity represented by "large truck" to construct input and determine the relationship between the two. Specifically, corresponding tags are added before and after the attribute values, and the text is truncated using a period ".". The input is as follows: Figure 2 As shown. Figure 2 The [CLS] label preceding each input example is a common processing method used in subsequent BERT models, serving as the semantic representation vector for the entire input. After the input is constructed, it is also transformed to obtain the input embedding vector for the BERT model.
[0069] It should be noted that if there are multiple attribute values of the same main attribute in the text data, when judging the relationship between any two entities, the attribute value that is closest to the main attribute value of the two entities is selected to construct the input of the relationship triple extraction model to obtain the prediction result.
[0070] For example, the text data is " truck Li Si The text data contains two identical attribute values for the subject "Li Si". When determining the relationship between the two entities "Li Si and the truck", the truck and the first Li Si are used as inputs to the relation triple extraction model. The relationship between Li Si and the truck is determined based on the relation triple extraction model.
[0071] The main model architecture used for attribute triple extraction and relation triple extraction is the same. Both utilize the BERT model to learn the embedding vectors of each token in the event text data. Furthermore, for two attribute values with labels in the input, there is a final representation vector. The average value is the embedding vector of each token contained in this attribute value, calculated using the following formula: .
[0072] The final representation vector of the entire input consists of the embedding vector of the [CLS] label and the representation vectors of the two attribute values. and The result obtained by piecing together: .
[0073] For attribute triple extraction, it is treated as a binary classification problem, with the number of categories set to 2. For relation triple extraction, the number of categories is determined by the number of relation categories contained in the event knowledge graph structure. The formula for calculating the classification result is as follows: Based on the classification results, attribute triples and relation triples are constructed respectively.
[0074] In this application, to make the construction of the event knowledge graph more accurate, the step of constructing the event knowledge graph corresponding to the text data based on the attribute triples and relation triples includes: Create event entities, connect each entity including the event entity according to the attribute triples, relation triples and the pre-defined connection relationships of the event entities, and populate the attributes and attribute values of each entity, as well as the relationships between the entities, to obtain the event knowledge graph corresponding to the text data.
[0075] For text data, the attribute triples and relation triples of the text data are determined according to the above process. Then, an event entity is created. This entity has no attribute values and is used to represent the input event text data, completing the mapping from subject attributes to entities. For example, the existence of the personName attribute value is considered as the existence of an entity person. Based on the attribute triples and relation triples, the entity attributes are filled and the relations are connected to obtain the event knowledge graph corresponding to the text data.
[0076] Figure 3 The event knowledge graph diagram provided in this application, such as Figure 3 As shown, the entities include Person 1, Person 2, Time, Location, Personal Injury, and Property Damage. Each of Person 1, Person 2, Time, Location, Personal Injury, and Property Damage includes attributes and attribute values. The relationship between Person 1 and Personal Injury is "suffering," and the relationship between Person 1 and Property Damage is also "suffering." The relationship between Person 2 and Personal Injury is "causing," and the relationship between Person 2 and Property Damage is also "causing." An event entity is created, and connections are established between the event entity and Person 1, Person 2, Time, and Location. The relationship between the event entity and Person 1 and Person 2 is "association," and the relationship between the event entity and Time and Location is "occurring."
[0077] To more accurately determine the event category corresponding to the text data, in this application, the step of inputting the event knowledge graph into a pre-trained event classification model and determining the event category corresponding to the text data based on the event classification model includes: The event knowledge graph is converted into an undirected graph, which is then expanded or pruned while maintaining a fixed size. The adjacency matrix of the undirected graph is determined. The representation vector of each entity in the event knowledge graph is determined, and the feature matrix is determined based on the representation vector of each entity. The adjacency matrix and the feature matrix are input into a pre-trained event classification model. Based on the event classification model, a category representation matrix is determined, and features are extracted from the category representation matrix to obtain the event category corresponding to the text data.
[0078] The determination of the representation vector of each entity in the event knowledge graph includes: For each entity other than the event entity, the representation vector of each entity is determined based on the attribute value of the main attribute of each entity. For the event entity, the representation vector of the event entity is determined based on the representation vectors of each entity connected to the event entity.
[0079] In this application, after the event knowledge graph is constructed, the attributes and specific attribute values of entities in the knowledge graph can reflect the main semantic information contained in the event text data, while the relationships between entities can well reflect the overall structural context of the event. In this application, a graph convolutional neural network (GCN) is applied for event label prediction, simultaneously capturing both semantic and structural information in the event text.
[0080] Specifically, the event knowledge graph is first converted into an undirected graph ori_G. Considering that the number of entities contained in different events varies, this application further expands or prunes the above graph structure to obtain an undirected graph G with a fixed size and N nodes in order to unify the model input. Specifically, expansion requires no additional operation and is naturally reflected in the subsequent fixed-size adjacency matrix. Pruning is carried out using a random walk sampling method, starting with event entities and randomly sampling. The nodes of this graph are labeled with indices. In particular, event entity nodes are marked as 0, and the labels of the remaining entity nodes can be randomly shuffled to obtain the adjacency matrix A representing the undirected graph. Further, a feature matrix X is constructed. Except for event entities, the feature vectors of other entities are the representation vectors of the attribute values of their main attributes. The feature vector of an event entity is the average of the feature vectors of its neighboring entities. Features can be extracted using two layers of GCN. : .
[0081] in Normalize the adjacency matrix A. and These represent the weights to be trained in the two layers of the GCN.
[0082] Therefore, the representation vector of the event entity That is, features The first row of the vector is considered the representation vector of the entire event, used to predict the event category label. Considering that an event may involve multiple labels, such as an event that may belong to both urban management and conflict / dispute categories, this is considered a multi-label classification problem. Representation Vector The dimension is ,in This represents the number of event categories. Each category dimension is activated independently using the sigmoid activation function to determine whether an event belongs to that category, i.e., whether it contains that type of label.
[0083] In this application, event text data is transformed into an event knowledge graph to mine the structural relationships between entities involved in the event text, and graph convolutional neural networks are further used to simultaneously capture potential semantic and structural information in the event for better event category label prediction.
[0084] This application uses the BERT model to encode elements in event text during named entity recognition, attribute triple extraction, and relation triple extraction. The shallower word2vec word vector model has stronger representation capabilities and can overcome the shortcomings of the word2vec model, which statically encodes the same word and cannot combine contextual semantic information.
[0085] This application considers the phenomenon that an event may have multiple category labels, and treats it as a multi-label classification problem in event label prediction, which is more in line with reality than many traditional methods that only perform multi-classification of events.
[0086] Figure 4 This is a schematic diagram of the event classification device provided in this application. The device includes: The first determining module 41 is used to acquire text data and determine each entity contained in the text data, the attributes of each entity, and the attribute values. The second determining module 42 is used to determine attribute triples and relation triples based on each entity, the attributes of each entity, and the attribute values. Module 43 is used to construct an event knowledge graph corresponding to the text data based on the attribute triples and relation triples; The classification module 44 is used to input the event knowledge graph into a pre-trained event classification model and determine the event category corresponding to the text data based on the event classification model.
[0087] The first determining module 41 is specifically used to convert the text data into a first embedding vector, input the first embedding vector into a bidirectional encoder BERT model for encoding to obtain an encoded second embedding vector; decode the second embedding vector by segment enumeration to obtain the representation vector corresponding to each segment; input each representation vector into a trained semantic recognition model, and determine the entity, entity attributes and attribute values corresponding to each representation vector based on the semantic recognition model.
[0088] The second determining module 42 is specifically used to determine the type of the entity and the attribute value of the main attribute for each entity; input the attribute value of the entity's main attribute and the attribute value of any attribute belonging to the entity type in the text data into a pre-trained attribute triple extraction model, and determine whether the attribute value of any attribute describes the entity based on the attribute triple extraction model; and determine each attribute triple of the entity according to each attribute describing the entity and its corresponding attribute value.
[0089] The second determining module 42 is further configured to, if there are multiple identical attribute values of the subject attribute in the text data, select the attribute value of the subject attribute that is closest to the attribute value to be judged to construct the input of the attribute triple extraction model and obtain the prediction result.
[0090] The second determining module 42 is specifically used to determine the main attributes of each entity; input the attribute values of any two main attributes into a pre-trained relation triplet extraction model, determine the relationship between the entities to which the two main attributes belong based on the relation triplet extraction model; and determine each relation triplet based on the relationship between each entity and any two entities.
[0091] The second determining module 42 is further configured to, if there are multiple attribute values of the same main attribute in the text data, when judging the relationship between any two entities, select the attribute value that is closest to the main attribute value of the two entities to construct the input of the relationship triplet extraction model and obtain the prediction result.
[0092] The construction module 43 is specifically used to create event entities. Based on the attribute triples, relation triples and the pre-defined connection relationships of event entities, it connects each entity, including the event entity, and fills in the attributes and attribute values of each entity, as well as the relationships between each entity, to obtain the event knowledge graph corresponding to the text data.
[0093] The construction module 43 is specifically used to convert the event knowledge graph into an undirected graph, expand or prune the undirected graph, and fix the size of the input graph; determine the adjacency matrix of the undirected graph; determine the representation vector of each entity in the event knowledge graph, and determine the feature matrix based on the representation vector of each entity; input the adjacency matrix and the feature matrix into a pre-trained event classification model, determine the category representation matrix based on the event classification model, and perform feature extraction on the category representation matrix to obtain the event category corresponding to the text data.
[0094] The construction module 43 is specifically used to determine the representation vector of each entity other than the event entity based on the attribute value of the main attribute of each entity; and to determine the representation vector of the event entity based on the representation vector of each entity connected to the event entity.
[0095] This application also provides an electronic device, such as Figure 5 As shown, it includes: processor 301, communication interface 302, memory 303 and communication bus 304, wherein processor 301, communication interface 302 and memory 303 communicate with each other through communication bus 304; The memory 303 stores a computer program, which, when executed by the processor 301, causes the processor 301 to perform any of the above method steps.
[0096] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0097] Communication interface 302 is used for communication between the above-mentioned electronic device and other devices.
[0098] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0099] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0100] This application also provides a computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform any of the above method steps.
[0101] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0102] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A knowledge graph-based multi-label event classification method, characterized in that, The method includes: Obtain text data, and determine the entities contained in the text data, the attributes of the entities, and the attribute values; Attribute triples and relation triples are determined based on each entity, the attributes of each entity, and the attribute values. Based on the attribute triples and relation triples, construct the event knowledge graph corresponding to the text data; The event knowledge graph is input into a pre-trained event classification model, and the event category corresponding to the text data is determined based on the event classification model. The process of determining attribute triples based on each entity, each entity's attributes, and attribute values includes: For each entity, determine the entity's type and the attribute values of its main attributes; The attribute value of the entity's main attribute and the attribute value of any attribute belonging to the entity's type in the text data are input into a pre-trained attribute triplet extraction model. Based on the attribute triplet extraction model, it is determined whether the attribute value of any attribute describes the entity. Based on the description of each attribute of the entity and its corresponding attribute value, determine each attribute triplet of the entity.
2. The method as described in claim 1, characterized in that, The process of determining the entities contained in the text data, the attributes of each entity, and the attribute values includes: The text data is converted into a first embedding vector, and the first embedding vector is input into the bidirectional encoder BERT model for encoding to obtain the encoded second embedding vector. The second embedding vector is decoded by segment enumeration to obtain the representation vector corresponding to each segment. Each representation vector is input into a trained semantic recognition model, and the entity, entity attributes, and attribute values corresponding to each representation vector are determined based on the semantic recognition model.
3. The method as described in claim 1, characterized in that, The method further includes: If multiple identical attribute values of a subject exist in the text data, the attribute value of the subject attribute that is closest to the attribute value to be judged is selected to construct the input of the attribute triple extraction model to obtain the prediction result.
4. The method as described in claim 1, characterized in that, The process of determining relation triples based on each entity, each entity's attributes, and attribute values includes: Determine the main attributes of each entity; input the attribute values of any two main attributes into a pre-trained relation triplet extraction model, and determine the relationship between the entities to which the two main attributes belong based on the relation triplet extraction model; Each relation triple is determined based on the entities and the relationships between any two entities.
5. The method as described in claim 4, characterized in that, The method further includes: If the text data contains multiple attribute values of the same main attribute, when judging the relationship between any two entities, the attribute value that is closest to the main attribute value of the two entities is selected to construct the input of the relationship triple extraction model to obtain the prediction result.
6. The method as described in claim 1, characterized in that, The step of constructing the event knowledge graph corresponding to the text data based on the attribute triples and relation triples includes: Create event entities, connect each entity including the event entity according to the attribute triples, relation triples and the pre-defined connection relationships of the event entities, and fill in the attributes and attribute values of each entity, as well as the relationships between the entities, to obtain the event knowledge graph corresponding to the text data.
7. The method as described in claim 6, characterized in that, The step of inputting the event knowledge graph into a pre-trained event classification model and determining the event category corresponding to the text data based on the event classification model includes: The event knowledge graph is converted into an undirected graph, which is then expanded or pruned while maintaining a fixed size. The adjacency matrix of the undirected graph is determined. The representation vectors of each entity in the event knowledge graph are determined, and the feature matrix is determined based on the representation vectors of each entity. The adjacency matrix and the feature matrix are input into a pre-trained event classification model. Based on the event classification model, a category representation matrix is determined, and features are extracted from the category representation matrix to obtain the event category corresponding to the text data.
8. The method as described in claim 7, characterized in that, Determining the representation vector of each entity in the event knowledge graph includes: For each entity other than the event entity, the representation vector of each entity is determined based on the attribute value of the main attribute of each entity. For the event entity, the representation vector of the event entity is determined based on the representation vectors of each entity connected to the event entity.
9. A knowledge graph-based event multi-label classification device, characterized in that, The device includes: The first determining module is used to acquire text data and determine each entity contained in the text data, the attributes of each entity, and the attribute values; The second determining module is used to determine attribute triples and relation triples based on each entity, the attributes of each entity, and the attribute values. The construction module is used to construct an event knowledge graph corresponding to the text data based on the attribute triples and relation triples. The classification module is used to input the event knowledge graph into a pre-trained event classification model and determine the event category corresponding to the text data based on the event classification model. The second determining module is specifically used to determine the type and attribute value of the main attribute of each entity; input the attribute value of the main attribute of the entity and the attribute value of any attribute belonging to the type of the entity in the text data into a pre-trained attribute triple extraction model, and determine whether the attribute value of any attribute describes the entity based on the attribute triple extraction model; and determine each attribute triple of the entity according to each attribute describing the entity and its corresponding attribute value.
10. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-8.