Power grid knowledge intelligent question-answering system construction method based on PLChatGLM2
By building a PLChatGLM2-based intelligent question and answer system for grid knowledge, the problems of insufficient professionalism, lag in knowledge updates and low response efficiency in grid knowledge query are solved, efficient and accurate information interaction and response are achieved, and the stable and safe operation of the power grid is ensured.
Patent Information
- Application Number
- CN202311713347.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2025-04-11
AI Technical Summary
When handling power grid knowledge inquiries, traditional question-and-answer systems face problems such as insufficient professional depth, lagging knowledge updates, inaccurate contextual correlations, inaccurate language processing and low response efficiency, which is difficult to meet the complex and changeable query needs of modern power grid systems.
The PLChatGLM2-based intelligent question-answer system construction method is adopted. By obtaining grid domain knowledge from authoritative sources, building a knowledge database and question-answer instruction dataset, combining Langchain and Chatglm2 models, using P-Tuning-v2 fine-tuning algorithm and similar questions and similar context enhancement technology, the question-answer model is optimized to improve accuracy and response rate.
It has achieved more accurate and professional information replies in the field of power grid knowledge, improved the response rate and accuracy of the question-and-answer system, met the real-time query needs of power grid operations and management personnel, and ensured the stable and safe operation of the power grid.
Smart Images

Figure CN119807334A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of power grid knowledge and a method for constructing an intelligent question-answering system, and in particular to a method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2. Background Art
[0002] With the advancement of technology and the expansion of power grid systems, the management and technical content of the power grid field is becoming increasingly complex. In order to ensure the safe and stable operation of the power grid, power grid operators and engineers have to continuously master the latest industry knowledge and technical trends. This increase in complexity also brings huge challenges to the demand for knowledge acquisition. In addition, due to the professionalism and real-time nature of power grid knowledge itself, traditional question-answering systems often face problems such as insufficient professional depth, delayed knowledge updates, inability to accurately capture contextual associations, inaccurate language processing, and low response efficiency when processing related queries. These problems not only affect the work efficiency of professionals, but may also threaten the safe and stable operation of the power grid.
[0003] What is more challenging is that modern power grid systems include not only traditional power equipment and technologies, but also a large number of digital and communication technologies. This makes power grid knowledge more cross-domain and requires the integration of knowledge from multiple disciplines and professional fields. Traditional question-answering systems are usually optimized for specific fields or topics and are difficult to meet such broad and varied query needs.
[0004] Therefore, designing and implementing an intelligent question-and-answer system specifically for power grid knowledge, which can respond to professional inquiries quickly and accurately, can not only improve the work efficiency of industry personnel, but also ensure the stability and safety of the power grid. The PLChatGLM2 algorithm proposed in the present invention came into being in this context. It comprehensively utilizes the latest artificial intelligence technology and combines professional knowledge in the field of power grids to provide users with a new and efficient way of acquiring knowledge. The proposed method realizes intelligent information interaction combined with knowledge in the field of power grids, and can provide more accurate and professional information replies based on user needs and consultations. It can solve the relevant shortcomings of traditional question-and-answer systems and improve the accuracy and response rate of Chatglm2 in the field of power grid knowledge question-and-answer. Summary of the invention
[0005] The purpose of the present invention is to fill the deficiency of intelligent information interaction platform in the field of power grid, and propose a method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2.
[0006] The purpose of the present invention can be achieved by the following technical solution: comprising the following steps:
[0007] S1: Obtain relevant documents in the power grid vertical field from various authoritative sources, power grid management organizations, technical forums and other channels, including but not limited to technical white papers, operation manuals, research reports and real-time data analysis, and build a knowledge database Data1 in the power grid field;
[0008] S2: Based on the text information of the power grid domain knowledge base in step S1, a question-and-answer instruction dataset Data2 based on power grid domain knowledge is constructed in a question-and-answer format;
[0009] S3: Based on the power grid vertical field database Data1 in step S1, the original power grid knowledge question-answering model Model1 based on Langchain-Chatglm2 is constructed in combination with the Langchain framework;
[0010] S4: Based on the power grid knowledge instruction data set Data2 in step S2, the power grid knowledge question answering model Model2 is constructed using the P-Tuning-v2 fine-tuning algorithm, and the relevant weight file Text1 of the model is obtained;
[0011] S5: Replace the corresponding weight file Text2 of the question-answering model Model1 in step S3 with the weight file Text1 obtained by fine-tuning the model Model2 in step S4, and construct a fine-tuning question-answering model Model3 dedicated to the power grid field;
[0012] S6: Based on the question-answering model Model3 in step S5, the model Model3 is optimized by similar question and similar context enhancement to obtain an optimized power grid knowledge base question-answering model Model4;
[0013] S7: Construct an evaluation file based on the power grid vertical domain knowledge base to test the accuracy and efficiency of the question-answering model Model 4 in step S6.
[0014] Preferably, the construction of the power grid domain knowledge database Data1 is specifically as follows:
[0015] S11: Load various power grid related files, obtain text information and perform text segmentation;
[0016] S12: Use NLP feature extraction technology to vectorize the segmented text in step S11, and save it persistently to the database to obtain the power grid domain knowledge database Data1.
[0017] Preferably, an original power grid knowledge question-answering model Model1 based on Langchain-Chatglm2 is constructed, specifically including:
[0018] S31: vectorizing the electricity customer question using the text vectorization algorithm in step S12 based on Langchain;
[0019] S32: Match the information block context related to the question from the database Data1 in step S1 through vector search;
[0020] S33: Combine the initial question question and related information context, build the original power grid knowledge question-answering model Model1 based on Chatglm2, and provide an answer answer or take action.
[0021] Preferably, step S4 comprises:
[0022] S41: Combined with the instruction data set Data2 prepared in step S2, the P-Tuning-v2 fine-tuning algorithm is used to fine-tune the parameters of Chatglm2 in step S3 to reduce the number of parameters and obtain the lightweight model Model2;
[0023] S42: Save the weight parameters of the specific features and patterns of the power grid knowledge domain captured in the model Model2 fine-tuned in step S41 as a file Text1.
[0024] Preferably, step S6 comprises:
[0025] S61: Based on the electricity customer question in step S31, construct a similar question dataset Data3 to enhance Model3 with similar questions;
[0026] S62: Based on the similar context interference in the database vector search in step S32, perform similar context enhancement optimization Model 3 on the training data to obtain the optimized power grid knowledge base question-answering model Model 4.
[0027] Preferably, step S7 includes:
[0028] S71: Combine the local knowledge base dataset Data1 and the training instruction dataset Data2 to construct a test sample dataset Data3 that meets the power grid knowledge question and answer requirements;
[0029] S72: Select the same test samples from the data set Data3 in step S71 and perform test results on the original question-answering model Model1, the fine-tuned question-answering model Model3, and the optimized power grid knowledge base question-answering model Model4 to compare and obtain the superiority of the proposed method in knowledge question-answering in the power grid field.
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] 1. The present invention uses the P-Tuning-v2 algorithm for fine-tuning, making the system highly adaptive. With more grid data and user interaction, the system's answers will become more accurate.
[0032] 2. Based on the structure of Langchain and Chatglm2 models, the system can parse and respond to inquiries from electricity users in real time, greatly improving the interactive experience of power grid users.
[0033] 3. The present invention optimizes the model based on advanced question-answering system technology, ensuring the lightweight and efficient operation of the model, meeting the needs of real-time query, and improving the decision-making efficiency of power grid operators and managers.
[0034] 4. The present invention constructs a question-answering system based on a large language model, which not only fills the gap in the traditional question-answering system in the field of power grid knowledge, but also provides a new, efficient and accurate intelligent tool, which is helpful for research, management and decision-making in the field of power grid. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to facilitate understanding by those skilled in the art, the present invention is further described below with reference to the accompanying drawings.
[0036] Figure 1 Original Langchain-Chatglm2 power grid question-answering model process framework diagram
[0037] Figure 2 Flowchart of the proposed optimized and fine-tuned PLChatGLM2 model. DETAILED DESCRIPTION
[0038] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than 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.
[0039] See also Figure 1-Figure 2 As shown, a method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2 includes the following steps:
[0040] S1: Obtain relevant documents in the power grid vertical field from various authoritative sources, power grid management organizations, technical forums and other channels, including but not limited to technical white papers, operation manuals, research reports and real-time data analysis, and build a knowledge database Data1 in the power grid field.
[0041] S11: Load various power grid related files, obtain text information and perform text segmentation.
[0042] The text segmentation involved is based on a custom segmentation method and is segmented by the smallest content unit. For example, an article is first parsed into a structured form of title and paragraph. If the paragraph length exceeds 512, it is segmented into segments not exceeding 512-len. Each segmented data is stored in one line, and a new "by line" feature extraction and storage method is added to the framework.
[0043] S12: Use NLP feature extraction technology to vectorize the segmented text in step S11, and save it persistently to the database to obtain the power grid domain knowledge database Data1.
[0044] The vectorization involved includes using the text2vec-large-chinese model to convert the segmented text into numerical vectors and store them persistently in the vector database Vector Stores. The knowledge base involved contains more than 100 supplementary knowledge files and supports uploading file types such as word, txt, and pdf.
[0045] S2: Based on the text information of the power grid domain knowledge base in step S1, a question-and-answer instruction dataset Data2 based on power grid domain knowledge is constructed in a question-and-answer format.
[0046] The instruction set construction involved includes: formulating a series of question-and-answer pairs containing information such as "power consumption" and "electricity price", for example: Question: "Users with power consumption (operating capacity) between 100-315kVA can choose to implement a two-part or single-part electricity price, including 100 kVA and 315 kVA?" Answer: "Not including 108 kVA and 315 kVA." Data2 contains about 1,000 power grid knowledge question-and-answer pairs.
[0047] S3: Based on the power grid vertical field database Data1 in step S1, combined with the Langchain framework, build the original power grid knowledge question and answer model Model1 based on Langchain-Chatglm2.
[0048] S31: Based on Langchain, the text vectorization algorithm in step S12 is used to vectorize the electricity customer question.
[0049] S32: Match the information block context related to the question from the database Data1 in step S1 through vector search.
[0050] S33: Combine the initial question question and related information context, build the original power grid knowledge question-answering model Model1 based on Chatglm2, and provide an answer answer or take action.
[0051] S4: Based on the power grid knowledge instruction data set Data2 in step S2, use the P-Tuning-v2 fine-tuning algorithm to build a power grid knowledge question-answering model Model2, and obtain the model-related weight file Text1.
[0052] S41: Combined with the instruction data set Data2 prepared in step S2, the P-Tuning-v2 fine-tuning algorithm is used to fine-tune the parameters of Chatglm2 in step S3 to reduce the number of parameters and obtain the lightweight model Model2.
[0053] S42: Save the weight parameters of the model Model2 fine-tuned in step S41 that capture the specific features and patterns in the power grid knowledge domain as a file Text1. For example, the size of the hidden layer "hidden_size": 4096; the sequence length "seq_length": 32768.
[0054] S5: Replace the corresponding weight file Text2 of the question-answering model Model1 in step S3 with the weight file Text1 obtained by fine-tuning the model Model2 in step S4, and construct a fine-tuning question-answering model Model3 dedicated to the power grid field.
[0055] S6: Based on the question-answering model Model3 in step S5, the model Model3 is optimized by similar question and similar context enhancement to obtain the optimized power grid knowledge base question-answering model Model4.
[0056] S61: Based on the electricity customer question in step S31, a similar question dataset Data3 is constructed to enhance Model3 with similar questions.
[0057] This involves generating 3-4 similar questions of the same question through a question-answering model, and constructing a QAC (Q: question; A: answer; C: context) dataset of similar questions to add to the training.
[0058] S62: Based on the similar context interference in the database vector search in step S32, perform similar context enhancement optimization Model 3 on the training data to obtain the optimized power grid knowledge base question-answering model Model 4.
[0059] It involves querying the database Data1 to search for the topk entries that are not related to the question, and querying the database Data1 to search for the topk entries that are not related to the context, and randomly splicing the two new entries and the text information context together as a new context.
[0060] S7: Construct an evaluation file based on the power grid vertical domain knowledge base to test the accuracy and efficiency of the question-answering model Model 4 in step S6.
[0061] S71: Combine the local knowledge base dataset Data1 and the training instruction dataset Data2 to construct a test sample dataset Data3 that meets the requirements of power grid knowledge question and answer.
[0062] S72: Select the same test samples from the data set Data3 in step S71 and perform test results on the original question-answering model Model1, the fine-tuned question-answering model Model3, and the optimized power grid knowledge base question-answering model Model4 to compare and obtain the superiority of the proposed method in knowledge question-answering in the power grid field.
[0063] It involves running the evaluation file after the training is completed. The evaluation index is Chinese Rougescore. Several inference data are prepared. There will be several prediction data in the corresponding file. Compare the prediction output and the generated result to evaluate the quality of model training. The response rate and accuracy comparison results of the same question in the professional field are original question-answering model Model < fine-tuned question-answering model Model3 < optimized question-answering model Model4, that is, the proposed method can achieve model optimization, so that the power grid knowledge question-answering model has a faster response speed and higher accuracy.
[0064] The power grid knowledge question-and-answer system constructed by the present invention can solve the problems in the traditional question-and-answer system that the answers to questions in the power grid knowledge field cannot be accurately matched, the unprofessional description of the reply information causes ambiguity, and the response rate is not fast enough. The proposed method constructs a knowledge base in the professional field related to the power grid, and combines the artificial intelligence algorithm to construct an intelligent question-and-answer system for power grid knowledge, which makes up for the relevant shortcomings of the traditional question-and-answer system in the power grid field, realizes intelligent information interaction combined with power grid field knowledge, and can provide more accurate and professional information replies according to user needs and consultations. At the same time, the optimized Langchain-Chatglm2 model improves the accuracy and response rate in the field of power grid knowledge question-and-answer.
[0065] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2, characterized in that: The steps include: S1: Obtain relevant documents in the vertical field of power grid and build the knowledge database Data1 in the field of power grid; relevant documents include technical white papers, operation manuals, research reports and real-time data analysis; S2: Based on the text information of the power grid domain knowledge database in step S1, a question-and-answer instruction dataset Data2 based on power grid domain knowledge is constructed in a question-and-answer format; S3: Based on the knowledge database Data1 in step S1 and the Langchain framework, the original power grid knowledge question-answering model Model 1 based on Langchain-Chatglm2 is constructed, including: S31: Based on the Langchain framework, the text vectorization algorithm is used to vectorize electricity customer problems; S32: Matching information blocks related to electricity customer problems from the knowledge database Data1 through vector search; S33: Combine the initial question and related information, build the original power grid knowledge question-answering model Model 1 based on Chatglm2, and provide answers or take actions; S4: Based on the question-answering instruction dataset Data2 in step S2, the P-Tuning-v2 fine-tuning algorithm is used to build the power grid knowledge question-answering model Model 2, and the relevant weight file Text1 of the model is obtained, which specifically includes: S41: Combined with the question-answer instruction dataset Data2 prepared in step S2, the parameters of Chatglm2 in step S3 are fine-tuned using the P-Tuning-v2 fine-tuning algorithm to reduce the number of parameters and obtain a lightweight model Model 2; S42: capturing the weight parameters of the specific features and patterns of the power grid knowledge domain from the lightweight model Model 2 fine-tuned in step S41 and saving them as a weight file Text1; S5: Replace the corresponding weight file Text2 of the original power grid knowledge question answering model Model 1 in step S3 with the weight file Text1 obtained by the lightweight model Model 2 in step S4, and construct a fine-tuned question answering model Model 3 dedicated to the power grid field; S6: Based on the fine-tuned question-answering model Model 3 in step S5, the model Model 3 is optimized by similar question and similar context enhancement to obtain the optimized power grid knowledge base question-answering model Model 4; S7: Construct an evaluation file based on the power grid vertical domain knowledge base to test the accuracy and efficiency of the question-answering model Model 4 in step S6, including: S71: Combine the local knowledge base dataset Data1 and the training instruction dataset Data2 to construct a test sample dataset Data3 that meets the power grid knowledge question and answer requirements; S72: Select the same test samples from the test sample data set Data3 in step S71 and test the results of the original question-answering model Model 1, the fine-tuned question-answering model Model 3, and the optimized power grid knowledge base question-answering model Model 4 to compare and obtain the superiority of the proposed method in knowledge question-answering in the power grid field.
2. A method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2 according to claim 1, characterized in that: The specific process of building the knowledge database Data1 is as follows: S11: Load various power grid related files, obtain text information and perform text segmentation; S12: Use NLP feature extraction technology to vectorize the segmented text in step S11 and save it persistently to the database to obtain the knowledge database Data1 in the power grid field.
3. A method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2 according to claim 2, characterized in that: In step S12, the segmented text is converted into a numerical vector using the text2vec-large-chinese model and stored in a vector database Vector Stores.
4. A method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2 according to claim 1, characterized in that: Step S6 includes: S61: Based on the electricity customer question in step S31, construct a similar question dataset Data3 to enhance Model 3 with similar questions; S62: Based on the similar context interference in the database vector search in step S32, perform similar context enhancement optimization Model 3 on the training data to obtain the optimized power grid knowledge base question-answering model Model 4.
5. The method for constructing a power grid knowledge intelligent question-answering system based on PLChatGLM2 according to claim 1, characterized in that: In step S7, the evaluation file tests the three question-answering models to obtain the output effects of the question-answering models before and after fine-tuning and optimization.
6. An intelligent question-answering system based on the vertical field of power grid, characterized in that: A method for constructing an intelligent question-answering system for power grid knowledge based on the PLChatGLM2 algorithm is implemented based on any one of claims 1-4.
Citation Information
Patent Citations
Intelligent questioning-answering system construction method and system based on deep learning and knowledge atlas
CN108182262A
Flight delay prediction method and system based on online increment MHHA-SRU
CN116362430A
LLMs cue word optimization-based power grid dispatching intelligent question-answering system and method
CN116860925A
Question and answer model training method and intelligent question and answer method and device in network security field
CN116933075A
Knowledge graph generation type question answering method and system based on large language model
CN117033608A