Forest fire knowledge modeling method based on named entity recognition and relation extraction
By combining multi-granularity adaptive word segmentation and dynamic standardization with pre-trained language models and spatiotemporal causal attention mechanisms, the accuracy and synergy issues of named entity recognition and relation extraction in the field of forest fires are solved, and a high-quality forest fire knowledge graph is constructed to support forest fire prevention and control decisions.
Patent Information
- Application Number
- CN202610049274.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-15
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2046-01-15
AI Technical Summary
Existing technologies for named entity recognition and relation extraction in the field of forest fires suffer from limitations in entity recognition accuracy, lack of coordination between entity type and relation information, high uncertainty in relation extraction results, and failure to explicitly incorporate spatiotemporal constraints and causal priors in the fire domain, resulting in low-quality knowledge graphs.
By employing multi-granularity adaptive word segmentation and dynamic standardization, combined with a pre-trained language model and a spatiotemporal causal attention mechanism, and optimizing the named entity recognition and relation extraction models through a multi-task joint training framework, a knowledge graph of forest fires is constructed.
It improves the stability and reliability of forest fire knowledge extraction, achieves high-precision entity recognition and relationship extraction, and constructs a high-quality knowledge graph to support forest fire prevention and control decision-making.
Smart Images

Figure CN121524352A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and particularly relates to a forest fire knowledge modeling method based on named entity recognition and relation extraction. BACKGROUND
[0002] The prior art has the following deficiencies: most of the prior art uses fixed granularity segmentation or general segmentation tools, which is difficult to adapt to the large number of professional compound terms and entity nested structures in the forest fire field, resulting in limited entity recognition accuracy; the existing named entity recognition and relation extraction methods are mostly pipeline or weakly coupled modeling, and there is a lack of effective coordination between entity types and relation information, and errors are easily propagated and amplified between stages; the existing relation extraction model mainly relies on semantic similarity or context features, and does not explicitly introduce temporal and spatial constraints and causal priors in the fire field, which is easy to produce relation results that violate common sense or domain rules; the existing method usually lacks a unified quantitative mechanism for the uncertainty of the extraction results, making it difficult to evaluate the reliability of the relation triplets, which is not conducive to building high-quality domain knowledge graphs that can be used for decision support.
[0003] Therefore, the present application proposes a forest fire knowledge modeling method based on named entity recognition and relation extraction to solve the above problems. SUMMARY
[0005] The present application is directed to the deficiencies of the prior art, and develops a forest fire knowledge modeling method based on named entity recognition and relation extraction. The present application can efficiently mine forest fire field knowledge and provide accurate knowledge support for forest fire prevention and control.
[0006] The technical scheme for solving the technical problem of the present application is a forest fire knowledge modeling method based on named entity recognition and relation extraction, comprising the following steps: S1, collect original text data in the forest fire field to construct an original text corpus, clean and preprocess the data in the original text corpus, and then label the entities and relations in the data to form a text data set, which contains text content, entity labeling and entity relation triplet list; S2, construct a named entity recognition and relation extraction model, perform multi-granularity adaptive segmentation and dynamic standardization on the text data in the text data set to generate a standardized multi-granularity word sequence, then perform feature enhancement on the standardized multi-granularity sequence based on a pre-trained language model encoder, and perform entity recognition and relation extraction oriented to forest fire knowledge to obtain the global confidence of the instance and relation triplets; S3, adopt a multi-task joint training framework, calculate the total loss function of the model based on the labeled data and the model prediction results, the total loss function is composed of entity recognition composite loss, relationship extraction adaptive contrast loss and multi-granularity consistency regularization loss, and the model parameters are optimized in an end-to-end manner, and the trained model is obtained; S4, input the new and unlabeled forest fire field text into the trained model, perform named entity recognition and relationship extraction, obtain the final type prediction of each entity, and then obtain the global confidence of the instance and relationship triplets, and select the relationship triplets with confidence higher than the preset threshold as the final extraction result; S5, based on the relationship triplets extracted from a large number of forest fire texts, a structured forest fire field knowledge graph is constructed.
[0007] S1 is as follows: Collect original text data in the forest fire field to construct an original text corpus, clean and pretreat the data in the original text database, and then label the entities and relationships in the data to form a text data set, which includes text content, entity labeling and entity relationship triplet list; The original text data is collected by combining the crawler technology with manual collection, and the data sources include public forest fire related academic literature database, public disaster investigation report, public historical fire event record and public real forest fire report text; The cleaning and pretreatment operation includes removing irrelevant formats, correcting obvious wrong characters, and unifying the expression of numbers and units; Manually label the entity boundaries and types and the relationships between entities in the text according to the pre-defined labeling specifications. The labeling categories of entities are set according to the characteristics of forest fire field knowledge, including geographical location, fire source type, disaster event, meteorological condition and rescue force. The interaction type between entities is defined through relationship labeling.
[0008] S2.1 multi-granularity adaptive segmentation and dynamic standardization operation is as follows: S2.1.1, based on the text content of the text data set, three preset granularity levels of domain dictionary are constructed by spectral clustering algorithm, and the sliding window center point and width parameters are initialized for each dictionary segment; the total number of preset granularity levels is used to organize the multi-scale dictionary structure, which respectively corresponds to the three semantic scales of character, word and phrase, indicates the granularity level index, when i=1, 2, 3, it respectively represents the character level, word level and phrase level; The domain text vector is dynamically divided into clusters by spectral clustering algorithm, Indicates the first The total number of dictionary segments at each granularity level, the first The granularity level is the first Each dictionary segment is represented as follows: , Indicates the first Dictionary segment index within each granularity level; the... The granularity level is the first The cluster center vector of each dictionary segment is represented as: , No. The granularity level is the first The center point parameter of each dictionary segment is represented as follows: , No. The granularity level is the first The window width parameter for each dictionary segment is expressed as: .
[0009] S2.1.2. Based on the global semantic vector of the current text content and the cluster centers of each dictionary segment, The distance is used to dynamically calculate the weight coefficient of each dictionary segment in the current word segmentation process; The process involves inputting the string of the current text content into a pre-trained BERT language model to obtain the final hidden state vector of its [CLS] tag, or performing average pooling on the hidden states of all tags to obtain a global semantic vector representation. S2.1.3. By combining a Gaussian kernel with a nonlinear adjustment function in a sliding window function, the context range of word segmentation operations at each granularity level is dynamically determined. The input to the adaptive sliding window function at each granularity level is the length offset of the current text, calculated by subtracting the center point parameter from the string length. Divide by the window width parameter The output of the adaptive sliding window function at each granularity level is used to modulate the intensity or confidence of word segmentation at that granularity level. S2.1.4. The original text is matched with the dictionary segments at each granularity level through matching and transformation functions to perform multi-pattern matching, and then the matching results are converted into corresponding feature vector representations. The matching and transformation function includes a matching pattern function and an embedding transformation function. The matching pattern function outputs different matching scores based on different matching patterns, while the embedding transformation function is used to convert the matched text fragments into feature vectors of fixed dimensions. S2.1.5 integrates the weight coefficients of each granularity layer, the output of the adaptive sliding window function, and the output of the matching and transformation functions, and generates a standardized multi-granularity word sequence representation matrix through splicing operations.
[0010] S2.2 Feature enhancement operations based on the pre-trained language model encoder are as follows: Feature enhancement is performed using a pre-trained language model encoder. This encoder employs a pre-trained BERT model, taking the standardized multi-granularity word sequence representation matrix of the current text content as input. Through BERT's internal multi-layer self-attention mechanism, semantic associations and dependencies are automatically captured, thereby obtaining the contextual representation and yielding the hidden state matrix output by BERT. The dimension of the hidden state matrix is... , Indicates the length of the input sequence. This represents the hidden layer dimension of the BERT model.
[0011] The specific operations for entity recognition and relation extraction of forest fire knowledge in S2.3 are as follows: S2.3.1. A gated fusion module is used to adaptively fuse the standardized multi-granularity word sequence representation matrix with the hidden state matrix to generate enhanced entity candidate representations, and entity boundary detection is performed on this basis. Specifically, an alignment matrix is first calculated using an attention mechanism to semantically align the two feature matrices along the sequence length dimension; then, through an alignment operation, the length of the hidden state matrix is obtained. Consistent alignment of multi-granularity feature matrices; then, a gating mechanism is used to fuse the hidden state matrix and the aligned multi-granularity feature matrix to generate an enhanced feature matrix; entity boundary detection is completed through dual affine markers, predicting the label probability of each enhanced feature vector in the enhanced feature matrix belonging to the beginning of an entity, inside an entity, or outside an entity; Among them, the dual affine marker is a neural network layer used for sequence labeling; S2.3.2. The spatiotemporal causal attention mechanism is used to directly model the potential relationship strength between any two candidate entities across the span, and the prior knowledge of fire events is incorporated. The specific assumption is that the boundary detection results are decoded. There are *n* candidate entities, each with its representation vector and type embedding vector. For any two candidate entities, calculate the relation strength score of the entity pair; the representation vectors of any two candidate entities are represented as follows: and The type embedding vector is represented as and , and Indicates the index of candidate entity M. ; The relationship strength score is obtained by adding three data items, including the product of the representation vectors of any two candidate entities and the weight matrix of their semantic interaction, the causal prior term, and the spatiotemporal constraint term. The causal prior term is used to inject causal logical priors specific to the forest fire domain, and the spatiotemporal constraint term is used to model the attenuation effect of spatial distance and time interval on the relationship strength. S2.3.3, using the relationship strength score as attention guidance, collaborative reasoning is performed on the type prediction of each entity; Specifically, for the first entity, the information of all other entities related to it is weighted and aggregated to obtain the context aggregation vector of the first entity, and then after aggregating the context information, the final type prediction probability of the first entity is obtained through the Softmax activation function; S2.3.4, the global confidence of each candidate triple is calculated by integrating entity boundary, entity type and entity relationship strength information, and the final output is obtained by threshold filtering; Specifically, the relationship strength score is converted into the probability of a specific relationship type, and the global confidence of the triple is determined by the entity type confidence, the relationship type confidence and the entity boundary confidence.
[0012] S3.1 The total loss function calculation process is as follows: (1) The entity recognition composite loss includes boundary detection loss and entity type classification loss, and a focus loss variant based on entity distribution rules is introduced; The boundary detection loss adopts a cross-entropy loss function, which is calculated based on the real distribution of the boundary label from artificial labeling and the boundary label probability calculated from the model; The entity type classification loss adopts an improved focus loss function, which is calculated from the real type one-hot encoding vector labeled by artificial labeling and the probability of the type to which the entity belongs predicted by the model; The boundary detection loss and the entity type classification loss are weighted and added to obtain the entity recognition composite loss; (2) The relationship extraction adaptive contrast loss adopts a contrast loss with adaptive margin, which narrows the positive triple and pushes away the negative triple through the contrast loss with adaptive margin; (3) The multi-granularity consistency regularization loss adopts a consistency regularization term based on multi-granularity features, which constrains the output stability of the model under different granularity feature perturbations; The entity recognition composite loss, the relationship extraction adaptive contrast loss and the multi-granularity consistency regularization loss are weighted and added to obtain the total loss function.
[0013] S3.2 The joint training process of the model is as follows: Based on the total loss function, the named entity recognition and relationship extraction model is trained end-to-end; The text data set in S1 is divided into a training set and a validation set, the training process uses data in the training set, and the AdamW optimizer is used to perform gradient descent based on the total loss value to iteratively update all trainable parameters in the model; In each training iteration, the batch data is calculated by forward propagation to obtain entity boundary probability, entity type probability, relationship strength score and final triple confidence, and then the total loss function is calculated according to the true label; through the back propagation algorithm, the gradient of the total loss function is calculated and used to update all trainable parameters, so that the model synchronously optimizes the ability of entity recognition and relation extraction; during the training process, the model performance is periodically evaluated using the validation set to monitor the changes of the entity recognition and relation extraction indicators; The judgment condition for stopping iteration is set: the comprehensive performance indicators on the validation set no longer improve for a plurality of consecutive training cycles, or reach the preset maximum training round; The model parameters with the best performance on the validation set are saved as the trained named entity recognition and relation extraction model.
[0014] S4 is as follows: The new original text to be extracted is input into the trained named entity recognition and relation extraction model, and after multi-granularity adaptive segmentation and dynamic standardization processing, a standardized multi-granularity word sequence representation matrix of the text is generated; then, the pre-trained BERT encoder is used for feature enhancement to obtain a hidden state matrix rich in context semantic information; then, the trained entity representation and boundary detection module fused with multi-granularity features is used to identify the boundaries of all candidate entities in the text and their corresponding enhanced feature vectors from the enhanced features; then, based on these candidate entities, the trained entity relationship strength modeling module based on the spatio-temporal causal attention mechanism is called to calculate the potential relationship strength score between any two entities, and simultaneously perform relationship-aware entity type collaborative reasoning to obtain the final type prediction of each entity; Finally, according to the triple confidence integration and threshold filtering mechanism, the global confidence of all possible triples is calculated by integrating the entity boundary confidence, entity type confidence and relationship type probability, and filtered according to the preset dynamic threshold, and the relationship triples with confidence higher than the threshold are retained as the final extraction result.
[0015] S5 is as follows: First, post-processing and fusion are performed on all extracted triples, including entity normalization, relationship verification and confidence weighting; Then, the processed triples are used as knowledge units and stored and organized using a Neo4j graph database or a special knowledge graph construction tool; In the graph, each unique entity is a node, and its attributes include entity name, type and additional information that may be extracted from the original text; each relationship is a directed edge connecting two nodes, and its attributes include relationship type and extraction confidence; Finally, the unstructured text data is converted into a semantic network with entities as nodes and relationships as edges, forming a forest fire knowledge graph.
[0016] The effects provided in the summary are only the effects of the embodiments, not all the full effects of the application, and the above technical solutions have the following advantages or beneficial effects: The application discloses a forest fire knowledge modeling method based on named entity recognition and relation extraction, adopts a multi-granularity self-adaptive word segmentation and dynamic standardization mechanism for a forest fire field, cooperatively models through character level, word level and phrase level, combines trainable clustering centers and sliding window parameters, effectively solves the problems of ambiguous professional term boundaries and serious entity nesting, constructs a gated enhanced entity representation method fusing multi-granularity dictionary features and pre-training language model context representation, realizes deep complementation of general semantic understanding ability and field prior knowledge through attention alignment and gated fusion, adopts an entity relation strength modeling mechanism of spatiotemporal constraint and causal prior, explicitly integrates spatial distance, time interval and fire causal type compatibility into the relation modeling process, and breaks through the limitation of insufficient physical and logical law perception of pure data-driven relation extraction, adopts a joint training framework of entity recognition, relation extraction and multi-granularity consistency regularization, realizes collaborative optimization of entity boundaries, entity types and relation triples through composite loss and adaptive contrast learning, and improves the stability and reliability of overall knowledge extraction. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings are included to provide a further understanding of the application, and constitute a part of the specification, illustrate the application, and are used to explain the application together with the embodiments of the application, and do not constitute a limitation on the application.
[0018] Figure 1 It is a method flowchart of the application.
[0019] Figure 2 It is a schematic diagram of the multi-granularity dictionary for the forest fire field.
[0020] Figure 3 It is an entity recognition result obtained by using the method of the application.
[0021] Figure 4 It is an example of the knowledge graph constructed by using the method of the application.
[0022] Figure 5 It is a triple relation corresponding to the forest fire as a queried entity. DETAILED DESCRIPTION
[0023] In order to clearly illustrate the technical features of the scheme, the application will be described in detail below with reference to the specific embodiments and the accompanying drawings.
[0024] Embodiment 1 As Figure 1 shown, a forest fire knowledge modeling method based on named entity recognition and relation extraction includes the following steps: S1, collect original text data in the field of forest fire to construct an original text corpus, clean and preprocess the data in the original text corpus, and then label the entities and relations in the data to form a text dataset containing text content, entity labeling, and entity relation triple lists; S2, build a named entity recognition and relation extraction model, perform multi-granularity adaptive segmentation and dynamic standardization on the text data in the text dataset to generate a standardized multi-granularity word sequence, then perform feature enhancement on the standardized multi-granularity sequence based on a pre-trained language model encoder, and perform entity recognition and relation extraction for forest fire knowledge to obtain global confidence of instance and relation triples; S3, use a multi-task joint training framework, calculate the total loss function of the model based on the labeled data and the model prediction results, and the total loss function is composed of entity recognition composite loss, relation extraction adaptive contrast loss, and multi-granularity consistency regularization loss. The model parameters are optimized in an end-to-end manner, and the trained model is obtained. S4, input new, unlabeled forest fire field text into the trained model to perform named entity recognition and relation extraction, obtain the final type prediction of each entity, and then obtain the global confidence of instance and relation triples. Select the relation triple with a confidence higher than the preset threshold as the final extraction result. S5, based on the relation triples extracted from a large number of forest fire texts, construct a structured forest fire field knowledge graph.
[0025] In the specific implementation, S1 is as follows: Systematically collect original text data in the field of forest fire, and the data sources mainly include public forest fire related academic literature library, public disaster investigation report, public historical fire event record, and public authoritative news media report on forest fire; through the combination of crawler technology and manual collection, a large-scale and high-quality original text corpus is constructed.
[0026] After obtaining the original text, strict cleaning and preprocessing are performed, including removing irrelevant formats, correcting obvious misspelled words, unifying number and unit expressions, etc., to ensure the quality of the text.
[0027] Then, the training data set is constructed, and the text is finely annotated; manually according to the pre-defined annotation specification, the entity boundary and type in the text and the relationship between entities are manually annotated, the annotation categories of entities are set according to the characteristics of forest fire field knowledge, mainly including: geographical location (such as mountainous area, forest farm), fire source type (such as lightning, human-caused fire), disaster event (such as fire, smoke), meteorological condition (such as high temperature, dryness, strong wind), rescue force (such as fire brigade, helicopter) and the like; the annotation categories of the relationship define the main interaction types between entities, for example: the relationship of “occurred in” connects the disaster event and the geographical location, the relationship of “caused by” connects the disaster event and the fire source type, the relationship of “resulted in” connects the fire source or the meteorological condition and the disaster event, the relationship of “adopted” connects the rescue force and the specific action and the like; the annotation process adopts the mode of multiple annotation and expert arbitration to ensure the consistency and accuracy of the annotation.
[0028] The annotated text data is divided into a training set and a validation set to form a standardized data set for model training and evaluation, including text content, corresponding entity annotation sequence and entity relationship triple list.
[0029] In the specific implementation, S2 constructs the named entity recognition and relationship extraction model as follows: S2.1, multi-granularity adaptive segmentation and dynamic standardization The forest fire field knowledge text data contains a large number of professional compound terms, the entity boundary is fuzzy, and the semantic structure has a multi-scale nesting phenomenon, so the conventional segmentation method based on a general dictionary cannot accurately segment the field-specific terms and cannot effectively process the entity nesting problem, and the fixed-granularity segmentation strategy is also difficult to adapt to the semantic representation requirements of different length texts such as short reports and detailed papers. The present application processes the original forest fire text data through multi-granularity adaptive segmentation and dynamic standardization to cope with the diversity of professional terms, the fuzziness of entity boundaries and the multi-scale nature of semantics, and converts the original text into a standardized multi-granularity word sequence representation, and the specific steps are as follows: S2.1.1, multi-granularity dictionary and parameter initialization Based on the forest fire field corpus, three preset granularity levels of domain dictionary of character level, word level and phrase level are constructed by spectral clustering algorithm, and the sliding window center point and width parameters are initialized for each dictionary segment; The domain corpus comes from academic literature, disaster reports and news texts related to forest fires, and is automatically divided according to the semantic vector similarity of the text segment by spectral clustering algorithm to form a hierarchical dictionary structure; Specifically, the total number of preset granularity levels is for organizing the multi-scale dictionary structure, respectively corresponding to the three semantic scales of character, word and phrase, and defining This represents a granularity level index, used to identify a specific level. Time represents the character level. Time represents word level, The time period represents a phrase level; definition Indicates the first The total number of dictionary segments at each granularity level is used to dynamically divide the domain text vectors into segments using a spectral clustering algorithm. A cluster, defined Indicates the first The dictionary segment index within each granularity level is a positive integer used to identify a specific segment at that level. Indicates the first The granularity level is the first Each dictionary segment contains a set of semantically similar domain terms; definition Indicates the first The granularity level is the first The cluster center vector of each dictionary segment represents the average semantic feature of the terms within that segment. Defined... Indicates the first The granularity level is the first The center point parameters of each dictionary segment, representing the preferred text length center of that segment, are trainable parameters that are dynamically updated during training. They are defined as follows: Indicates the first The granularity level is the first The window width parameter of each dictionary segment controls the sensitivity range of the segment to changes in text length. It is a trainable parameter and is dynamically updated during training.
[0030] A multi-granularity dictionary for forest fire research is available for details. Figure 2 .
[0031] S2.1.2 Calculate the piecewise adaptive weight coefficients Based on the distance between the global semantic vector of the current text sample and the cluster centers of each dictionary segment, the weight coefficient of each dictionary segment in the current word segmentation process is dynamically calculated, enabling the model to adaptively focus on the domain term fragments most relevant to the current text, as shown below: In the formula, Indicates for the first The text sample, the first The first granularity level The adaptive weight coefficient of each dictionary segment, the larger the value, the higher the feature contribution of the segment to the current text; Indicates the first A text sample string vectorized representation of the text, obtained by pre-trained language model, as global semantic representation of the text; denotes the weight decay coefficient of the -th granularity level, controlling the sensitivity of the difference between text representation and cluster center to weight calculation, is a trainable parameter; denotes the index of the text sample in the batch, is a positive integer, ; denotes the batch size; denotes the L2 norm.
[0032] obtained by pre-trained BERT language model, the specific steps are as follows: input the -th text sample string into the pre-trained BERT language model, obtain the final hidden state vector of its [CLS] token, or perform average pooling on the hidden states of all tokens, as the vector representation of the entire text.
[0033] S2.1.3, applying adaptive sliding window function By combining the Gaussian kernel and the nonlinear adjustment function of the sliding window function, the context range of the segmentation operation of each granularity level is dynamically determined to smooth the boundary and enhance the adaptability to language units of different lengths, which is represented as: In the formula, denotes the adaptive sliding window function of the -th granularity level, and the output value is used to modulate the strength or confidence of the segmentation of the granularity level; denotes the input variable of the function, which refers to the normalized text length offset in the adaptive sliding window function, and is represented as ; denotes the length of the -th text sample string ; denotes the nonlinear adjustment coefficient of the -th granularity level, is a trainable parameter, which is used to adjust the slope of the hyperbolic tangent activation function, is a trainable parameter; denotes the hyperbolic tangent activation function, which introduces nonlinearity to enhance the modeling ability of the model for fuzzy boundary conditions.
[0034] It should be noted that, the term adopts the calculation method of Gaussian kernel, representing the weight distribution of the local text window centered at , which is used to define a segment centered at , The probability density function of the variance is used to generate a weight value based on the length of the current text and the offset of the center point. The larger the weight value, the closer the current text length is to the typical length preferred by the segment, and the higher the confidence of the segment being activated during word segmentation. Using a Gaussian kernel can smoothly model the nonlinear relationship between text length and word segmentation granularity, making the model robust to length changes.
[0035] S2.1.4 Perform multi-pattern matching and feature transformation The original text is segmented into dictionary segments at various granular levels for multi-pattern matching, and the matching results are converted into corresponding feature vector representations, as follows: In the formula, Indicates the first The granularity level is the first The function for matching and transforming the dictionary segments takes the nth segment as input. A text sample string and the The granularity level is the first Each dictionary segment The output is the first... Feature representation at each granularity level; Indicates the first Level 1 The total number of matching patterns used in a segment is a hyperparameter, manually set according to task requirements. Common matching patterns include: exact matching, prefix matching, suffix matching, containment matching, and fuzzy matching based on edit distance. All segments can take the same value, such as 3 or 4; This represents the index of the matching pattern, which is a positive integer; Indicates the first The granularity level is the first The first dictionary segment The weight coefficients of each matching pattern are trainable parameters used to measure the importance of different matching patterns; Indicates the first The granularity level is the first The first dictionary segment Such matching pattern functions, for example, when For exact string matching, For fuzzy matching based on edit distance, this function outputs a matching score; Indicates the first The granularity level is the first The dictionary segment and the first The embedding transformation function corresponding to each matching pattern is used to convert the matched text fragments into feature vectors of fixed dimensions.
[0036] function Used to calculate the A text sample string Segmentation with dictionary In the Scoring in various matching modes, taking two common modes as examples, when If the time corresponds to an exact match, then the function can be defined as follows: In implementation, an efficient multi-pattern string matching algorithm can be used to simultaneously detect the occurrence of all terms, such as the Aho-Corasick algorithm. For time-based fuzzy matching based on edit distance, the function can be defined as follows: ,in, This indicates calculating the Levenstein distance between two strings. Indicates dictionary segmentation A term string, Indicates the first A text sample string The length of the characters, Term string The character length, further, the score is normalized to The interval is defined by the value; a higher value indicates greater similarity.
[0037] function The matched text fragments are converted into fixed-dimensional feature vectors. Taking a pre-trained BERT model as an example, for text fragments from... Text fragments matched in Input it into the pre-trained BERT model to obtain the fragment representation, which is represented as ,in, This represents the vector labeled [CLS] in the BERT output. Representing fragments The Middle A vector of tags.
[0038] It should be noted that, It is used to measure the contribution of the current matching pattern to the final matching result. As a trainable parameter, it enables the model to automatically learn the importance of different matching patterns in different contexts. For example, for technical terms, exact matching may have a higher weight, while for colloquial descriptions, fuzzy matching may have a higher weight.
[0039] S2.1.5, Generate standardized multi-granularity word sequences Integrate the weighted, windowed, and matching transformation results at each granularity level, and generate a standardized multi-granularity word sequence representation matrix through concatenation operations, which is expressed as: In the formula,[[]]END]] represents the standardized multi-granularity word sequence representation matrix of the th text sample, which is the feature representation matrix output after multi-granularity adaptive word segmentation and dynamic standardization, with a dimension of ; represents the multi-granularity adaptive word segmentation and dynamic standardization processing function, which is used to convert unstructured original text into a standardized feature matrix that integrates multi-scale semantic information; represents the concatenation operator, which is used to concatenate the feature representations calculated at different granularity levels on the feature dimension; represents the sequence length after the finest granularity division; represents the total dimension of the concatenated multi-granularity feature vectors.
[0040] In the specific implementation process, assume a sentence "The forest fire risk level has increased". After the finest granularity division , that is, after division, we get "森", "林", "火", "险", "等", "级", "升", "高". Assume the character-level feature dimension is 64, the word-level is 128, and the phrase-level is 64, then , then is a matrix, and each row of the matrix corresponds to a character position, but the row vector integrates the feature information of the character, word, and phrase at three granularity levels.
[0041] S2.2. Feature Enhancement Based on the Pre-trained Language Model Encoder Use the pre-trained language model encoder for feature enhancement. The pre-trained language model encoder adopts the pre-trained BERT model. Regard the standardized multi-granularity word sequence representation matrix of the th text sample as the input, and obtain the context representation through the pre-trained BERT model. The multi-layer self-attention mechanism inside BERT can automatically capture semantic associations and dependencies, and obtain the hidden state matrix output by BERT. Define to represent the hidden state matrix of the th text sample output by BERT, with a dimension of ; Among them, represents the length of the input sequence, which is based on the number of tokens of BERT, including special tokens [CLS], [SEP], etc.; This represents the hidden layer dimension of the BERT model, such as the hidden layer dimension of BERT-base. .
[0042] In the specific implementation process, if the input sentence "Forest fire risk level increased" is segmented into 8 tokens by BERT, then... , The dimension is .
[0043] S2.3 Entity Recognition and Relation Extraction for Forest Fire Knowledge To address the diverse entity types and complex relationships in the field of forest fires, conventional sequence labeling and relation classification models struggle to effectively model deep semantic relationships and complex interactions between entities. This invention, based on context-enhanced features obtained through feature enhancement using a pre-trained language model encoder, employs a joint relation extraction mechanism that integrates entity type priors and multi-granularity interaction awareness. By modeling the interdependencies between entity boundaries, entity types, and relation triples, it achieves accurate domain knowledge extraction. The specific steps are as follows: S2.3.1 Entity Representation and Boundary Detection Integrating Multi-Granularity Features Directly utilizing the context-enhanced features output by the pre-trained language model encoder for entity recognition may overlook the multi-scale semantic information generated by multi-granularity adaptive word segmentation and dynamic standardization. This invention employs a gated fusion module to adaptively fuse the standardized multi-granularity word sequence representation matrix with the context-enhanced features output by the encoder, generating enhanced entity candidate representations. Based on this, entity boundary detection is performed. Specifically... First, an alignment matrix is calculated using an attention mechanism to achieve semantic alignment of the two features along the sequence length dimension, as shown below: In the formula, Represents the alignment matrix The Middle Line number The element value of the column, i.e., the first element of the encoder output sequence. The position and the multi-granularity sequence The semantic alignment weight between positions, the larger the value, the more related the two positions are; This represents the position index in the encoder output sequence, and is a positive integer with a value range of 1 to 2. ; Representation matrix of standardized multi-granular word sequence The row index in the table corresponds to the position after the finest-grained partitioning, and is a positive integer with a value range of 1 to 2. ; Indicates the first The length of a text sample after being divided into the finest-grained segments, with the default finest-grained segment being the character level; Represents the natural exponential function; Indicates the BERT output of the th The hidden state matrix of each text sample The Row vector, dimension ; Indicates the first Standardized multi-granularity word sequence representation matrix of a text sample The Row vector, dimension ; This represents the scaled cosine similarity function, used to measure the semantic similarity between two vectors. The calculation method is expressed as follows: ; This represents the first input vector used to calculate similarity, i.e. ; This represents the second input vector used to calculate similarity, i.e. ; express Transpose of; The weight matrix used to calculate similarity is a trainable parameter with dimension 1. .
[0044] By performing an alignment operation, the length of the encoder output sequence is obtained. Consistent alignment and multi-granularity feature representation, represented as ; in, Indicates the first Aligned multi-granularity feature matrices for text samples, with dimensions of The multi-granular features are aggregated through the attention weight matrix and transformed into a matrix with the same length as the encoder output sequence, i.e., dimension 1. This achieves semantic alignment of the two features in the sequence dimension.
[0045] A gating mechanism is used to fuse the encoder output features with the aligned multi-granular features to generate an enhanced feature matrix, represented as follows: In the formula, Indicates the first Enhanced feature matrix of each text sample In the The enhanced feature vectors at each position have a dimension of . , which adaptively fuses the deep contextual semantics of the encoder output and the aligned multi-scale dictionary features through a gating mechanism, combining global context understanding and sensitivity to domain-specific, multi-granularity terms; denotes the gating vector representing the th position, which is used to control the fusion proportion of the two feature sources, and has a dimension of , and the calculation method is represented as ; denotes the vector concatenation operation; denotes the th row vector of the aligned multi-granularity feature matrix of the th text sample; denotes the weight matrix in the gating mechanism, which is a trainable parameter, and has a dimension of , which is used to linearly transform the concatenated features; denotes the bias vector in the gating mechanism, which is a trainable parameter, and has a dimension of ; denotes the Sigmoid activation function, which maps the input to the interval; denotes the element-wise multiplication.
[0046] Entity boundary detection is completed by a bi-affine marker, which predicts the label probability of each position in the sequence belonging to entity start, entity interior or entity exterior, represented as: In the formula, denotes the boundary label probability distribution of the th position, which is a three-dimensional vector corresponding to the start, interior and exterior three labels respectively; denotes the weight tensor of bi-affine transformation, which is a trainable parameter, and has a dimension of , which is the core weight tensor of bi-affine transformation; denotes the bias term of boundary prediction, which has a dimension of , which provides a learnable bias for each boundary label; denotes the transpose of .
[0047] It should be noted that the bi-affine marker is a neural network layer for sequence labeling, and its structural core is bi-affine transformation, which calculates a score matrix for each position in the sequence, which is used to jointly predict the label of each position. It can better model the dependency between labels than a simple linear classifier.
[0048] S2.3.2, entity relationship strength modeling based on spatio-temporal causal attention mechanism The relationship between forest fire entities often has strong spatio-temporal characteristics or causal logic. A spatio-temporal causal attention mechanism is adopted to directly model the potential relationship strength between any two candidate entity spans, and prior knowledge of fire events is incorporated, specifically, Assuming that candidate entities are decoded from the boundary detection results, each entity has its representation vector and type embedding vector, and the relationship strength score of an entity pair is calculated as follows: In the formula, represents the relationship strength score between the th candidate entity and the th candidate entity, and a higher score indicates a higher possibility of a relationship; represents the index of the first candidate entity, which is a positive integer and has a value range of ; represents the index of the second candidate entity, which is a positive integer and has a value range of , and ; represents the number of candidate entities decoded from the boundary detection results; represents the representation vector of the th candidate entity, which is obtained by aggregating the vectors of the starting and ending positions on the enhanced feature matrix through max-pooling operation, and has a dimension of , is the transpose of ; represents the representation vector of the th candidate entity; represents the weight matrix of relationship semantic interaction, which is a trainable parameter and has a dimension of , modeling the semantic interaction pattern between two entity vectors; represents the spatio-temporal constraint term, which is a scalar value, used to model the decay effect of spatial distance and time interval on relationship strength; represents the causal prior term, which is a scalar value, used to inject specific causal logic prior in the forest fire domain.
[0049] The calculation method of the spatio-temporal constraint term is represented as: In the formula, represents the spatial coordinate encoding vector of the th entity, which is set to vector if there is no spatial information available in the text, and the default dimension is ; represents the spatial coordinate encoding vector of the th entity; represents the spatial coordinate encoding vector of the Timestamp encoding scalar of the entity, set to 0 if no timestamp information is available in the text ; Timestamp encoding scalar of the entity, set to 0 if no timestamp information is available in the text ; Spatial term proportionality coefficient, used to adjust the weight of spatial distance contribution to relationship strength, is a trainable parameter Temporal term proportionality coefficient, used to adjust the weight of temporal interval contribution to relationship strength, is a trainable parameter Spatial decay coefficient, used to control the degree of negative impact of spatial distance on relationship strength, is a trainable parameter Temporal decay coefficient, used to control the degree of negative impact of temporal interval on relationship strength, is a trainable parameter
[0050] The calculation method of the causal prior term is represented as: In the formula, Type embedding vector of the entity, obtained by looking up the entity type index through a trainable embedding table, with a default dimension of , , is the transpose of ; Type embedding vector of the entity ; Causal type compatibility matrix, a trainable parameter, with a dimension of , used to model the potential causal compatibility between different entity types Predicted or real type index of the entity , in the model training stage, Indicates the real entity type index obtained from the labeled data, in the model inference stage, Indicates the entity type index predicted by the model itself Predicted or real type index of the entity ; Predefined causal entity type set, i.e., the entity type set as "cause", for example ; Predefined causal entity type set, i.e., the entity type set as "result", for example ; Indicates the indicator function, when all conditions in the parentheses are true, the function value is , otherwise .
[0051] It should be noted that An item represents the strength of semantic interaction between two entity representations, used to capture general semantic associations between entities. The term characterizes the modulating effect of spatiotemporal constraints on the strength of the relationship; the closer the spatial distance and the smaller the time interval, the greater the positive contribution of this term to the relationship score. The term represents the enhancing effect of causal prior knowledge on relation strength. When the head entity type belongs to the cause set and the tail entity type belongs to the result set, the relation score is increased through type embedding and compatibility matrix. The three work together to make relation strength modeling both dependent on data-driven semantic matching and in line with the physical and logical constraints of domain events.
[0052] S2.3.3 Relationship-Aware Entity Type Collaborative Reasoning There is a strong correlation between entity type and relation type. Using relation strength scores as attention guides, collaborative reasoning is performed on the type prediction of each entity, enhancing the context-awareness of type prediction. Specifically, For the An entity, whose context-aware type representation is obtained by weighted aggregation of information from all other related entities, is represented as follows: In the formula, Indicates the first The context aggregation vector of each entity, with dimension . It represents contextual clues implied by association with other entities in the current textual context, which help in infer the entity type; Denotes a linear transformation matrix with dimension . , are trainable parameters used to perform linear transformations on the representations of related entities.
[0053] After aggregating context information, the first The final type prediction probability for each entity is: In the formula, Indicates the first The probability distribution of the type prediction for each entity, with dimension [ ]. is a probability distribution vector, where each element represents an entity. The probability of belonging to a specific entity type, the sum of all elements is 1; The total number of preset entity types; The weight matrix representing the type classification is a trainable parameter with dimension 1. This is used to map the concatenated vector, which integrates its own features and contextual features, onto the dimension of the number of entity types in order to calculate a score for each type; The bias vector representing the type classification is a trainable parameter with dimension . Provide learnable bias for each entity type.
[0054] S2.3.4, Triplet confidence integration and threshold filtering Integrate entity boundary, entity type and entity relationship strength information to calculate the global confidence of each candidate triplet, and get the final output through threshold filtering, specifically, First, convert the relationship strength score into the probability of a specific relationship type, denoted as: In the formula, denotes the probability of the relationship between the th entity and the th entity being the th relationship type, representing the conditional probability that the relationship between the th and the th entity is the th relationship type under the premise that there is a relationship between the th and the th entity; denotes the relationship type index, which is a positive integer, and the value range is ; denotes the total number of preset relationship types; denotes the relationship type probability weight matrix, which is a trainable parameter, and the dimension is , which is a common interaction representation for calculating the probability of different types of relationships; denotes the query vector of the th relationship type, which is a trainable parameter, and the dimension is , which is used to calculate the dot product similarity with the common interaction representation, thereby obtaining the score of the relationship type; denotes the transpose of
[0055] . In the formula, denotes the global confidence of the triplet with the th entity as the head entity, the th entity as the tail entity, and the th relationship type, and the value range is ; denotes the probability value of the th entity being predicted as its most likely type , that is, the probability value with index in the distribution; denotes the probability value of the th entity being predicted as its most likely type The probability value; Indicates the first The prediction type index for each entity, i.e. The index corresponding to the type with the highest probability. Indicates the first Prediction type index for each entity; Indicates the first The boundary confidence of an entity is calculated from the average start or internal label probability of all its constituent locations, with a value range of [value range missing]. ; This represents the power-law hyperparameter of entity type confidence, used to adjust its contribution to the total confidence. An example value is shown below. ; This represents the power-law hyperparameter of the relation type confidence score, used to adjust the contribution of this part to the total confidence score. Example values are provided. ; The hyperparameter representing the power of the entity boundary confidence score is used to adjust its contribution to the total confidence score. An example value is shown below. .
[0056] Set dynamic threshold Only retain global confidence level The triplet is used as the final output. Example of values: .
[0057] It should be noted that, The item represents the confidence level of the entity type. The confidence level of the relation type is represented by the item. The term represents the confidence level of the entity boundary. The product of the three terms is the global confidence level. Only when a candidate triplet achieves high scores in all three aspects—accurate entity boundary, correct entity type, existence of relation, and credible type—will its global confidence level be high and thus be retained as the final result. It is a decision-making mechanism that integrates multiple pieces of evidence.
[0058] Figure 3 The entity recognition result is obtained using the method of the present invention.
[0059] In a specific implementation, the S3 loss function calculation and joint training are as follows: S3.1 Loss Function Calculation To optimize multiple interrelated subtasks in entity recognition and relation extraction, and to fully utilize limited forest fire annotation data, this invention employs a multi-task joint training framework. Its total loss function consists of three parts: entity recognition composite loss, relation extraction adaptive contrast loss, and multi-granularity consistency regularization loss. The model parameters are jointly optimized end-to-end. The specific steps are as follows: (1) Entity recognition compound loss calculation The entity recognition compound loss includes boundary detection loss and entity type classification loss, and a focus loss variant based on entity distribution rules is introduced to alleviate the class imbalance problem, specifically, The boundary detection loss adopts a cross-entropy loss function, denoted as: In the formula, denotes the boundary detection loss, which is used to train the model to accurately predict the entity boundary label of each position in the text sequence; denotes the boundary label true distribution of the th position, which is a three-dimensional one-hot encoding vector converted from the manually annotated entity boundary information; denotes the probability that the th position belongs to the boundary label predicted by the model; denotes the class of the boundary label.
[0060] The entity type classification loss adopts an improved focus loss function to introduce adjustable focus parameters for different entity types, denoted as: In the formula, denotes the entity type classification loss, which is used to train the model to accurately predict the specific type of each identified entity; denotes the total number of entities correctly identified in all text samples in the current training batch, i.e., the number of entities with true type annotations; denotes the true type one-hot encoding vector of the th entity, with a dimension of from the manual annotations of the training data, which is the one-hot encoding representation of the true type index of the th entity; denotes the logarithmic function, with a default base of the natural constant; denotes the probability that the th entity belongs to the th type predicted by the model, which is the scalar probability value corresponding to the th entity type in the type prediction probability distribution of the th entity; denotes the adjustable focus parameter related to the th entity type, which is assigned a larger value for entity types with lower frequency in the training set to increase the model's attention to difficult samples, and is specifically set to the inverse ratio of the frequency of the entity type in the training set.
[0061] It should be noted that during training, the model first performs entity boundary prediction, and then determines which predicted entity spans need to calculate type loss according to the alignment of the predicted boundary and the real boundary. Only the predicted entity that matches the real entity annotation on the boundary (such as IoU exceeding a certain threshold) will be included in the calculation , so as to ensure that the loss function only performs type supervision on those "entities considered by the model", avoiding forced type classification on non-entity segments.
[0062] The entity recognition composite loss is the weighted sum of the boundary detection loss and the entity type classification loss, represented as: In the formula, the entity recognition composite loss is used to optimize the entity boundary detection and entity type classification subtasks, and is the overall training target of the entity recognition part; is a weight hyperparameter for balancing the boundary detection loss, with a value example of , used to adjust the relative weight of the boundary detection loss in the composite loss, and balance the influence of the two subtasks on the overall gradient; is a weight hyperparameter for balancing the entity type classification loss, with a value example of , used to adjust the relative weight of the entity type classification loss in the composite loss.
[0063] (2) Relationship extraction adaptive contrast loss calculation The relationship extraction task designs an adaptive margin contrast loss to better distinguish positive and negative relationship triples, and to bring the positive triple closer and the negative triple farther. The calculation method of the relationship extraction adaptive contrast loss is represented as: , In the formula, the relationship extraction adaptive contrast loss is used to train the relationship strength modeling module; is the set of positive triples, i.e. the (head entity, relationship, tail entity) triples that actually exist in the training data; is the set of negative triples, which is constructed by randomly replacing the head entity, tail entity or relationship type of the positive triple; is the subset of negative triples related to the th head entity; is the temperature coefficient, used to adjust the smoothing degree of the probability distribution, with a value example of ; is the adaptive negative margin, calculated as , the entity pairs with similar semantics require lower confidence when they are negative examples; denotes the larger of the two values; denotes the base margin hyperparameter, and the value example is , which is used to control the reference size of the adaptive margin; denotes the cosine similarity function.
[0064] (3) Multi-granularity consistency regularization loss calculation To facilitate the model to benefit from multi-granularity segmentation, and ensure the knowledge consistency between entity recognition and relation extraction tasks, a multi-granularity feature-based consistency regularization term is adopted to constrain the output stability of the model under different granularity feature perturbations. The calculation method of the multi-granularity consistency regularization loss is represented as: In the formula, denotes the multi-granularity consistency regularization loss, which constrains the model to maintain the relative stability of the output under the slight perturbation of the input multi-granularity feature; denotes the Kullback-Leibler divergence, which is used to measure the difference between two probability distributions, and the smaller the value, the closer the distributions; denotes the distribution function, which normalizes the confidence set of all candidate triplets of a sample to form a discrete probability distribution; denotes the confidence set of triplets calculated based on the original multi-granularity feature of the th text sample; denotes the confidence set of triplets recalculated after a slight random Gaussian perturbation is applied to the multi-granularity feature of the th text sample; denotes the stop gradient operation, whose variables do not update the gradient during backpropagation, and is used to prevent the distribution of from being excessively smoothed by the consistency target.
[0065] (4) Total loss function calculation The total loss function is the weighted sum of the entity recognition composite loss, the relation extraction adaptive contrast loss, and the multi-granularity consistency regularization loss. Through joint optimization, the model learns the various abilities required for forest fire knowledge extraction in an end-to-end manner, and is represented as: In the formula, denotes the total loss value of model training, which is the final target of backpropagation optimization; denotes the weight hyperparameter of the relation extraction loss term, which is used to control the importance of the relation extraction task in joint training, and the value example is ; denotes a weight hyper-parameter of the consistency regularization loss term, used to control the strength of the multi-granularity consistency constraint, and the value example is .
[0066] S3.2, joint training of named entity recognition and relation extraction model Based on the total loss function, the named entity recognition and relation extraction model is trained end-to-end.
[0067] The training process uses the training data set constructed in step S1, and the AdamW optimizer is used to perform gradient descent based on the total loss value, and all trainable parameters in the model are iteratively updated; In each round of training iteration, the batch data is sequentially processed by multi-granularity adaptive segmentation and dynamic standardization, pre-trained language model encoder feature enhancement, and entity recognition and relation extraction steps, and the entity boundary probability, entity type probability, relation strength score and final triple confidence are calculated by forward propagation. Then, according to the real label, the entity recognition compound loss, the relation extraction adaptive contrast loss and the multi-granularity consistency regularization loss are calculated, and the total loss is obtained by weighted summation; Through the back propagation algorithm, the gradient of the total loss is calculated and used to update all trainable parameters, so that the model can simultaneously optimize the ability of entity recognition and relation extraction.
[0068] During the training process, the model performance is evaluated periodically using the validation set to monitor the changes in entity recognition and relation extraction indicators (such as precision, recall, F1 value).
[0069] The stopping condition of iteration is usually set as: the comprehensive performance index on the validation set no longer improves within a certain number of training cycles (i.e. early stopping patience value), or reaches the preset maximum training round.
[0070] Save the model parameters with the best performance on the validation set as the trained named entity recognition and relation extraction model, which can be used for subsequent extraction tasks.
[0071] In the specific implementation, S4 named entity recognition and relation extraction is as follows: After the joint training of the model is completed, the named entity recognition and relation extraction of new, unlabeled forest fire field text can be realized, and the specific process is as follows: The original text to be extracted is input, and first passes through multi-granularity adaptive segmentation and dynamic standardization to generate a standardized multi-granularity word sequence representation matrix of the text; Then, the matrix is sent to the pre-trained BERT encoder for feature enhancement to obtain a hidden state matrix rich in context semantic information; Then, the trained entity representation and boundary detection module based on the fusion of multi-granularity features is used to identify the boundaries of all candidate entities in the text and their corresponding enhanced feature vectors from the enhanced features; Then, based on these candidate entities, the trained entity relationship strength modeling module based on the spatio-temporal causal attention mechanism is called to calculate the potential relationship strength scores between any two entities, and simultaneously perform relationship-aware entity type collaborative reasoning to obtain the final type prediction of each entity. Finally, according to the triple confidence integration and threshold filtering mechanism, the global confidence of all possible triples is calculated by integrating the entity boundary confidence, entity type confidence, and relationship type probability, and filtered according to the pre-set dynamic threshold, retaining the relationship triples with confidence higher than the threshold as the final extraction result.
[0072] The output of this process is the structured knowledge automatically extracted from the input text, presented as a list of triples in the form of (head entity, relationship type, tail entity).
[0073] In the specific implementation, S5 triple generation and knowledge graph construction is as follows: Based on the relationship triples extracted from a large number of forest fire texts in S4, a structured forest fire domain knowledge graph is constructed.
[0074] First, all extracted triples are post-processed and fused, including entity normalization (merging entities with different expressions but referring to the same entity, such as "forest east" and "east forest" if they refer to the same place, into one entity), relationship verification (removing obviously contradictory or incorrect triples according to domain logic), and confidence weighting (keeping the extraction confidence of each triple as a reliability weight); Then, the processed triples are stored and organized using Neo4j graph database or dedicated knowledge graph construction tools as knowledge units.
[0075] In the graph, each unique entity is a node, and its attributes include entity name, type, and additional information that may be extracted from the original text (such as time, spatial coordinate code); Each relationship is a directed edge connecting two nodes, and its attributes include relationship type and extraction confidence.
[0076] In this way, unstructured text data is converted into a semantic network with entities as nodes and relationships as edges. Finally, the forest fire knowledge graph can visually display the complex associations between fire events, disaster factors, environmental conditions, and disposal forces, supporting graph-based query, reasoning, and analysis, and providing structured knowledge support for fire risk assessment, emergency disposal decision-making, and disaster knowledge research.
[0077] As Figure 4 shown, an example of the constructed knowledge graph is shown, taking forest fire as the queried entity, and its triple relationship is as shown in Figure 5 .
[0078] Although the specific embodiments of the application are described above with reference to the drawings, the description is not a limitation on the scope of protection of the application. Various modifications or variations made by those skilled in the art on the basis of the technical solutions of the application without creative labor are still within the scope of protection of the application.
Claims
1. A method for forest fire knowledge modeling based on named entity recognition and relation extraction, characterized in that, Includes the following steps: S1. Collect raw text data in the field of forest fires to build a raw text corpus. Clean and preprocess the data in the raw text corpus, and then label the entities and relations in the data to form a text dataset, which includes text content, entity labels and a list of entity relation triples. S2. Construct a named entity recognition and relation extraction model, perform multi-granularity adaptive word segmentation and dynamic standardization on the text data in the text dataset to generate standardized multi-granularity word sequences, and then perform feature enhancement on the standardized multi-granularity subsequences based on the pre-trained language model encoder. Finally, perform entity recognition and relation extraction for forest fire knowledge to obtain the global confidence of triples of instances and relations. S3. A multi-task joint training framework is adopted. Based on labeled data and model prediction results, the total loss function of the model is calculated. The total loss function consists of three parts: entity recognition composite loss, relation extraction adaptive contrast loss, and multi-granularity consistency regularization loss. The model parameters are jointly optimized in an end-to-end manner to improve the trained model. S4. Input new, unlabeled forest fire domain text into the trained model, perform named entity recognition and relation extraction, obtain the final type prediction for each entity, and then obtain the global confidence of the triplet of the instance and relation. Select the relation triplet with a confidence higher than the preset threshold as the final extraction result. S5. Based on relation triples extracted from a large number of forest fire texts, construct a structured knowledge graph for the forest fire domain.
2. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 1, characterized in that, S1 is as follows: We collected raw text data in the field of forest fires to build a raw text corpus. We cleaned and preprocessed the data in the raw text corpus, and then labeled the entities and relations in the data to form a text dataset, which includes text content, entity labels and a list of entity relation triples. Raw text data was collected through a combination of web crawling technology and manual collection. Data sources included publicly available academic literature databases related to forest fires, publicly available disaster investigation reports, publicly available historical fire event records, and publicly available reports of real forest fires. Cleaning and preprocessing operations include removing irrelevant formatting, correcting obvious typos, and standardizing the expression of numbers and units; Manual annotation is performed on the entity boundaries and types, as well as the relationships between entities, in the text according to predefined annotation specifications. The annotation categories of entities are set according to the characteristics of knowledge in the field of forest fires, including geographical location, fire source type, disaster event, meteorological conditions, and rescue forces. The type of interaction between entities is defined by the annotation of the relationship.
3. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 1, characterized in that, The S2.1 multi-granularity adaptive word segmentation and dynamic standardization operations are as follows: S2.1.1 Based on the text content in the text dataset, construct domain dictionaries at three preset granularity levels—character level, word level, and phrase level—using the spectral clustering algorithm, and initialize the center point and width parameters of the sliding window for each dictionary segment. Preset total number of granularity levels This is used to organize a multi-scale dictionary structure, corresponding to three semantic scales: character, word, and phrase. Indicates granularity level index, The numbers 1, 2, and 3 represent character-level, word-level, and phrase-level operations, respectively. The domain text vectors are dynamically divided using a spectral clustering algorithm. Clusters, Indicates the first The total number of dictionary segments at each granularity level, the first The granularity level is the first Each dictionary segment is represented as follows: , Indicates the first Dictionary segment index within each granularity level; the... The granularity level is the first The cluster center vector of each dictionary segment is represented as: , No. The granularity level is the first The center point parameter of each dictionary segment is represented as follows: , No. The granularity level is the first The window width parameter for each dictionary segment is expressed as: .
4. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 3, characterized in that: S2.1.
2. Based on the global semantic vector of the current text content and the cluster centers of each dictionary segment, The distance is used to dynamically calculate the weight coefficient of each dictionary segment in the current word segmentation process; The process involves inputting the string of the current text content into a pre-trained BERT language model to obtain the final hidden state vector of its [CLS] tag, or performing average pooling on the hidden states of all tags to obtain a global semantic vector representation. S2.1.
3. By combining a Gaussian kernel with a nonlinear adjustment function in a sliding window function, the context range of word segmentation operations at each granularity level is dynamically determined. The input to the adaptive sliding window function at each granularity level is the length offset of the current text, calculated by subtracting the center point parameter from the string length. Divide by the window width parameter The output of the adaptive sliding window function at each granularity level is used to modulate the intensity or confidence of word segmentation at that granularity level. S2.1.
4. The original text is matched with the dictionary segments at each granularity level through matching and transformation functions to perform multi-pattern matching, and then the matching results are converted into corresponding feature vector representations. The matching and transformation function includes a matching pattern function and an embedding transformation function. The matching pattern function outputs different matching scores based on different matching patterns, while the embedding transformation function is used to convert the matched text fragments into feature vectors of fixed dimensions. S2.1.5 integrates the weight coefficients of each granularity layer, the output of the adaptive sliding window function, and the output of the matching and transformation functions, and generates a standardized multi-granularity word sequence representation matrix through splicing operations.
5. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 4, characterized in that, S2.2 Feature enhancement operations based on the pre-trained language model encoder are as follows: Feature enhancement is performed using a pre-trained language model encoder. This encoder employs a pre-trained BERT model, taking the standardized multi-granularity word sequence representation matrix of the current text content as input. Through BERT's internal multi-layer self-attention mechanism, semantic associations and dependencies are automatically captured, thereby obtaining the contextual representation and yielding the hidden state matrix output by BERT. The dimension of the hidden state matrix is... , Indicates the length of the input sequence. This represents the hidden layer dimension of the BERT model.
6. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 5, characterized in that, The specific operations for entity recognition and relation extraction of forest fire knowledge in S2.3 are as follows: S2.3.
1. A gated fusion module is used to adaptively fuse the standardized multi-granularity word sequence representation matrix with the hidden state matrix to generate enhanced entity candidate representations, and entity boundary detection is performed on this basis. Specifically, an alignment matrix is first calculated using an attention mechanism to semantically align the two feature matrices along the sequence length dimension; then, through an alignment operation, the length of the hidden state matrix is obtained. Consistent alignment of multi-granularity feature matrices; then, a gating mechanism is used to fuse the hidden state matrix and the aligned multi-granularity feature matrix to generate an enhanced feature matrix; Entity boundary detection is accomplished using a dual affine labeler, which predicts the probability of the enhanced feature vector at each position in the enhanced feature matrix belonging to the start of an entity, inside an entity, or outside an entity. Among them, the dual affine marker is a neural network layer used for sequence labeling; S2.3.
2. The spatiotemporal causal attention mechanism is used to directly model the potential relationship strength between any two candidate entities across the span, and the prior knowledge of fire events is incorporated. The specific assumption is that the boundary detection results are decoded. There are candidate entities, each with its own representation vector and type embedding vector. For any two candidate entities, calculate the relationship strength score of the entity pair. The representation vectors of any two candidate entities are represented as follows: and The type embedding vector is represented as and , and Indicates the index of candidate entity M. ; The relationship strength score is obtained by adding three data items, including the product of the representation vectors of any two candidate entities and the weight matrix of their semantic interaction, the causal prior term, and the spatiotemporal constraint term. The causal prior term is used to inject causal logical priors specific to the forest fire domain, and the spatiotemporal constraint term is used to model the attenuation effect of spatial distance and time interval on the relationship strength. S2.3.3 Utilize relationship strength scores as attention guides to perform collaborative reasoning for type prediction of each entity; Specifically for the first The first entity, by weighted aggregation of information from all other related entities, obtains the second entity. The context aggregation vector of the nth entity is then used to aggregate the context information and pass it through the Softmax activation function to obtain the nth entity. The probability of predicting the final type of an entity; S2.3.
4. Integrating entity boundary, entity type, and entity relationship strength information, calculate the global confidence of each candidate triplet, and obtain the final output through threshold filtering; Specifically, the probability of converting the relation strength score into a specific relation type is determined by the global confidence of the triple, which is jointly determined by the entity type confidence, relation type confidence, and entity boundary confidence.
7. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 6, characterized in that, The calculation process for the total loss function in S3.1 is as follows: (1) The entity recognition composite loss includes boundary detection loss and entity type classification loss, and introduces a focus loss variant based on entity distribution patterns; The boundary detection loss uses the cross-entropy loss function, which is calculated based on the true distribution of boundary labels from manual annotation and the boundary label probabilities calculated from the model. The entity type classification loss adopts an improved focus loss function, which is specifically calculated from the manually labeled real type one-hot encoding vector and the probability of the entity's predicted type. The boundary detection loss and entity type classification loss are weighted and added together to obtain the entity recognition composite loss. (2) Relation extraction adaptive contrast loss adopts the contrast loss with adaptive margin. The contrast loss with adaptive margin brings positive triples closer and pushes negative triples further away. (3) Multi-granularity consistency regularization loss adopts a consistency regularization term based on multi-granularity features to constrain the output stability of the model under perturbations of different granularity features; The entity recognition composite loss, relation extraction adaptive contrast loss, and multi-granularity consistency regularization loss are weighted and summed to obtain the total loss function.
8. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 1, characterized in that, The joint training process for the model in S3.2 is as follows: End-to-end joint training of named entity recognition and relation extraction models is performed based on the total loss function; The text dataset in S1 is divided into a training set and a validation set. The training process uses the data in the training set and uses the AdamW optimizer to perform gradient descent based on the total loss value to iteratively update all trainable parameters in the model. In each training iteration, the batch data is forward propagated to calculate the entity boundary probability, entity type probability, relation strength score and final triple confidence. Then, the total loss function is calculated based on the real annotation. Through the backpropagation algorithm, the gradient of the total loss function is calculated and used to update all trainable parameters, so that the model can simultaneously optimize the ability of entity recognition and relation extraction. During training, the model performance is evaluated periodically using a validation set to monitor changes in entity recognition and relation extraction metrics. Set the criteria for stopping iterations: when the overall performance metric on the validation set no longer improves within multiple consecutive training cycles, or when the preset maximum number of training cycles is reached; Save the optimal model parameters from the validation set as the trained named entity recognition and relation extraction model.
9. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 1, characterized in that, S4 is as follows: The new, original text to be extracted is taken as input, and after being trained by the named entity recognition and relation extraction model, it undergoes multi-granularity adaptive word segmentation and dynamic standardization processing to generate a standardized multi-granularity word sequence representation matrix of the text. The pre-trained BERT encoder then enhances the features to obtain a hidden state matrix rich in contextual semantic information. The trained entity representation and boundary detection module, which integrates multi-granular features, then identifies the boundaries of all candidate entities in the text and their corresponding enhanced feature vectors from the enhanced features. Then, based on these candidate entities, the trained entity relationship strength modeling module based on spatiotemporal causal attention mechanism is invoked to calculate the potential relationship strength score between any two entities, and relationship-aware entity type collaborative reasoning is performed simultaneously to obtain the final type prediction for each entity. Finally, based on the triple confidence integration and threshold filtering mechanism, the global confidence of all possible triples is calculated by combining the entity boundary confidence, entity type confidence, and relation type probability. Then, the triples are filtered according to the preset dynamic threshold, and relation triples with confidence higher than the threshold are retained as the final extraction result.
10. The forest fire knowledge modeling method based on named entity recognition and relation extraction according to claim 1, characterized in that, S5 is detailed below: First, all extracted triples are post-processed and fused, including entity normalization, relation verification, and confidence weighting. Then, the processed triples are used as knowledge units and stored and organized using Neo4j graph database or dedicated knowledge graph construction tools; In the graph, each unique entity is a node, and its attributes include entity name, type, and additional information that may be extracted from the original text; Each relation is a directed edge connecting two nodes, and its attributes include relation type and extraction confidence. Ultimately, the unstructured text data is transformed into a semantic network with entities as nodes and relationships as edges, forming a forest fire knowledge graph.
Citation Information
Patent Citations
Emergency plan knowledge graph construction method and device for subway fire scene
CN115952297A
Knowledge acquisition and representation method for power grid risk field
CN116739081A
Large model fine tuning method of track domain knowledge base and scene adaptation system
CN118606439A
Gas accident entity relation joint extraction method based on improved CasRel
CN119476459A
Medical text big data intelligent labeling and knowledge graph construction method and system
CN119851968A
Cited By
Entity relation joint extraction method and system
CN121980014A
Nursing teaching task-oriented nursing field text annotation corpus construction method
CN122020186A
Vehicle fault named entity recognition method, device, equipment, medium and product
CN122221859A
Vehicle fault named entity recognition method, device, equipment, medium and product
CN122221859B