Triple extraction method based on diffusion enhancement relation

By employing an end-to-end diffusion-enhanced relation triple extraction method, and utilizing techniques such as the BERT model and multilayer perceptron, this method addresses the issues of error propagation, label imbalance, and incomplete decoding in relation triple extraction from Chinese text. This improves the accuracy and completeness of the extraction, making it suitable for information question answering and search engine optimization.

CN121833928APending Publication Date: 2026-04-10ZHEJIANG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG UNIV OF TECH
Filing Date
2025-12-29
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing relation triple extraction methods suffer from problems such as error propagation, label imbalance, and incomplete decoding in Chinese text, especially performing poorly on small domain datasets.

Method used

An end-to-end diffusion-enhanced relation triple extraction method is adopted. Word embedding information is obtained through the BERT model. It combines relative position-latent entity prediction classification, word perturbation and diffusion boundary prediction, uses multilayer perceptron and Biaffine model to capture entity dependencies, and alleviates the label imbalance problem through word embedding perturbation mechanism.

Benefits of technology

It significantly improves the accuracy and completeness of Chinese relation triple extraction, solves the problems of complex Chinese semantics and lack of natural delimiters, and is suitable for natural language processing applications such as information question answering and search engine optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833928A_ABST
    Figure CN121833928A_ABST
Patent Text Reader

Abstract

The invention discloses a diffusion enhancement relation-based triple extraction method, which comprises the following steps of: 1) inputting a Chinese text into a BERT model, and converting the Chinese text into a corresponding index to obtain word embedding information; 2) inputting word embedding information into a triple diffusion model, and performing noise addition, feature fusion and de-noising processing to obtain a predicted triple; 3) inputting word embedding information into the character feature extraction network model, learning semantic information through a multi-layer perceptron and a double-affine attention mechanism in combination with relative position coding and a multi-head attention module, relieving a label imbalance problem by adopting a word embedding disturbance mechanism, and outputting a relation triple matrix; and 4) respectively decoding the triads obtained in the two steps, and taking union sets to obtain a final relation triad. According to the method, the boundary diffusion information and the character-level semantic information are fused, so that the problems that Chinese semantics are complex, natural separators are lacked, small-field data semantics extraction is insufficient, extraction of a traditional decoding method is incomplete, labels are unbalanced and the like are effectively solved, the accuracy and integrity of Chinese relation triple extraction and model stability are remarkably improved, and the method is suitable for large-scale popularization and application. The method is suitable for various natural language processing application scenes such as information questions and answers and search engine optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of relation triple extraction technology based on deep learning, and in particular to a method for extracting relation triples based on diffusion enhancement. Background Technology

[0002] Relation triple extraction (RTE) plays a crucial role in various applications of natural language processing, such as question answering, search engine optimization, and voice assistants. Early approaches to RTE in these applications often employed a pipelined approach, which breaks the task down into entity extraction and relation extraction stages. This allows for independent model optimization for each subtask, offering significant flexibility. However, this approach suffers from inconsistencies between training and inference stages and is prone to error propagation, thus limiting its widespread adoption.

[0003] Compared to traditional pipelined RTE methods, joint entity relation extraction strategies have proven to more effectively reduce error propagation and have become the mainstream technology direction for current RTE tasks. A typical approach is a joint model based on table completion, which constructs a relation matrix of token pairs and uses a scorer to complete the matrix. This idea originated from multi-head selection models. However, this table completion-based method suffers from the problem of not fully utilizing local sentence information and relative information between entities, resulting in poor performance in the Chinese RTE field. In subsequent research, researchers proposed improved table completion models such as TPLinker and OneRel; however, these models still did not achieve good results in Chinese RTE tasks. Recent related work has attempted to optimize table completion models by combining relative position encoding and attention mechanisms. These models have significantly improved extraction accuracy compared to previous versions, but still cannot effectively handle the problems of label imbalance and incomplete decoding in Chinese RTE tasks.

[0004] In summary, existing models have not achieved satisfactory results for Chinese RTE tasks. This is because existing table-filling models are primarily designed for general text scenarios, while Chinese, compared to other languages, has a more complex vocabulary, lacks natural word separators, and presents greater challenges in entity boundary delineation and relation annotation. Therefore, traditional RTE methods struggle to achieve good results on Chinese. Consequently, a diffusion-enhanced relation triple extraction technique is urgently needed to address these issues. Summary of the Invention

[0005] To overcome the above-mentioned shortcomings of the prior art, the present invention provides a method for extracting diffusion-enhanced relation triples.

[0006] This invention designs an end-to-end relation triple extraction method. The framework consists of three parts: relative position-potential entity prediction classification, word perturbation, and diffusion boundary prediction, which respectively address the core problems of existing methods.

[0007] This invention achieves the above objective through the following technical solution: a diffusion-enhanced relation triplet extraction technique, comprising the following steps: (1) Input the Chinese text into the BERT model and obtain the corresponding word embedding information; (2) Input the word embedding information into the triple diffusion model to obtain the noisy triples, and then obtain the predicted triples by reasoning and denoising. (3) Input the word embedding information into the character feature extraction network model, learn the semantic information through the multilayer perceptron, and use the Biaffine model combined with relative position encoding and Multihead to capture entity dependencies. The word embedding perturbation mechanism is used to alleviate the label imbalance problem. The obtained features are classified and finally the relation triple matrix [batch_size, max_sen_len, max_sen_len,N] is obtained. (4) The triplet matrix obtained above is decoded and then the union is performed to obtain the final triplet.

