Question and answer method and device for power grid operation monitoring system, medium and equipment

By using bidirectional encoder characterization model and search enhancement generation technology in the field of power grid operation monitoring, questions that cannot be answered accurately and intelligently in the existing technology are solved, and fast, accurate and professional intelligent question-and-answer are achieved, which improves system efficiency and user satisfaction.

CN120216534APending Publication Date: 2025-06-27GUANGDONG ELECTRIC POWER SCI RES INST ENERGY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510295700.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The existing technology cannot accurately answer questions in the field of power grid operation monitoring, mainly because the SQL statements generated by the code model do not meet the query field requirements of the operation monitoring SQL database, the data does not match, the key information is missing, the answers do not meet user preferences, and the problem involving professional field knowledge cannot be accurately answered.

Method used

The bidirectional encoder characterization model (BERT) is used to classify the questions and extract sentence vectors, combine the search enhancement generation technology (RAG) to search domain knowledge fragments, calculate the similarity between the question sentence vector and the sample question sentence vector in the dataset, find the most matching question answers, and generate input prompt words to output SQL query statements, and finally generate text answers based on the power grid operation monitoring database.

Benefits of technology

It realizes quick, accurate and professional intelligent answers to questions in the field of power grid operation monitoring, improves the relevance and accuracy of the answers, and improves the efficiency and user satisfaction of the intelligent question-and-answer system in the entire power grid operation monitoring field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216534A_ABST
    Figure CN120216534A_ABST
Patent Text Reader

Abstract

The invention discloses a question answering method and device for a power grid operation monitoring system, a medium and equipment. According to the method, the to-be-answered question and the preset classification data set are obtained, the category of the question is determined and the sentence vector is extracted by training a vegetative bidirectional encoder representation model (such as BERT), and then the related neighborhood knowledge fragments are obtained through the retrieval enhancement generation technology; the method comprises the steps of obtaining sentence vectors, matching most relevant question-answer pairs on the basis of similarity between the sentence vectors and samples in a data set, finally generating input cue words in combination with the information, and accurately outputting first text answers of questions according to a power grid operation monitoring database, the input cue words and the question-answer pairs, so that an efficient and accurate question-answering system is realized; and the response quality and satisfaction of user query are improved. The problem that problems cannot be accurately and intelligently answered during power grid operation monitoring in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of question and answer of power grid operation monitoring systems, and particularly to a question and answer method, device, medium and equipment for a power grid operation monitoring system. Background Art

[0002] With the advancement of digital transformation, power companies are keen on establishing strategic operation control platforms for real-time monitoring of the operation status of the power grid and related business data. With the expansion of system services, the data types and data volumes are also increasing continuously. Platform users will have more and more query and analysis requirements for the system's business functions and indicator data, and it requires a large amount of time and effort from system operation and maintenance personnel to respond to these requirements. Due to limited human resources, it is impossible to use manual methods to quickly reply to and solve user problems, which brings certain troubles to users during the use of the platform. In addition, the platform with only the functions of storing and displaying data lacks scientific and effective tools to mine and represent the correlation relationships between indicator data in various fields.

[0003] In the field of operation monitoring, existing technical solutions only use basic deep learning methods to perform word vector representation learning on user questions and answers, and then calculate the semantic connection degree using word vectors to retrieve relevant answers. These technical solutions cannot be directly applied to the operation monitoring field for five reasons: (1) When there is only an input question, the SQL statements generated by conventional code large models do not meet the query field requirements of the operation monitoring SQL database, resulting in the inability to execute the SQL statements or bugs in the execution process (unable to query); (2) The data tables retrieved by the SQL statements generated by conventional code large models do not match the question answers, that is, the data retrieved by the generated SQL statements is not what the user wants (inaccurate query); (3) When some key information is missing in the user question, conventional large models cannot output the answers preferred by the user. For example, when the user asks "How about the electricity sales volume?", there is no information on the organization and time dimensions in this question, but what the user actually wants to know is the electricity sales volume of each local power supply bureau at the latest time, that is, equivalent to the question "How about the electricity sales volume of each local power supply bureau in September 2024?", and the information on time and organization is hidden. Since the conventional model does not know the information on time and organization, it cannot generate the answers wanted by the user, and may even answer the corresponding electricity sales volume for all organizations and all times (information hiding problem); (5) There are certain template specification requirements for the specific text answers to user questions. After obtaining the data results, conventional large language models will directly list all the data and answer them one by one, and this general type of answer is not what the user actually wants. For example, in the question "How about the electricity sales volume of each local power supply bureau in September 2024?", the user only requires the text to answer the two local power supply bureaus with the highest and lowest electricity sales volumes and their specific values, while the values of all local power supply bureaus are presented in a chart (answer preference problem). (5) User questions involve a lot of professional field knowledge, and the training data used by conventional general large models does not cover this part of professional knowledge, resulting in the inability to accurately answer user questions. For example, "Electricity bill recovery situation" involves four indicators: "Current year electricity bill recovery rate, electricity bill recovery rate for overdue accounts of 1 year, electricity bill recovery rate for overdue accounts of 2 - 3 years, electricity bill recovery rate for overdue accounts of more than 3 years". When answering questions such as "How about the electricity bill recovery situation?", conventional general large models cannot be associated with these four indicators (field knowledge problem). These problems cause the existing technology to be unable to accurately and intelligently answer questions in power grid operation monitoring. Summary of the Invention

