CN115905538A - Event multi-label classification method, device, equipment and medium based on knowledge graph - Google Patents

Event multi-label classification method, device, equipment and medium based on knowledge graph Download PDF

Info

Publication number
CN115905538A
CN115905538A CN202211601836.8A CN202211601836A CN115905538A CN 115905538 A CN115905538 A CN 115905538A CN 202211601836 A CN202211601836 A CN 202211601836A CN 115905538 A CN115905538 A CN 115905538A
Authority
CN
China
Prior art keywords
attribute
event
entity
determining
text data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211601836.8A
Other languages
Chinese (zh)
Inventor
陈丽红
范鹏召
刘伟棠
陈立力
周明伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202211601836.8A priority Critical patent/CN115905538A/en
Publication of CN115905538A publication Critical patent/CN115905538A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a knowledge graph-based event multi-label classification method, a knowledge graph-based event multi-label classification device, knowledge graph-based event multi-label classification equipment and a knowledge graph-based event multi-label classification medium. Attribute triples and relationship triples can contain more potential semantic information in the text data. Therefore, the event knowledge graph corresponding to the text data is constructed according to the attribute triples and the relation triples, the event category corresponding to the text data is determined based on the event classification model, and more semantic information can be mined to accurately classify the events. Compared with the technical scheme of event classification based on word vectors, keywords and other technical means, the accuracy of event classification is improved.

Description