[0008] Preferably, in step (1), the Chinese text is converted into the corresponding index in vocab using the vocab.txt file provided with the BERT model, and the obtained index is input into the BERT model to obtain the corresponding word embedding vector; specifically, the steps are as follows: (1.1) Preprocessing the data: Using the Chinese vocab.txt provided in the BERT model as a vocabulary, the input Chinese text is converted into the index of the corresponding word in the vocabulary; at the same time, the maximum length of all sentences in the batch is obtained, and a batch of Chinese sentences is input into the BERT model; (1.2) The BERT pre-trained model is used as the word embedding model, where the hidden layer dimension of the model is 768. In the word embedding process, the Chinese text obtained in step (1.1) is input into the BERT model. The BERT model is used to capture the complex dependencies and semantic associations between words and output word embedding vectors containing rich language information, with dimensions of [batch_size, max_sen_len, hidden_dim].

[0009] Preferably, step (2) specifically includes the following steps: (2.1) Input the word embedding vectors (embeds) obtained in step (1.2) into the LSTM model to capture long-distance relationships, and then sample the corresponding data to obtain the set of true bounding boxes B, as... By using forward propagation, the bounding box of the noise triplet at any time t can be obtained. The formula is as follows: For noise to conform to a standard Gaussian distribution, This represents the amount of noise added at time t, sampled at each time step. Having the same shape

[0010] (2.2) The features with long-distance relationships obtained in step (2.1) Relationship between the triplet bounding box and noise Noise bounding box word indexing is performed to obtain :

[0011] (2.3) To better interact with and integrate noise features with original text features, a self-attention mechanism is used. The noise features are processed to extract more semantically rich noise features. Then, these noise features are compared with... A cross-attention mechanism is used to achieve deep interaction with the original text. Finally, temporal location information is embedded into the fused features to further enhance the expressiveness of the denoising network. The embedded features include location information at time step t. :

[0012] (2.4) Four MLPs are used to predict the triplet bounding boxes. For the four coordinates Calculate the fusion representation of text features and noise features. Using an MLP layer can more effectively store coordinate positions. After predicting the bounding boxes of the triplet sets, the relationships between the bounding box regions are classified and predicted. The formula is as follows:

[0013] (2.5) Input the true bounding box B obtained from step (2.1) and the coordinates and relationship results predicted in step (2.4) into the loss function, and use the gradient descent optimization algorithm to update the model parameters to minimize the loss function, as shown in the following formula:

[0014] Formula (10) is the cross-entropy loss function. When training the diffusion module, the Hungarian algorithm is used to match the M noise triplet bounding boxes with the true bounding boxes. This represents the result after matching the i-th noise span. and It is a hyperparameter that balances the two losses. It calculates a cross-entropy of the matched results, and the ultimate goal is to minimize this cross-entropy loss.

[0015] (2.6) Inference phase, from the noise triple bounding box after forward diffusion Initially, the non-Markovian method used by DDIM is employed for denoising to accelerate the recovery of triplet bounding boxes. A predefined length of... Arithmetic sequence [1,…,T], using formulas (11), (12), and (13), the bounding boxes of the M noise triples randomly sampled from the Gaussian distribution are... Convert to Through iteration The final predicted triplet bounding box is then obtained:

[0016] Preferably, step (3) specifically includes the following steps: (3.1) The word embedding vectors obtained by the BERT model are input into the attention layer of the character feature extraction network model, and mapped into head entity representations through three MLP layers respectively. tail entity representation Relationship-Entity Representation The formula used in the attention layer is shown below:

[0017] The output size obtained after passing through the MLP layer is [batch_size, max_sen_len, hidden_dim]; (3.2) The head and tail entity features extracted in step (3.1) are then fed into a dual affine attention module and a multi-head attention module that can process relative position information:

[0018] Formulas (17), (18), and (19) apply a dual affine attention process to construct a scoring matrix for all head and tail entities. This scoring matrix is ​​presented in K×K form, representing all possible head-and-tail entity pairs with a relationship. Finally, the relative position information of the head and tail entities in the sentence is used, employing the concept of AliBi-encoded position bias matrices, to obtain the relative bias matrices for all combinations of head and tail entities. The final matrix is ​​obtained by superimposing these matrices onto the score matrix. .

[0019]

[0020] Formulas (20), (21), and (22) are the calculation process of the multi-head attention module, which calculates the head entity... Tail entity and potential relationships By performing multi-head attention operations on three tensors and employing a linear attention mechanism, fine-grained fused representations can be obtained. Then, a linear concatenation operation is performed using this feature representation to compute the possible relation type representation for each entity pair. Finally, it is combined with... Perform feature fusion to obtain each tokenpair matrix under each relation r. :

[0021] (3.3) The result obtained in step (3.2) Normalization is performed using softmax, and a confidence score is assigned to each label of each token pair to obtain the token pair confidence matrix of sentence S. The training objective is achieved by minimizing the cross-entropy loss. This represents the actual label, which is the result after labeling using the annotation method.