[0004] The present invention provides a question - answering method, device, medium and equipment for a power grid operation monitoring system to solve the problem that existing technologies cannot accurately and intelligently answer questions in power grid operation monitoring.

[0005] In a first aspect, the present application provides a question - answering method for a power grid operation monitoring system, including:

[0006] Obtain the question to be answered and a preset classification dataset;

[0007] Input the question into a pre-trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category of the question and a sentence vector;

[0008] Obtain an input prompt word according to the question, the neighborhood knowledge fragments of the category, and the question-answer pair of the question; wherein, the neighborhood knowledge fragments of the category are obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and the sentence vectors of each sample question in the classification dataset;

[0009] Obtain a first text answer to the question according to the power grid operation monitoring database, the input prompt word, and the question-answer pair.

[0010] This application ensures that the method can be customized for a specific power grid operation field by obtaining the question to be answered and a preset classification dataset. Then, a trained bidirectional encoder representation model (BERT) is used to classify the question and extract the sentence vector. This step enables the model to deeply understand the semantic content of the question and map it to the corresponding category, laying a foundation for subsequent accurate answers. Then, through the retrieval-augmented generation technology (RAG), domain knowledge fragments related to the question category are retrieved, further enhancing the model's understanding ability of professional domain questions. Calculate the similarity between the question sentence vector and the sentence vectors of the sample questions in the dataset to find the most matching question-answer pair (QA Pairs). This matching process ensures that the most relevant previous Q&A instances can be found for the user's question, thereby improving the relevance and accuracy of the answer. Finally, an input prompt word is generated by combining the question, the neighborhood knowledge fragments, and the question-answer pair and input into the code generation module to output an SQL query statement. This step realizes the conversion from a natural language question to a structured query. Finally, a first text answer is generated according to the power grid operation monitoring database, the SQL query statement, and the question-answer pair. This answer not only quickly responds to the user's query needs but also ensures the professionalism and accuracy of the answer by integrating domain knowledge, thereby improving the efficiency and user satisfaction of the intelligent Q&A system in the entire power grid operation monitoring field. To solve the problem that in the prior art, questions cannot be intelligently answered accurately in power grid operation monitoring.

[0011] As a preferred embodiment of the first aspect, the step of inputting the question into a pre-trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category of the question and a sentence vector is specifically:

[0012] Obtain a preset classification dataset, and input the classification dataset into an initial bidirectional encoder representation model for training to obtain a bidirectional encoder representation model;

[0013] Input the question into the bidirectional encoder representation model, so that the bidirectional encoder representation model outputs the sentence vector of the question according to the bidirectional Transformer Encoder architecture, and outputs the category of the question according to the classifier.

[0014] In this preferred embodiment, the present application trains by inputting a preset classification dataset into an initial bidirectional encoder representation model to obtain an optimized bidirectional encoder representation model (BERT). This model can understand the complexity and professionalism of questions in the field of power grid operation. Subsequently, the question proposed by the user is input into this well-trained model. Using its bidirectional Transformer Encoder architecture, the model can deeply understand the context and semantics of the question, output the sentence vector of the question, and determine the category of the question through a classifier. The reasoning process of this process is: through the optimization of the model in the training stage, it is ensured that the model can accurately capture the core intention and relevant domain knowledge of the question in actual application. Thus, in the reasoning stage, the model can quickly and accurately classify and vectorize the question, providing an accurate basis for subsequent domain knowledge retrieval and question answering. This not only improves the efficiency of question processing but also enhances the relevance and accuracy of the answer, ultimately improving the effectiveness of the entire intelligent question-answering system and user satisfaction.

[0015] As a preferred embodiment of the first aspect, the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification dataset. Specifically:

[0016] According to the preset classification dataset, calculate the similarities between the sentence vector and each sentence vector of each sample question in the classification dataset;

[0017] Judge whether each similarity is greater than a preset threshold;

[0018] If so, calculate the question-answer pair with the largest similarity according to each similarity.

[0019] In this preferred embodiment, by calculating the similarity between the sentence vector of the user's question and the sentence vectors of each sample question in the classification dataset, the present application can quantify the semantic proximity between each sample question and the user's question. Then, by setting a preset threshold, the present application can screen out the sample questions that are semantically similar enough to the user's question. This threshold serves as a decision criterion to help distinguish which sample questions are relevant and useful. Finally, from these sample questions with similarities greater than the threshold, the one with the highest similarity is selected as the question-answer pair, ensuring that the selected answer pair is the most semantically matched with the user's question. The present application can quickly and accurately find the most relevant information from a large amount of data, thereby improving the pertinence and accuracy of the answer, and ultimately enhancing the response quality and user satisfaction of the entire question-and-answer system.

[0020] As a preferred embodiment of the first aspect, determining whether each of the similarities is greater than the preset threshold further includes:

[0021] If each of the similarities is less than the preset threshold, input the question into a preset large language model so that the large language model outputs a second text answer to the question.