Event multi-label classification method, device, equipment and medium based on knowledge graph
Technical Field
The present application relates to the field of natural language processing technologies, and in particular, to a method, an apparatus, a device, and a medium for event multi-label classification based on a knowledge graph.
Background
In recent years, with the rapid development of information technology, the construction work of network platforms in various regions is steadily promoted, and a new mode of civil services in the information age is opened. The event classification is carried out on the civil text data on the network platform, which is beneficial to relevant workers to carry out more effective civil service work and better classification management and storage of the civil text data.
With the development of natural language processing technology, some research has been focused on applying such technology to mine potential information in text data for text data analysis. The existing event classification methods adopt technical means such as word vectors, keywords and the like. The method has the problems that the capability of mining potential semantic information in text data by shallow word vectors and keywords is limited, and the accuracy of mining the semantic information in the text data is difficult to ensure for the problem of polysemy of a word, so that the accuracy of event classification cannot be ensured.
Disclosure of Invention
The embodiment of the application provides a knowledge graph-based event multi-label classification method, a knowledge graph-based event multi-label classification device, knowledge graph-based event multi-label classification equipment and a knowledge graph-based event multi-label classification medium, and aims to solve the problems that the existing scheme is limited in capability of mining semantic information in text data and accuracy of event classification cannot be guaranteed.
The application provides a knowledge graph-based event multi-label classification method, which comprises the following steps:
acquiring text data, and determining each entity contained in the text data, and the attribute value of each entity;
determining attribute triples and relationship triples according to the entities, the attributes and the attribute values of the entities;
constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples;
and inputting the event knowledge graph into a pre-trained event classification model, and determining an event category corresponding to the text data based on the event classification model.
Further, the determining of each entity contained in the text data, the attribute and the attribute value of each entity includes:
converting the text data into a first embedded vector, and inputting the first embedded vector into a BERT model of a bidirectional encoder for encoding to obtain a second encoded embedded vector;
decoding the second embedded vector in a fragment enumeration mode to obtain a characterization vector corresponding to each fragment;
and inputting each characterization vector into a trained semantic recognition model, and determining an entity, an attribute of the entity and an attribute value corresponding to each characterization vector based on the semantic recognition model.
Further, the determining an attribute triple according to the entities, the attributes of the entities, and the attribute values includes:
for each entity, determining the type of the entity and the attribute value of the body attribute;
inputting 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 judging whether the attribute value of any attribute describes the entity based on the attribute triple extraction model;
and determining each attribute triple of the entity according to each attribute describing the entity and the corresponding attribute value.
Further, the method further comprises:
and if the text data has a plurality of same attribute values of the main attribute, selecting the attribute value of the main attribute nearest to the attribute value to be judged to construct the input of the attribute triple extraction model, and obtaining a prediction result.
Further, the determining a relationship triple according to the entities, the attributes of the entities, and the attribute values includes:
determining respective subject attributes of the respective entities; inputting the attribute values of any two main body attributes into a pre-trained relation triple extraction model, and determining the relation between the entities to which the any two main body attributes belong based on the relation triple extraction model;
and determining each relation triple according to the relation between each entity and any two entities.
Further, the method further comprises:
and if the text data has a plurality of same attribute values of the main body attributes, selecting the most adjacent attribute values representing the main body attribute values of the two entities to construct the input of the relation triple extraction model when judging the relation of any two entities, and obtaining a prediction result.
Further, the constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples includes:
and creating event entities, connecting each entity including the event entities according to the connection relationship between the attribute triples, the relationship triples and the preset event entities, filling the attributes and the attribute values of each entity and the relationship among the entities, and obtaining an event knowledge graph corresponding to the text data.
Further, the inputting the event knowledge graph into a pre-trained event classification model, and the determining the event category corresponding to the text data based on the event classification model includes:
converting the event knowledge graph into a undirected graph, expanding or reducing the undirected graph, and fixing the scale of an input graph; determining a adjacency matrix of the undirected graph; determining a representation vector of each entity in the event knowledge graph, and determining a feature matrix according to the representation vector of each entity;
inputting the adjacency matrix and the feature matrix into a pre-trained event classification model, determining a category characterization matrix based on the event classification model, and performing feature extraction on the category characterization matrix to obtain an event category corresponding to the text data.
Further, the determining the characterization vectors of the respective entities in the event knowledge-graph comprises:
for each entity except the event entity, determining a characterization vector of each entity according to the attribute value of the main attribute of each entity;
and for the event entity, determining the characterization vector of the event entity according to the characterization vectors of all entities connected with the event entity.
In another aspect, the present application provides a knowledge-graph-based event multi-label classification apparatus, the apparatus comprising:
the first determining module is used for acquiring text data and determining each entity, and the attribute value of each entity contained in the text data;
the second determining module is used for determining the attribute triples and the relationship triples according to the entities, the attributes and the attribute values of the entities;
the construction module is used for constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples;
and the classification module is used for 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.
The first determining module is specifically used for converting the text data into a first embedded vector, and inputting the first embedded vector into a bidirectional encoder BERT model for encoding to obtain a second encoded embedded vector; decoding the second embedded vector in a fragment enumeration mode to obtain a characterization vector corresponding to each fragment; and inputting each characterization vector into a trained semantic recognition model, and determining an entity, an attribute of the entity and an attribute value corresponding to each characterization vector based on the semantic recognition model.
A second determining module, configured to determine, for each entity, a type of the entity and an attribute value of a body attribute; inputting 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 judging whether the attribute value of any attribute describes the entity based on the attribute triple extraction model; and determining each attribute triple of the entity according to each attribute describing the entity and the corresponding attribute value.
And the second determining module is further used for selecting the attribute value of the main attribute nearest to the attribute value to be judged to construct the input of the attribute triple extraction model if the text data has a plurality of identical attribute values of the main attribute, so as to obtain a prediction result.
A second determining module, configured to determine respective subject attributes of the entities; inputting the attribute values of any two main body attributes into a pre-trained relation triple extraction model, and determining the relation between the entities to which the any two main body attributes belong based on the relation triple extraction model; and determining each relationship triple according to the relationship between each entity and any two entities.
And the second determining module is further configured to, if a plurality of identical attribute values of the body attributes exist in the text data, select the most adjacent attribute value representing the body attribute values of the two entities to construct an input of the relationship triple extraction model when determining the relationship between any two entities, so as to obtain a prediction result.
And the construction module is specifically used for creating event entities, connecting each entity including the event entities according to the connection relationship between the attribute triples and the relationship triples and the preset event entities, filling the attributes and the attribute values of each entity and the relationship among the entities, and obtaining the event knowledge graph corresponding to the text data.
The construction module is specifically used for converting the event knowledge graph into a undirected graph, expanding or cutting the undirected graph, and fixing the scale of an input graph; determining a adjacency matrix of the undirected graph; determining a characteristic vector of each entity in the event knowledge graph, and determining a characteristic matrix according to the characteristic vector of each entity; inputting the adjacency matrix and the feature matrix into a pre-trained event classification model, determining a category characterization matrix based on the event classification model, and performing feature extraction on the category characterization matrix to obtain an event category corresponding to the text data.
A construction module, configured to determine, for each entity other than the event entity, a characterization vector of each entity according to an attribute value of a body attribute of each entity; and for the event entity, determining the characterization vector of the event entity according to the characterization vectors of all entities connected with the event entity.
In another aspect, the present application provides an electronic device, including a processor, a communication interface, a memory and a communication bus, where the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing any of the above method steps when executing a program stored in the memory.
In yet another aspect, the present application provides a computer readable storage medium having stored therein a computer program which, when executed by a processor, performs the method steps of any of the above.
The application provides a knowledge graph-based event multi-label classification method, a knowledge graph-based event multi-label classification device, knowledge graph-based event multi-label classification equipment and a knowledge graph-based event multi-label classification medium, wherein the method comprises the following steps: acquiring text data, and determining each entity contained in the text data, and the attribute value of each entity; determining attribute triples and relationship triples according to the entities, the attributes and the attribute values of the entities; constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relation triples; and inputting the event knowledge graph into a pre-trained event classification model, and determining an event category corresponding to the text data based on the event classification model.
The technical scheme has the following advantages or beneficial effects:
in the application, text data is obtained, and each entity contained in the text data, and the attribute value of each entity are determined, so that attribute triples and relationship triples are determined. Attribute triples and relationship triples can contain more potential semantic information in the text data. Therefore, the event knowledge graph corresponding to the text data is constructed according to the attribute triples and the relation triples, and then the event category corresponding to the text data is determined based on the event classification model, so that more semantic information can be mined, and the events can be accurately classified. Compared with the technical scheme of event classification based on word vectors, keywords and other technical means, the method improves the accuracy of event classification.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a schematic diagram of an event classification process provided herein;
FIG. 2 is an exemplary diagram of relational triple extraction inputs provided herein;
FIG. 3 is a schematic illustration of an event knowledge graph as provided herein;
FIG. 4 is a schematic structural diagram of an event classification device provided in the present application;
fig. 5 is a schematic structural diagram of an electronic device provided in the present application.
Detailed Description
To make the purpose and embodiments of the present application clearer, the following will clearly and completely describe the exemplary embodiments of the present application with reference to the attached drawings in the exemplary embodiments of the present application, and it is obvious that the described exemplary embodiments are only a part of the embodiments of the present application, and not all of the embodiments.
It should be noted that the brief descriptions of the terms in the present application are only for convenience of understanding of the embodiments described below, and are not intended to limit the embodiments of the present application. These terms should be understood in their ordinary and customary meaning unless otherwise indicated.
The terms "first," "second," "third," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between similar or analogous objects or entities and not necessarily for describing a particular sequential or chronological order, unless otherwise indicated. It is to be understood that the terms so used are interchangeable under appropriate circumstances.
The terms "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements is not necessarily limited to all elements expressly listed, but may include other elements not expressly listed or inherent to such product or apparatus.
The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and/or software code that is capable of performing the functionality associated with that element.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and these modifications or substitutions do not depart from the scope of the technical solutions of the embodiments of the present application.
The foregoing description, for purposes of explanation, has been presented in conjunction with specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the embodiments to the precise forms disclosed above. Many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles and the practical application, to thereby enable others skilled in the art to best utilize the embodiments and various embodiments with various modifications as are suited to the particular use contemplated.
FIG. 1 is a schematic diagram of a knowledge-graph-based event multi-label classification process provided by the present application, which includes the following steps:
s101: acquiring text data, and determining each entity, and the attribute value of each entity contained in the text data.
S102: and determining attribute triples and relationship triples according to the entities and the attributes and attribute values of the entities.
S103: and constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples.
S104: and inputting the event knowledge graph into a pre-trained event classification model, and determining an event category corresponding to the text data based on the event classification model.
The event classification method is applied to electronic equipment, and the electronic equipment can be equipment such as a PC (personal computer), a tablet personal computer and the like, and can also be a server.
The electronic device first obtains text data, which may be input to the electronic device by a user. The text data is, for example, text data under a civil service, educational text data, medical text data, or the like. After the electronic equipment acquires the text data, determining each entity contained in the text data, the attribute and the attribute value of each entity, determining attribute triples and relationship triples based on the determined information, further constructing an event knowledge graph, and finally finishing final event classification based on the knowledge graph.
The event knowledge graph is constructed, and firstly, entities, attributes and relationships contained in the event knowledge graph need to be defined in advance. Optionally, the entities include events, people, times, places, items, organizations, and the like. The event entity is an entity created in the application, and entity attributes do not exist in the event entity. Meanwhile, for entities other than the event entity, a plurality of attributes describing the entity may be included, for example, entity-person includes attributes such as name, gender, age, and person category, entity-item includes attributes such as item name, item size, and item value, and entity-organization includes attributes such as organization name and organization responsible person. The attribute value is specific content of the attribute, for example, attribute-gender attribute values include male or female, attribute-name attribute values include zhang san, lie siu, and the like, and attribute-age attribute values include 18 years, 20 years, and the like.
In addition, the subject attributes of each entity are predefined in the present application. The subject attribute of an entity refers to the attribute which is relatively most capable of representing the distinctiveness of the entity in the attributes of the entity, such as the name of an entity-person is the subject attribute, and the name of an entity-article is the subject attribute. Another important component of the event knowledge-graph structure is the relationship between entities. Optionally, examples given in this application include an association relationship between an event and a person, an belonging relationship between a person and an organization, a social relationship between persons, and the like, for example, a couple, a neighbor, a sister, and the like. Table 1 is an example of entity types and body attributes provided herein, and table 2 is an example of relationship types between entities provided herein. It should be noted that table 1 and table 2 are only examples of the present application, and the present application does not limit specific entity types and relationship types.
Numbering EntityTypes of Entity label Subject Properties Body attribute tag
1 Event(s) event Is free of Is composed of
2 Person(s) person Name(s) personName
3 Time time Time of a kitchen eventTime
4 Location of a site address Location of case eventAddress
5 Article with a cover thing Name of article thingName
6 Tissue of organization Organization name organizationName
…… …… …… ……
TABLE 1
Figure SMS_1
Figure SMS_2
TABLE 2
The electronic device predefines entities, attributes, and relationships contained by the event knowledge graph. And during event classification, after the text data is acquired, determining each entity contained in the text data, and the attribute value of each entity. The method can determine each entity in the text data, and the attribute value of each entity in the text data by combining a BERT model and a fragment enumeration Span.
And after determining each entity, each attribute and each attribute value of each entity in the text data, determining attribute triples and relationship triples. The attribute triples comprise entities, attributes and attribute values, and the relationship triples comprise entities 1, entities 2 and relationships between the two.
In determining the attribute triples of each entity, for each entity, a type of the entity is first determined, for example, the type of the entity is a person, an item, and the like. Then, the respective attributes in the text data belonging to the entity type are determined. Taking the type of the entity as a person as an example, the various attributes belonging to the entity type include name, gender, age, person category, and the like. Then, it is necessary to determine whether the attribute values of the attributes in the text data describe the same entity. For example, if the text data includes two human entities, namely, zhang three and lie four, and includes a gender attribute and an age attribute, it is necessary to determine which attribute value describes zhang three and which attribute value describes lie four.
The attribute triple extraction model may be trained in advance, and based on the attribute triple extraction model, it is determined which attribute values of the attributes describe the same entity. When training the attribute triple extraction model, a first training set may be saved, where the first training set includes attribute values of the respective sample attributes, and tag information of entities described by the attribute values of the respective sample attributes, where the tag information indicates which specific entity is described by the attribute values of the sample attributes. And training the attribute triple extraction model based on the attribute values and the label information of the sample attributes in the first training set.
When determining the relationship triples of each entity, for any two entities, selecting respective subject attributes of the two entities, inputting the respective subject attributes into a pre-trained relationship triplet extraction model, and determining the relationship between the two entities based on the relationship triplet extraction model. And then establishing a relation triple according to the entities and the relation among the entities.
When the relationship triplet extraction model is trained, a second training set may be stored, where the second training set includes each sample attribute and label information of a relationship between entities to which each sample attribute belongs, and the label information indicates a relationship between specific entities described by the sample attributes. And training the relation triple extraction model based on the attributes and the label information of each sample in the second training set.
And after the attribute triples and the relation triples are determined, establishing event knowledge maps corresponding to the text data according to the attribute triples and the relation triples. The event knowledge graph comprises all entities, attributes and attribute values of all the entities and relations among all the entities.
And inputting the event knowledge graph into a pre-trained event classification model, and determining an event category corresponding to the text data based on the event classification model. The event category is, for example, city management, disputes, and the like.
When the event classification model is trained, the electronic equipment stores a third training set, the third training set comprises each sample event knowledge graph and corresponding event class label information, and the sample event knowledge graphs and the corresponding event class label information are input into the event classification model to complete the training of the event classification model.
In the application, text data is obtained, each entity contained in the text data, and the attribute value of each entity are determined, so that attribute triples and relationship triples are determined. Attribute triples and relationship triples can contain more potential semantic information in the text data. Therefore, the event knowledge graph corresponding to the text data is constructed according to the attribute triples and the relation triples, the event category corresponding to the text data is determined based on the event classification model, and more semantic information can be mined to accurately classify the events. Compared with the technical scheme of event classification based on word vectors, keywords and other technical means, the accuracy of event classification is improved.
In order to make determining each entity and attribute value of each entity contained in text data more accurate, in the present application, the determining each entity and attribute value of each entity contained in the text data includes:
converting the text data into a first embedded vector, and inputting the first embedded vector into a BERT model of a bidirectional encoder for encoding to obtain a second encoded embedded vector;
decoding the second embedded vector in a fragment enumeration mode to obtain a characterization vector corresponding to each fragment;
and inputting each characterization vector into the trained semantic recognition model, and determining an entity, an attribute of the entity and an attribute value of the entity corresponding to each characterization vector based on the semantic recognition model.
In this applicationFirstly, converting text data into a first embedded vector to construct an input E of a BERT model of a bidirectional encoder input . The structural formula is as follows:
E input =E token +E segment +E position
wherein E is token Representing word-embedded vectors, obtained by encoding text data using the word2vec model used to generate word vectors, E segment Representing segment embedding vectors, E position And representing a position embedding vector, and coding the position where each mark token is located.
Embedding the first embedded vector E input And inputting a BERT model for coding to obtain a coded second embedded vector. Application of deep BERT model E input And coding is carried out, and the obtained second embedded vector has richer semantic information and stronger representation capability.
And then decoding the second embedded vector in a fragment enumeration mode to obtain the characterization vectors corresponding to the fragments, inputting the characterization vectors into the trained semantic recognition model after determining the characterization vectors corresponding to the fragments, and determining the entities corresponding to the characterization vectors, the attributes and the attribute values of the entities based on the semantic recognition model.
For example, the maximum segment length max _ span _ length is set to 15, which is customizable. Segment enumeration, i.e. enumerating all possible segments in the text data, classifies these segments. For segment i, its final token vector h i From its start token's embedded vector x start(i) Ending the embedded vector x of token end[i] And model learning derived segment length embedding vector splicing phi i And the following steps:
h i =[x start(i) ;x end[i] ;φ i ];
token vector h i Activation by the softmax function through a full-junction layer, resulting in the final class of fragments, i.e. z = softmax (Wh) i ). Wherein, W is a weight coefficient matrix. The final category includes the instance type and the attributes and attribute values of the entityAny one of them. It should be noted that there is a possibility that there is no category in some segments, that is, the recognition result of the segment is not within the preset range of the subject type, attribute, and attribute value.
In order to make determining the attribute triple more accurate, in the present application, the determining the attribute triple according to the entities, the attributes of the entities, and the attribute values includes:
determining attribute values of the type and the subject attribute of the entity for the respective entities;
inputting 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 judging whether the attribute value of any attribute describes the entity based on the attribute triple extraction model;
and determining each attribute triple of the entity according to each attribute describing the entity and the corresponding attribute value.
In the method, for attribute triple extraction, an attribute value of a main attribute represents a certain entity, the attribute value is respectively combined with attribute values of other attributes of the entity in pairs, a position label is added, text truncation processing is carried out, model input is constructed, and only whether the two combined attribute values describe the same entity is judged as a binary classification problem.
It should be noted that, if a plurality of identical attribute values of the subject attribute exist in the text data, the attribute value of the subject attribute nearest to the attribute value to be determined is selected to construct the input of the attribute triple extraction model, and the prediction result is obtained.
For example, the text data is "× 18 × three ×," two identical attribute values of the main body attribute "three", the attribute value to be determined is "18 years", the attribute value of the main body attribute nearest to the attribute value to be determined is the first three, 18 years and the first three are taken as the input of the attribute triple extraction model, and whether 18 years describes three is determined based on the attribute triple extraction model.
In order to make the determination of the relationship triple more accurate, in the present application, the determining the relationship triple according to the entities, the attributes of the entities, and the attribute values includes:
determining respective subject attributes of the respective entities; inputting the attribute values of any two main body attributes into a pre-trained relation triple extraction model, and determining the relation between the entities to which the any two main body attributes belong based on the relation triple extraction model;
and determining each relationship triple according to the relationship between each entity and any two entities.
For the extraction of the relation triples, the attribute values of the main attributes represent a certain entity, every two of the main attributes are combined, the position tags are added, text truncation processing is carried out, model input is constructed, and the entity is regarded as a multi-classification problem due to the fact that various relations exist among the entities.
Taking the extraction of the relationship triples as an example, the construction method is as follows: existing event text data "12/7/4/2022, large truck with license plate XXX in a certain driving is parked on the XX road, which causes traffic congestion. "the entity recognition result includes the attribute value of the body attribute personName of an entity person characterized by" lie certain ", and the input can be constructed with the attribute value of the body attribute thingName of an entity thing characterized by" van ", and the relationship between the two can be judged. Specifically, corresponding labels are added before and after the attribute value, respectively, and periods are used. And' performing truncation processing on the text for the mark. The constituent inputs are shown in FIG. 2. The [ CLS ] label before each input instance in FIG. 2 is a common way to process the following BERT model, and is used as a semantic representation vector of the whole input. After completing input construction, the input embedded vector of the BERT model is obtained through conversion.
It should be noted that, if there are multiple identical attribute values of the body attribute in the text data, when the relationship between any two entities is determined, the most adjacent attribute value representing the body attribute values of the two entities is selected to construct the input of the relational triple extraction model, and a prediction result is obtained.
For example, the text data is "× × plectrum four", the text data has two attribute values "plectrum four" of the same main attribute, and when the relationship between two entities "plectrum four and van" is judged, the van and the first plectrum four are used as the input of the relational triple extraction model, and the relationship between the plectrum four and the van is determined based on the relational triple extraction model.
Model main body architectures adopted by the attribute triple extraction and the relation triple extraction are consistent, the BERT model is also utilized to learn and output embedded vectors of tokens in event text data, and further, for two attribute values with labels in input, a final characterization vector H is provided i For the average of the embedding vectors for each token contained in the attribute value, the formula is as follows:
H i =average(h start(i) +...+h end(i) )。
and the final token vector of the whole input is represented by [ CLS]Embedding vector of label and characterization vector H of two attribute values i And H j Splicing to obtain:
H=[H cls ;H i ;H j ]。
regarding the attribute triple extraction task, the task is regarded as a binary classification problem, and the number of classes is set to 2. And the relational triple extracting task is determined by the number of relational categories contained in the event knowledge graph structure. The classification result calculation formula is as follows: z is a radical of type =softmax(W type H) In that respect And respectively constructing attribute triples and relationship triples according to the classification result.
In this application, in order to make the construction of the event knowledge graph more accurate, the constructing of the event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples includes:
and creating event entities, connecting each entity including the event entities according to the connection relationship between the attribute triples, the relationship triples and the preset event entities, filling the attributes and the attribute values of each entity and the relationship among the entities, and obtaining an event knowledge graph corresponding to the text data.
And for the text data, determining attribute triples and relation triples of the text data according to the process. And then creating an event entity which does not have any attribute value and is used for representing input event text data and finishing mapping of the main body attribute to the entity, if the personName attribute value exists, judging that an entity person exists, finishing entity attribute filling and relation connection according to the attribute triples and the relation triples to obtain an event knowledge graph corresponding to the text data.
FIG. 3 is a schematic view of an event knowledge graph provided by the present application, as shown in FIG. 3, with entities including people 1, people 2, time, location, personal injury, and property injury. Person 1, person 2, time, location, personal injury, and property injury each include an attribute and an attribute value. The relationship of person 1 to personal damage is suffered, and the relationship of person 1 to property damage is suffered. The relationship of personnel 2 to personal damage is cause, and the relationship of personnel 2 to property damage is cause. Creating an event entity, and establishing a connection relationship between the event entity and the personnel 1 and 2 as well as between the event entity and the time and the place as well as between the event entity and the place.
In order to make the determination of the event category corresponding to the text data more accurate, in the present application, the 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:
converting the event knowledge graph into a directed graph, expanding or reducing the directed graph, and fixing the scale of an input graph; determining a adjacency matrix of the undirected graph; determining a representation vector of each entity in the event knowledge graph, and determining a feature matrix according to the representation vector of each entity;
inputting the adjacency matrix and the feature matrix into a pre-trained event classification model, determining a category characterization matrix based on the event classification model, and performing feature extraction on the category characterization matrix to obtain an event category corresponding to the text data.
Wherein the determining the characterization vectors for the respective entities in the event knowledge-graph comprises:
for each entity except the event entity, determining a characterization vector of each entity according to the attribute value of the main attribute of each entity;
and for the event entity, determining the characterization vector of the event entity according to the characterization vectors of all entities connected with the event entity.
In the application, after the event knowledge graph is constructed, the attributes and specific attribute values contained in the entities in the knowledge graph can reflect the main semantic information contained in the event text data, and the relationship among the entities can well reflect the overall structure context of the event. In the application, event label prediction is carried out by applying a graph convolution neural network GCN, and semantic information and structural information in an event text are captured at the same time.
Specifically, the event knowledge graph is converted into an undirected graph ori _ G, and in consideration of the fact that the number of entities contained in different events is inconsistent, in order to unify model input, the graph structure is further expanded or reduced to obtain the undirected graph G with the fixed-size node number of N. Specifically, the extension is naturally embodied in the subsequent adjacency matrix of fixed size without additional operation, and the clipping is obtained by random walk sampling starting from the event entity in a random walk sampling manner. The nodes of the graph are marked with serial numbers, particularly, the event entity node is marked with 0, and the marks of the rest entity nodes can be randomly disturbed to obtain an adjacent matrix A representing the undirected graph. Further, a feature matrix X is constructed, and except for the event entity, the feature vectors of other entities are all the feature vectors h of the attribute values of the main attributes of the entities i . The feature vector of an event entity is the average of the feature vectors of its neighboring entities. The feature Z can be extracted by two layers of GCN:
Figure SMS_3
/>
wherein
Figure SMS_4
The adjacent matrix A is normalized, W (0) And W (1) Respectively representing the weights to be trained in the two layers of GCNs.
Thus, the characterization vector Z of the event entity is 0 I.e. the first line vector in feature Z, is considered as a characterization vector for the entire event to predict the event class label. Considering that multiple tags may be involved in an event, for example, an event may belong to both city management and contradiction disputes, a multi-tag classification problem is considered. Token vector Z 0 Is 1 x F, where F represents the number of event categories. And (4) independently activating each category of dimensions by using a sigmoid activation function, and judging whether the event belongs to the category, namely whether the event contains the type of tags.
In the method, the event text data are converted into the event knowledge graph, the structural association among entities involved in the event text is mined, and the graph convolution neural network is further utilized to capture potential semantic information and structural information in the event at the same time so as to perform better event category label prediction.
According to the method and the device, BERT models are applied to encoding elements in event texts in the processes of named entity identification, attribute triple extraction and relation triple extraction, a shallower word2vec word vector model has stronger representation capability, and the defects that the same word is statically encoded by the word2vec model and cannot be combined with context semantic information can be overcome.
The event label prediction method considers the phenomenon that one event may have a plurality of class labels, and the event label prediction is carried out as a multi-label classification problem, so that the method is more suitable for the actual situation compared with the operation of carrying out multi-classification on the event in many traditional methods.
Fig. 4 is a schematic structural diagram of an event classification device provided in the present application, where the device includes:
a first determining module 41, configured to obtain text data, and determine each entity, and an attribute value of each entity included in the text data;
a second determining module 42, configured to determine attribute triples and relationship triples according to the entities, the attributes, and the attribute values of the entities;
a building module 43, configured to build an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples;
and the classification module 44 is configured to input the event knowledge graph into a pre-trained event classification model, and determine an event category corresponding to the text data based on the event classification model.
A first determining module 41, configured to convert the text data into a first embedded vector, and input the first embedded vector into a BERT model of a bi-directional encoder for encoding to obtain a second encoded embedded vector; decoding the second embedded vector in a fragment enumeration mode to obtain a characterization vector corresponding to each fragment; and inputting each characterization vector into a trained semantic recognition model, and determining an entity, an attribute of the entity and an attribute value corresponding to each characterization vector based on the semantic recognition model.
A second determining module 42, specifically configured to determine, for each entity, a type of the entity and an attribute value of a subject attribute; inputting 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 judging whether the attribute value of any attribute describes the entity based on the attribute triple extraction model; and determining each attribute triple of the entity according to each attribute describing the entity and the corresponding attribute value.
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 an attribute value of the subject attribute nearest to the attribute value to be determined to construct an input of the attribute triple extraction model, so as to obtain a prediction result.
A second determining module 42, specifically configured to determine respective subject attributes of the entities; inputting the attribute values of any two main body attributes into a pre-trained relation triple extraction model, and determining the relation between the entities to which the any two main body attributes belong based on the relation triple extraction model; and determining each relation triple according to the relation between each entity and any two entities.
The second determining module 42 is further configured to, if a plurality of identical attribute values of the subject attribute exist in the text data, select an attribute value representing the subject attribute value of any two entities and the most adjacent attribute value, when determining the relationship between the two entities, to construct an input of the relationship triple extraction model, so as to obtain a prediction result.
The building module 43 is specifically configured to create an event entity, connect the entities including the event entity according to the connection relationship between the attribute triple, the relationship triple and the preset event entity, and fill the attribute and the attribute value of each entity and the relationship between the entities to obtain the event knowledge graph corresponding to the text data.
A construction module 43, specifically configured to convert the event knowledge graph into a undirected graph, expand or reduce the undirected graph, and fix the scale of the input graph; determining a adjacency matrix of the undirected graph; determining a representation vector of each entity in the event knowledge graph, and determining a feature matrix according to the representation vector of each entity; inputting the adjacency matrix and the feature matrix into a pre-trained event classification model, determining a category characterization matrix based on the event classification model, and performing feature extraction on the category characterization matrix to obtain an event category corresponding to the text data.
A building module 43, specifically configured to determine, for each entity other than the event entity, a characterization vector of each entity according to an attribute value of a body attribute of each entity; and for the event entity, determining the characterization vector of the event entity according to the characterization vectors of all entities connected with the event entity.
The present application also provides an electronic device, as shown in fig. 5, including: the system comprises a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 complete mutual communication through the communication bus 304;
the memory 303 has stored therein a computer program which, when executed by the processor 301, causes the processor 301 to perform any of the above method steps.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface 302 is used for communication between the above-described electronic apparatus and other apparatuses.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a central processing unit, a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc.
A computer-storage-readable storage medium is provided, in which a computer program executable by an electronic device is stored, which program, when run on the electronic device, causes the electronic device to carry out any of the above method steps when executed.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all changes and modifications that fall within the scope of the present application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (12)