[0022] (3.4) Table filling tasks often face the problem of imbalanced positive and negative token pairs. However, directly downsampling the matrix may lead to semantic loss or the loss of useful tokens. Therefore, this imbalance can be alleviated by starting with the word embedding matrix and indirectly perturbing the token pairs by randomly perturbing the embeddings of some tokens. Specifically, the word embedding matrix is ​​perturbed using the fast gradient method, its parameter gradient is regularized and normalized, then the perturbed parameter gradient is added to the original matrix, and finally a gradient descent is performed to achieve the perturbation of the word embeddings. Represents the training set, This indicates that in the training set The expected value on the graph, where x represents the input and y represents the output. Represents network parameters, The space representing the disturbance. This represents the noise sampled from the disturbed space. This represents the perturbation noise after regularization. This represents the loss for a single sample.

[0023] According to the fast gradient method formula, the gradient of the embedding matrix is ​​treated as noise in the perturbation and regularized to ensure that the noise is not too large. This represents the parameter matrix of word embeddings. This represents the gradient of the embeddings after input x. This indicates network loss. This represents the sign function, which can quantify the gradient. This represents the standardized value. This represents the L2 norm of the gradient. This indicates the magnitude of the disturbance. This represents the parameter matrix after perturbation.

[0024] Preferably, step (4) specifically includes the following steps: (4.1) Take the denoised, undecoded predicted triples obtained in step (2), and discard some candidate triples with low probability by setting a threshold of 0.1. This will result in triples with high confidence. The form of the triples is [batch_size,num,max_len,max_len,max_len,max_len,N]. batch_size represents the batch size, num is the number of candidate triples, max_len is the sentence length, and N represents the number of relations. Then decode these triples. During training, the first coordinate is set to left, the second to up, the third to right, and the fourth to down. This is similar to the representation of bounding boxes in object detection. [left,right] represents the head entity, [up,down] represents the tail entity, and N represents the relation between the two entities. The final extracted form is (head entity, relation, tail entity). Through this correspondence, the set of decoded triples A will be obtained.

[0025] (4.2) Normalize the token pair confidence matrix obtained in step 3 to obtain a matrix of [batch_size, N, max_len, max_len]. During training, a loudspeaker labeling method is used. The model fills in the blanks of this matrix and sets three types of labels: HB-TB (start of head entity - start of tail entity), HB-TE (start of head entity - end of tail entity), and HE-TE (end of head entity - end of tail entity). With these three labels, a max_len matrix can be generated. By extracting a pair of head and tail entities from the max_len matrix, and then identifying which relation N they correspond to, a complete relation triplet can be extracted, ultimately yielding the relation triplet set B.

[0026] (4.3) Perform a union operation on sets A and B obtained in steps (4.1) and (4.2):

[0027] This invention effectively solves problems such as the complexity of Chinese semantics, lack of natural delimiters, insufficient semantic extraction of small domain data, incomplete extraction by traditional decoding methods, and label imbalance by integrating boundary diffusion information and character-level semantic information. It significantly improves the accuracy, completeness, and model stability of Chinese relation triple extraction and is applicable to various natural language processing application scenarios such as information question answering and search engine optimization.

[0028] The beneficial effects of this invention are as follows: (1) This invention has achieved significant results for small domain datasets; the use of dual affine mechanism + relative position encoding significantly improves the accuracy of joint entity relationship recognition; the successful combination of boundary semantic information and character semantic information improves the accuracy of the method in the overall prediction results; (2) In view of the shortcomings of the horn-type decoding method incomplete decoding, this invention designs a diffusion prediction network, and predicts triples that the dual affine module cannot decode through the target detection coordinate method; (3) This invention alleviates the problem of label imbalance caused by too many O-labels in the table-filling method through the word embedding perturbation mechanism. Attached Figure Description

[0029] Figure 1 This is a schematic diagram of the method flow framework of the present invention; Figure 2 This is a schematic diagram of the model prediction process in an embodiment of the present invention. Detailed Implementation

[0030] The present invention will be further described below with reference to specific embodiments, but the scope of protection of the present invention is not limited thereto: An automated product design method applying the joint entity relation extraction method of the fusion diffusion enhanced relation triple extraction technique of this invention, such as... Figure 1 As shown, it includes the following steps: 1) Taking the application scenario of product design automation, using a heart rate sensor as an example, the Chinese sentences related to the product design of the heart rate sensor are converted into the corresponding indexes in the vocab.txt file that comes with the BERT model; the obtained sentence indexes are then input into the BERT model to obtain the corresponding word embedding vectors. 2) Input the word embedding information into the triple diffusion model to obtain the noisy triples, and then obtain the predicted triples through inference denoising; 3) Input the word embedding information into the character feature extraction network model, learn the semantic information through the multilayer perceptron, and use the Biaffine model combined with relative position encoding and Multihead to capture entity dependencies. The word embedding perturbation mechanism is used to alleviate the label imbalance problem. The obtained features are classified, and finally the relation triple matrix [batch_size, max_sen_len, max_sen_len,N] is obtained. 4) The triplet matrix obtained above is decoded and then the union is performed to obtain the final triplet.

[0031] 5) Construct triples into knowledge functional units, add them to the knowledge graph, and automate product design through search algorithms.