[0022] In this preferred embodiment, by comparing the similarity between the sentence vector of the user's question and the sentence vectors of the sample questions in the preset classification dataset and comparing it with the preset threshold, the present application can evaluate which sample questions are semantically relevant enough to the user's question. When it is found that the similarities of all sample questions are lower than the preset threshold, that is, no semantically close sample questions are found, the present application will input the user's question into a preset large language model instead, and utilize the extensive knowledge and language understanding ability of the large model to generate a second text answer. If there are no question-answer pairs that are similar enough in the dataset, directly relying on the dataset may not provide a satisfactory answer, while the large language model can provide a fallback answer based on its extensive training, thereby ensuring that even in the case of insufficient dataset matching, the user's question can be responded to in a timely and effective manner, enhancing the robustness of the system and the user's satisfaction.

[0023] As a preferred embodiment of the first aspect, obtaining the first text answer to the question according to the power grid operation monitoring database, the input prompt word, and the question-answer pair specifically includes:

[0024] Input the input prompt word into a preset code generation module so that the code generation module outputs an SQL query statement;

[0025] Obtain the first text answer to the question according to the power grid operation monitoring database, the SQL query statement, and the question-answer pair.

[0026] In this preferred embodiment, the present application inputs the input prompt into a preset code generation module. This step utilizes the information of the problem context, domain knowledge fragments, and problem-answer pairs contained in the prompt, enabling the code generation module to generate highly targeted SQL query statements. Then, by executing these SQL query statements on the power grid operation monitoring database, the present application can retrieve specific data directly related to the user's problem. This step ensures the data accuracy and real-time nature of the answer. Finally, by combining the retrieved data and the problem-answer pairs, the method generates and outputs a first text answer. This answer is not only based on real-time data but also takes into account the context and domain knowledge of the problem, thereby improving the relevance and accuracy of the answer. The present application enables users to obtain more accurate, rich, and timely Q&A services, significantly enhancing the Q&A efficiency and user experience in the field of power grid operation monitoring.

[0027] As a preferred embodiment of the first aspect, obtaining the first text answer to the problem according to the power grid operation monitoring database, the SQL query statement, and the problem-answer pair specifically includes:

[0028] Generate a data table according to the power grid operation monitoring database and the SQL query statement;

[0029] Obtain the prompt for the problem according to the data table and the problem-answer pair of the problem;

[0030] Input the prompt into a preset large language model so that the large language model outputs the first text answer to the problem.

[0031] In this preferred embodiment, the present application generates a data table according to the power grid operation monitoring database and the SQL query statement. This step ensures that the data source of the answer is accurate and up-to-date because the data table directly comes from the database and reflects the real-time state of the power grid operation. Then, using the data table and the problem-answer pair to generate the prompt enables the prompt to accurately capture the core requirements and relevant data of the problem, providing a basis for generating an accurate answer. Finally, inputting the prompt into a preset large language model and using the language understanding and generation capabilities of the large model to output the first text answer. This answer is not only based on accurate data but also takes into account the context and semantics of the problem, thus ensuring the relevance and readability of the answer.

[0032] In a second aspect, the present application provides a Q&A device for a power grid operation monitoring system. The Q&A device for the power grid operation monitoring system includes an acquisition module, an input / output module, and a generated text answer module;

[0033] The acquisition module is used to acquire the question to be answered and a preset classification data set;

[0034] The input-output module is used to input the problem into the pre-trained bidirectional encoder representation model, so that the bidirectional encoder representation model outputs the category of the problem and the sentence vector.

[0035] The generated text answer module is used to obtain an input prompt word according to the problem, the neighborhood knowledge fragment of the category, and the question-answer pair of the problem; wherein, the neighborhood knowledge fragment of the category is obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and the sentence vectors of each sample question in the classification dataset.

[0036] According to the power grid operation monitoring database, the input prompt word, and the question-answer pair, a first text answer to the problem is obtained.

[0037] This device uses three modules to work in division of labor and coordination, and can accurately provide text responses to the questions raised by users. This application ensures that the method can be customized for specific power grid operation fields by obtaining the questions to be answered and the preset classification dataset. Then, the well-trained Bidirectional Encoder Representations from Transformers (BERT) is used to classify the questions and extract sentence vectors. This step enables the model to deeply understand the semantic content of the questions and map them to corresponding categories, laying a foundation for subsequent accurate answers. Then, through the Retrieval-Augmented Generation (RAG) technology, the domain knowledge fragments related to the question category are retrieved, further enhancing the model's understanding ability of professional domain questions. Calculate the similarity between the question sentence vector and the sentence vectors of the sample questions in the dataset to find the most matching question-answer pairs (QA Pairs). This matching process ensures that the most relevant previous Q&A instances can be found for the user's question, thereby improving the relevance and accuracy of the answers. Finally, combine the question, the neighborhood knowledge fragment, and the question-answer pair to generate an input prompt word, and input it into the code generation module to output an SQL query statement. This step realizes the conversion from natural language questions to structured queries. Finally, according to the power grid operation monitoring database, the SQL query statement, and the question-answer pair, a first text answer is generated. This answer not only quickly responds to the user's query needs, but also ensures the professionalism and accuracy of the answer by integrating domain knowledge, thereby improving the efficiency and user satisfaction of the intelligent Q&A system in the entire power grid operation monitoring field. To solve the problem that in the prior art, questions cannot be intelligently answered accurately in power grid operation monitoring.

[0038] As a preferred embodiment of the second aspect, the inputting the problem into the pre-trained bidirectional encoder representation model, so that the bidirectional encoder representation model outputs the category of the problem and the sentence vector is specifically as follows:

[0039] Obtain a preset classification data set, and input the classification data set into an initial bidirectional encoder representation model for training to obtain a bidirectional encoder representation model;

[0040] Input the question into the bidirectional encoder representation model, so that the bidirectional encoder representation model outputs the sentence vector of the question according to the bidirectional Transformer Encoder architecture, and outputs the category of the question according to the classifier.

[0041] In this preferred embodiment, the present application trains by inputting a preset classification data set into an initial bidirectional encoder representation model to obtain an optimized bidirectional encoder representation model (BERT). This model can understand the complexity and professionalism of questions in the field of power grid operation. Subsequently, the question proposed by the user is input into this well-trained model. Using its bidirectional Transformer Encoder architecture, the model can deeply understand the context and semantics of the question, output the sentence vector of the question, and determine the category of the question through the classifier. The reasoning process of this process is as follows: Through the optimization of the model in the training stage, it is ensured that the model can accurately capture the core intention of the question and relevant domain knowledge in actual applications. Thus, in the reasoning stage, the model can quickly and accurately classify and vectorize the question, providing an accurate basis for subsequent domain knowledge retrieval and question answering. This not only improves the efficiency of question processing but also enhances the relevance and accuracy of the answers, ultimately improving the effectiveness of the entire intelligent question and answer system and user satisfaction.

[0042] In a third aspect, the present application provides a computer-readable storage medium, which includes a stored computer program. When the computer program runs, it controls the device where the computer-readable storage medium is located to execute the question and answer method of a power grid operation monitoring system as described above. Its beneficial effects are the same as those of the question and answer method of a power grid operation monitoring system provided in the first aspect of the present application.

[0043] In a fourth aspect, the present application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the question and answer method of any power grid operation monitoring system as described in the first aspect. Brief Description of the Drawings

[0044] Figure 1 : It is a schematic flowchart of an embodiment of the question and answer method of the power grid operation monitoring system provided by the present application;

[0045] Figure 2 : It is a schematic flowchart of an embodiment of the intelligent question and answer for power grid operation monitoring data information retrieval provided by the present application;

[0046] Figure 3 : Schematic flow diagram of an embodiment of the intelligent question - answering algorithm in the power grid operation monitoring field provided by this application;

[0047] Figure 4 : Schematic structural diagram of an embodiment of the question - answering device of the power grid operation monitoring system provided by this application. Detailed implementation manners

[0048] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts belong to the scope of protection of the present invention.

[0049] Embodiment 1

[0050] Please refer to Figure 1 , which is a question - answering method for a power grid operation monitoring system provided by an embodiment of the present invention.

[0051] In this embodiment, the process of the question - answering method for the power grid operation monitoring system in this application is described in detail through steps S01 - S04.

[0052] S01: Obtain the question to be answered and the preset classification data set.

[0053] As a preferred embodiment of Embodiment 1, the preset classification data set is specifically:

[0054] Construct a question classification data set in the power grid operation monitoring field. Each sample in the data set is a question - answer pair (QA Pairs), and the label is the classification category of the QA Pairs. The answer includes the SQL statement corresponding to the question and the text answer.

[0055] S02: Input the question into the trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question.

[0056] As a preferred embodiment of Embodiment 1, the inputting the question into the trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question is specifically:

[0057] Train a semantic understanding and classification module based on the question classification dataset D and the Bidirectional Encoder Representations from Transformers (BERT) architecture to achieve accurate classification of user input questions. The core architecture adopted by BERT is the bidirectional Transformer Encoder, which is stacked by multiple identical layers. Each layer contains two main modules: the Multi-Head Self-Attention mechanism and the Feed-Forward Neural Network. The self-attention mechanism dynamically assigns different attention weights to each word by calculating the correlation between words. This enables the model to flexibly capture long-distance dependencies without being restricted by the sequence length. The output of each attention layer passes through a feed-forward neural network, usually composed of two fully connected layers with a ReLU activation function in the middle. This network processes the representation of each position independently. The core advantage of the bidirectional Transformer Encoder is its ability to consider both the left and right context information of words simultaneously. Different from unidirectional models (such as GPT), when processing each word, the bidirectional model can utilize the information of the entire sequence, thus understanding semantics more comprehensively. In the training phase, the input of BERT is the question text of the samples in the dataset D, such as "How about the line loss rate of each local sub-bureau?", and the text is transformed into word vectors through the vector layer of BERT. Through the bidirectional Transformer Encoder architecture in BERT, the sentence vector CLS of this sentence is output q , input CLS q to the fully connected layer, and finally obtain the predicted label vector y through softmax p , and finally calculate y p and the true classification label y t 's cross-entropy loss L to train the parameters of BERT. The mathematical formulas involved in the process are described as follows:

[0058] CLS q = BERT(Q);

[0059] y p = softmax(fully_conneted(CLS q ));

[0060] L = CrossEntropy(y p , y t );

[0061] In the inference phase, the question asked by the user is Q, and the sentence vector CLS is obtained after BERT output q :

[0062] CLS q = BERT(Q);

[0063] In this preferred embodiment, the present application trains by inputting a preset classification data set into an initial Bidirectional Encoder Representations from Transformers (BERT) model, and obtains an optimized BERT model. This model can understand the complexity and professionalism of problems in the field of power grid operation. Subsequently, the question proposed by the user is input into this well-trained model. Using its bidirectional Transformer Encoder architecture, the model can deeply understand the context and semantics of the question, output the sentence vector of the question, and determine the category of the question through a classifier. The reasoning process of this process is as follows: Through the optimization of the model in the training stage, it is ensured that the model can accurately capture the core intention of the question and relevant domain knowledge in actual applications. Thus, in the reasoning stage, the model can quickly and accurately classify and vectorize the question, providing an accurate basis for subsequent domain knowledge retrieval and question answering. This not only improves the efficiency of question processing, but also enhances the relevance and accuracy of the answer, ultimately improving the effectiveness of the entire intelligent question-answering system and user satisfaction.

[0064] S03: Obtain an input prompt word according to the question, the neighborhood knowledge fragment of the category, and the question-answer pair of the question; wherein, the neighborhood knowledge fragment of the category is obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set.

[0065] As a preferred embodiment of Embodiment 1, the obtaining of the input prompt word according to the question, the neighborhood knowledge fragment of the category, and the question-answer pair of the question; wherein, the neighborhood knowledge fragment of the category is obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set, specifically:

[0066] According to the question Q, use the Retrieval-Augmented Generation (RAG) algorithm to obtain the knowledge fragment K related to Q.

[0067] Traverse the data set D and calculate the sentence vector CLS of each sample question k with CLS q similarity s k , where CLS k is obtained by inputting the corresponding sample question Q k to the trained BERT.

[0068] Judge whether there is an s k , greater than the preset threshold st If it exists, find the largest s k The corresponding QAPairs P k , P k represents the question-answer pair in the dataset D that is semantically closest to the target question Q; if it does not exist, the question Q is irrelevant to the business, and Q is embedded into a general prompt template to form a prompt p l .

[0069] In this preferred embodiment, by calculating the similarity between the sentence vector of the user's question and the sentence vectors of each sample question in the classification dataset, the present application can quantify the semantic proximity of each sample question to the user's question; then, by setting a preset threshold, the present application can screen out the sample questions that are semantically similar enough to the user's question, and this threshold serves as a decision criterion to help distinguish which sample questions are relevant and useful; finally, from these sample questions with a similarity greater than the threshold, the one with the highest similarity is selected as the question-answer pair, ensuring that the selected answer pair is the most semantically matched with the user's question. The present application can quickly and accurately find the most relevant information from a large amount of data, thereby improving the pertinence and accuracy of the answer, and ultimately enhancing the response quality and user satisfaction of the entire question-answer system.

[0070] S04: Obtain the first text answer to the question based on the power grid operation monitoring database, the input prompt, and the question-answer pair

[0071] As a preferred embodiment of Embodiment 1, the obtaining the first text answer to the question based on the power grid operation monitoring database, the input prompt, and the question-answer pair is specifically as follows

[0072] Combine the question Q, the knowledge fragment K, and the Q&A pair P of the similar question k into a prompt p c , as the input to the code large model. The code large model is a large and complex model that uses deep learning technology to process, understand, and generate code. The model can understand and generate natural language, and can also understand and generate programming language code. In this invention, the code large model is responsible for processing the input question Q and generating the corresponding SQL statement

[0073] The code large model outputs an SQL statement according to the prompt p c .

[0074] Execute the SQL statement in the database to obtain a data table, and combine the data table and P k into a prompt p l , as the input to the large language model

[0075] The large language model outputs an answer according to the prompt p l, output the answer summarized in the text.

[0076] In this preferred embodiment, the present application generates a data table based on the power grid operation monitoring database and SQL query statements. This step ensures that the data source of the answer is accurate and up-to-date because the data table directly comes from the database and reflects the real-time state of the power grid operation. Then, using the data table and the question-answer pair to generate a prompt. This step enables the prompt to accurately capture the core requirements and relevant data of the question, providing a basis for generating an accurate answer. Finally, input the prompt into a preset large language model, and utilize the language understanding and generation capabilities of the large language model to output a first text answer. This answer is not only based on accurate data but also takes into account the context and semantics of the question, thus ensuring the relevance and readability of the answer.

[0077] As a preferred embodiment of Embodiment 1, determining whether each similarity is greater than a preset threshold further includes:

[0078] If each similarity is less than the preset threshold, input the question into a preset large language model so that the large language model outputs a second text answer to the question.

[0079] In this preferred embodiment, the present application can evaluate which sample questions are semantically relevant enough to the user's question by comparing the sentence vectors of the user's question with those of the sample questions in the preset classification dataset and comparing with the preset threshold. When it is found that the similarities of all sample questions are lower than the preset threshold, that is, no semantically close sample questions are found, the present application will input the user's question into a preset large language model and utilize the extensive knowledge and language understanding ability of the large language model to generate a second text answer. If there are not enough similar question-answer pairs in the dataset, directly relying on the dataset may not provide a satisfactory answer, while the large language model can provide a fallback answer based on its extensive training, thus ensuring that even in the case of insufficient dataset matching, the user's question can be responded to in a timely and effective manner, enhancing the robustness of the system and the satisfaction of the user.

[0080] The process of the above intelligent question-answering application for retrieving power grid operation monitoring data information is as Figure 2 shown, and the structure of the intelligent question-answering algorithm module in the field of power grid operation monitoring is as Figure 3 shown.