1. A knowledge graph-based event multi-label classification method, characterized in that the method comprises the following steps:
acquiring text data, and determining each entity contained in the text data, and the attribute value of each entity;
determining attribute triples and relationship triples according to the entities, the attributes and the attribute values of the entities;
constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship 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.
2. The method of claim 1, wherein the determining of the respective entities, the attributes and attribute values of the respective entities contained in the text data comprises:
converting the text data into a first embedded vector, and inputting the first embedded vector into a BERT model of a bidirectional encoder for encoding to obtain a second encoded embedded vector;
decoding the second embedded vector in a fragment enumeration mode to obtain a characterization vector corresponding to each fragment;
and inputting each characterization vector into a trained semantic recognition model, and determining an entity, an attribute of the entity and an attribute value corresponding to each characterization vector based on the semantic recognition model.
3. The method of claim 1, wherein said determining an attribute triple from the respective entity, the attribute of the respective entity, and the attribute value comprises:
determining attribute values of the type and the subject attribute of the entity for the respective entities;
inputting 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 judging whether the attribute value of any attribute describes the entity based on the attribute triple extraction model;
and determining each attribute triple of the entity according to each attribute describing the entity and the corresponding attribute value.
4. The method of claim 3, wherein the method further comprises:
and if the text data has a plurality of same attribute values of the main attribute, selecting the attribute value of the main attribute nearest to the attribute value to be judged to construct the input of the attribute triple extraction model, and obtaining a prediction result.
5. The method of claim 1, wherein said determining a relationship triplet as a function of the respective entity, the attributes of the respective entity, and the attribute values comprises:
determining respective subject attributes of the respective entities; inputting the attribute values of any two main body attributes into a pre-trained relation triple extraction model, and determining the relation between the entities to which the any two main body attributes belong based on the relation triple extraction model;
and determining each relation triple according to the relation between each entity and any two entities.
6. The method of claim 5, wherein the method further comprises:
and if the text data has a plurality of same attribute values of the main body attributes, selecting the most adjacent attribute values representing the main body attribute values of the two entities to construct the input of the relation triple extraction model when judging the relation of any two entities, and obtaining a prediction result.
7. The method of claim 1, wherein the constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relationship triples comprises:
and creating event entities, connecting each entity including the event entities according to the connection relationship between the attribute triples, the relationship triples and the preset event entities, filling the attributes and the attribute values of each entity and the relationship among the entities, and obtaining an event knowledge graph corresponding to the text data.
8. The method of claim 7, wherein the inputting the event knowledge graph into a pre-trained event classification model, and the determining the event category corresponding to the text data based on the event classification model comprises:
converting the event knowledge graph into a undirected graph, expanding or reducing the undirected graph, and fixing the scale of an input graph; determining a adjacency matrix of the undirected graph; determining a representation vector of each entity in the event knowledge graph, and determining a feature matrix according to the representation vector of each entity;
inputting the adjacency matrix and the feature matrix into a pre-trained event classification model, determining a category characterization matrix based on the event classification model, and performing feature extraction on the category characterization matrix to obtain an event category corresponding to the text data.
9. The method of claim 8, wherein the determining the characterization vectors for the respective entities in the event knowledgegraph comprises:
for each entity except the event entity, determining a characterization vector of each entity according to the attribute value of the main attribute of each entity;
and for the event entity, determining the characterization vector of the event entity according to the characterization vectors of all entities connected with the event entity.
10. A knowledge-graph based event multi-label classification apparatus, the apparatus comprising:
the first determining module is used for acquiring text data and determining each entity, and the attribute value of each entity contained in the text data;
the second determining module is used for determining the attribute triples and the relationship triples according to the entities, the attributes and the attribute values of the entities;
the construction module is used for constructing an event knowledge graph corresponding to the text data according to the attribute triples and the relation triples;
and the classification module is used for 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.
11. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 9 when executing a program stored in the memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 9.
CN202211601836.8A 2022-12-13 2022-12-13 Event multi-label classification method, device, equipment and medium based on knowledge graph Pending CN115905538A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211601836.8A CN115905538A (en) 2022-12-13 2022-12-13 Event multi-label classification method, device, equipment and medium based on knowledge graph

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211601836.8A CN115905538A (en) 2022-12-13 2022-12-13 Event multi-label classification method, device, equipment and medium based on knowledge graph