[0032] Step 1) Convert the Chinese text into word embedding vectors, specifically including: 1.1) In the data processing stage, the batch data with an input size of [batch_size, max_sen_len] needs to be transformed, where batch_size represents the batch size and max_sen_len represents the length of the longest sentence in the batch. Each character in the input batch is converted into its corresponding index in vocab.txt, which is the Chinese vocabulary included with the BERT model, containing 21,129 characters, which can meet the requirements of the Chinese relation extraction task; 1.2) The obtained sentence indexes are input into the BERT model to obtain the corresponding word embeddings. This invention uses the BERT-Base model, which has 12 layers, each with a hidden layer dimension of 768, and 12 attention heads, with a total parameter count of approximately 110M. BERT-Base was chosen considering the requirements of scale and computational resources. The output of the BERT layers yields word embeddings with dimensions of [batch_size, max_sen_len, hidden_dim]. Embeddings can capture more semantic information, providing more information for subsequent model training.

[0033] Step 2) The model learns Chinese boundary diffusion information, specifically including: 2.1) To enable the model to learn entity relationship boundary information, the original labels need to be modified when calculating the loss function. Before conducting the experiment, this invention resamples each entity and relationship in each batch of the dataset into [left, up, right, down, relation]. The embeddables obtained in step 1) are input into the LSTM model to capture long-distance relationships, using the previous set of true bounding boxes B as... By using forward propagation, the bounding box of the noise triplet at any time t can be obtained. The formula is as follows:

[0034] Where formula (1) represents the output of the LSTM model, and formula (2) represents... By adding Gaussian noise, a noise frame at any time t can be obtained. For noise to conform to a standard Gaussian distribution, This represents the amount of noise added at time t, sampled at each time step. Having the same shape

[0035] 2.2) The features with long-distance relationships obtained in step 2.1) Relationship between the triplet bounding box and noise Noise bounding box word indexing is performed to obtain :

[0036] 2.3) To better interact with and fuse noise features with original text features, a self-attention mechanism is used. The noise features are processed to extract more semantically rich noise features. Then, these noise features are compared with... A cross-attention mechanism is used to achieve deep interaction with the original text. Finally, temporal location information is embedded into the fused features to further enhance the expressiveness of the denoising network. The embedded features include location information at time step t. :

[0037] 2.4) Four MLPs are used to predict triplet bounding boxes. For four coordinates... Calculate the fusion representation of text features and noise features. Using an MLP layer can more effectively store coordinate positions. After predicting the bounding boxes of the triplet sets, the relationships between the bounding box regions are classified and predicted. The formula is as follows:

[0038] in , These are trainable parameters.

[0039] 2.5) Input the true bounding box B obtained from sampling in (2.1) and the coordinates and relationship results predicted in (2.4) into the loss function, and use the gradient descent optimization algorithm to update the model parameters to minimize the loss function, as shown in the following formula:

[0040] Formula 10 is the cross-entropy loss function. During training of the diffusion module, the Hungarian algorithm is used to match the M noisy triplet bounding boxes with the ground truth bounding boxes. This represents the result after matching the i-th noise span. and It is a hyperparameter that balances the two losses. It calculates a cross-entropy of the matched results, and the ultimate goal is to minimize this cross-entropy loss.

[0041] 2.6) Inference phase: From the noise triplet bounding box after forward diffusion Initially, the non-Markovian method used by DDIM is employed for denoising to accelerate the recovery of triplet bounding boxes. A predefined length of... Arithmetic sequence [1,…,T], using formulas 11, 12, and 13, the bounding boxes of the M noise triples randomly sampled from the Gaussian distribution are... Convert to Through iteration The final predicted triplet bounding box is then obtained:

[0042] Step 3) The model learns character-level semantic information and alleviates the label imbalance problem, specifically including: 3.1) Input the word embedding vector obtained in step 1) into the attention layer of the character feature extraction network model, and map it into head entity representations through three MLP layers respectively. tail entity representation Relationship-Entity Representation The formula used in the attention layer is shown below:

[0043] The output size obtained after passing through the MLP layer is [batch_size, max_sen_len, hidden_dim]; 3.2) The head and tail entity features extracted in 3.1) are then fed into a dual affine attention module and a multi-head attention module that can process relative position information:

[0044] Formulas (17), (18), and (19) apply a dual affine attention process to construct a scoring matrix for all head and tail entities. This scoring matrix is ​​presented in K×K form, representing all possible head-and-tail entity pairs with a relationship. Finally, the relative position information of the head and tail entities in the sentence is used, employing the concept of AliBi-encoded position bias matrices, to obtain the relative bias matrices for all combinations of head and tail entities. The final matrix is ​​obtained by superimposing these matrices onto the score matrix. .

[0045] and These are two trainable parameter matrices. This indicates a concat operation. It is a bias vector. Let be the relative position of the entity at position i and the entity at position j, where m is a hyperparameter. This forms the linear bias of the entire head and tail entity matrix.

[0046]

[0047] Formulas (20), (21), and (22) are the calculation process of the multi-head attention module, which calculates the head entity... Tail entity and potential relationships By performing multi-head attention operations on three tensors and employing a linear attention mechanism, fine-grained fused representations can be obtained. Then, a linear concatenation operation is performed using this feature representation to compute the possible relation type representation for each entity pair. Finally, it is combined with... Perform feature fusion to obtain each tokenpair matrix under each relation r. : These are trainable parameters. This indicates that a multi-head attention calculation operation is being performed. This indicates a regularization operation. This indicates the number of tags; 3.3) The result obtained from (3.2) Normalization is performed using softmax, and a confidence score is assigned to each label of each token pair to obtain the token pair confidence matrix of sentence S. The training objective is achieved by minimizing the cross-entropy loss. This represents the actual label, which is the result after labeling using the annotation method.