[0081] By obtaining the questions to be answered and the preset classification dataset, this application ensures that the method can be customized for specific power grid operation fields. Then, a trained Bidirectional Encoder Representations from Transformers (BERT) is used to classify the questions and extract sentence vectors. This step enables the model to deeply understand the semantic content of the questions and map them to corresponding categories, laying a foundation for accurate subsequent answers. Then, through the Retrieval-Augmented Generation (RAG) technology, domain knowledge fragments related to the question category are retrieved, further enhancing the model's understanding ability for professional domain questions. The similarity between the question sentence vector and the sample question sentence vectors in the dataset is calculated to find the most matching question-answer pairs (QA Pairs). This matching process ensures that the most relevant previous Q&A instances can be found for the user's questions, thereby improving the relevance and accuracy of the answers. Finally, input prompts are generated by combining the questions, neighborhood knowledge fragments, and question-answer pairs and input into the code generation module to output SQL query statements. This step realizes the conversion from natural language questions to structured queries. Ultimately, the first text answer is generated based on the power grid operation monitoring database, SQL query statements, and question-answer pairs. This answer not only quickly responds to the user's query needs but also ensures the professionalism and accuracy of the answer by integrating domain knowledge, thus improving the efficiency and user satisfaction of the intelligent Q&A system in the entire power grid operation monitoring field. To solve the problem in the prior art that intelligent answers cannot be accurately given to questions in power grid operation monitoring.

[0082] Embodiment 2

[0083] Please refer to Figure 4 , which is a Q&A device for a power grid operation monitoring system provided by an embodiment of this application.

[0084] In this embodiment, the Q&A device of the power grid operation monitoring system includes an acquisition module 10, an input / output module 20, and a generated text answer module 30.

[0085] The acquisition module 10 is used to acquire the questions to be answered and the preset classification dataset.

[0086] As a preferred embodiment of Embodiment 2, the preset classification dataset is specifically:

[0087] A question classification dataset for the power grid operation monitoring field is constructed. Each sample in the dataset is a question-answer pair (QA Pairs), and the label is the classification category of the QA Pairs, where the answer includes the SQL statement corresponding to the question and the text answer.

[0088] The input / output module 20 is used to input the question into the trained Bidirectional Encoder Representations from Transformers so that the Bidirectional Encoder Representations from Transformers outputs the category and sentence vector of the question.

[0089] As a preferred embodiment of the second embodiment, inputting the problem into the trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category of the problem and the sentence vector specifically includes:

[0090] Train the semantic understanding and classification module based on the problem classification dataset D and the bidirectional encoder representation method (BERT, Bidirectional Encoder Representations from Transformers) architecture to achieve accurate classification of the user input problem. The core architecture adopted by BERT is the bidirectional Transformer Encoder, which is stacked by multiple identical layers. Each layer contains two main modules: the multi-head self-attention mechanism and the feed-forward neural network. The self-attention mechanism dynamically assigns different attention weights to each word by calculating the correlation between words. This enables the model to flexibly capture long-distance dependencies without being restricted by the sequence length. The output of each attention layer passes through a feed-forward neural network, usually composed of two fully connected layers, with the ReLU activation function used in the middle. This network independently processes the representations of each position. The core advantage of the bidirectional Transformer Encoder is that it can consider the left and right context information of words simultaneously. Different from unidirectional models (such as GPT), when processing each word, the bidirectional model can utilize the information of the entire sequence, thereby more comprehensively understanding the semantics. In the training stage, the input of BERT is the problem text of the samples in the dataset D, such as "How about the line loss rate of each local city bureau?", and the text is transformed into word vectors through the vector layer of BERT. Through the bidirectional Transformer Encoder architecture in BERT, the sentence vector CLS of this sentence is output. q , input CLS q into the fully connected layer, and finally obtain the predicted label vector y through softmax. p , finally calculate the cross-entropy loss L between y p and the true classification label y t , and train the parameters of BERT. The mathematical formulas involved in the process are described as follows:

[0091] CLS q = BERT(Q);

[0092] y p = softmax(fully_conneted(CLS q ));

[0093] L = CrossEntropy(y p , y t );

[0094] In the inference stage, the question asked by the user is Q, and after being output by BERT, the sentence vector CLS is obtained q :

[0095] CLS q = BERT(Q);

[0096] In this preferred embodiment, the present application trains by inputting a preset classification data set into the initial bidirectional encoder representation model to obtain an optimized bidirectional encoder representation model (BERT). This model can understand the complexity and professionalism of problems in the field of power grid operation. Subsequently, the question proposed by the user is input into this trained model. Using its bidirectional Transformer Encoder architecture, the model can deeply understand the context and semantics of the question, output the sentence vector of the question, and determine the category of the question through a classifier. The inference process of this process is as follows: Through the optimization of the model in the training stage, it is ensured that the model can accurately capture the core intention of the question and relevant domain knowledge in actual applications. Thus, in the inference stage, the model can quickly and accurately classify and vectorize the question, providing an accurate basis for subsequent domain knowledge retrieval and question answering. This not only improves the efficiency of question processing, but also enhances the relevance and accuracy of the answer, ultimately improving the effectiveness of the entire intelligent question and answer system and user satisfaction.

[0097] The generated text answer module 30 is used to obtain input prompt words according to the question, the neighborhood knowledge fragments of the category, and the question-answer pair of the question; wherein, the neighborhood knowledge fragments of the category are obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set.

[0098] As a preferred embodiment of Embodiment 2, obtaining the input prompt words according to the question, the neighborhood knowledge fragments of the category, and the question-answer pair of the question; wherein, the neighborhood knowledge fragments of the category are obtained by retrieving the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set, specifically:

[0099] According to the question Q, use the RAG retrieval-augmented generation algorithm to obtain the knowledge fragment K related to Q.

[0100] Traverse the data set D and calculate the sentence vector CLS of each sample question k and CLS q for the similarity sk , where CLS k obtained by inputting the corresponding sample question Q k to the trained BERT until completion.

[0101] Determine whether there is an s k greater than a pre-set threshold s t If there is, find the largest s k corresponding QAPairs P k , P k represents the question-answer pair in the dataset D that is semantically closest to the target question Q; if not, the question Q is irrelevant to the business, and Q is embedded into a general prompt template to form a prompt p l .

[0102] In this preferred embodiment, the present application can quantify the semantic proximity between each sample question and the user's question by calculating the similarity between the sentence vectors of the user's question and the sentence vectors of each sample question in the classification dataset; then, by setting a preset threshold, the present application can screen out the sample questions that are semantically similar enough to the user's question, and this threshold serves as a decision criterion to help distinguish which sample questions are relevant and useful; finally, from these sample questions with similarities greater than the threshold, the one with the highest similarity is selected as the question-answer pair, ensuring that the selected answer pair is the most semantically matched with the user's question. The present application can quickly and accurately find the most relevant information from a large amount of data, thereby improving the pertinence and accuracy of the answer, and ultimately enhancing the response quality and user satisfaction of the entire question-answering system.

[0103] The generated text answer module 30 is further configured to obtain a first text answer to the question according to the power grid operation monitoring database, the input prompt word, and the question-answer pair.

[0104] As a preferred embodiment of the second embodiment, the obtaining of the first text answer to the question according to the power grid operation monitoring database, the input prompt word, and the question-answer pair is specifically as follows:

[0105] Combine the question Q, the knowledge fragment K, and the question-answer pair P of the similar question k to form a prompt p c , as the input to the code large model. The code large model is a large and complex model that uses deep learning technology to process, understand, and generate code. The model can understand and generate natural language, and can also understand and generate programming language code. In this invention, the code large model is responsible for processing the input question Q and generating the corresponding SQL statement.

[0106] The code large model outputs an SQL statement according to the prompt p c .

[0107] Execute SQL statements in the database to obtain a data table, and combine the data table with P k to form a prompt p l , which is used as the input to the large language model.

[0108] Based on the prompt p l , the large language model outputs an answer for text summarization.

[0109] In this preferred embodiment, the present application generates a data table according to the power grid operation monitoring database and SQL query statements. This step ensures that the data source of the answer is accurate and up-to-date because the data table directly comes from the database and reflects the real-time state of the power grid operation. Then, a prompt is generated using the data table and the question-answer pair. This step enables the prompt to accurately capture the core requirements and relevant data of the question, providing a basis for generating an accurate answer. Finally, the prompt is input into a preset large language model, and using the language understanding and generation capabilities of the large model, a first text answer is output. This answer is not only based on accurate data but also takes into account the context and semantics of the question, thus ensuring the relevance and readability of the answer.

[0110] As a preferred embodiment of the second embodiment, the step of determining whether each similarity is greater than a preset threshold further includes:

[0111] If each similarity is less than the preset threshold, input the question into a preset large language model so that the large language model outputs a second text answer to the question.

[0112] In this preferred embodiment, by comparing the sentence vectors of the user's question with the sentence vectors of the sample questions in the preset classification dataset and comparing with the preset threshold, the present application can evaluate which sample questions are semantically relevant enough to the user's question. When it is found that the similarities of all sample questions are lower than the preset threshold, that is, no semantically close sample questions are found, the present application will input the user's question into a preset large language model and use the extensive knowledge and language understanding ability of the large model to generate a second text answer. If there are not enough similar question-answer pairs in the dataset, directly relying on the dataset may not provide a satisfactory answer, while the large language model can provide a fallback answer based on its extensive training, thus ensuring that even in the case of insufficient dataset matching, the user's question can be responded to in a timely and effective manner, enhancing the robustness of the system and the satisfaction of the user.

[0113] The process of the above intelligent question-answering application for power grid operation monitoring data information retrieval is as Figure 2 shown, and the structure of the intelligent question-answering algorithm module in the field of power grid operation monitoring is as Figure 3 shown.

[0114] This device uses three modules to divide labor and work in coordination, and can accurately provide text responses to the questions raised by users. This application ensures that the method can be customized for specific power grid operation fields by obtaining the questions to be answered and the preset classification data set. Then, a trained Bidirectional Encoder Representations from Transformers (BERT) is used to classify the questions and extract sentence vectors. This step enables the model to deeply understand the semantic content of the questions and map them to the corresponding categories, laying a foundation for subsequent accurate answers. Then, through the Retrieval-Augmented Generation (RAG) technology, domain knowledge fragments related to the question category are retrieved, further enhancing the model's understanding ability of questions in the professional field. Calculate the similarity between the question sentence vector and the sample question sentence vectors in the data set to find the most matching question-answer pairs (QA Pairs). This matching process ensures that the most relevant previous Q&A instances can be found for the user's questions, thereby improving the relevance and accuracy of the answers. Finally, combine the question, the neighborhood knowledge fragments, and the question-answer pairs to generate input prompt words, and input them into the code generation module to output SQL query statements. This step realizes the conversion from natural language questions to structured queries. Ultimately, generate the first text answer based on the power grid operation monitoring database, the SQL query statement, and the question-answer pairs. This answer not only quickly responds to the user's query needs, but also ensures the professionalism and accuracy of the answer by integrating domain knowledge, thereby improving the efficiency and user satisfaction of the intelligent Q&A system in the entire power grid operation monitoring field. To solve the problem in the prior art that intelligent answers cannot be accurately provided to questions in power grid operation monitoring.