Publications (1)

Publication Number Publication Date
CN115905538A true CN115905538A (en) 2023-04-04

Family

ID=86493168

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211601836.8A Pending CN115905538A (en) 2022-12-13 2022-12-13 Event multi-label classification method, device, equipment and medium based on knowledge graph

Country Status (1)

Country Link
CN (1) CN115905538A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116090560A (en) * 2023-04-06 2023-05-09 北京大学深圳研究生院 Knowledge graph establishment method, device and system based on teaching materials
CN116703682A (en) * 2023-08-08 2023-09-05 菏泽市牡丹区大数据中心 Government affair data platform based on deep learning

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116090560A (en) * 2023-04-06 2023-05-09 北京大学深圳研究生院 Knowledge graph establishment method, device and system based on teaching materials
CN116703682A (en) * 2023-08-08 2023-09-05 菏泽市牡丹区大数据中心 Government affair data platform based on deep learning
CN116703682B (en) * 2023-08-08 2023-10-31 菏泽市牡丹区大数据中心 Government affair data platform based on deep learning

Similar Documents

Publication Publication Date Title
CN109740620B (en) Method, device, equipment and storage medium for establishing crowd figure classification model
CN110827929B (en) Disease classification code recognition method and device, computer equipment and storage medium
CN115905538A (en) Event multi-label classification method, device, equipment and medium based on knowledge graph
WO2021139191A1 (en) Method for data labeling and apparatus for data labeling
CN111177326A (en) Key information extraction method and device based on fine labeling text and storage medium
CN109978060B (en) Training method and device of natural language element extraction model
CN109871452B (en) Method, apparatus and storage medium for determining crime characteristics
CN111476023A (en) Method and device for identifying entity relationship
CN112988963B (en) User intention prediction method, device, equipment and medium based on multi-flow nodes
CN110929524A (en) Data screening method, device, equipment and computer readable storage medium
CN113360654A (en) Text classification method and device, electronic equipment and readable storage medium
CN112071429A (en) Medical automatic question-answering system construction method based on knowledge graph
CN114331122A (en) Key person risk level assessment method and related equipment
CN114880449B (en) Method and device for generating answers of intelligent questions and answers, electronic equipment and storage medium
CN111985207A (en) Method and device for acquiring access control policy and electronic equipment
CN116433969A (en) Zero sample image recognition method, system and storable medium
CN114428860A (en) Pre-hospital emergency case text recognition method and device, terminal and storage medium
CN114840684A (en) Map construction method, device and equipment based on medical entity and storage medium
CN114722196A (en) Enterprise text multi-label labeling method and system based on attention mechanism
CN113918704A (en) Question-answering method and device based on machine learning, electronic equipment and medium
CN116703682B (en) Government affair data platform based on deep learning
CN115859989A (en) Entity identification method and system based on remote supervision
CN113590846B (en) Legal knowledge map construction method and related equipment
CN114398482A (en) Dictionary construction method and device, electronic equipment and storage medium
CN113515591A (en) Text bad information identification method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination