Geological entity relation extraction method based on domain multi-prompt template
By constructing a geological entity relationship extraction method based on domain-specific multi-cue templates, and combining the BERT model and global pointer network, the problem of insufficient semantic understanding in geological texts is solved, and the accurate extraction and generalization ability of geological entity relationships are improved.
Patent Information
- Application Number
- CN202510984976.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-07-17
AI Technical Summary
Existing methods for extracting geological entity relationships struggle to accurately understand the semantics of technical terms and domain knowledge in geological texts, resulting in insufficient generalization and flexibility.
A method for extracting geological entity relationships based on domain-specific multi-cue templates is adopted. By manually constructing cue templates and target templates, combining geological entity and relationship embedding, using the BERT model as the encoder, and employing a global pointer network for decoding, the problem of entity nesting and relationship overlap is solved, thereby improving semantic understanding capabilities.
It effectively enhances the model's semantic understanding of geological texts, improves the accuracy and generalization ability of geological entity relationship extraction, and solves the problem of overlapping entity relationships.
Smart Images

Figure CN120874837B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of geological text analysis, and more particularly to a geological entity relationship extraction method based on a domain multi-prompt template. BACKGROUND
[0002] The geological survey process is a process of collecting, processing, processing, and integrating various types of geological information. Over the years, geological survey work has accumulated vast amounts of multi-scale and multi-modal data. How to mine data and discover knowledge, build a geological knowledge graph, and explore the evolution of geological knowledge is an important direction for the development of industry information technology in recent years. Especially in the face of the contradiction between the explosive growth of unstructured geological information and effective utilization, obtaining hidden and non-obvious geological information from text to build a geological knowledge graph has become an urgent problem to be solved for further breakthroughs and landing applications of current geological survey intelligent technology. Geological entity relationship extraction is one of the important key technologies for building a domain knowledge graph.
[0003] In recent years, important progress has been made in the study of geological entity relationship extraction methods. The main methods can be broadly divided into pattern matching-based methods, machine learning-based methods, and deep learning-based methods. Among them, the pattern matching-based method and the machine learning-based entity relationship extraction method lack flexibility and have weak generalization. The deep learning-based entity relationship extraction method can be divided into pipeline-based entity relationship extraction method and entity relationship-based joint extraction method, which shows strong automatic feature learning ability and generalization performance. However, due to the existence of a large number of professional terms and domain knowledge in geological text, it is difficult for existing methods to accurately understand semantics.
[0004] Therefore, how to improve semantic understanding ability and achieve accurate geological entity relationship extraction is a problem that needs to be solved by those skilled in the art. SUMMARY
[0005] Therefore, the present application provides a geological entity relationship extraction method based on a domain multi-prompt template, which constructs a prompt template, a target template, and embeds geological entities and relationships to form a new prompt template, uses a BERT model as an encoder, and three global pointer networks as decoders, effectively solving the problems of entity nesting and relationship overlap. The present application can enhance data, improve semantic understanding ability, and achieve accurate geological entity relationship extraction.
[0006] To achieve the above purpose, the present application adopts the following technical solutions:
[0007] The geological entity relationship extraction method based on the domain multi-prompt template comprises the following steps:
[0008] Step 1: Collect the geological survey report and preprocess it to obtain the original text;
[0009] Step 2: Perform data augmentation on the original text to obtain augmented text;
[0010] Step 3: Construct prompt templates and target templates;
[0011] Step 4: Optimize the prompt templates using the augmented text and target templates to obtain updated prompt templates;
[0012] Step 5: Concatenate the augmented text and updated prompt templates to obtain new prompt templates, and transmit the augmented text and new prompt templates to the input sequence encoder for encoding, outputting hidden layer word vectors;
[0013] Step 6: Use a decoder composed of three global pointer networks to jointly decode the entity positions and relationships in the hidden layer word vectors to obtain head entity positions, tail entity positions, and relationships, forming relationship triples; the first global pointer network processes the hidden layer word vectors to identify entity positions, the second global pointer network and the third global pointer network calculate the probabilities of different character pairs acting as head entities and tail entities under a specific relationship, further enabling the model to predict multiple relationships between entities.
[0014] Preferably, the GPT-NEO model in the OpenAI library is called to perform data augmentation on the original text.
[0015] Preferably, the data augmentation method in step 2 includes synonym and near-synonym replacement, same type entity replacement, and sentence reorganization; wherein,
[0016] Synonym and near-synonym replacement generates new sentences by replacing synonyms or near-synonyms of entities or keywords in the sentence;
[0017] Same type entity replacement replaces entities in the sentence with other entities of the same type without changing the sentence structure and geological semantics;
[0018] Sentence reorganization generates new sentences by changing the order of words or phrases in the sentence.
[0019] Preferably, three types of prompt templates are designed according to the head entity, tail entity, and relationship in the triple.
[0020] Preferably, the target templates include entity non-overlapping target templates and entity overlapping target templates.
[0021] Preferably, the process of optimizing the prompt templates in step 4 is as follows:
[0022] Step 41: replace the connection text of the connection context in the prompt template and the target template with the extracted prompt, and merge the replaced target template into the prompt template;
[0023] Step 42: add feature symbols around the entities in the augmented text, determine the entity types of the two entities on both sides of the feature symbols through the prior knowledge of the specific relationship, and obtain an entity prompt embedding representation;
[0024] Step 43: extract the relationship description text corresponding to the domain relationship label set from the augmented text to obtain a relationship prompt embedding representation;
[0025] Step 44: fuse the entity prompt embedding representation and the relationship prompt embedding representation into the prompt template to obtain an optimized prompt template;
[0026] Step 45: map the relationship types according to different meanings of different relationship types to obtain a mapping relationship, and map the relationship types in the optimized prompt template according to the mapping relationship to obtain an updated prompt template. The relationship categories involving the same meaning but different expressions in the constructed prompt template are mapped to provide stronger domain knowledge support when extracting entity relationships.
[0027] Preferably, the formula for calculating the entity prompt embedding representation in step 42 is:
[0028]
[0029] wherein, and represent the prompt embedding representations around the head entity and the tail entity, e represents the word embedding layer of the pre-trained model, P head represents the probability distribution of the head entity type on the known entity label data set; P tail represents the probability distribution of the tail entity type on the known entity label data set; E head and E tail represent the set of head entity types and tail entity types obtained from the augmented text. The pre-trained model can be a BERT model.
[0030] Preferably, the formula for calculating the relationship prompt embedding representation in step 43 is:
[0031]
[0032] wherein, represents the relationship prompt embedding representation, e is the word embedding layer of the pre-trained model, R is the relationship prompt set obtained from the augmented text; P relationrepresents the probability distribution of the relation type on the known relation label dataset Y; R represents the relation prompt set composed of the weighted average of the embedding representations of each label of the existing relation label and the average of the probability distribution.
[0033] Preferably, the input sequence encoder adopts a BERT model, and the output hidden layer word vector contains the semantic environment of the entire text.
[0034] Preferably, the input sequence encoder comprises an encoding layer, a self-attention layer and a multi-head attention layer; the encoding layer sequentially performs word embedding, segment embedding and position embedding on the sequence composed of the enhanced text and the new prompt template to obtain an embedding vector; the self-attention layer calculates global information according to the embedding vector by using a self-attention mechanism; and the multi-head attention layer enhances modeling of the relationship between different words in the global information by using a multi-attention mechanism to obtain a hidden layer word vector.
[0035] The calculation formula of the self-attention layer is:
[0036]
[0037] wherein Q, K and V represent three matrices with sizes of nxd k , mxd k and mxd v respectively; Attention(Q, K, V) represents the global information; and softmax represents an activation function.
[0038] The calculation formula of the multi-head attention layer is:
[0039] MultiHead(Q, K, V) = Concat(head1, head2,..., head n )
[0040] headi = Attention(QW i Q , KW i K , VW i V )
[0041] wherein n represents the number of multi-head attentions; W i Q , W i K and W i V represent mapping weights of Q, K and V respectively; head i represents the global information of the i-th multi-head attention; and MultiHead(Q, K, V) represents the hidden layer word vector.
[0042] Preferably, the decoder in step 6 uses three global pointer networks to complete the three tasks of entity boundary position identification, potential relationship prediction and entity extraction based on specific relationships, and the decoding process of the decoder is as follows:
[0043] Step 61: Linearly transform the hidden layer word vector to a new space through the first global pointer network, and decompose the output into two groups of entity-related query vectors qw entity and entity-related key vectors kw entity corresponding to entities, and calculate the overall boundary position probability score matrix logits entity of all entities through the dot product of the entity-related query vectors qw entity and the entity-related key vectors kw entity , which is expressed as:
[0044] qw entity ·kw entity =Split(E′);
[0045] logits entity =qw entity ×kw entity ;
[0046] Step 62: Linearly transform the hidden layer word vector to a new space through the second global pointer network, and decompose the output into two groups of entity-related query vectors and entity-related key vectors corresponding to the head entity under different relationships, and calculate the head entity boundary position probability score matrix logits head under different relationships through the dot product of the two groups of vectors.
[0047] Step 63: Linearly transform the hidden layer word vector to a new space through the third global pointer network, and decompose the output into two groups of entity-related query vectors and entity-related key vectors corresponding to the tail entity under different relationships, and calculate the tail entity boundary position probability score matrix logits tail under different relationships through the dot product of the two groups of vectors.
[0048] Step 64: Extract entities from the enhanced text according to the overall boundary position probability score matrix; predict the relationship between the head entity and the tail entity using a pre-trained NLP model according to the head entity boundary position probability score matrix and the tail entity boundary position probability score matrix under different relationships; and construct a relationship triple according to the extracted entities and the predicted relationship.
[0049] As can be seen from the above technical solution, compared with the prior art, this invention discloses a geological entity relation extraction method based on domain multi-cue templates. First, to address the problems of unbalanced data quantity and small corpus size in the current geological corpus, a data augmentation method is proposed. Second, to address the problem of different entity and relation word order positions in geological texts, a method based on multi-cue template integration and domain label mapping is proposed. By manually constructing cue templates and target templates and incorporating geological entity and relation embeddings, new cue templates are formed. This method effectively injects geological domain knowledge into the subsequent encoder BERT model, increases the model's understanding of semantic information, and effectively improves the model's generalization ability. It also considers that the manually constructed templates may involve relation categories with different expressions of the same meaning. According to the different meanings of different relation types, the original relation types are mapped to provide stronger domain knowledge support when extracting entity relations. Then, using the BERT model as the encoder, semantic information in the text can be effectively extracted. Finally, a global pointer network is used to predict and jointly decode the head and tail entity boundaries and the head and tail entity boundaries under different relations, effectively solving the problem of entity relation overlap. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0051] Figure 1 A schematic diagram of the geological entity relationship extraction process based on domain multi-hint template provided by the present invention;
[0052] Figure 2 This is a schematic diagram illustrating the construction of the prompt template and the target template in the embodiments provided by the present invention;
[0053] Figure 3 This is a schematic diagram of encoder data transmission provided by the present invention;
[0054] Figure 4 This is a schematic diagram of decoder data transmission provided by the present invention. Detailed Implementation
[0055] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0056] The embodiments of the present application disclose a geological entity relationship extraction method based on a field multi-prompt template, as shown in Figure 1 The specific steps are as follows:
[0057] S1: Data collection and annotation; collect Chinese regional geological survey reports, and perform annotation processing on the collected data to obtain original text;
[0058] S2: Data enhancement; the data enhancement method mainly relies on transformation and rewriting of the original text, and the original text sequence is obtained by calling the GPT-NEO model in the OpenAI library to perform data enhancement on the original text; the method for enhancing data based on prompt learning mainly includes synonym and near-synonym replacement, same type entity replacement and sentence reorganization;
[0059] S3: Constructing a prompt template; the prompt template is constructed in an artificial manner, mainly based on the purpose of the information extraction task, and the prompt template is designed around the three attributes of the head entity, the tail entity and the relationship in the triple, and three types of prompt templates are designed, which are type A, type B and type C; type A: <prompt>"HEAD" Relation <tail>"TAIL"; Type B: <prompt>"Relation" "HEAD" <tail>"TAIL"; Type C: <prompt>"HEAD" <tail>"TAIL" "Relation"; "Relation" denotes a relation; denotes the class of the head entity, <tail>"HEAD" represents a head entity, and "TAIL" represents a tail entity;
[0060] S4: Constructing a target template; in order to solve the problem of overlapping entity relations that may exist in the extraction of geological entity relations, i.e. the case that the same entity has multiple relations with different entities, a corresponding target template is designed; no overlapping of entities: <prompt>["HEAD", "Relation", "TAIL"] ; entities have overlap: <prompt>{“HEAD”, “Relation a”, “TAILa”, +, “Relation b”, “TAIL b”, +, …};
[0061] S5: Preliminary optimization of prompt template; by using the extraction prompt, the natural language used to connect the context in the artificially designed prompt template and the target template is replaced with the extraction prompt, and the prompt template is further optimized;
[0062] S6: Geological entity prompt embedding representation; special symbols [E] are added around the entity in the original input text sequence, and then the entity types of the two marked entities are obtained by giving the prior knowledge of specific relations, and embedding representation is performed; the geological entity prompt embedding representation is integrated into the prompt template;
[0063] S7: Geological relationship prompt embedding representation; extract specific domain relationship labels and their description text from the original input text sequence, and perform embedding representation; the geological relationship prompt embedding representation is integrated into the prompt template, aiming to enhance the semantic understanding of the pre-trained model;
[0064] S8: Geological relationship type mapping strategy; considering that the artificially constructed template will involve relationship categories with different expressions of the same meaning, the original relationship type is mapped according to the different meanings of different relationship types, so as to provide stronger domain knowledge support when extracting entity relationships;
[0065] S9: Use S5-S8 to further update the prompt template formed before, to obtain a new prompt template;
[0066] S10: Input the new prompt template into the input sequence encoder using the BERT model for encoding, and pass the encoded word vectors from the previous layer to the next layer, where the dimensions of the word vectors are the same, and the final output hidden layer word vector contains the semantic environment of the entire text;
[0067] S11: Use the decoder composed of three global pointer networks to jointly decode the entity position and its relationship, determine the head and tail entity positions and the relationship, and extract the relationship triplets, including entity boundary position recognition, potential relationship prediction and entity extraction based on specific relationship;
[0068] S12: Model evaluation of the model composed of input sequence encoder, decoder and address relationship type mapping strategy; mainly use precision, recall and F1 value three key indicators to evaluate the performance of the model.
[0069] In a specific embodiment, a provincial geological record is taken as a data source for geological survey report, the collected data is preprocessed, and the existing 4 categories and 24 subcategories of spatial relationship, structural relationship, attribute relationship and functional relationship are labeled. Based on the above data, a geological entity relationship extraction method based on multi-prompt template integration and domain label mapping is used to extract the geological entity relationship, and the specific steps are as follows:
[0070] S1: The collected data is preprocessed to form a corpus;
[0071] S2: Data augmentation is performed on the current corpus based on prompt learning to form data sample text X; there are three ways of synonym and near-synonym replacement, same type entity replacement and sentence reorganization:
[0072] (1) Synonym and near-synonym replacement: new sentences are generated by replacing the synonyms or near-synonyms of entities or keywords in the sentence, as shown in Table 1;
[0073] Table 1 Synonym and near-synonym replacement data augmentation
[0074]
[0075] (2) Same type entity replacement: without changing the sentence structure and geological semantics, the entity in the sentence is replaced by other entities of the same type, as shown in Table 2;
[0076] Table 2 Same type entity replacement data augmentation
[0077]
[0078] (3) Sentence reorganization: new sentences are generated by changing the order of words or phrases in the sentence. This method can increase the syntactic diversity of the model, so that it can handle sentences of different structures. When reorganizing the sentence, it is necessary to ensure that the semantics of the new sentence is consistent with the original sentence, as shown in Table 3;
[0079] Table 3 Sentence reorganization data augmentation
[0080]
[0081] S3: For the different order of entities and relationships in geological text, artificial prompt templates are constructed, and the entity relationship extraction task is converted into relationship cloze test; according to the three attributes of head entity, tail entity and relationship in the triple, three types of prompt templates are designed, which are type A, type B and type C, as shown in the following Table 4;
[0082] (1) Type A: <prompt>"HEAD" Relation <tail>"TAIL"
[0083] (2) Type B: <prompt>"Relation" "HEAD" <tail>"TAIL"
[0084] (3) Type C: <prompt>"HEAD" <tail>"TAIL”"Relation”
[0085] wherein "Relation" means a relationship; "Class" means a class of head entities, <tail>"HEAD" denotes a head entity, "TAIL" denotes a tail entity; <str>representing a formation;
[0086] Table 4 prompts template
[0087]
[0088] S4: target template generation; in order to solve the entity overlap that may exist in entity relation extraction, that is, there are multiple relations between the same head entity and different entities, if the target template without entity overlap is used, the extracted triplets will be incomplete, therefore, the target template is designed, and the generation process of the target template is as shown in Figure 2 , and specifically as follows:
[0089] (1) entity without overlap: <prompt>: ["HEAD", "Relation", "TAIL"];
[0090] (2) Entities have overlap: <prompt>{ "HEAD", "Relation a", "TAILa", +, "Relation b", "TAIL b", +,...} ;
[0091] Wherein, the target template is connected with "+" sign;
[0092] S5: prompt template preliminary optimization; by using the extraction prompt, the natural language used for connecting the context in the artificially designed prompt template and the target template is replaced with the extraction prompt, and the prompt template is further optimized;
[0093] S6: geological entity prompt embedding representation; the embedding representation of geological entity knowledge refers to adding special symbols [E] around the entity in the original input text sequence, and then obtaining the range of entity types of two marked entities through given prior knowledge of specific relations; for example, given the relation "contains", the head entity may be rock, or mineral, etc., and the tail entity may be rock, or mineral element, etc., therefore, the probability of the existence of the head and tail entities is calculated according to the set of possible existence of the head and tail entities, so as to determine the position of the head and tail entities; the embedding representation formula of the geological entity prompt is as follows:
[0094]
[0095] Wherein, and represent the embedding representation of the prompt around the head entity and the tail entity, P head and P tail represent the probability of possible entity types of the head entity and the tail entity respectively, e represents the word embedding layer of the pre-training model (BERT), E head and E tail represent the set of head entity types and tail entity types obtained from the data sample text X; the embedding representation of the geological entity prompt is integrated into the prompt template;
[0096] S7: geological relation prompt embedding representation; the specific domain relation label and its description text are extracted from the data sample text X, and after embedding representation, they are integrated into the prompt template to obtain the optimized prompt template, which aims to enhance the semantic understanding of the pre-training model; this step is mainly used to estimate the probability distribution P relation of the type of relation on the existing relation label data set Y, and the weighted average of P relation is used to average the embedding representation of each label of the existing relation label, forming the relation prompt set R; the embedding representation formula of the relation prompt is as follows:
[0097]
[0098] Wherein, The representation relation prompt embedding represents, e is a word embedding layer of a pre-training model, R is a set of relation prompts obtained from the data sample text X; P relation The probability distribution of the relation type on the known relation label data set Y;
[0099] S8: According to different meanings of different relation types, the relation type is mapped to obtain a mapping relationship, and the relation type in the optimized prompt template is mapped according to the mapping relationship to obtain an updated prompt template T m ;
[0100] S9: The data sample text X and the updated prompt template T m are spliced to form a new prompt word template T, and then input into a sequence encoder (mainly using a BERT model) for encoding. The input word vector is encoded by the previous layer and passed to the next layer, wherein the dimensions of the word vectors are the same, and finally the output hidden layer word vector contains the semantic environment of the entire text, as shown in Figure 3 The main steps are as follows:
[0101] (1) Input the sequence (X, T) into the BERT model encoder for vector encoding. After word embedding, segment embedding and position embedding, the global information is obtained by self-attention mechanism calculation in the BERT model. The specific calculation formula is as follows:
[0102]
[0103] Wherein, Q, K, V represent three matrices with size nxd Q , mxd k , mxd v , respectively, wherein d Q , d k , d v represent the dimensions of Q, K, V vectors; attention (Q, K, V) represents global information; softmax represents an activation function;
[0104] (2) Use multi-attention mechanism to enhance the modeling of the relationship between different words in the global information, and the calculation formula is as follows:
[0105] MultiHead (Q, K, V) = Concat (head1, head2,..., head n );
[0106] head i = Attention (QW i Q , KW i K , VW i V )
[0107] wherein n represents the number of multi-head attentions, head i represents the output of the i-th multi-head attention; first, according to different weights W i Q , W i K and W i V map to form new Q, K and V values, then calculate the corresponding global information Attention value through head i , and finally splice to output the value of the multi-head attention mechanism;
[0108] S10: decoder; jointly decoding the entity position and its relationship by using three global pointer networks, determining the head and tail entity positions and the relationship, and extracting the relationship triplets, including entity boundary position recognition, potential relationship prediction and entity extraction based on specific relationship, as shown in Figure 4 , the main steps are as follows:
[0109] (1) using a global pointer network to output H(X, T) obtained by BERT encoding, mapping H(X, T) to a new space through linear transformation, and decomposing the output into qw entity and kw entity two parts, the specific formula is as follows;
[0110] qw entity ·kw entity =Split(E′)
[0111] wherein qw entity represents the query vector related to the entity, kw entity represents the key vector related to the entity; Split represents the splitting operation; E' represents the output of BERT encoding mapped to the new space;
[0112] Calculate the dot product between qw entity and kw entity , generate the head and tail entity boundary position probability score matrix logits entity , which represents the possibility of different characters as the boundary position of the head entity and the tail entity respectively, and the specific calculation formula is as follows:
[0113] logits entity =qw entity ×kw entity
[0114] Through the above calculation, the boundary position of the entity can be obtained, so as to identify the entity;
[0115] (2) Use two global pointer networks to calculate the probability of different entities as head entities and tail entities under a certain relationship, respectively, to obtain the probability score matrix of the head and tail boundary positions of different entities as head entities and tail entities under different relationships logits head and logits tail ; use different matrices to represent different relationship types, so that the pre-trained NLP model can predict multiple relationships between entities;
[0116] (3) Construct the predicted relationship of the extracted entity into a relationship triple;
[0117] S11: Model evaluation; mainly use precision, recall and F1 value three key indicators to evaluate the performance of the model comprehensively, and the specific results are shown in Tables 5 and 6;
[0118] Table 5 Comparison of experimental results
[0119]
[0120] Table 6 Comparison of different data enhancement methods
[0121]
[0122] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the related parts can be referred to the method part.
[0123] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.< / prompt> < / prompt> < / str> < / tail> < / tail> < / prompt> < / tail> < / prompt> < / tail> < / prompt> < / prompt> < / prompt> < / tail> < / tail> < / prompt> < / tail> < / prompt> < / tail> < / prompt>
Claims
1. A method for extracting geological entity relations based on a field multi-prompt template, characterized in that, The method comprises the following steps: Step 1: collecting a geological survey report and preprocessing the original text; Step 2: data augmentation is performed on the original text to obtain augmented text; Step 3: constructing a prompt template and a target template; Step 4: optimizing the prompt template using the augmented text and the target template to obtain an updated prompt template; Step 5: splicing the augmented text and the updated prompt template to obtain a new prompt template, and transmitting the augmented text and the new prompt template to an input sequence encoder for encoding to output a hidden layer word vector; Step 6: jointly decoding the entity position and the relationship in the hidden layer word vector using a decoder composed of three global pointer networks to obtain a head entity position, a tail entity position and a relationship, and forming a relationship triple.
2. The method of claim 1, wherein the method is a method of extracting relationships of geological entities based on a domain multi-prompt template. The data augmentation method in step 2 includes synonym and near-synonym replacement, same type entity replacement and sentence reorganization; wherein, The synonym and near-synonym replacement generates a new sentence by replacing the synonym or near-synonym of an entity or a keyword in the sentence; The same type entity replacement replaces an entity in the sentence with another entity of the same type without changing the sentence structure and geological semantics; The sentence reorganization generates a new sentence by changing the order of words or phrases in the sentence.
3. The method of claim 1, wherein the method further comprises: Three kinds of prompt templates are designed according to the head entity, the tail entity and the relationship in the triple.
4. The method of claim 1, wherein the method further comprises: The target template includes an entity non-overlapping target template and an entity overlapping target template.
5. The method of claim 1, wherein, The process of optimizing the prompt template in step 4 is as follows: Step 41: using an extraction prompt to replace the connection text connecting the context in the prompt template and the target template, and merging the replaced target template into the prompt template; Step 42: adding feature symbols around the entities in the augmented text, determining the entity types of the two entities on both sides of the feature symbols through prior knowledge of specific relationships, and performing word embedding processing to obtain entity prompt embedding representation; Step 43: extracting relationship description text corresponding to the domain relationship label set from the augmented text, and performing word embedding processing to obtain relationship prompt embedding representation; Step 44: fusing the entity prompt embedding representation and the relationship prompt embedding representation into the prompt template to obtain an optimized prompt template; Step 45: mapping the relationship types according to their different meanings to obtain a mapping relationship, and mapping the relationship types in the optimized prompt template according to the mapping relationship to obtain an updated prompt template.
6. The method of claim 5, wherein the method further comprises: The formula for calculating the entity prompt embedding representation in step 42 is: wherein, and respectively represent a head entity hint embedding representation and a tail entity hint embedding representation, e represents a word embedding layer of a pre-trained model; P head represents a probability distribution of the head entity type over the known entity label dataset; P tail represents a probability distribution of the tail entity type over the known entity label dataset; E head and E tail respectively represent a set of head entity types and a set of tail entity types obtained from the augmented text.
7. The method of claim 5, wherein the method further comprises: The formula for calculating the relationship prompt embedding representation in step 43 is: wherein, denotes the relation hint embedding representation, e is a word embedding layer of a pre-trained model, and R is a set of relation hints obtained from the augmented text; P relation denotes the probability distribution of the relation type over the known relation label dataset; R denotes a set of relation hints composed by averaging the embedding representations of each token of the existing relation label with the weighted average of the probability distribution.
8. The method of claim 1, wherein, The input sequence encoder includes an encoding layer, a self-attention layer and a multi-head attention layer; The encoding layer sequentially performs word embedding, segment embedding and position embedding on the sequence composed of the augmented text and the new prompt template to obtain an embedding vector; the self-attention layer uses a self-attention mechanism to calculate global information according to the embedding vector; and the multi-head attention layer uses a multi-attention mechanism to enhance the modeling of the relationship between different words in the global information to obtain a hidden layer word vector.
9. The domain-based multi-prompt template-based geologic entity relationship extraction method of claim 1, wherein, The process of decoding by the decoder is as follows: Step 61: Linearly transform the hidden layer word vectors to a new space by the first global pointer network, and decompose the output into two groups of entity-related query vectors qw entity and entity-related key vectors kw entity ; and calculate the overall boundary position probability score matrix logits entity of all entities by the dot product of entity-related query vectors qw entity and entity-related key vectors kw entity ; represented as: qw entity ·k wentity = Split(E'); logits entity = qw entity x kw entity ; Step 62: mapping the hidden layer word vectors to a new space by linear transformation through a second global pointer network, and decomposing the output into two groups of entity-related query vectors and entity-related key vectors corresponding to the head entity under different relations, and calculating the head entity boundary position probability score matrix under different relations through the dot product of the two groups of vectors; Step 63: mapping the hidden layer word vectors to a new space by linear transformation through a third global pointer network, and decomposing the output into two groups of entity-related query vectors and entity-related key vectors corresponding to the tail entity under different relations, and calculating the tail entity boundary position probability score matrix under different relations through the dot product of the two groups of vectors; Step 64: extracting entities from the augmented text according to the overall boundary position probability score matrix; predicting the relationship between the head entity and the tail entity by using a pre-trained NLP model according to the head entity boundary position probability score matrix and the tail entity boundary position probability score matrix under different relations; and constructing a relationship triple according to the extracted entities and the predicted relationship.
Citation Information
Patent Citations
Method, system and equipment for extracting entity relationship of Chinese and English books
CN115658898A
End-to-end relation extraction method and system fusing entity and relation information
CN116628174A