[0115] Embodiment 3:

[0116] An embodiment of this application provides a computer-readable storage medium, which includes a stored computer program. When the computer program runs, it controls the device where the computer-readable storage medium is located to execute the Q&A method of a power grid operation monitoring system as described above;

[0117] Among them, for the Q&A method of the power grid operation monitoring system, when it is implemented in the form of a software functional unit and used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-mentioned embodiment methods of the present invention, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc.

[0118] Embodiment 4

[0119] This application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the Q&A method of any one of the power grid operation monitoring systems described in Embodiment 1.

[0120] The specific embodiments described above further elaborate on the purpose, technical solutions, and beneficial effects of the present invention. It should be understood that the above descriptions are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. In particular, it is pointed out that for those skilled in the art, any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A question-answering method for a power grid operation monitoring system, characterized in that: include: Get the questions to be answered and the preset classification data set; Input the question into a trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question; According to the question, the neighborhood knowledge fragment of the category and the question-answer pair of the question, an input prompt word is obtained; wherein the neighborhood knowledge fragment of the category is obtained by searching the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set; A first text answer to the question is obtained according to the power grid operation monitoring database, the input prompt word and the question-answer pair.

2. The question-answering method of the power grid operation monitoring system according to claim 1, characterized in that: The question is input into a trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question, specifically: Obtain a preset classification data set, and input the classification data set into an initial bidirectional encoder representation model for training to obtain a bidirectional encoder representation model; The question is input into the bidirectional encoder representation model so that the bidirectional encoder representation model outputs a sentence vector of the question according to a bidirectional Transformer Encoder architecture, and outputs a category of the question according to a classifier.

3. The question-answering method of the power grid operation monitoring system according to claim 1, characterized in that: The question-answer pair is obtained based on the similarity between the sentence vector and each sentence vector of each sample question in the classification data set, specifically: According to the preset classification data set, calculating each similarity between the sentence vector and each sentence vector of each sample question in the classification data set; Determine whether each similarity is greater than a preset threshold; If so, the question-answer pair with the greatest similarity is obtained according to the above-mentioned similarities.

4. The question-answering method of the power grid operation monitoring system according to claim 3, characterized in that: The determining whether each similarity is greater than a preset threshold value further includes: If each of the similarities is less than a preset threshold, the question is input into a preset language model so that the language model outputs a second text answer to the question.

5. The question-answering method of a power grid operation monitoring system according to any one of claims 1 to 4, characterized in that: The first text answer to the question is obtained according to the power grid operation monitoring database, the input prompt word and the question answer pair, specifically: Inputting the input prompt word into a preset code generation module so that the code generation module outputs an SQL query statement; A first text answer to the question is obtained according to the power grid operation monitoring database, the SQL query statement and the question-answer pair.

6. The question-answering method of the power grid operation monitoring system according to claim 5, characterized in that: The first text answer to the question is obtained according to the power grid operation monitoring database, the SQL query statement and the question-answer pair, specifically: Generate a data table according to the power grid operation monitoring database and the SQL query statement; Obtaining a prompt word for the question according to the data table and the question answer pair of the question; The prompt word is input into a preset language model so that the language model outputs a first text answer to the question.

7. A question-answering device for a power grid operation monitoring system, characterized in that: It includes an acquisition module, an input and output module, and a text answer generation module; The acquisition module is used to obtain questions to be answered and preset classification data sets; The input-output module is used to input the question into the trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question; The text answer generation module is used to obtain an input prompt word according to the question, the neighborhood knowledge fragment of the category and the question-answer pair of the question; wherein the neighborhood knowledge fragment of the category is obtained by searching the category; the question-answer pair is obtained according to the similarity between the sentence vector and each sentence vector of each sample question in the classification data set; A first text answer to the question is obtained according to the power grid operation monitoring database, the input prompt word and the question-answer pair.

8. The question-answering device of the power grid operation monitoring system according to claim 7, characterized in that: The question is input into a trained bidirectional encoder representation model so that the bidirectional encoder representation model outputs the category and sentence vector of the question, specifically: Obtain a preset classification data set, and input the classification data set into an initial bidirectional encoder representation model for training to obtain a bidirectional encoder representation model; The question is input into the bidirectional encoder representation model so that the bidirectional encoder representation model outputs a sentence vector of the question according to a bidirectional Transformer Encoder architecture, and outputs a category of the question according to a classifier.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the question-answering method of the power grid operation monitoring system according to any one of claims 1 to 6.

10. A terminal device, characterized in that: It comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the question-answering method of the power grid operation monitoring system according to any one of claims 1 to 6.