[0048] 3.4) Table filling tasks often face the problem of imbalanced positive and negative token pairs. However, directly downsampling the matrix may lead to semantic loss or the loss of useful tokens. Therefore, this imbalance can be alleviated by starting with the word embedding matrix and indirectly perturbing the token pairs by randomly perturbing the embeddings of some tokens. Specifically, the fast gradient method is used to perturb the word embedding matrix, its parameter gradient is regularized and normalized, then the perturbed parameter gradient is added to the original matrix, and finally a gradient descent is performed to achieve the perturbation of word embeddings. Represents the training set, This indicates that in the training set The expected value on the graph, where x represents the input and y represents the output. Represents network parameters, The space representing the disturbance. This represents the noise sampled from the disturbed space. This represents the perturbation noise after regularization. This represents the loss for a single sample.

[0049] According to the fast gradient method formula, the gradient of the embedding matrix is ​​treated as noise in the perturbation and regularized to ensure that the noise is not too large. This represents the parameter matrix of word embeddings. This represents the gradient of the embeddings after input x. This indicates network loss. This represents the sign function, which can quantify the gradient. This represents the standardized value. This represents the L2 norm of the gradient. This indicates the magnitude of the disturbance. This represents the parameter matrix after perturbation.

[0050] Step 4) Decode the matrices from Steps 2) and 3) respectively and take their union, specifically including: 4.1) The denoised, undecoded predicted triples obtained in step 2) are filtered out by setting a probability threshold of 0.1 to remove low-probability candidate triples, thereby selecting high-confidence triples. The dimensional form of this triple is [batch_size, num, max_len, max_len, max_len, max_len, N], where each dimension has the following meaning: batch_size represents the batch size, num is the number of candidate triples, max_len represents the sentence length (specifically represented as entity location coordinates in the dimension), and N is the total number of relation categories.

[0051] The selected triples are then decoded: During training, the first four coordinates are designated as left, up, right, and down, using a representation similar to bounding boxes in object detection—[left, right] corresponds to the position interval of the head entity, [up, down] corresponds to the position interval of the tail entity, and N represents the relation category to which the head and tail entities belong. Finally, the decoding result is extracted into a structured form of (head entity, relation, tail entity), thus obtaining the decoded triple set A.

[0052] 4.2) Perform normalization on the token pair confidence matrix obtained in step 3 to obtain a matrix with dimensions [batch_size, N, max_len, max_len]. During the training phase, a "megaphone labeling method" is used. The model performs a table completion task on this matrix and defines three types of labels: 1. HB-TB: Head Begin - Tail Begin. 2. HB-TE: Head Begin - Tail End. 3. HE-TE: Head End - Tail End.

[0053] Based on these three types of labels, it is possible to obtain a single max_len Extract a head and tail entity pair from the matrix of max_len; combine it with the relation category corresponding to N in the matrix dimension, and you can extract a relation triple in the form of (head entity, relation, tail entity) to obtain the final set of relation triples B.

[0054] 4.3) Perform a union operation on sets A and B obtained in steps 4.1) and 4.2):

[0055] Step 5) Construct a product design domain knowledge graph based on the aforementioned relation triples, and integrate reinforcement learning search algorithms to realize an automated product design solution generation mechanism based on user product requirements as input; specific implementation content includes: 5.1) Based on the relation triples obtained in step 4), construct several knowledge functional units; a knowledge functional unit is defined as the smallest and indivisible functional carrier, which not only includes modifiers and keywords to clarify functional attributes, but also identifies the input and output elements corresponding to the function.

[0056] 5.2) Store the knowledge functional units as nodes and edges of the graph in the graph database to construct a knowledge graph belonging to the product design category, which will facilitate the provision of data sources for subsequent searches.

[0057] 5.3) Utilizing reinforcement learning search algorithms to perform path retrieval on the product design domain knowledge graph: Based on the product requirements proposed by the user, the algorithm matches the optimal path in the knowledge graph and extracts the knowledge functional units contained in the path, feeding them back to the user; the aforementioned knowledge functional units fully cover the functional components required by the product. For example, if knowledge related to heart rate sensors has been incorporated into the knowledge graph, when a user proposes a similar product design requirement, this method can quickly generate a design scheme for a heart rate sensor product.

[0058] This invention possesses significant technical advantages and application value, specifically reflected in the following aspects: (1) Significantly improved adaptability and recognition performance for small domain datasets: This invention performs well on small domain datasets. By introducing a dual affine mechanism combined with the core design of relative position encoding, the accuracy of joint entity relationship recognition task is greatly improved. At the same time, the innovative deep fusion of boundary semantic information and character semantic information effectively improves the accuracy of the overall prediction results of the model and solves the problem of insufficient semantic feature extraction in small domain data scenarios.

[0059] (2) Breaking through the limitations of traditional decoding methods to achieve complete triple extraction: In response to the "incomplete decoding" defect of existing horn-type decoding methods, this invention specifically designed a diffusion prediction network. This network adopts the coordinate positioning approach in the field of target detection, which can accurately predict and complete triples that the dual affine module cannot decode, significantly improving the completeness and recall of triple extraction.

