Question and answer method based on knowledge graph
By introducing the AEDA-BERT-DSC-BiLSTM-GAT model and graph query statement generation model in the power industry question and answer system, the limitations of multi-intention recognition and semantic analysis in the processing of complex question sentences in the power industry are solved, and more accurate intent recognition and answer generation are achieved.
Patent Information
- Application Number
- CN202411905467.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-05-06
AI Technical Summary
When dealing with complex questions in the power industry, the existing knowledge graph-based question-answer methods have limitations in multi-intention recognition, contextual correlation understanding and complex semantic structure analysis, making it difficult to accurately capture the key information in the question, resulting in low answer accuracy.
A question-and-answer method based on knowledge graph is adopted, and the original question text is obtained and the intention recognition vector is obtained by obtaining the preset AEDA-BERT-DSC-BiLSTM-GAT model, and then inputting it into the graph query statement generation model to generate a graph query statement, and finally querying it in the preset knowledge graph to generate the answer text.
It improves the accuracy of multi-intention recognition, enhances the ability to understand contextual associations and analyze complex semantic structures, and can quickly and accurately query and generate answer texts in preset knowledge graphs, solving the shortcomings of the existing technology in dealing with complex questions in the power industry.
Smart Images

Figure CN119938829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power systems, and in particular to a question-answering method based on a knowledge graph. Background Art
[0002] With the profound transformation of energy structure and the booming development of the power industry worldwide, power transmission and transformation equipment, as the key cornerstone of the power network, has a stable and efficient operating status that is directly related to the safe operation of the entire power grid and the effective use of energy. In this era, power companies have put forward higher requirements for the management and maintenance of power transmission and transformation equipment, and urgently need to achieve real-time monitoring of equipment operating status, accurate fault diagnosis, and the formulation of scientific maintenance strategies. This requires companies to quickly and accurately obtain and analyze a large amount of relevant data to support intelligent decision-making processes.
[0003] As a cutting-edge information organization and representation technology, knowledge graphs have shown great potential in the intelligent transformation of the power industry with their powerful data integration and structuring capabilities. By building a complex network structure containing entities, relationships, and attributes, knowledge graphs can efficiently integrate and manage scattered power data resources, providing power companies with rich information support for intelligent decision-making.
[0004] However, existing question-answering methods based on knowledge graphs have significant deficiencies when dealing with complex questions in the power industry. These methods have limitations in multi-intent recognition, contextual understanding, and complex semantic structure analysis, making it difficult to accurately capture key information in questions, resulting in low accuracy in the generated answers. This limitation not only affects the efficiency of knowledge acquisition, but also limits the effective application of knowledge graphs in intelligent decision-making in the power industry, and cannot meet the needs of power companies for fast and accurate information acquisition. Summary of the invention
[0005] Based on this, it is necessary to propose a question-answering method based on knowledge graph to address the above problems. It not only improves the accuracy of multi-intent recognition, but also enhances the ability of contextual understanding and complex semantic structure analysis, effectively solving the shortcomings of existing technologies in dealing with complex questions in the power industry.
[0006] To achieve the above object, the present invention provides a question-answering method based on a knowledge graph in a first aspect, the method comprising:
[0007] Get the original question text;
[0008] Input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain an intent recognition vector;
[0009] Inputting the intention recognition vector into a preset graph query statement generation model to obtain a graph query statement;
[0010] According to the graph query statement, a query is performed in the preset knowledge graph to generate an answer text.
[0011] Optionally, the preset AEDA-BERT-DSC-BiLSTM-GAT model includes a feature extraction layer, a parallel layer, a classification layer and an intent recognition layer, and the inputting the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain the intent recognition vector includes:
[0012] Input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model;
[0013] The feature extraction layer is used to extract features from the original question text to obtain a text attention matrix;
[0014] The parallel layer is used to perform parallel feature extraction on the text attention matrix to obtain a parallel feature vector;
[0015] The classification layer is used to classify the parallel feature vectors to obtain a predicted word segmentation result;
[0016] The intention recognition layer is used to recognize the predicted word segmentation result to obtain the intention recognition vector.
[0017] Optionally, the feature extraction layer includes an AEDA module and a BERT module;
[0018] The AEDA module is used to perform data enhancement on the original question text to obtain an enhanced question text, and determine a target question text according to the enhanced question text and the original question text;
[0019] The BERT module is used to extract feature representation of the target question text to obtain the text attention matrix.
[0020] Optionally, the expression of the attention mechanism of the bidirectional Transformer encoder in the BERT module is:
[0021]
[0022] Wherein, selfAttention(Q,K,V) is the fused output of the attention mechanism of the bidirectional Transformer encoder, softmax() is the softmax() function, Q is the query matrix, and the query matrix is composed of the query vector of each word in the target question text, W qis a learnable query dynamic adjustment matrix, K is a key matrix, and the key matrix is composed of the key vector of each word in the target question text, T is the inverse sign, and W k Dynamically adjust the matrix for learnable keys, d k is the scaling operation matrix, V is the value matrix, and the value matrix is composed of the value vector of each word in the target question text, W v Dynamically adjust the matrix for learnable values.
[0023] Optionally, the parallel layer includes a DSC module and a BiLSTM module, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector;
[0024] The DSC module is used to perform deep feature extraction on the text attention matrix to obtain the DSC feature vector;
[0025] The BiLSTM module is used to extract sequence features from the text attention matrix to obtain the BiLSTM feature vector.
[0026] Optionally, the expression of the DSC module is:
[0027] DSC(X attention )=PointwiseConv[DepthwiseConv(X attention )];
[0028] Among them, DSC (X attention ) is the DSC feature vector, PointwiseConv[] is a point-wise convolution operation, DepthwiseConv() is a channel-by-channel convolution operation, X attention is the text attention matrix.
[0029] Optionally, the classification layer includes a concatenation layer, a fully connected layer and a Softmax function layer, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector;
[0030] The splicing layer is used to splice and fuse the DSC feature vector and the BiLSTM feature vector to obtain a spliced fused feature vector;
[0031] The fully connected layer is used to perform a linear transformation on the concatenated fusion feature vector to obtain an original score vector;
[0032] The Softmax function layer is used to transform the original score vector to obtain the predicted word segmentation result.
[0033] Optionally, the intent recognition layer includes a synonym conversion module and a GAT module;
[0034] The synonym conversion module is used to convert the words with synonymous parts of speech into corresponding entity words, relation words, attribute words or attribute threshold words according to a preset synonym library when there are synonyms for the parts of speech of the words in the predicted word segmentation result, so as to obtain the target predicted word segmentation result;
[0035] The GAT module is used to perform intent recognition on the target prediction segmentation result to obtain the intent recognition vector.
[0036] Optionally, the expression of the GAT module is:
[0037]
[0038] Among them, h i ” is the i-th object element in the intent recognition vector, σ is the sigmoid activation function, K is the total number of groups of the multi-head attention mechanism in the GAT module, N i is the total number of entity words in the predicted word segmentation results that have relationship words, attribute words and / or attribute threshold word relationships with the ith entity word, α ij k is the attention coefficient between the i-th entity word and the j-th entity word in the predicted word segmentation result in the k-th group, LeakyReLU() is the LeakyReLU activation function, is the learnable feature weight matrix of the i-th entity word in the k-th group in the predicted word segmentation result, h j is the feature of the j-th entity word in the predicted word segmentation result, is the feature weight matrix of the relationship words, attribute words and / or attribute threshold words in the kth group between the i-th entity word and the j-th entity word in the predicted word segmentation result, E ij is the feature of the relationship word, attribute word and / or attribute threshold word between the i-th entity word and the j-th entity word in the predicted word segmentation result, Residual() is the residual connection operation, and h i is the feature of the ith entity word in the predicted word segmentation result.
[0039] Optionally, the method further comprises:
[0040] Using the formula Determine the attention coefficient between the i-th entity word and the j-th entity word in the predicted word segmentation result in the k-th group;
[0041] Among them, e is a natural constant, a[||] is the connection processing operation of the feedforward neural network, T is the inverse sign, and W k is the learnable weight matrix of the kth group.
[0042] To achieve the above object, the present invention provides a question-answering device based on a knowledge graph in a second aspect, the device comprising:
[0043] The acquisition module is used to obtain the original question text;
[0044] A model intent recognition module, used for inputting the original question text into a preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain an intent recognition vector;
[0045] A model statement generation module, used for inputting the intention recognition vector into a preset graph query statement generation model to obtain a graph query statement;
[0046] The query module is used to query in a preset knowledge graph according to the graph query statement and generate an answer text.
[0047] To achieve the above-mentioned object, the present invention provides in a third aspect a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the method as described in any one of the first aspects.
[0048] To achieve the above-mentioned purpose, the present invention provides a computer device in a fourth aspect, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method as described in any one of the first aspects.
[0049] The embodiment of the present invention has the following beneficial effects: the above method obtains the original question text, and then inputs the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain the intent recognition vector, and then inputs the intent recognition vector into the preset graph query statement generation model to obtain the graph query statement, and finally searches in the preset knowledge graph according to the graph query statement to generate the answer text; that is, by introducing the preset AEDA-BERT-DSC-BiLSTM-GAT model, accurate intent recognition of the original question text is achieved, and efficient graph query statements are generated on this basis, which not only improves the accuracy of multi-intent recognition, but also enhances the ability of context association understanding and complex semantic structure parsing. Through this method, it is possible to quickly and accurately query and generate answer text in the preset knowledge graph, effectively solving the shortcomings of the prior art in processing complex questions in the power industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0051] in:
[0052] Figure 1 A schematic diagram of a question-answering method based on a knowledge graph in an embodiment of the present application;
[0053] Figure 2 A schematic diagram of a question-answering device based on a knowledge graph in an embodiment of the present application;
[0054] Figure 3 1 is a diagram of the internal structure of a computer device in some embodiments. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] With the profound transformation of energy structure and the booming development of the power industry worldwide, power transmission and transformation equipment, as the key cornerstone of the power network, has a stable and efficient operating status that is directly related to the safe operation of the entire power grid and the effective use of energy. In this era, power companies have put forward higher requirements for the management and maintenance of power transmission and transformation equipment, and urgently need to achieve real-time monitoring of equipment operating status, accurate fault diagnosis, and the formulation of scientific maintenance strategies. This requires companies to quickly and accurately obtain and analyze a large amount of relevant data to support intelligent decision-making processes.
[0057] As a cutting-edge information organization and representation technology, knowledge graphs have shown great potential in the intelligent transformation of the power industry with their powerful data integration and structuring capabilities. By building a complex network structure containing entities, relationships, and attributes, knowledge graphs can efficiently integrate and manage scattered power data resources, providing power companies with rich information support for intelligent decision-making.
[0058] However, existing question-answering methods based on knowledge graphs have significant deficiencies when dealing with complex questions in the power industry. These methods have limitations in multi-intent recognition, contextual understanding, and complex semantic structure analysis, making it difficult to accurately capture key information in questions, resulting in low accuracy in the generated answers. This limitation not only affects the efficiency of knowledge acquisition, but also limits the effective application of knowledge graphs in intelligent decision-making in the power industry, and cannot meet the needs of power companies for fast and accurate information acquisition.
[0059] In response to the above problems, this application proposes a question-answering method based on knowledge graph, which not only improves the accuracy of multi-intent recognition, but also enhances the ability of contextual association understanding and complex semantic structure parsing, effectively solving the shortcomings of the existing technology in processing complex questions in the power industry. The specific implementation principle will be described in detail in the following embodiments.
[0060] In a first aspect, the present application provides a question-answering method based on a knowledge graph.
[0061] See also Figure 1 , is a schematic diagram of a question-answering method based on a knowledge graph in an embodiment of the present application, the method comprising:
[0062] Step 110: Get the original question text.
[0063] The original question text is a natural language question input by the user.
[0064] In some embodiments, the original question text may be a natural language question sentence input by a worker in the power industry.
[0065] Step 120: Input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain the intent recognition vector.
[0066] Among them, the preset AEDA-BERT-DSC-BiLSTM-GAT model here refers to the trained AEDA-BERT-DSC-BiLSTM-GAT model, which can be directly used to predict the output intent recognition vector based on the input original question text; AEDA stands for An Easier Data Augmentation; BERT stands for Bidirectional Encoder Representations from Transformers; DSC stands for Depthwise Separable Convolution; BiLSTM stands for Bidirectional Long Short-Term Memory; GAT stands for Graph Attention Network.
[0067] In some embodiments, AEDA, BERT, DSC, BiLSTM and GAT can be combined to construct an initial AEDA-BERT-DSC-BiLSTM-GAT model; further, after the initial AEDA-BERT-DSC-BiLSTM-GAT model is constructed, a large number of historical original question texts and historical intent recognition vectors corresponding to the historical original question texts can be obtained, and then the large number of historical original question texts and the historical intent recognition vectors corresponding to the historical original question texts can be sequentially input into the initial AEDA-BERT-DSC-BiLSTM-GAT model for training. After training to a certain extent, a trained preset AEDA-BERT-DSC-BiLSTM-GAT model can be obtained; wherein each historical intent recognition vector can be used as the true value of the initial AEDA-BERT-DSC-BiLSTM-GAT model, that is, by comparing the true value with each historical intent recognition vector output during the training process one by one, it can be determined whether the initial AEDA-BERT-DSC-BiLSTM-GAT model is well trained and has met the expected requirements.
[0068] It should be noted that after obtaining the preset AEDA-BERT-DSC-BiLSTM-GAT model, you only need to input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to automatically perform predictions and obtain the predicted output intent recognition vector.
[0069] Furthermore, in the process of inputting the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to predict the intent recognition vector, the preset AEDA-BERT-DSC-BiLSTM-GAT model can also continuously learn and update to make the predicted output intent recognition vector more accurate.
[0070] Step 130: Input the intent recognition vector into a preset graph query statement generation model to obtain a graph query statement.
[0071] Among them, the preset graph query statement generation model can be constructed in advance by the operator.
[0072] It should be noted that the preset graph query statement generation model can convert the intent recognition vector into a query statement that can be executed in the knowledge graph, namely, a graph query statement; further, the converted graph query statement is adapted to the structure and storage method of the knowledge graph, so as to accurately locate the relevant nodes and relationships in the knowledge graph, thereby obtaining the answer information corresponding to the original question text entered by the user.
[0073] Step 140: Based on the graph query statement, query the preset knowledge graph and generate answer text.
[0074] Among them, the preset knowledge graph can be constructed in advance by the operator.
[0075] It should be noted that the preset knowledge graph is a complex network structure containing a large number of entities, relationships, attributes and attribute thresholds (compared to the existing knowledge graph, it has additional attribute thresholds), which stores various professional knowledge and data.
[0076] In some embodiments, the various professional knowledge and data stored in the preset knowledge graph may be professional knowledge and data of the electric power industry (it may also simply refer to professional knowledge and data related to the field of power transmission and transformation equipment in the electric power industry).
[0077] In some embodiments, a query is performed in a preset knowledge graph based on a graph query statement, and the query results obtained are returned in the form of a graph, and then the information returned in the form of the graph is converted into a natural language answer, that is, answer text, and finally the answer text is presented to the user for review; further, in the process of converting the information returned in the form of the graph into a natural language answer, different answer templates can be called according to the information returned in the form of the graph to convert the information returned in the form of the graph into a natural language answer, that is, answer text.
[0078] In some embodiments, if there is only one object element in the intent recognition vector, the final answer text will have only one specific answer. If there are multiple object elements in the intent recognition vector, the final answer text will have multiple specific answers, which can be displayed in a list for the user to choose.
[0079] In an embodiment of the present application, by introducing the preset AEDA-BERT-DSC-BiLSTM-GAT model, accurate intent recognition of the original question text is achieved, and efficient graph query statements are generated on this basis, which not only improves the accuracy of multi-intent recognition, but also enhances the ability of contextual association understanding and complex semantic structure parsing. Through this method, it is possible to quickly and accurately query and generate answer text in the preset knowledge graph, effectively solving the shortcomings of the existing technology in processing complex questions in the power industry.
[0080] In addition, the method of the present application also has the following advantages: by quickly and accurately parsing complex questions in the power industry and generating corresponding answer texts, the speed at which power companies obtain key information can be significantly improved, which helps power companies make decisions more quickly on equipment operating conditions, maintenance needs, etc., thereby improving the operating efficiency and safety of the entire power grid; by accurately identifying the intent of the question and generating targeted answers, power companies can more reasonably allocate maintenance resources and human resources. For example, for urgent equipment failure problems, relevant teams can be quickly mobilized for repairs, and for routine maintenance tasks, more flexible maintenance plans can be arranged, which helps to reduce operating costs and improve resource utilization efficiency; by providing fast and accurate question-and-answer services, the user experience of power industry staff can be significantly improved, so that they can carry out their work more efficiently.
[0081] In a feasible implementation, the preset AEDA-BERT-DSC-BiLSTM-GAT model in the above embodiment includes a feature extraction layer, a parallel layer, a classification layer and an intent recognition layer.
[0082] Then step 120 in the above embodiment, inputting the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain the intention recognition vector, includes: inputting the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model; the feature extraction layer is used to extract features from the original question text to obtain a text attention matrix; the parallel layer is used to perform parallel feature extraction on the text attention matrix to obtain a parallel feature vector; the classification layer is used to classify the parallel feature vectors to obtain a predicted word segmentation result; the intention recognition layer is used to recognize the predicted word segmentation result to obtain an intention recognition vector.
[0083] In an embodiment of the present application, the feature extraction layer can capture key information in the text by performing feature extraction on the original question text, focus on the important parts of the text more accurately, and improve the accuracy of intent recognition; the parallel layer can process multiple feature vectors simultaneously by performing parallel feature extraction on the text attention matrix, thereby improving processing speed and efficiency, and helping to generate accurate intent recognition vectors more quickly when processing complex, multi-intention problems; the classification layer can identify different semantic components in the text by classifying parallel feature vectors; the intent recognition layer can determine the true intent of the original question text input by the user by identifying the predicted word segmentation results, thereby generating an accurate intent recognition vector.
[0084] In a feasible implementation, the feature extraction layer in the above embodiment includes an AEDA module and a BERT module; the AEDA module is used to perform data enhancement on the original question text to obtain an enhanced question text, and determine the target question text based on the enhanced question text and the original question text; the BERT module is used to perform feature representation extraction on the target question text to obtain a text attention matrix.
[0085] In an embodiment of the present application, the AEDA module generates an enhanced question text by performing data augmentation on the original question text, and then combines the enhanced question text with the original question text to determine the target question text, thereby further enriching the model's understanding of question diversity and helping the model to perform better when dealing with complex and changing problems; the BERT module can capture the contextual information and semantic relationships in the text by extracting feature representations of the target question text, thereby generating a more accurate and rich text attention matrix.
[0086] Furthermore, by combining the feature extraction layers of the AEDA module and the BERT module, the key information in the original question text can be captured more accurately, which helps the model to more accurately identify the user's real needs when processing complex questions in the power industry, thereby generating a more accurate and useful intent recognition vector.
[0087] In addition, the feature extraction layer can process question texts containing complex semantic structures and multiple intentions through the collaboration of the AEDA module and the BERT module. This enables the model to more accurately parse the semantic structure and intention of questions when responding to complex questions in the power industry, thereby generating more accurate and comprehensive answer texts.
[0088] In a feasible implementation, the expression of the attention mechanism of the bidirectional Transformer encoder in the BERT module in the above embodiment is:
[0089]
[0090] Among them, selfAttention(Q,K,V) is the fusion output of the attention mechanism of the bidirectional Transformer encoder, softmax() is the softmax() function, Q is the query matrix, and the query matrix consists of the query vector of each word in the target question text, W q The matrix is dynamically adjusted for learnable queries, K is the key matrix, which consists of the key vectors of each word in the target question text, T is the inverse sign, and W k Dynamically adjust the matrix for learnable keys, d k is the scaling operation matrix, V is the value matrix, which consists of the value vector of each word in the target question text, and W v Dynamically adjust the matrix for learnable values.
[0091] It should be noted that the learnable query dynamic adjustment matrix, the learnable key dynamic adjustment matrix and the learnable value dynamic adjustment matrix are all randomly generated default matrices in the initial AEDA-BERT-DSC-BiLSTM-GAT model, that is, in the initial AEDA-BERT-DSC-BiLSTM-GAT model before training begins. Then, during the training process, learning adjustments can be performed, and in the subsequent prediction process, learning dynamic adjustments can also be performed (there are also learnable matrices in the following embodiments, please refer to the explanation here, and I will not repeat them here).
[0092] In the embodiments of the present application, a rigorous expression of the attention mechanism of the bidirectional Transformer encoder is provided from a mathematical perspective. The accuracy of the expression of the attention mechanism of the bidirectional Transformer encoder can be ensured from the rigor of mathematical logic, and the expression of the attention mechanism of the bidirectional Transformer encoder is preferably shown to provide reference, understanding and calculation for technical personnel.
[0093] In addition, the expression of the attention mechanism of the bidirectional Transformer encoder preferably provided by the present application, by introducing a learnable query dynamic adjustment matrix, a learnable key dynamic adjustment matrix and a learnable value dynamic adjustment matrix, the model can process the input target question text more flexibly, and these learnable dynamic adjustment matrices allow the model to automatically adjust and optimize during the training process, thereby more accurately capturing the key information and semantic relationships in the text. This dynamic adjustment capability enhances the model's ability to understand complex and changeable problems, so that the model can more accurately parse the semantic structure and intent of the problem when processing complex questions in the power industry; the attention mechanism of the bidirectional Transformer encoder generates a fused output by calculating the correlation between the query matrix, the key matrix and the value matrix, which can capture the correlation and importance between different parts of the text, thereby more accurately identifying the true intent of the original question text input by the user.
[0094] In a feasible implementation method, the parallel layer in the above embodiment includes a DSC module and a BiLSTM module, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector; the DSC module is used to perform deep feature extraction on the text attention matrix to obtain the DSC feature vector; the BiLSTM module is used to perform sequence feature extraction on the text attention matrix to obtain the BiLSTM feature vector.
[0095] In an embodiment of the present application, the DSC module generates a DSC feature vector by performing deep feature extraction on the text attention matrix, capturing local features and contextual relationships in the text through convolution operations. This deep feature extraction method helps the model understand the complex semantic structures and patterns in the text. At the same time, the BiLSTM module performs sequence feature extraction on the text attention matrix, capturing the temporal relationships and dependency relationships in the text, and generates a BiLSTM feature vector. This sequence feature extraction method helps the model understand the dynamic changes and contextual relationships in the text.
[0096] Furthermore, by using DSC feature vectors and BiLSTM feature vectors as parallel feature vectors, the model can more comprehensively capture the key information and semantic relationships in the text. This parallel feature extraction method enhances the model's ability to understand complex and changing problems, enabling the model to more accurately parse the semantic structure and intent of the question when processing complex questions in the power industry, thereby generating a more accurate and comprehensive answer text.
[0097] In addition, by combining the DSC module and the BiLSTM module, the parallel layer can extract features of the text attention matrix from both the depth feature and sequence feature perspectives. This parallel processing method not only improves the efficiency of feature extraction, but also helps to capture more comprehensive and rich text information.
[0098] In a feasible implementation, the expression of the DSC module in the above embodiment is:
[0099] DSC(X attention )=PointwiseConv[DepthwiseConv(X attention )];
[0100] Among them, DSC (X attention ) is the DSC feature vector, PointwiseConv[] is the point-wise convolution operation, DepthwiseConv() is the channel-wise convolution operation, X attention is the text attention matrix.
[0101] In the embodiments of the present application, a rigorous expression of the DSC module is provided from a mathematical perspective. The accuracy of the expression of the DSC module can be ensured from the rigor of mathematical logic, and the expression of the DSC module is preferably shown to provide reference, understanding and calculation for technical personnel.
[0102] In addition, the expression of the DSC module preferably provided in the above-mentioned application, by combining point-by-point convolution operations and channel-by-channel convolution operations, performs deep feature extraction on the text attention matrix in different dimensions, which can not only improve the efficiency of feature extraction and reduce the amount of calculation, but also generate a more representative feature vector (i.e., DSC feature vector), which can more accurately reflect the key information and semantic relationships in the text, thereby facilitating subsequent classification and intent recognition tasks.
[0103] In a feasible implementation method, the classification layer in the above embodiment includes a splicing layer, a fully connected layer and a Softmax function layer, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector; the splicing layer is used to splice and fuse the DSC feature vector and the BiLSTM feature vector to obtain a spliced and fused feature vector; the fully connected layer is used to perform a linear transformation on the spliced and fused feature vector to obtain the original score vector; the Softmax function layer is used to transform the original score vector to obtain a predicted word segmentation result.
[0104] In the embodiment of the present application, the splicing layer can obtain a spliced fusion feature vector that combines deep features and sequence features by splicing and fusing the DSC feature vector and the BiLSTM feature vector. This fusion method not only retains the respective advantages of the two feature vectors, but also improves the comprehensiveness and accuracy of the feature vector through information complementation and enhancement, which helps subsequent classification tasks to more accurately identify key information and semantic structures in the text; the fully connected layer performs a linear transformation on the spliced fusion feature vector, and further extracts and integrates feature information through the operation of the weight matrix and the bias term to obtain the original score vector, which helps to map the high-dimensional feature vector to the low-dimensional classification space, and provide a more concise and effective feature representation for subsequent classification tasks; the Softmax function layer can convert the original score vector into a probability distribution form by converting the original score vector, so that each classification label corresponds to a probability value. This probability distribution form not only helps to understand the confidence of the classification result, but also provides a more intuitive and reliable basis for subsequent classification decisions. By comparing the probability values of different classification labels, the label with the highest probability can be selected as the final classification result, that is, the predicted word segmentation result.
[0105] In addition, the classification layer realizes the effective fusion, linear transformation and probability distribution conversion of parallel feature vectors through the collaboration of the splicing layer, the fully connected layer and the Softmax function layer, thereby improving the accuracy and reliability of the classification task. This classification method performs well in processing complex and changeable text data, and helps to achieve accurate understanding and classification of user input problems in the intelligent transformation of the power industry.
[0106] In a feasible implementation, the intent recognition layer in the above embodiment includes a synonym conversion module and a GAT module; the synonym conversion module is used to convert the words with synonymous parts of speech in the predicted word segmentation results into corresponding entity words, relationship words, attribute words or attribute threshold words according to a preset synonym library when there are synonyms for the parts of speech of the words in the predicted word segmentation results, so as to obtain the target predicted word segmentation results; the GAT module is used to perform intent recognition on the target predicted word segmentation results to obtain an intent recognition vector.
[0107] The preset synonym library may be constructed in advance by an operator.
[0108] It should be noted that the parts of speech of the words in the predicted word segmentation results obtained in the present application include entity words, relationship words, attribute words, attribute threshold words and synonyms, among which synonyms are non-standard writing methods of entity words, relationship words, attribute words or attribute threshold words. In order to achieve more accurate intent recognition, it is necessary to convert synonyms into corresponding entity words, relationship words, attribute words or attribute threshold words.
[0109] In an embodiment of the present application, the synonym conversion module can automatically convert the synonyms in the predicted word segmentation results into corresponding standard entity words, relationship words, attribute words or attribute threshold words according to a preset synonym library, which ensures that the subsequent intent recognition process is based on a unified and accurate concept system, avoiding intent recognition errors caused by synonym confusion; the GAT module can deeply analyze and understand the target predicted word segmentation results by performing intent recognition on the target predicted word segmentation results, that is, in the graph attention network, each node (that is, each word in the target predicted word segmentation result) has potential associations with other nodes, and the importance of these associations is represented by the attention coefficient, so that a more accurate intent recognition vector can be obtained.
[0110] In addition, the intent recognition layer can more accurately capture the true intention of the user's input questions through the collaboration of the synonym conversion module and the GAT module. This accuracy is not only reflected in the recognition of a single intent, but also in the analysis of complex, multi-intent questions.
[0111] In a feasible implementation, the expression of the GAT module in the above embodiment is:
[0112]
[0113] Among them, h i ” is the i-th object element in the intention recognition vector, σ is the sigmoid activation function, K is the total number of groups of the multi-head attention mechanism in the GAT module, and N i is the total number of entity words in the predicted word segmentation results that have relationship words, attribute words, and / or attribute threshold word relationships with the i-th entity word. To predict the attention coefficient between the i-th entity word and the j-th entity word in the k-th group in the word segmentation result, LeakyReLU() is the LeakyReLU activation function. is the learnable feature weight matrix of the i-th entity word in the k-th group in the predicted word segmentation result, h j To predict the features of the j-th entity word in the word segmentation result, is the feature weight matrix of the relationship words, attribute words and / or attribute threshold words in the kth group between the i-th entity word and the j-th entity word in the word segmentation result, E ij To predict the features of the relationship words, attribute words and / or attribute threshold words between the i-th entity word and the j-th entity word in the word segmentation result, Residual() is the residual connection operation, and h i It is the feature of predicting the i-th entity word in the word segmentation result.
[0114] It should be noted that, in the present application, entity words are used as nodes, and relationship words, attribute words and attribute threshold words are used as edges between nodes.
[0115] In the embodiments of the present application, a rigorous expression of the GAT module is provided from a mathematical perspective. The accuracy of the expression of the GAT module can be ensured from the rigor of mathematical logic, and the expression of the GAT module is preferably shown to provide reference, understanding and calculation for technical personnel.
[0116] In addition, the expression of the GAT module preferably provided in the above-mentioned application, by adopting a multi-head attention mechanism and setting the total number of groups, allows the model to understand the relationship between nodes from multiple angles and levels, which enhances the model's ability to parse complex semantic structures, so that the model can more comprehensively understand the semantic structure and intention of the problem when dealing with complex questions in the power industry.
[0117] In a feasible implementation, the method in the above embodiment further includes:
[0118] Using the formula Determine the attention coefficient between the i-th entity word and the j-th entity word in the predicted word segmentation result in the k-th group;
[0119] Among them, e is a natural constant, a[||] is the connection processing operation of the feedforward neural network, T is the inverse sign, and W k is the learnable weight matrix of the kth group.
[0120] In the embodiments of the present application, a rigorous calculation formula for the attention coefficient is provided from a mathematical perspective. The accuracy of the calculated attention coefficient can be ensured from the rigor of mathematical logic, and the calculation formula for the above-mentioned attention coefficient is preferably shown to provide reference, understanding and calculation for technical personnel.
[0121] In addition, the above-mentioned calculation formula of the attention coefficient of the GAT module preferably provided in the present application calculates the attention coefficient. The model can more accurately understand the relevance and importance between each entity word in the predicted word segmentation results. This understanding of relevance and importance is crucial for the subsequent graph attention network (GAT) module to perform intent recognition.
[0122] It can be understood that the introduction of the attention coefficient enables the model to focus on more important entity words and relationships, thereby reducing noise and interference in the intent recognition process and improving recognition accuracy.
[0123] In a second aspect, the present application provides a question-answering device based on a knowledge graph.
[0124] See also Figure 2 , is a schematic diagram of a question-answering device based on a knowledge graph in an embodiment of the present application, wherein the device 210 includes:
[0125] An acquisition module 211 is used to acquire the original question text;
[0126] Model intent recognition module 212, used to input the original question text into a preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain an intent recognition vector;
[0127] The model statement generation module 213 is used to input the intent recognition vector into a preset graph query statement generation model to obtain a graph query statement;
[0128] The query module 214 is used to query in a preset knowledge graph according to the graph query statement and generate an answer text.
[0129] In the embodiment of the present application, the relevant contents of the acquisition module 211, the model intent recognition module 212, the model sentence generation module 213 and the query module 214 can be referred to in Figure 1 The contents in the illustrated embodiment will not be described in detail here.
[0130] It should be noted that the device 210 of the present application also includes some other modules. It can be understood that the method of the present application and the device 210 have a one-to-one correspondence. Therefore, some other modules of the device 210 of the present application are the contents corresponding to the method of the present application in the above-mentioned embodiment.
[0131] In an embodiment of the present application, by introducing the preset AEDA-BERT-DSC-BiLSTM-GAT model, accurate intent recognition of the original question text is achieved, and efficient graph query statements are generated on this basis, which not only improves the accuracy of multi-intent recognition, but also enhances the ability of contextual association understanding and complex semantic structure parsing. Through this method, it is possible to quickly and accurately query and generate answer text in the preset knowledge graph, effectively solving the shortcomings of the existing technology in processing complex questions in the power industry.
[0132] In addition, the method of the present application also has the following advantages: by quickly and accurately parsing complex questions in the power industry and generating corresponding answer texts, the speed at which power companies obtain key information can be significantly improved, which helps power companies make decisions more quickly on equipment operating conditions, maintenance needs, etc., thereby improving the operating efficiency and safety of the entire power grid; by accurately identifying the intent of the question and generating targeted answers, power companies can more reasonably allocate maintenance resources and human resources. For example, for urgent equipment failure problems, relevant teams can be quickly mobilized for repairs, and for routine maintenance tasks, more flexible maintenance plans can be arranged, which helps to reduce operating costs and improve resource utilization efficiency; by providing fast and accurate question-and-answer services, the user experience of power industry staff can be significantly improved, so that they can carry out their work more efficiently.
[0133] In a third aspect, the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes a question-and-answer method based on a knowledge graph in the above method embodiment.
[0134] In a fourth aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes a question-and-answer method based on a knowledge graph in the above method embodiment.
[0135] Figure 3 The internal structure diagram of a computer device in some embodiments is shown. The computer device may be a terminal, a server, or a gateway. Figure 3 As shown, the computer device includes a processor, a memory and a network interface connected through a system bus.
[0136] The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement each step in the above method embodiment. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can implement each step in the above method embodiment. Those skilled in the art can understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0137] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods.
[0138] Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0139] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0140] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A question-answering method based on knowledge graph, characterized in that: The method comprises: Get the original question text; Input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain an intent recognition vector; Inputting the intention recognition vector into a preset graph query statement generation model to obtain a graph query statement; According to the graph query statement, a query is performed in the preset knowledge graph to generate an answer text.
2. The method according to claim 1, characterized in that The preset AEDA-BERT-DSC-BiLSTM-GAT model includes a feature extraction layer, a parallel layer, a classification layer and an intent recognition layer. The original question text is input into the preset AEDA-BERT-DSC-BiLSTM-GAT model to obtain an intent recognition vector, including: Input the original question text into the preset AEDA-BERT-DSC-BiLSTM-GAT model; The feature extraction layer is used to extract features from the original question text to obtain a text attention matrix; The parallel layer is used to perform parallel feature extraction on the text attention matrix to obtain a parallel feature vector; The classification layer is used to classify the parallel feature vectors to obtain a predicted word segmentation result; The intention recognition layer is used to recognize the predicted word segmentation result to obtain the intention recognition vector.
3. The method according to claim 2, characterized in that The feature extraction layer includes an AEDA module and a BERT module; The AEDA module is used to perform data enhancement on the original question text to obtain an enhanced question text, and determine a target question text according to the enhanced question text and the original question text; The BERT module is used to extract feature representation of the target question text to obtain the text attention matrix.
4. The method according to claim 3, characterized in that The expression of the attention mechanism of the bidirectional Transformer encoder in the BERT module is: Wherein, selfAttention(Q,K,V) is the fused output of the attention mechanism of the bidirectional Transformer encoder, softmax() is the softmax() function, Q is the query matrix, and the query matrix is composed of the query vector of each word in the target question text, W q is a learnable query dynamic adjustment matrix, K is a key matrix, and the key matrix is composed of the key vector of each word in the target question text, T is the inverse sign, and W k Dynamically adjust the matrix for learnable keys, d k is the scaling operation matrix, V is the value matrix, and the value matrix is composed of the value vector of each word in the target question text, W v Dynamically adjust the matrix for learnable values.
5. The method according to claim 2, characterized in that: The parallel layer includes a DSC module and a BiLSTM module, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector; The DSC module is used to perform deep feature extraction on the text attention matrix to obtain the DSC feature vector; The BiLSTM module is used to extract sequence features from the text attention matrix to obtain the BiLSTM feature vector.
6. The method according to claim 5, characterized in that The expression of the DSC module is: DSC(X attention )=PointwiseConv[DepthwiseConv(X attention )]; Among them, DSC (X attention ) is the DSC feature vector, PointwiseConv[] is a point-wise convolution operation, DepthwiseConv() is a channel-by-channel convolution operation, X attention is the text attention matrix.
7. The method according to claim 2, characterized in that The classification layer includes a concatenation layer, a fully connected layer and a Softmax function layer, and the parallel feature vector includes a DSC feature vector and a BiLSTM feature vector; The splicing layer is used to splice and fuse the DSC feature vector and the BiLSTM feature vector to obtain a spliced fused feature vector; The fully connected layer is used to perform a linear transformation on the concatenated fusion feature vector to obtain an original score vector; The Softmax function layer is used to transform the original score vector to obtain the predicted word segmentation result.
8. The method according to claim 2, characterized in that: The intention recognition layer includes a synonym conversion module and a GAT module; The synonym conversion module is used to convert the words with synonymous parts of speech into corresponding entity words, relation words, attribute words or attribute threshold words according to a preset synonym library when there are synonyms for the parts of speech of the words in the predicted word segmentation result, so as to obtain the target predicted word segmentation result; The GAT module is used to perform intent recognition on the target prediction segmentation result to obtain the intent recognition vector.
9. The method according to claim 8, characterized in that The expression of the GAT module is: Among them, h i ” is the i-th object element in the intent recognition vector, σ is the sigmoid activation function, K is the total number of groups of the multi-head attention mechanism in the GAT module, N i is the total number of entity words in the predicted word segmentation result that have a relationship word, attribute word and / or attribute threshold word relationship with the i-th entity word, is the attention coefficient between the i-th entity word and the j-th entity word in the predicted word segmentation result in the k-th group, LeakyReLU() is the LeakyReLU activation function, is the learnable feature weight matrix of the i-th entity word in the k-th group in the predicted word segmentation result, h j is the feature of the j-th entity word in the predicted word segmentation result, is the feature weight matrix of the relationship words, attribute words and / or attribute threshold words in the kth group between the i-th entity word and the j-th entity word in the predicted word segmentation result, E ij is the feature of the relationship word, attribute word and / or attribute threshold word between the i-th entity word and the j-th entity word in the predicted word segmentation result, Residual() is the residual connection operation, and h i is the feature of the ith entity word in the predicted word segmentation result.
10. The method according to claim 9, characterized in that The method further comprises: Using the formula Determine the attention coefficient between the i-th entity word and the j-th entity word in the predicted word segmentation result in the k-th group; Among them, e is a natural constant, a[||] is the connection processing operation of the feedforward neural network, T is the inverse sign, and W k is the learnable weight matrix of the kth group.