A method, system, device, and storage medium for joint extraction of Chinese entity relations
By using the Chinese pre-trained models ZEN and GCN network, and combining scenic spot files and address files as dictionaries, a joint Chinese entity relation extraction method is constructed. This method solves the problem of low accuracy of Chinese entity relation extraction models caused by the differences in the characteristics of Chinese and English languages, and improves the accuracy and recall of entity relation extraction. It is applicable to Chinese tourism text data.
Patent Information
- Application Number
- CN202211350139.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-10-31
AI Technical Summary
Due to the differences in the characteristics of Chinese and English languages, existing technologies lack entity relation extraction models for Chinese corpora in the tourism field, resulting in low accuracy and recall rates for Chinese entity relation extraction models.
We employ the Chinese pre-trained models ZEN and GCN networks, combined with scenic spot files and address files as dictionaries, and construct a joint Chinese entity relationship extraction method through text embedding representation, syntactic dependency analysis, and entity span representation to improve the accuracy of entity recognition and relationship classification.
By integrating entity type and grammatical information, the accuracy of Chinese entity relation extraction is improved, the workload of manual annotation is reduced, and the accuracy of preliminary entity annotation is enhanced, making it suitable for Chinese tourism text data.
Smart Images

Figure CN115600605B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology and relates to a method, system, device and storage medium for joint extraction of Chinese entity relations. Background Technology
[0002] The advent of the big data era has generated massive amounts of data in people's daily lives, such as news reports, blogs, forums, research literature, and social media comments. The overlap between data domains is prominent, and valuable information is often hidden within these vast amounts of data. Information extraction (IE) aims to quickly and efficiently extract valuable information from these large datasets. Entity relation joint extraction, as a core task of information extraction, has received widespread attention from academia and industry in recent years. By modeling textual information, entity relation joint extraction automatically identifies entities, entity types, and specific relationship types between entities, providing fundamental support for downstream tasks such as knowledge graph construction, intelligent question answering, and semantic search.
[0003] Based on the degree of reliance on manually labeled data, the mainstream entity relation extraction methods are mainly divided into three types: supervised learning methods, semi-supervised learning methods, and unsupervised learning methods.
[0004] While unsupervised entity relation extraction methods do not require any labeled data, greatly reducing manual costs, the boundaries of the clustered relation categories are not clear enough, the overall accuracy of the model is low, and low-frequency relation instances result in low recall.
[0005] Entity relation extraction methods based on semi-supervised learning can alleviate the model's dependence on labeled data to some extent. Currently, the most widely used semi-supervised learning-based entity relation extraction algorithm is the Bootstrapping algorithm. However, this method suffers from semantic drift and is easily affected by the quality of the initial seed.
[0006] In supervised entity relation extraction research, the first step is to obtain a large amount of manually labeled data, then train a model based on this data, and apply the model to different domains. The advantage is that the model has high accuracy, but the disadvantage is that it requires a large amount of manually labeled data.
[0007] With the development of neural networks, a large number of researchers have begun to use neural network-based methods. Neural networks possess excellent feature learning capabilities, and entity relation extraction based on neural networks can be categorized structurally into pipeline models and joint models. Currently, there is considerable research on entity relation extraction from English corpora. However, the differences in language characteristics between Chinese and English mean that Chinese entity relation extraction models cannot be directly applied to English-related research models. Therefore, there is still significant room for research in this area. Furthermore, in the current tourism sector, travel recommendation is a hot topic, making research on entity relation extraction in this field crucial for solving the travel recommendation problem. Summary of the Invention
[0008] The purpose of this invention is to address the problem that existing technologies for entity relation extraction from corpora mainly target English corpora. Due to the differences in the characteristics of Chinese and English languages, no corresponding entity relation extraction model has been established for Chinese corpora in the tourism field. This invention provides a method, system, device, and storage medium for joint extraction of Chinese entity relations.
[0009] To achieve the above objectives, the present invention employs the following technical solution:
[0010] A method for joint extraction of Chinese entity relations includes the following steps:
[0011] Obtain data and information from travel websites;
[0012] Preprocess the data to obtain a dataset;
[0013] Perform text embedding and entity span representation on each text in the dataset to obtain entity width representation and entity representation with contextual semantic information;
[0014] Entity recognition and entity type matrix construction are performed based on entity span representation, entity width representation, and contextual semantic information.
[0015] Extract grammatical information, perform grammatical dependency analysis on each text, use entity span representation as the feature of each node in the syntax tree, calculate word vector representation containing grammatical information, and obtain entity span representation with grammatical information;
[0016] A new entity span representation is obtained by fusing the entity span representation and the entity span representation with syntactic information. The non-entity part in the middle of the entity span representation is pooled to obtain local text information. The new entity span representation, entity type matrix, entity width representation and local text information representation are concatenated as input to the relation classifier to obtain the relation classification result.
[0017] A further improvement of the present invention is that:
[0018] The process of preprocessing the data to obtain a dataset specifically includes the following steps:
[0019] The acquired data is filtered to generate attraction files, address files, and text files;
[0020] Use the attraction files and address files as dictionary files to identify entities, and define entity categories and relationship categories;
[0021] Natural language processing tools are used to segment the text and perform preliminary entity annotation. Relationship extraction rules are defined based on entity category and relation category to perform preliminary entity relation extraction.
[0022] The entity annotation results are corrected and supplemented by manual annotation to complete the annotation and generate a dataset.
[0023] The entity categories include location, administrative region category, climate conditions, attraction, level, person, attraction type, attraction ticket, and activity; the relationship categories include location, part, and inheritance.
[0024] The process of performing text embedding representation and entity span representation on each text in the dataset specifically includes the following steps:
[0025] Each text in the dataset is input into the Chinese pre-trained model ZEN, and labels are added to the beginning and end of each text.
[0026] Convert the characters in each text into their corresponding numerical identifiers to obtain the text embedding representation;
[0027] Obtain the vector representation of each character and calculate the character representation with contextual semantic relationships;
[0028] The entity span is represented by max pooling.
[0029] The entity recognition and entity type matrix construction specifically include the following steps:
[0030] The entity span representation, entity width representation, and contextual semantic information are concatenated, and the concatenated result is reduced in dimensionality to obtain the final vector representation.
[0031] The final vector representation is fed into the entity classifier through the activation function to identify entities and obtain the entity classification result.
[0032] The final vector representation and the entity span representation are subjected to attention operations to generate an entity type matrix with contextual semantic information.
[0033] The extraction of syntax information specifically includes the following steps:
[0034] The Stanza tool is used to perform syntactic dependency analysis on the input text to generate a syntactic dependency tree.
[0035] The entity span is represented as a feature of the corresponding node in the syntactic dependency tree;
[0036] The features of the grammatical dependency tree and corresponding nodes are input into the GCN network, and the resulting word vector representations with grammatical information are obtained after computation.
[0037] Finally, max pooling is used to obtain the entity span representation with syntactic information.
[0038] The relationship classification results are obtained through the following steps:
[0039] The entity span representation and the entity span representation with syntactic information are fused together using a fusion function to obtain a new entity span representation;
[0040] Entity pairs are formed by using a relational mask matrix and an entity span representation. Then, the entity type representation and entity width representation of each entity in the entity pair are obtained based on the entity type matrix and the entity width representation.
[0041] The character representation of the non-entity part between two entities is reduced in dimensionality by max pooling and then fused with the corresponding entity span representation with syntactic information to obtain a local text information representation.
[0042] The new entity span representation, entity type matrix, entity width representation, and local text information representation are concatenated as input to the relation classifier to obtain the relation classification result.
[0043] A Chinese entity relation joint extraction system, comprising:
[0044] The data acquisition module is used to acquire data information from tourism websites;
[0045] A data preprocessing module is used to preprocess data information to obtain a dataset;
[0046] The first data processing module is used to perform text embedding representation and entity span representation on each text in the dataset, and to obtain entity width representation and contextual semantic information of the entity representation.
[0047] The second data processing module is used to perform entity recognition and entity type matrix construction based on entity span representation, entity width representation and contextual semantic information.
[0048] The grammar extraction module is used to extract grammatical information, perform grammatical dependency analysis on each text, use entity span representation as the feature of each node of the syntax tree, calculate word vector representation containing grammatical information, and obtain entity span representation with grammatical information.
[0049] The relation extraction module is used to obtain a new entity span representation by fusing entity span representation and entity span representation with syntactic information, pool the non-entity part in the middle of the entity span representation to obtain local text information, and concatenate the new entity span representation, entity type matrix, entity width representation and local text information representation as input to the relation classifier to obtain the relation classification result.
[0050] An apparatus includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the steps of the method as described in any of the preceding items.
[0051] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in any of the preceding claims.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] This invention proposes a joint extraction method for Chinese entity relations. By using the entity representation before classification as the entity type representation, and calculating with the entity representation, entity information is integrated into the entity type. At the same time, entity information is supplemented in the entity type dimension, thereby establishing an entity relation extraction method for Chinese tourism text data and improving the accuracy of entity relation extraction.
[0054] Furthermore, by using attraction files and address files as dictionary information to supplement natural language processing tools, the accuracy of initial entity annotation was improved, and the subsequent manual workload was reduced.
[0055] Furthermore, by employing the Chinese pre-trained model ZEN to produce word vector representations, it can better represent the latent information of Chinese words compared to the traditional BERT model.
[0056] Furthermore, by using this GCN network to compute text grammatical information, and then fusing the grammatical information with entity representation to obtain entity span representation with grammatical information, entity information can be supplemented in the grammatical dimension, entity feature representation can be enriched, and the accuracy of entity relation extraction can be effectively improved. Attached Figure Description
[0057] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0058] Figure 1 This is a schematic diagram of the Chinese entity relation joint extraction method of the present invention;
[0059] Figure 2 This is a schematic diagram of the Chinese entity relationship joint extraction system module of the present invention;
[0060] Figure 3 This is a flowchart illustrating the specific data information preprocessing process of the present invention.
[0061] Figure 4 This is a flowchart of the joint extraction of Chinese entity relations based on a pre-trained model in this invention;
[0062] Figure 5 Flowchart for obtaining entity span representation with grammatical information;
[0063] Figure 6 This is a structural diagram of a Chinese entity relation joint extraction model based on a pre-trained model. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0065] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0066] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0067] In the description of the embodiments of the present invention, it should be noted that if terms such as "upper," "lower," "horizontal," or "inner" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of the invention is in use, they are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, terms such as "first" and "second" are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0068] Furthermore, the use of the term "horizontal" does not imply that the component must be absolutely horizontal, but rather that it can be slightly tilted. For example, "horizontal" simply means that its direction is more horizontal than "vertical," and does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0069] In the description of the embodiments of the present invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention according to the specific circumstances.
[0070] The present invention will now be described in further detail with reference to the accompanying drawings:
[0071] See Figure 1 The flowchart below shows the Chinese entity relation joint extraction method of the present invention, which specifically includes the following steps:
[0072] S1, retrieve data information from travel websites.
[0073] S2, preprocess the data to obtain the dataset.
[0074] S2.1 Filter the acquired data to generate attraction files, address files, and text files;
[0075] S2.2, use the attraction files and address files as dictionary files for identifying entities, and define entity categories and relationship categories;
[0076] S2.3, use natural language processing tools to segment the text and perform preliminary annotation of entities, define relation extraction rules according to entity category and relation category, and perform preliminary extraction of entity relations;
[0077] S2.4 involves manually annotating, correcting and supplementing entity annotation results to complete the annotation and generate a dataset.
[0078] S3 performs text embedding representation and entity span representation on each text in the dataset.
[0079] S3.1 Input each text in the dataset into the Chinese pre-trained model ZEN, and add labels to the beginning and end of each text respectively;
[0080] S3.2, convert the characters in each text into corresponding numerical identifiers to obtain the text embedding representation;
[0081] S3.3, Obtain the vector representation of each character and calculate the character representation with contextual semantic relationships;
[0082] S3.4, the entity span is represented by max pooling.
[0083] S4 performs entity recognition and entity type matrix construction based on entity span representation, entity width representation, and entity representation of contextual semantic information.
[0084] S4.1, concatenate the entity span representation, entity width representation, and contextual semantic information entity representation, and reduce the dimensionality of the concatenated result to obtain the final vector representation;
[0085] S4.2, The final vector representation is fed into the entity classifier through the activation function to identify entities and obtain the entity classification result;
[0086] S4.3 performs an attention operation on the final vector representation and the entity span representation to generate an entity type matrix with contextual semantic information.
[0087] S5 extracts grammatical information, performs grammatical dependency analysis on each text, uses the entity span representation as the feature of each node in the syntax tree, calculates the word vector representation containing grammatical information, and obtains the entity span representation with grammatical information.
[0088] S5.1 uses the Stanza tool to perform syntactic dependency analysis on the input text and generates a syntactic dependency tree;
[0089] S5.2, the entity span representation is used as a feature of the corresponding node in the syntax dependency tree;
[0090] S5.3, input the features of the grammatical dependency tree and corresponding nodes into the GCN network, and after processing, obtain word vector representations with grammatical information;
[0091] S5.4 Finally, the entity span representation with syntactic information is obtained through max pooling.
[0092] S6: A new entity representation is obtained by fusing the entity span representation and the entity span representation with syntactic information. The non-entity part in the middle of the entity span representation is pooled to obtain local text information. The new entity span representation, entity type matrix, entity width representation and local text information representation are concatenated as input to the relation classifier to obtain the relation classification result.
[0093] S6.1, the entity span representation and the entity span representation with syntactic information are fused together using a fusion function to obtain a new entity span representation;
[0094] S6.2, Entity pairs are formed by using the relation mask matrix and entity span representation, and then the entity type representation and entity width representation of each entity in the entity pair are obtained according to the entity type matrix and entity width representation;
[0095] S6.3, after the character representation of the non-entity part between two entities is reduced in dimensionality by max pooling, it is fused with the corresponding entity span representation with syntactic information to obtain the local text information representation;
[0096] S6.4 concatenates the new entity span representation, entity type matrix, entity width representation, and local text information representation as input to the relation classifier to obtain the relation classification result.
[0097] See Figure 2 The diagram below illustrates a Chinese entity relation joint extraction system module according to the present invention, which specifically includes the following modules:
[0098] The data acquisition module is used to acquire data information from tourism websites;
[0099] A data preprocessing module is used to preprocess data information to obtain a dataset;
[0100] The first data processing module is used to perform text embedding representation and entity span representation on each text in the dataset.
[0101] The second data processing module is used to perform entity recognition and entity type matrix construction based on entity span representation, entity width representation and contextual semantic information.
[0102] The grammar extraction module is used to extract grammatical information, perform grammatical dependency analysis on each text, use entity span representation as the feature of each node of the syntax tree, calculate word vector representation containing grammatical information, and obtain entity span representation with grammatical information.
[0103] The relation extraction module is used to obtain a new entity span representation by fusing entity span representation and entity span representation with syntactic information, pool the non-entity part in the middle of the entity span representation to obtain local text information, and concatenate the new entity span representation, entity type matrix, entity width representation and local text information representation as input to the relation classifier to obtain the relation classification result.
[0104] See Figure 3 The following is a flowchart illustrating the specific preprocessing steps for data information in this invention. The specific steps for constructing the tourism dataset are as follows:
[0105] Step 1: Write a web crawler script to obtain data from relevant tourism websites. Then, clean and organize the data to generate a file containing attraction names, an address name file, and a text file.
[0106] Step two: Analyze the requirements. Based on the cleaned data and the requirements, define the entity types and relation types that need to be identified. For example, for the tourism field, entity types can include location, administrative region category, climate conditions, attractions, level, people, attraction type, attraction tickets, and activities; for relations, there are types such as located in, part of, and is a.
[0107] Step 3: The scenic spot files and address files serve as dictionary files for entity identification. Natural language processing tools, such as Stanza, are used to perform word segmentation and automatically perform preliminary entity labeling.
[0108] Step 4: Define relation extraction rules based on entity category and relation category to perform preliminary relation extraction;
[0109] Step 5: Correct and supplement the entity annotation results through manual annotation to complete the annotation task.
[0110] join Figure 4This paper presents a method for joint extraction of Chinese entity relations based on a pre-trained model, designed using processed data. Firstly, the processed data is input into a pre-trained model (ZEN and BiLSTM layers) to obtain word vector representations with contextual semantics. Secondly, the processed data is input into the Stanza tool to obtain a grammatical dependency tree. Then, the generated word vectors are used as features of the grammatical tree and input into a GCN to finally generate entity vector representations with grammatical features. Next, the word vector representations with contextual semantics are used to generate contextual entity vector representations through entity masking. This vector representation is then concatenated with entity width representation and contextual information representation for dimensionality reduction. This result is fed into an entity classifier to obtain entity classification results, and simultaneously performs an attention operation with the entity representations to generate entity type representations. Finally, a new entity span representation is obtained through entity span representation and entity span representation with grammatical information. This new entity span representation is concatenated with the entity type matrix, entity width representation, and local textual information representation as input to a relation classifier to obtain relation classification results. The specific steps of the joint extraction of Chinese entity relations based on the pre-trained model are as follows:
[0111] Step 1, Text Embedding Representation and Entity Representation: Complete the text embedding representation and entity representation.
[0112] Step 1-1, data preprocessing, the input text is s = [w1, w2, ..., w i , ..., w n ], where w i This indicates that for the i-th character, [cls] and [sep] are added to s, i.e., s = [[cls], w1, w2, ..., w i , ..., w n ,[sep]。
[0113] Step 1-2: Text embedding representation. The characters in s obtained in step 1 are replaced with their corresponding identifiers (id), and input into ZEN (ZEN is a BERT-based model), resulting in the output x = [c, x1, x2, ..., x...]. n+1 Let the size of the hidden layer be hidden. size The batch size is batch size Therefore, the final output dimension of x is x = [batch] size n+2, hidden size [x1], where x1 is the representation of the entire sentence S, i.e., [cls]. Then, x is input into the BiLSTM layer to obtain the output X = [X1, X2, ..., X...]. n+1 The final dimension of X is X = [batch] size n+1, hidden size *2].
[0114] Steps 1-3, entity span representation, based on entity mask. mask A candidate entity span can be obtained as span = [X] i X i+1 , ..., X i+k Let max-pooling be a function f, i.e., f = (X i X i+1 , ..., X i+k The final entity representation is obtained as E = [e1, e2, ..., e...]. i , ..., e j ] indicates that there are j entities, so the dimension is E = [batch] size ,j,hidden size *2].
[0115] Step 2, Entity Recognition and Entity Type Construction: In this step, entity recognition and entity type construction are completed, laying the foundation for relationship recognition.
[0116] Step 2-1, Entity recognition, based on the entity mask. mask The width of each entity is obtained, and the entity width embedding matrix is generated as W = [w1, w2, ..., w...]. i , ..., w j The dimension is the same as the dimension of the entity representation E. First, the entity span representation E and the entity width are embedded and concatenated, that is,
[0117] X(e)=f(X i X i+1 , ..., X i+k )*w k+1 (1)
[0118] The operator * indicates concatenation.
[0119] Next, the representation of the entire sentence is generated, that is,
[0120] X s =X(s)*c (2)
[0121] Here, 'c' represents contextual semantic information.
[0122] Finally, it is fed into a fully connected layer for dimensionality reduction, i.e.
[0123] y s =Relu(W s ·X s +b s (3)
[0124] WS b S These represent the weight matrix and offset in an S-layer neural network, respectively.
[0125] The final result is fed into the entity classifier to obtain the entity classification result, i.e.,
[0126]
[0127] W q b q These represent the weight matrix and offset in the q-layer neural network, respectively.
[0128] Step 2-2, Entity type construction, will generate y s As a query, the entity is represented as E = [e1, e2, ..., e...]. i , ..., e j The header is set to 8 characters, used as both value and key, and is calculated using the following formula:
[0129] T s =Attention(Query,key,value)
[0130]
[0131] Finally T s = [t1, t2, ..., t i , ..., t j ], T s The dimension is T s =[batch size ,j,hidden size ].
[0132] Where, d k The dimension of entity e1 or e2.
[0133] Step 3, as follows Figure 5 As shown, to generate an entity span representation with syntactic information, in order to utilize the syntactic information of the text, it is necessary to first convert the text into a syntactic dependency tree, then use the GCN network to compute each node, and finally generate an entity representation with syntactic information. The specific steps are as follows:
[0134] Step 3-1, syntactic dependency parsing, processing the text s = [w1, w2, ..., w...] i , ..., w n As input to stanza, we obtain the syntactic dependency relations nodes = [n1, n2, ..., n]. i , ..., n m-1], where id represents the current character and is also the sort position, and head is the current n. i The parent node's ID identifier will be used to identify each n. i The id and head are extracted to form an index tuple, i.e., edge = (head, id), which represents the edge of the syntax dependency tree. Since the dependency tree node identifiers generated by GCN start from 0, and n i IDs start from 1, so they are uniformly represented as follows: In GCN, a node 0 is added to represent the root node, and the actual root node is the node whose parent is node 0 (there is one and only one root node, e.g., ...). Figure 6 The leftmost part of the grammatical dependency tree. Also, because Stanza may split the same group of words into different tokens during grammatical dependency analysis, for example ($90,000, would be split into '$90' and '000'), in order to generate entity representations with grammatical information later, according to s = [w1, w2, ..., w...]... i , ..., w n The start and end indices and n of each word in the [] i The start_char and end_char identifiers are used in X = [X1, X2, ..., X... n+1 Generate a feature representation for each token in the [process], that is,
[0135] k i =f(X) i X i+1 , ..., X i+k )
[0136] Given m nodes, the resulting feature k = [c, k1, k2, ..., k m-1 The root node feature is replaced by the feature representation of the entire sentence.
[0137] Step 3-2: Define the GCN network using the DGL framework. In this invention, the entire GCN network consists of two layers of GCN:
[0138] First layer: Input dimension: hidden size *2; Output dimension: hidden size Activation function: ReLU
[0139] Second layer: Input dimension: hidden size Output dimension: hidden size Activation function: None
[0140] Step 3-3: Input the defined graph and corresponding features into the GCN to calculate the representation g of each node, i.e.,
[0141] g = GCN(G, k)
[0142] G is a syntax dependency tree formed by nodes and edges. The dimension of g is g = [batch] size m, hidden size ], according to s=[w1,w2,...,w i , ..., w n The start and end indices and n of each word in the [] i The start_char and end_char identifiers are stacked, forming a dimension of g = [batch] size n+1, hidden size *2] Then g is based on the entity mask entity mask Generate the final span-based representation E with syntactic information. g =[e g1 e g2 , ..., e gi , ..., e gj ].
[0143] Step 4: Relationship Classification. To obtain the final relationship classification result, candidate entity pairs need to be found and combined with entity span representation and local text embedding representation. Finally, these are fed into the relationship classifier to obtain the classification result, as detailed below:
[0144] Step 4-1, set E = [e1, e2, ..., e i , ..., e j ] and E g =[e g1 e g2 , ..., e gi, ..., e gj [Using the following formula:]
[0145] E s =(W n E+W m E g +b) (6)
[0146] Then from E s =[e s1 e s2 , ..., e si , ..., e sj Based on the relation mask matrix [relation] mask Two entities are selected as representatives, such as e. s1 e s2 , will e s1 e s2 The corresponding entity type is from Ts Acquire and merge, that is,
[0147]
[0148] We can then obtain it from formula (1). e s1 e s2 The intermediate text information is obtained by BiLSTM and max-pooling, where c = (e s1 e s2 ), stipulating that if e s1 e s2 If they are two adjacent entities, then c(e) s1 e s2 ) = 0, in order to distinguish the relation (e) s1 e s2 ) and (e s2 e s1 Finally, we can obtain the following representation:
[0149]
[0150]
[0151] Step 4-2, finally The data is fed into a relation classifier to obtain the final relation classification result, i.e.,
[0152]
[0153] In the Chinese entity relation joint extraction model based on a pre-trained model of this invention, entity type and syntactic information are integrated to improve the accuracy of relation extraction. First, data information from tourism websites is crawled, cleaned, and organized, and then generated using a combination of automatic and manual annotation to produce the required dataset. Then, the Chinese pre-trained models ZEN and BiLSTM are used to obtain an entity span representation with contextual semantics. The entity span representation, entity width representation, and sentence vector representation are concatenated and the dimensionality reduced. This result is then used to perform attention operations with the entity span representation to obtain an entity type matrix, and subsequently fed into an entity classifier to obtain the final entity classification result. Next, Stanza is used to perform syntactic dependency analysis on the input text to obtain a syntactic dependency tree. The entity representation is used as the feature of each node in the syntactic dependency tree, and a GCN network is used to calculate an entity span representation with syntactic information. Finally, the entity span representation with contextual semantics and the entity span representation with syntactic information are fused to obtain a new entity representation result. Entity pairs are then generated using this new entity representation result, and the resulting representation, combined with the entity width representation and the textual information between the entity pairs, is used as input to the relation classifier to obtain the final relation classification result.
[0154] One embodiment of the present invention provides a terminal device. This terminal device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the above-described embodiments of the Chinese entity relationship joint extraction method. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments.
[0155] The computer program can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention.
[0156] The Chinese entity relation extraction device / terminal can be a desktop computer, laptop, handheld computer, or cloud server, etc. The Chinese entity relation extraction device / terminal may include, but is not limited to, a processor and a memory.
[0157] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0158] The memory can be used to store the computer program and / or modules. The processor implements various functions of the Chinese entity relationship extraction device / terminal device by running or executing the computer program and / or modules stored in the memory and calling the data stored in the memory.
[0159] If the modules / units integrated in the Chinese entity relationship extraction device / terminal device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content contained in the computer-readable medium may be appropriately added to or subtracted from the content as required by the legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium may not include electrical carrier signals and telecommunication signals.
[0160] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for joint extraction of Chinese entity relations, characterized in that, Includes the following steps: Obtain data and information from travel websites; Preprocess the data to obtain a dataset; Perform text embedding and entity span representation on each text in the dataset to obtain entity width representation and entity representation with contextual semantic information; Entity recognition and entity type matrix construction are performed based on entity span representation, entity width representation, and contextual semantic information. Extract grammatical information, perform grammatical dependency analysis on each text, use entity span representation as the feature of each node in the syntax tree, calculate word vector representation containing grammatical information, and obtain entity span representation with grammatical information; A new entity span representation is obtained by fusing the entity span representation and the entity span representation with syntactic information. The non-entity part in the middle of the entity span representation is pooled to obtain local text information. The new entity span representation, entity type matrix, entity width representation and local text information representation are concatenated as input to the relation classifier to obtain the relation classification result.
2. The method for joint extraction of Chinese entity relations as described in claim 1, characterized in that, The process of preprocessing the data to obtain a dataset specifically includes the following steps: The acquired data is filtered to generate attraction files, address files, and text files; Use the attraction files and address files as dictionary files to identify entities, and define entity categories and relationship categories; Natural language processing tools are used to segment the text and perform preliminary entity annotation. Relationship extraction rules are defined based on entity category and relation category to perform preliminary entity relation extraction. The entity annotation results are corrected and supplemented by manual annotation to complete the annotation and generate a dataset.
3. The method for joint extraction of Chinese entity relations as described in claim 2, characterized in that, The entity categories include location, administrative region category, climate conditions, attraction, level, person, attraction type, attraction ticket, and activity; the relationship categories include location, part, and inheritance.
4. The method for joint extraction of Chinese entity relations as described in claim 1, characterized in that, The process of performing text embedding representation and entity span representation on each text in the dataset specifically includes the following steps: Each text in the dataset is input into the Chinese pre-trained model ZEN, and labels are added to the beginning and end of each text. Convert the characters in each text into their corresponding numerical identifiers to obtain the text embedding representation; Obtain the vector representation of each character and calculate the character representation with contextual semantic relationships; The entity span is represented by max pooling.
5. The method for joint extraction of Chinese entity relations as described in claim 1, characterized in that, The entity recognition and entity type matrix construction specifically include the following steps: The entity span representation, entity width representation, and contextual semantic information are concatenated, and the concatenated result is reduced in dimensionality to obtain the final vector representation. The final vector representation is fed into the entity classifier through the activation function to identify entities and obtain the entity classification result. The final vector representation and the entity span representation are subjected to attention operations to generate an entity type matrix with contextual semantic information.
6. The method for joint extraction of Chinese entity relations as described in claim 1, characterized in that, The extraction of syntax information specifically includes the following steps: The Stanza tool is used to perform syntactic dependency analysis on the input text to generate a syntactic dependency tree. The entity span is represented as a feature of the corresponding node in the syntax dependency tree; The features of the grammatical dependency tree and corresponding nodes are input into the GCN network, and the resulting word vector representations with grammatical information are obtained after computation. Finally, max pooling is used to obtain an entity span representation with syntactic information.
7. The method for joint extraction of Chinese entity relations as described in claim 1, characterized in that, The relationship classification results are obtained through the following steps: The entity span representation and the entity span representation with syntactic information are fused together using a fusion function to obtain a new entity span representation; Entity pairs are formed by using a relational mask matrix and an entity span representation. Then, the entity type representation and entity width representation of each entity in the entity pair are obtained based on the entity type matrix and the entity width representation. The character representation of the non-entity part between two entities is reduced in dimensionality by max pooling and then fused with the corresponding entity span representation with syntactic information to obtain a local text information representation. The new entity span representation, entity type matrix, entity width representation, and local text information representation are concatenated as input to the relation classifier to obtain the relation classification result.
8. A Chinese entity relation joint extraction system, characterized in that, include: The data acquisition module is used to acquire data information from tourism websites; A data preprocessing module is used to preprocess data information to obtain a dataset; The first data processing module is used to perform text embedding representation and entity span representation on each text in the dataset, and to obtain entity width representation and contextual semantic information of the entity representation. The second data processing module is used to perform entity recognition and entity type matrix construction based on entity span representation, entity width representation and contextual semantic information. The grammar extraction module is used to extract grammatical information, perform grammatical dependency analysis on each text, use entity span representation as the feature of each node of the syntax tree, calculate word vector representation containing grammatical information, and obtain entity span representation with grammatical information. The relation extraction module is used to obtain a new entity span representation by fusing entity span representation and entity span representation with syntactic information, pool the non-entity part in the middle of the entity span representation to obtain local text information, and concatenate the new entity span representation, entity type matrix, entity width representation and local text information representation as input to the relation classifier to obtain the relation classification result.
9. An apparatus comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Question and answer method and system based on BERT and knowledge base
CN112115238A
Spatial relation extraction method based on pre-training language model and text feature fusion
CN114528368A