[0060] (3) Alleviating label imbalance and optimizing model training stability: To address the label imbalance problem caused by the excessive proportion of O-labels (no entity / relationship labels) in the table-filling recognition framework, this invention proposes a word embedding perturbation mechanism. By reasonably perturbing the input word vectors to enhance sample diversity, the training weights of various labels are effectively balanced, thereby improving the stability and generalization ability of model training.

[0061] In this embodiment, a component of the heart rate sensor, the "voltage amplifier," will be used as an example. Based on the steps given above, the sentence "To meet the stringent standards of high-precision signal processing, a high-precision voltage amplifier was designed. This product can effectively amplify small voltage signals, ensuring accurate signal transmission. Its working principle is to connect a voltage signal and convert an input voltage of 0 to 0.2V into a 100-fold amplified output voltage, thereby enabling users to perform more refined analysis or signal processing, providing reliable support for scientific experiments and industrial applications." Considering the length of the sentence, to simplify the subsequent processing, it is simplified to the core statement: "Its working principle is to connect a voltage signal and convert an input voltage of 0 to 0.2V into a 100-fold amplified output voltage." Subsequently, this simplified sentence is constructed into an n×n dimension matrix; in this embodiment, the matrix dimension is 26. 26. The triples in this sentence are (0 to 0.2V, input modifier / modifier / input keyword, input voltage) and (100x magnification, output modifier / modifier / output keyword, output voltage). To label the entities in the matrix, the entity "0 to 0.2V" is at index 11 to 16, "input voltage" is at index 18 to 21, and the label corresponding to input modifier / modifier / input keyword is relation 0. Therefore, the diffusion module label is set to [18, 11, 21, 16, 0]. The other triple is similarly labeled as [32, 25, 35, 30, 1]. The diffusion module is mainly for learning a denoising network so that the model outputs labels in this form. During the stage where the model learns character-level semantic information, the required label dimension is n. 26 26, where represents the number of relation triples to be extracted. For the first triple in this embodiment (0 to 0.2V, input modifier / modifier / input keyword, input voltage), a trumpet-style labeling method is used for tag assignment. Positions [0]

[11]

[18] of the label tensor are labeled as HB-TB (corresponding to value 1), positions [0]

[11]

[21] are labeled as HB-TE (corresponding to value 2), and positions [0]

[16]

[21] are labeled as HE-TE (corresponding to value 3). For the second triple (100x magnification, output modifier / modifier / output keyword, output voltage), the same trumpet-style labeling method is used. Positions [1]

[25]

[32] of the label tensor are labeled as HB-TB, positions [1]

[25]

[35] are labeled as HB-TE (corresponding to value 2), and positions [1]

[30]

[35] are labeled as HE-TE (corresponding to value 3). Specifically, as follows... Figure 2 As shown: After step 1.1), the sentence is converted into the index corresponding to vocab.txt, namely [101, 1072, 868, 868, 1333, 4415, 3221, 6868, 2990, 4510, 7274, 3248, 5307, 8024, 2799, 121, 6820, 121, 119, 122, 110, 4638, 6842, 3696, 4510, 7274, 6639, 4375, 711, 122, 121, 121, 6973, 3124, 1920, 4638, 6842, 5307, 4510, 7274, 102]; After step 1.2), the transformed data is input into BERT. The hidden_dim of the BERT model is 748, so the output size is [1, 41, 748], representing the word embeddings of the sentence. The word embedding vectors are then input into the boundary information extraction network model. After step 2.1), (0 to 0.2V, input modifier / modifier / input keyword, input voltage) and (100x magnification, output modifier / modifier / output keyword, output voltage) are sampled into true bounding boxes, namely [18,11,21,16,0] and [32,25,35,30,1]. Then, Gaussian noise is added to obtain noisy bounding boxes, and the word embedding features are input into LSTM to obtain long-range semantic vectors with dimensions [1,41,768]. After step 2.2), each noise box is indexed using long-distance semantic vectors, resulting in dimensions [1,2,4,41,768]. After step 2.3), the word indexed vectors are fused with the original text features through self-attention mechanism and cross-attention fusion, and embedded at time step t. The final dimension is [1,2,4,41,768]. After step 2.4), the output of step 2.3) and the word embedding vector are fused together by parameter matrix and input into five MLPs to obtain four coordinates and relations. The four coordinate dimensions are [1,2,4,41] and the relation dimensions are [1,2,2]. After step 2.5), the output of step 2.4) and the sampled ground truth bounding boxes of step 2.1) are Hungarian matching, the cross-entropy loss is calculated on the matching matrix, and then gradient descent is performed.

[0062] After training, the reasoning phase: After step 2.6), noisy triplet bounding boxes are sampled from the Gaussian distribution, and then denoised using the DDIM method. After 5 iterations, the final predicted triplet bounding boxes are obtained.

