An electric power industry entity relation extraction method, device, equipment and medium
By constructing a text dataset of the power industry and utilizing ELMO and Transformer-CRF models, the problem of insufficient accuracy and coverage in the extraction of entity relationships in the power industry in existing technologies is solved, and highly accurate extraction of entity relationships in the power industry is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-06
- Publication Date
- 2026-03-24
AI Technical Summary
Existing methods for extracting entity relationships in the power industry struggle to fully utilize contextual information, resulting in insufficient accuracy and coverage.
By constructing a text dataset of the power industry, using the ELMO model for contextual feature extraction, and combining it with the Transformer-CRF model to obtain global dependencies, entity relationship extraction in the power industry is achieved.
It improves the accuracy and consistency of entity relationship extraction, and can better utilize contextual information for entity label prediction, achieving highly accurate entity relationship extraction in the power industry.
Smart Images

Figure CN117171361B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and in particular to a power industry entity relationship extraction method and device, a terminal device and a computer readable storage medium. BACKGROUND
[0002] Power industry entity relationship extraction aims to extract the relationship between power industry entities from text, thereby helping people understand the connection and semantic association between power entities. Power industry entity relationship extraction usually includes two core sub-tasks of entity recognition and relationship classification. Entity recognition is achieved by locating and identifying specific types of entities in the text. In power industry entity relationship extraction, common entity types include "power equipment", "energy company", "power station", etc. The goal of the entity recognition task is to identify each entity in the text and classify them into the corresponding predefined type. Relationship classification is the process of determining the semantic relationship between two entities. In power industry entity relationship extraction, the relationship classification task aims to analyze entity pairs in the text and classify them into predefined relationship categories, such as "power equipment A is a supplier of energy company B", "power station A is located in region B", etc.
[0003] Existing entity relationship extraction methods usually use machine learning and deep learning techniques, but often have the following problems: on the one hand, local feature modeling and rule-based pattern matching algorithms cannot fully utilize the global nature of contextual information, on the other hand, the need for large-scale labeled data limits the applicability of the method, so the existing entity relationship extraction method is difficult to achieve high accuracy and coverage. SUMMARY
[0004] The present application provides a power industry entity relationship extraction method, device, equipment and medium, which can improve the accuracy and coverage of entity relationship extraction by constructing a labeled entity dataset based on a power industry text dataset. In addition, by using the ELMO model to extract contextual features and the Transformer-CRF model to obtain global dependency relationships, the context information can be better utilized for entity label prediction of each word in the entity relationship extraction process, thereby achieving high accuracy and consistency of power industry entity relationship extraction.
[0005] To solve the above technical problems, the first aspect of the embodiment of the present application provides a power industry entity relationship extraction method, comprising the following steps:
[0006] Obtain a power industry text dataset and preprocess the power industry text dataset;
[0007] Based on the preset power industry entity query template, the power industry entities are extracted from the preprocessed power industry text data set by using the generative pre-training language model, and a labeled entity data set is constructed according to the extracted power industry entities.
[0008] The ELMO model is used for feature extraction on the power industry text data set to obtain a first word vector sequence related to the context of each word in the power industry text data set, and based on the labeled entity data set, the first word vector sequence is sequentially labeled by using the Transformer-CRF model to obtain the global dependency relationship of the first word vector sequence.
[0009] The ELMO model is used for feature extraction on the to-be-labeled text data to obtain a second word vector sequence related to the context of each word in the to-be-labeled text data, and based on the global dependency relationship and the labeled entity data set, the second word vector sequence is sequentially labeled by using the Transformer-CRF model to obtain an entity label sequence of the to-be-labeled text data.
[0010] The continuous and same entity labels in the entity label sequence are merged to determine a plurality of entities in the to-be-labeled text data.
[0011] Based on the preset entity relationship query template, the generative pre-training language model is used to extract a plurality of relationship information from the second word vector sequence, and the plurality of entities in the to-be-labeled text data are matched with the plurality of relationship information according to the preset matching rule to generate a plurality of relationship instances.
[0012] As a preferred solution, the power industry text data set is obtained, and the power industry text data set is preprocessed, specifically including the following steps:
[0013] The power industry text data set is obtained by using a network crawler technology;
[0014] The power industry text data set is respectively processed by using an NLP tool to determine a sentence set of the power industry text data set and a word set and an entity set of each sentence.
[0015] As a preferred solution, the ELMO model is used for feature extraction on the power industry text data set to obtain a first word vector sequence related to the context of each word in the power industry text data set, specifically including the following steps:
[0016] The ELMO model is used to express h i,i =ELMO(x i,i;Θ) Perform feature extraction on the power industry text dataset to obtain the first word vector related to the context of each word in the power industry text dataset; where, x i,i Let represent the i-th word in the i-th sentence of the power industry text dataset, Θ represent the parameters of the ELMO model, and h i,i Indicates word x i,i The first word vector related to the context;
[0017] The first word vector sequence is generated based on the first word vector related to the context of each word.
[0018] As a preferred embodiment, the step of using the ELMO model to extract features from the text data to be annotated, and obtaining a context-related second word vector sequence for each word in the text data to be annotated, specifically includes the following steps:
[0019] Using the ELMO model through the expression: h′ i,i =ELMO(x′) i,i ;Θ) Perform feature extraction on the text data to be labeled to obtain the context-related second word vector for each word in the text data to be labeled; where, x′ i,i Let Θ represent the i-th word in the i-th sentence of the text data to be labeled, and let h′ represent the parameters of the ELMO model. i,i Indicates the word x′ i,i The context-dependent second word vector;
[0020] Based on the context-related second word vector of each word, generate the second word vector sequence; wherein, the second word vector sequence is represented as: H′={h′1,h′2,...,h′ n}, n represents the total number of sentences in the text data to be annotated, m i h′ represents the total number of words in the i-th sentence of the text data to be annotated. i This represents the context-dependent second word vector sequence for each word in the i-th sentence of the text data to be annotated.
[0021] As a preferred embodiment, the step of using the Transformer-CRF model to perform sequence labeling on the second word vector sequence based on the global dependency relationship and the labeled entity dataset to obtain the entity label sequence of the text data to be labeled specifically includes the following steps:
[0022] Based on the global dependency relationship and the annotated entity data set, the Transformer-CRF model is used to perform sequence labeling on the second word vector sequence by the following expression, obtain an entity label sequence score value, and take the entity label sequence corresponding to the maximum entity label sequence score value as the entity label sequence of the text data to be annotated:
[0023]
[0024] wherein Score(Y) represents an entity label sequence score value, represents an entity label y i corresponding to the probability of the observed second word vector, represents the probability of transitioning from an entity label y i to an entity label y j .
[0025] As a preferred solution, the entity relationship query template includes a first placeholder for representing a relationship main entity, a second placeholder for representing a relationship type, and a third placeholder for representing a relationship guest entity.
[0026] Based on the preset entity relationship query template, the generative pre-training language model is used to extract several relationship information from the second word vector sequence, which specifically includes the following steps:
[0027] According to the current several entities to be extracted and the relationship types to be extracted, the entity relationship query template is filled to obtain several query texts.
[0028] The several query texts and the second word vector sequence are input into the generative pre-training language model, and the generative pre-training language model outputs a response text.
[0029] The several relationship information is extracted from the response text.
[0030] As a preferred solution, the several entities in the text data to be annotated are matched with the several relationship information according to the preset matching rule to generate several relationship instances, which specifically includes the following steps:
[0031] Based on the preset several relationship patterns for representing different relationship types between entities, the pattern matching algorithm is used to match the several entities in the text data to be annotated with the several relationship information to obtain several entity pairs satisfying any one relationship pattern and the relationship information corresponding to each entity pair.
[0032] According to the obtained several entity pairs and the relationship information corresponding to each entity pair, the several relationship instances are generated.
[0033] The second aspect of the embodiment of the application provides an electric power industry entity relation extraction device, comprising:
[0034] A data preprocessing module is configured to acquire an electric power industry text dataset and preprocess the electric power industry text dataset.
[0035] An annotated entity dataset construction module is configured to extract electric power industry entities from the preprocessed electric power industry text dataset by using a generative pre-training language model based on a preset electric power industry entity query template, and construct an annotated entity dataset according to the extracted electric power industry entities.
[0036] A global dependency relation acquisition module is configured to extract features of the electric power industry text dataset by using an ELMO model, obtain a first word vector sequence related to a context of each word in the electric power industry text dataset, and perform sequence labeling on the first word vector sequence by using a Transformer-CRF model based on the annotated entity dataset, to obtain a global dependency relation of the first word vector sequence.
[0037] An entity label sequence acquisition module is configured to extract features of to-be-labeled text data by using the ELMO model, obtain a second word vector sequence related to a context of each word in the to-be-labeled text data, and perform sequence labeling on the second word vector sequence by using the Transformer-CRF model based on the global dependency relation and the annotated entity dataset, to obtain an entity label sequence of the to-be-labeled text data.
[0038] An entity label merging module is configured to merge continuous and identical entity labels in the entity label sequence, to determine a plurality of entities in the to-be-labeled text data.
[0039] An entity relation extraction module is configured to extract a plurality of relation information from the second word vector sequence by using the generative pre-training language model based on a preset entity relation query template, and match the plurality of entities in the to-be-labeled text data with the plurality of relation information according to a preset matching rule, to generate a plurality of relation instances.
[0040] The third aspect of the embodiment of the application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the electric power industry entity relation extraction method according to any one of the first aspect when executing the computer program.
[0041] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, the computer readable storage medium comprises a stored computer program, wherein the computer program controls the device where the computer readable storage medium is located to execute the power industry entity relationship extraction method according to any one of the first aspect when the computer program is running.
[0042] Compared with the prior art, the embodiment of the present application has the beneficial effects that by constructing the annotated entity dataset based on the power industry text dataset, the accuracy and coverage of entity relationship extraction can be improved, and by using the ELMO model to extract context features and the Transformer-CRF model to obtain global dependency relationships, the context information can be better utilized for entity label prediction of each word in the entity relationship extraction process, thereby realizing high accuracy and consistency of power industry entity relationship extraction. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 is a flow diagram of the power industry entity relationship extraction method in the embodiment of the present application;
[0044] Figure 2 is a structural diagram of the power industry entity relationship extraction device in the embodiment of the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0046] Referring to Figure 1 The first aspect of the embodiment of the present application provides a power industry entity relationship extraction method, comprising the following steps S1 to S6:
[0047] Step S1, acquiring a power industry text dataset and preprocessing the power industry text dataset;
[0048] Step S2, based on a preset power industry entity query template, using a generative pre-training language model to extract power industry entities from the preprocessed power industry text dataset, and constructing an annotated entity dataset according to the extracted power industry entities;
[0049] Step S3, feature extraction is performed on the power industry text data set by using the ELMO model to obtain a first context-related word vector sequence of each word in the power industry text data set, and based on the annotated entity data set, the first word vector sequence is sequentially labeled by using the Transformer-CRF model to obtain the global dependency relationship of the first word vector sequence;
[0050] Step S4, feature extraction is performed on the to-be-labeled text data by using the ELMO model to obtain a second context-related word vector sequence of each word in the to-be-labeled text data, and based on the global dependency relationship and the annotated entity data set, the second word vector sequence is sequentially labeled by using the Transformer-CRF model to obtain an entity label sequence of the to-be-labeled text data;
[0051] Step S5, the continuous and same entity labels in the entity label sequence are merged to determine a plurality of entities in the to-be-labeled text data;
[0052] Step S6, based on a preset entity relationship query template, a plurality of relationship information is extracted from the second word vector sequence by using the generative pre-training language model, and a plurality of entities in the to-be-labeled text data are matched with a plurality of relationship information according to a preset matching rule to generate a plurality of relationship instances.
[0053] Specifically, in step S1, the embodiment collects a large-scale text data set related to the power industry, and pre-processes the obtained power industry text data set. In the process of extracting power industry entity relationship, applying a large-scale power industry text data set helps to improve the accuracy and coverage of extraction, so as to more comprehensively capture the power industry entity relationship.
[0054] In step S2, the embodiment pre-constructs a power industry entity query template according to the characteristics of the power industry, such as "extracting power company name", "obtaining power equipment model", etc., which is used to obtain specific types of entities through the generative pre-training language model. It is worth noting that the generative pre-training language model is pre-trained through a large amount of text data, which contains information of various entities such as "power company name" and "power equipment model", so as to learn a certain degree of entity recognition ability. Through the power industry entity query template, the generative pre-training language model is requested to generate response text that meets the query template, and then the generated response text is screened and sorted to extract power industry entities from the pre-processed power industry text data set, and to ensure the accuracy and consistency of entity annotation. Preferably, the rule-based pattern matching method is combined to further optimize the entity annotation result to obtain the annotated entity data set of the power industry.
[0055] As one of the optional embodiments, the rule-based pattern matching method can adopt regular expressions to match and extract the generated response text by defining regular expression patterns for entities and relationships in the power industry.
[0056] In step S3, the power industry text sequence X={x1, x2,..., x n} is input into the ELMO model, so as to obtain the context-related first word vector sequence H={h1, h2,..., h n} of each word in the power industry text data set, and then the generated first word vector sequence H is taken as input, and based on the annotated entity data set, the first word vector sequence is labeled by using the Transformer-CRF model. The Transformer-CRF model captures local dependencies in the sequence through the Transformer encoder and models global dependencies through the CRF layer, so as to obtain more accurate prediction results in the sequence labeling task, and the entity label of each word is predicted.
[0057] In step S4, for the unannotated text data to be annotated, the global dependencies modeled in step S3 are used to respectively extract features and sequence label the text data to be annotated, so as to identify and extract the entity label sequence of the text data to be annotated.
[0058] In step S5, for the entity label sequence of each sentence The continuous and same entity labels are identified and merged into complete entities, which are formally represented as:
[0059] Entities(x i )={e1, e2,..., e l};
[0060] Wherein, represents the start position and end position of the jth complete entity, s j represents the start index of the jth entity, e j represents the end index of the jth entity, and l represents the number of complete entities in the sentence.
[0061] Finally, a number of entity relationship instances in the text data to be annotated are constructed in step S6.
[0062] As a preferred solution, the power industry text data set is obtained, and the power industry text data set is preprocessed, specifically including the following steps:
[0063] The power industry text data set is obtained by using a web crawler technology;
[0064] The power industry text data set is processed by using an NLP tool to perform sentence division, word segmentation, and entity tagging, to determine a sentence set of the power industry text data set, and a word set and an entity set of each sentence.
[0065] Specifically, the embodiment uses a web crawler technology to automatically collect a large-scale text data set related to the power industry from the Internet, including data from power industry news websites, industry forums, and enterprise websites, to obtain the power industry text data set. It is worth noting that the embodiment can use a crawler technology based on a robots.txt rule, which can understand the crawling rules of a website by reading the robots.txt file and make corresponding adjustments to ensure that unauthorized pages are not accessed, avoid excessive load on the target website, and comply with the regulations of the website owner and avoid infringing the rights of others.
[0066] The power industry text data set is processed by using an NLP tool to perform sentence division, word segmentation, and entity tagging. Specifically, sentence division can be represented as S = {s1, s2,..., s n}, word segmentation can be represented as W = {w1, w2,..., w m}, and entity tagging can be represented as T = {t1, t2,..., t p}, where S represents the sentence set after division, W represents the word set after segmentation, and T represents the entity set after tagging. It should be noted that the following NLP tools and libraries can be used for sentence division, word segmentation, and entity tagging: NLTK (Natural Language Toolkit), SpaCy, StanfordCoreNLP, etc. These tools and libraries provide rich functions and flexible interfaces, suitable for processing text data and supporting sentence division, part-of-speech tagging, named entity recognition, and other tasks.
[0067] As a preferred solution, the ELMO model is used to extract features from the power industry text data set to obtain a first word vector sequence related to the context of each word in the power industry text data set, which includes the following steps:
[0068] The ELMO model is used to extract features from the power industry text data set by the expression: h i,i = ELMO(x i,i ; Θ), to obtain a first word vector related to the context of each word in the power industry text data set; where x i,i represents the i-th word in the i-th sentence in the power industry text data set, Θ represents the parameters of the ELMO model, and h i,i represents the word xi,i a first word vector related to the context of each word;
[0069] The first word vector sequence is generated according to the first word vector related to the context of each word.
[0070] As a preferred solution, the feature extraction of the to-be-labeled text data by using the ELMO model to obtain the second word vector sequence related to the context of each word in the to-be-labeled text data specifically includes the following steps:
[0071] The feature extraction of the to-be-labeled text data by using the ELMO model through the expression: h′ i,i = ELMO (x′ i,i ; Θ) obtains the second word vector related to the context of each word in the to-be-labeled text data; wherein x′ i,i represents the i-th word in the i-th sentence in the to-be-labeled text data, Θ represents the parameters of the ELMO model, h′ i,i represents the second word vector related to the context of the word x′ i,i ;
[0072] The second word vector sequence is generated according to the second word vector related to the context of each word; wherein the second word vector sequence is represented as: H′ = {h′1, h′2,..., h′ n}, n represents the total number of sentences in the to-be-labeled text data, m i represents the total number of words in the i-th sentence in the to-be-labeled text data, h′ i represents the second word vector sequence related to the context of each word in the i-th sentence in the to-be-labeled text data.
[0073] As a preferred solution, the sequence labeling of the second word vector sequence by using the Transformer-CRF model based on the global dependency relationship and the annotated entity data set to obtain the entity label sequence of the to-be-labeled text data specifically includes the following steps:
[0074] The sequence labeling of the second word vector sequence by using the Transformer-CRF model based on the global dependency relationship and the annotated entity data set through the following expression to obtain the entity label sequence score value, and the entity label sequence corresponding to the maximum entity label sequence score value is taken as the entity label sequence of the to-be-labeled text data:
[0075]
[0076] wherein Score (Y) represents the entity label sequence score value, denotes the entity label y i the probability corresponding to the observed second word vector, denotes the entity label y i transition to the entity label y j .
[0077] Specifically, the embodiment defines a transition probability matrix T = [t ij ] in R k*k , where t ij denotes the probability of transitioning from label i to label j. At the same time, a emission probability matrix E = [e ik ] in R k*d is defined, where e ik denotes the probability of label i corresponding to the observed feature k, and d denotes the dimension of the feature. The embodiment only needs to maximize the entity label sequence score value Score(Y), and further obtains the optimal entity label sequence Y' = {y'1, y'2,..., y' T n}, where, denotes the entity label of each word in the i-th sentence, that is, the prediction result of the model entity label.
[0078] As a preferred solution, the entity relation query template includes a first placeholder for representing a relation main entity, a second placeholder for representing a relation type, and a third placeholder for representing a relation guest entity.
[0079] Based on the preset entity relation query template, the generative pre-training language model is used to extract a plurality of relation information from the second word vector sequence, specifically including the following steps:
[0080] According to the current plurality of to-be-extracted entities and to-be-extracted relation types, the entity relation query template is filled to obtain a plurality of query texts;
[0081] The plurality of query texts and the second word vector sequence are input into the generative pre-training language model, and the generative pre-training language model outputs a response text;
[0082] The plurality of relation information is extracted from the response text.
[0083] Specifically, the embodiment uses specific grammar rules or placeholders to represent relation main entities, relation guest entities, and relation types. For example, the placeholders [ENTITY1], [ENTITY2] are used to represent entities, and the placeholder [RELATION] is used to represent a relation type.
[0084] Further, the entity relationship query template is filled according to the current several to-be-extracted entities and to-be-extracted relationship types, a plurality of query texts are obtained, the plurality of query texts and the second word vector sequence are input into the generative pre-training language model, and a response text containing information about the entity relationship in the power industry is output by the generative pre-training language model.
[0085] The generated response text is parsed, and the entity and relationship type in the obtained text response are extracted using an entity recognition and relationship extraction algorithm.
[0086] As a preferred solution, the plurality of entities in the to-be-labeled text data are matched with the plurality of relationship information according to the preset matching rule, and a plurality of relationship instances are generated, specifically including the following steps:
[0087] Based on the preset plurality of relationship patterns for representing relationship types between different entities, the plurality of entities in the to-be-labeled text data are matched with the plurality of relationship information using a pattern matching algorithm, and a plurality of entity pairs satisfying any one relationship pattern and the relationship information corresponding to each entity pair are obtained.
[0088] According to the obtained plurality of entity pairs and the relationship information corresponding to each entity pair, a plurality of relationship instances are generated.
[0089] Specifically, the embodiment uses a pattern matching algorithm to combine prior knowledge in the power industry field to match and combine a plurality of entities in the to-be-labeled text data, and constructs relationship instances. Let E1 and E2 represent two entities, and R represent a relationship type. Define a relationship pattern Pattern(E1, R, E2) and a matching rule Rule(E1, R, E2)→RelInstance(E1, R, E2). For a given entity label and context information, a regular expression or other pattern matching algorithm can be used to find an entity pair that satisfies the relationship pattern, i.e., Match(Pattern(E1, R, E2), Text)→{(E1, R, E2)}. Finally, for the matched entity pair and the corresponding relationship information (E1, R, E2), a relationship instance is generated according to the matching rule, i.e., Apply(Rule(E1, R, E2))→RelInstance(E1, R, E2).
[0090] The embodiment of the present application provides an entity relation extraction method in the power industry, which can improve the accuracy and coverage of entity relation extraction by constructing an annotated entity dataset based on a power industry text dataset, and further, by using an ELMO model to extract context features and a Transformer-CRF model to obtain global dependency relations, the context information can be better utilized for entity label prediction of each word in the entity relation extraction process, so that high accuracy and consistency of the entity relation extraction in the power industry are realized.
[0091] In addition, by constructing an entity relation query template and a pattern matching based method, the response text can be timely parsed and processed to construct a relation instance. Meanwhile, by utilizing the advantages of a large model, the embodiment of the present application can better understand the global relations between entities and obtain more accurate entity relation extraction results, thereby enriching the relation knowledge in the power industry.
[0092] Referring to Figure 2 The embodiment of the present application provides an entity relation extraction device in the power industry, which comprises:
[0093] The data preprocessing module 201 is configured to acquire a power industry text dataset and pre-process the power industry text dataset;
[0094] The annotated entity dataset construction module 202 is configured to extract power industry entities from the pre-processed power industry text dataset by using a generative pre-training language model based on a preset power industry entity query template, and construct an annotated entity dataset according to the extracted power industry entities;
[0095] The global dependency relation acquisition module 203 is configured to extract features of the power industry text dataset by using an ELMO model, obtain a first word vector sequence related to context of each word in the power industry text dataset, and perform sequence labeling on the first word vector sequence by using a Transformer-CRF model based on the annotated entity dataset, so as to obtain global dependency relations of the first word vector sequence;
[0096] The entity label sequence acquisition module 204 is configured to extract features of the text data to be labeled by using the ELMO model, obtain a second word vector sequence related to context of each word in the text data to be labeled, and perform sequence labeling on the second word vector sequence by using the Transformer-CRF model based on the global dependency relations and the annotated entity dataset, so as to obtain an entity label sequence of the text data to be labeled;
[0097] The entity label merging module 205 is configured to merge continuous and same entity labels in the entity label sequence, and determine a plurality of entities in the text data to be labeled.
[0098] The entity relation extraction module 206 is configured to extract relation information from the second word vector sequence based on a preset entity relation query template and a generative pre-training language model, and match entities in the text data to be labeled with the relation information according to a preset matching rule to generate relation instances.
[0099] It should be noted that the power industry entity relation extraction device provided in the embodiments of the present application can implement all processes of the power industry entity relation extraction method described in any of the above embodiments, and the functions and technical effects of each module in the device correspond to those of the power industry entity relation extraction method described in the above embodiments. Therefore, the functions and technical effects of each module in the device are not described here.
[0100] The third aspect of the embodiments of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the power industry entity relation extraction method according to any of the first aspect.
[0101] The terminal device can be a desktop computer, a notebook computer, a palm computer, a cloud server, and other computing devices. The terminal device can include, but is not limited to, a processor and a memory. The terminal device can also include input / output devices, network access devices, buses, and the like.
[0102] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, or the like. The general-purpose processor can be a microprocessor or any conventional processor, and the like. The processor is the control center of the terminal device, and connects all parts of the terminal device through various interfaces and lines.
[0103] The memory can be used to store the computer program and / or modules, and the processor realizes various functions of the terminal device by running or executing the computer program and / or modules stored in the memory, and calling data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), and the like; and the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), and the like. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.
[0104] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, which comprises a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to execute the power industry entity relationship extraction method according to any one of the first aspect.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software and necessary hardware platforms, and of course, can also be implemented entirely by hardware. Based on such understanding, all or part of the technical solutions of the present application that contribute to the background art can be embodied in the form of a software product. The computer software product can be stored in a storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the method described in each embodiment or some parts of the embodiments of the present application.
[0106] The above is the preferred embodiment of the present application, and it should be pointed out that, for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements are also considered to be within the protection scope of the present application.
Claims
1. A method for extracting entity relationships in the power industry, characterized in that, Includes the following steps: Obtain a text dataset of the power industry and preprocess the power industry text dataset; Based on a pre-defined power industry entity query template, a generative pre-trained language model is used to extract power industry entities from a pre-processed power industry text dataset, and a labeled entity dataset is constructed based on the extracted power industry entities. The ELMO model is used to extract features from the power industry text dataset to obtain the first word vector sequence related to the context of each word in the power industry text dataset. Based on the labeled entity dataset, the Transformer-CRF model is used to perform sequence labeling on the first word vector sequence to obtain the global dependency relationship of the first word vector sequence. The ELMO model is used to extract features from the text data to be labeled, and the context-related second word vector sequence of each word in the text data to be labeled is obtained. Based on the global dependency relationship and the labeled entity dataset, the Transformer-CRF model is used to perform sequence labeling on the second word vector sequence to obtain the entity label sequence of the text data to be labeled. Merge consecutive and identical entity labels in the entity label sequence to determine several entities in the text data to be labeled; Based on the preset entity relationship query template, the generative pre-trained language model is used to extract several relationship information from the second word vector sequence, and several entities in the text data to be labeled are matched with several of the relationship information according to the preset matching rules to generate several relationship instances. Specifically, the step of using the Transformer-CRF model to perform sequence labeling on the second word vector sequence based on the global dependency relationship and the labeled entity dataset to obtain the entity label sequence of the text data to be labeled includes the following steps: Based on the global dependencies and the labeled entity dataset, the Transformer-CRF model is used to perform sequence labeling on the second word vector sequence using the following expression to obtain entity label sequence scores. The entity label sequence corresponding to the highest entity label sequence score is then used as the entity label sequence of the text data to be labeled: in, This represents the score value of the entity label sequence. Represents entity tags The probabilities corresponding to the observed second word vectors, Indicates from entity label Transfer to physical label The probability of.
2. The method for extracting entity relationships in the power industry as described in claim 1, characterized in that, The process of acquiring and preprocessing the power industry text dataset includes the following steps: Obtain a text dataset of the power industry using web crawling technology; The power industry text dataset was processed by NLP tools to perform sentence segmentation, word segmentation, and entity annotation, thereby determining the sentence set, word set, and entity set of each sentence.
3. The method for extracting entity relationships in the power industry as described in claim 1, characterized in that, The step of using the ELMO model to extract features from the power industry text dataset to obtain the context-dependent first word vector sequence for each word in the power industry text dataset specifically includes the following steps: Using the ELMO model through the expression: Feature extraction is performed on the power industry text dataset to obtain the context-dependent first word vector for each word in the power industry text dataset; wherein, This indicates the first [item] in the power industry text dataset. i The first sentence i One word, The parameters of the ELMO model are represented. Words The first word vector related to the context; The first word vector sequence is generated based on the first word vector related to the context of each word.
4. The method for extracting entity relationships in the power industry as described in claim 1, characterized in that, The step of using the ELMO model to extract features from the text data to be annotated, and obtaining the context-related second word vector sequence for each word in the text data to be annotated, specifically includes the following steps: Using the ELMO model through the expression: Feature extraction is performed on the text data to be labeled to obtain a context-dependent second word vector for each word in the text data; wherein, This indicates the first element in the text data to be annotated. i The first sentence i One word, The parameters of the ELMO model are represented. Words The context-dependent second word vector; The second word vector sequence is generated based on the context-dependent second word vector of each word; wherein the second word vector sequence is represented as: , , This represents the total number of sentences in the text data to be annotated. This indicates the first element in the text data to be annotated. i The total number of words in each sentence This indicates the first element in the text data to be annotated. i The second word vector sequence related to the context of each word in a sentence.
5. The method for extracting entity relationships in the power industry as described in claim 1, characterized in that, The entity relationship query template includes a first placeholder for representing the primary entity of the relationship, a second placeholder for representing the relationship type, and a third placeholder for representing the secondary entity of the relationship. The process of extracting relational information from the second word vector sequence based on the preset entity relation query template and using the generative pre-trained language model specifically includes the following steps: The entity relationship query template is populated based on the current number of entities to be extracted and the types of relationships to be extracted to obtain several query texts; The query text and the second word vector sequence are input into the generative pre-trained language model, and the response text is output through the generative pre-trained language model. Extract several relational information from the response text.
6. The method for extracting entity relationships in the power industry as described in claim 1, characterized in that, The step of matching several entities in the text data to be labeled with several relational information according to preset matching rules to generate several relational instances specifically includes the following steps: Based on several preset relation patterns used to represent the relationship types between different entities, a pattern matching algorithm is used to match several entities in the text data to be labeled with several relation information to obtain several entity pairs that satisfy any relation pattern and the relation information corresponding to each entity pair. Based on the acquired entity pairs and the relationship information corresponding to each entity pair, several relationship instances are generated.
7. A device for extracting entity relationships in the power industry, characterized in that, include: The data preprocessing module is used to acquire a text dataset of the power industry and preprocess the text dataset of the power industry. The labeled entity dataset construction module is used to extract power industry entities from the preprocessed power industry text dataset based on a preset power industry entity query template and a generative pre-trained language model, and to construct a labeled entity dataset based on the extracted power industry entities. The global dependency acquisition module is used to extract features from the power industry text dataset using the ELMO model, obtain the first word vector sequence related to the context of each word in the power industry text dataset, and perform sequence labeling on the first word vector sequence using the Transformer-CRF model based on the labeled entity dataset to obtain the global dependency of the first word vector sequence. The entity label sequence acquisition module is used to extract features from the text data to be labeled using the ELMO model, obtain the context-related second word vector sequence of each word in the text data to be labeled, and perform sequence labeling on the second word vector sequence using the Transformer-CRF model based on the global dependency relationship and the labeled entity dataset to obtain the entity label sequence of the text data to be labeled. The entity label merging module is used to merge consecutive and identical entity labels in the entity label sequence to determine several entities in the text data to be labeled. The entity relation extraction module is used to extract several relation information from the second word vector sequence based on a preset entity relation query template using the generative pre-trained language model, and to match several entities in the text data to be labeled with several relation information according to preset matching rules to generate several relation instances. Specifically, the step of using the Transformer-CRF model to perform sequence labeling on the second word vector sequence based on the global dependency relationship and the labeled entity dataset to obtain the entity label sequence of the text data to be labeled includes the following steps: Based on the global dependencies and the labeled entity dataset, the Transformer-CRF model is used to perform sequence labeling on the second word vector sequence using the following expression to obtain entity label sequence scores. The entity label sequence corresponding to the highest entity label sequence score is then used as the entity label sequence of the text data to be labeled: in, This represents the score value of the entity label sequence. Represents entity tags The probabilities corresponding to the observed second word vectors, Indicates from entity label Transfer to physical label The probability of.
8. A terminal device, characterized in that, The method 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, implements the power industry entity relationship extraction method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the power industry entity relationship extraction method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Named entity recognition method, electronic device and storage medium
CN110287479A
Entity and relation joint extraction method and device, storage medium and terminal
CN115374786A