[0063] After step 3.1), the word embeddings from step 1.2) are input into the character feature extraction network model. The character feature information is enhanced through three MLP layers, and the output vectors have three dimensions [1, 41, 748]. Following step 3.2), the head and tail entity vectors output from step 3.1) are input into a 748-dimensional dual affine attention model to learn the relationships between entities. Then, relative position encoding is added, resulting in an output dimension of [1, 41]. [41,1496], and simultaneously input the head, tail, and relation vectors into the multi-head attention, outputting a dimension of [1,41,1496]. Then, the two resulting vectors are concatenated and subjected to a full-c operation, finally yielding a dimension of [1,2,41,41]. After step 3.3), the final token pair matrix is ​​normalized using softmax to obtain the final confidence matrix, and then training is performed by minimizing the loss function; After step 3.4), the gradient of the BERT word embedding matrix parameters is regularized, then added back to the word embedding matrix, and finally gradient descent is performed again. The denoised triple bounding boxes obtained in steps 4.1) and 2.6) are decoded to obtain a set of relation triples; After step 4.2), the token pair matrix obtained in step 3.3) is decoded to obtain a set of relation triples; After step 4.3), the two sets of triples are joined to obtain the final set of triples.

[0064] In summary, this invention mainly comprises four parts: a BERT layer for word embeddings, a boundary diffusion network model, a character feature extraction network model for acquiring more character-level semantic information, and word embedding perturbation. This invention employs word embedding perturbation to address the label imbalance problem when acquiring relational information and introduces a dual affine attention mechanism to fuse relative positional encoding for better character information learning. By fusing boundary and character information, this invention successfully solves problems such as the complexity of Chinese semantics and the lack of natural delimiters. The boundary diffusion network model overcomes the shortcomings of traditional decoding methods, such as incomplete decoding. Significant results have been achieved on both a self-constructed functional unit extraction dataset and large public datasets. The research results show that in Chinese datasets, the label accuracy is significantly improved for datasets with fewer data labels.

[0065] The above description describes specific embodiments of the present invention and the technical principles employed. Any changes made in accordance with the concept of the present invention that do not exceed the spirit of the specification and drawings should still fall within the protection scope of the present invention.

Claims

1. A method for extracting triples based on diffusion-enhanced relational relationships, characterized in that, Includes the following steps: (1) Input the Chinese text into the BERT model and obtain the corresponding word embedding information; (2) Input the word embedding information into the triple diffusion model to obtain the noisy triples, and then obtain the predicted triples by reasoning and denoising. (3) Input the word embedding information into the character feature extraction network model, learn the semantic information through the multilayer perceptron, and use the Biaffine model combined with relative position encoding and Multihead to capture entity dependencies. The word embedding perturbation mechanism is used to alleviate the label imbalance problem. The obtained features are classified and finally the relation triple matrix [batch_size, max_sen_len, max_sen_len,N] is obtained. (4) The triplet matrix obtained above is decoded and then the union is performed to obtain the final triplet.

2. The method for extracting triples based on diffusion-enhanced relation according to claim 1, characterized in that: In step (1), the Chinese text is converted into the corresponding index in vocab using the vocab.txt file that comes with the BERT model, and the obtained index is input into the BERT model to obtain the corresponding word embedding vector. Specifically, the steps are as follows: (1.1) First, the data needs to be preprocessed: use the Chinese vocab.txt provided in the BERT model as the vocabulary, and convert the input Chinese text into the index of the corresponding word in the vocabulary; at the same time, obtain the maximum length of all sentences in the batch, and input a batch of Chinese sentences into the BERT model; (1.2) The BERT pre-trained model is used as the word embedding model, where the hidden layer dimension of the model is 768. In the word embedding process, the Chinese text obtained in step (1.1) is input into the BERT model. The BERT model is used to capture the complex dependencies and semantic associations between words and output word embedding vectors containing rich language information, with dimensions of [batch_size, max_sen_len, hidden_dim].

3. The method for extracting triples based on diffusion-enhanced relation according to claim 1, characterized in that: Step (2) specifically includes: (2.1) Input the embeds obtained in step 1) into the LSTM model to capture long-distance relationships, and use the previous set of ground truth bounding boxes B as... Using forward propagation, the bounding box of the noise triplet at any time t is obtained. The formula is as follows: Where formula (1) represents the output of the LSTM model, and formula (2) represents... By adding Gaussian noise, a noise frame at any time t can be obtained; For noise to conform to a standard Gaussian distribution, This represents the amount of noise added at time t, sampled at each time step. Having the same shape ; (2.2) The features with long-distance relationships obtained in step (2.1) Relationship between the triplet bounding box and noise Noise bounding box word indexing is performed to obtain : (2.3) Through self-attention mechanism The noise features are processed to extract more semantically rich noise features; then, these noise features are compared with... The system performs cross-attention fusion with deep interaction with the original text. Then, temporal location information is embedded into the fused features to enhance the expressiveness of the denoising network. Finally, the embedded location information with time step t is used to... : (2.4) Four MLPs are used to predict the triplet bounding boxes; for four coordinates Calculate the fusion representation of text features and noise features. The MLP layer is used to determine the coordinate position. After predicting the bounding boxes of the triplet sets, the relationships between the bounding box regions are classified and predicted using the following formula: in , These are trainable parameters; (2.5) Input the true bounding box B obtained from step (2.1) and the coordinates and relationship results predicted in step (2.4) into the loss function, and use the gradient descent optimization algorithm to update the model parameters to minimize the loss function, as shown in the following formula: Formula (10) is the cross-entropy loss function. When training the diffusion module, the Hungarian algorithm is used to match the M noise triplet bounding boxes with the true bounding boxes. This represents the result after matching the i-th noise span. and It is a hyperparameter that balances the two losses. It calculates a cross-entropy of the matched results and minimizes this cross-entropy loss. (2.6) Inference phase, from the noise triple bounding box after forward diffusion Initially, the non-Markovian denoising method used by DDIM is employed to accelerate the denoising and recovery of triplet bounding boxes; a predefined length of... Arithmetic sequence [1,…,T], using formulas (11), (12), and (13), the bounding boxes of the M noise triples randomly sampled from the Gaussian distribution are... Convert to Through iteration The final predicted triplet bounding box is then obtained: 。 4. The method for extracting triples based on diffusion-enhanced relation according to claim 1, characterized in that: Step (3) specifically includes the following steps: (3.1) Input the word embedding vector obtained in step (1) into the attention layer of the character feature extraction network model, and map it into head entity representation through three MLP layers respectively. tail entity representation Relationship-Entity Representation The formula used in the attention layer is shown below: The output size obtained after passing through the MLP layer is [batch_size, max_sen_len, hidden_dim]; (3.2) The head and tail entity features extracted in step (3.1) are then fed into the dual affine attention module and the multi-head attention module for processing relative position information: Formulas (17), (18), and (19) apply a dual affine attention process to construct a scoring matrix for all head and tail entities. This scoring matrix is ​​presented in K×K form, representing all possible head-and-tail entity pairs with a relationship. Finally, the relative position information of the head-and-tail entities in the sentence is used to obtain the relative bias matrix for all combinations of head-and-tail entities, employing the concept of AliBi-encoded position bias matrices. The final matrix is ​​obtained by superimposing these matrices onto the score matrix. ; and These are two trainable parameter matrices. This indicates a concat operation. It is a bias vector. Let be the relative position of the entity at position i and the entity at position j, where m is a hyperparameter. This forms the linear bias of the entire head and tail entity matrix; Formulas (20), (21), and (22) are the calculation process of the multi-head attention module, which calculates the head entity... Tail entity and potential relationships By performing multi-head attention operations on three tensors and employing a linear attention mechanism, fine-grained fused representations can be obtained. Then, a linear concatenation operation is performed using this feature representation to compute the possible relation type representation for each entity pair; finally, it is combined with... Perform feature fusion to obtain the matrix of each token pair under each relation r. : These are trainable parameters. This indicates that a multi-head attention calculation operation is being performed; This indicates a regularization operation; This indicates the number of tags; (3.3) The result obtained in step (3.2) Normalization is performed using softmax, and a confidence score is assigned to each label of each token pair to obtain the token pair confidence matrix of sentence S. The training objective is achieved by minimizing the cross-entropy loss. This represents the actual label, which is the result after labeling using the annotation method; (3.4) Regularize the parameter gradient of the word embedding matrix, then add the perturbed parameter gradient to the original matrix, and finally perform gradient descent to achieve the perturbation of the word embedding: Represents the training set, This indicates that in the training set The expected value on the graph, where x represents the input and y represents the output. Represents network parameters, The space representing the disturbance. This represents the noise sampled from the disturbed space. This represents the perturbation noise after regularization. This represents the loss for a single sample; According to the fast gradient method formula, the gradient of the embedding matrix is ​​treated as noise perturbation and regularized accordingly: The parameter matrix representing word embeddings, This represents the gradient of the embeddings after input x. Indicates network loss. The sign function represents the numerical representation of the gradient; This represents the standardized value. The L2 norm of the gradient is represented. Indicates the magnitude of the disturbance. This represents the parameter matrix after perturbation.

5. The method for extracting triples based on diffusion-enhanced relation according to claim 1, characterized in that: Step (4) specifically includes: (4.1) The denoised undecoded predicted triples obtained in step (2) are filtered out by setting a probability threshold to remove low-probability candidate triples and select high-confidence triples; the dimension of the triples is [batch_size, num, max_len, max_len, max_len, max_len, N], where each dimension has the following meaning: batch_size represents the batch size, num is the number of candidate triples, max_len represents the sentence length, and N is the total number of relation categories; The selected triples are then decoded: During the training phase, the first four coordinates are defined as left, up, right, and down, using a representation similar to bounding boxes in object detection—[left, right] corresponds to the position interval of the head entity, [up, down] corresponds to the position interval of the tail entity, and N represents the relation category to which the head and tail entities belong; finally, the decoding result is extracted into a structured form of (head entity, relation, tail entity), thus obtaining the set of decoded triples A; (4.2) Perform normalization on the token pair confidence matrix obtained in step (3) to finally obtain a matrix with dimensions [batch_size, N, max_len, max_len]. During the training phase, the "trumpet labeling method" is used. The model performs a table completion task on this matrix and defines three types of labels:

1. HB-TB: Head Begin - Tail Begin.

2. HB-TE: Head Begin - Tail End.

3. HE-TE: Head End - Tail End. Based on these three types of labels, from a single max_len Extract a head and tail entity pair from the matrix of max_len; combine the relation categories corresponding to N in the matrix dimension to extract a complete relation triplet in the form of (head entity, relation, tail entity), and finally obtain the relation triplet set B; (4.3) Perform a union operation on sets A and B obtained in steps (4.1) and (4.2): 。