Knowledge question-answering system based on large language model
Through a knowledge question and answer system based on a large language model, a power operation and maintenance knowledge base is built, which solves the problems of complex power operation and maintenance scenarios and difficult knowledge acquisition, and realizes efficient fault diagnosis and processing.
Patent Information
- Application Number
- CN202411521430.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The power operation and maintenance scenarios are complex and there are many types of data. It is difficult for existing technology to efficiently obtain and utilize power operation and maintenance knowledge, which affects the fault handling efficiency.
Using a knowledge question-and-answer system based on a large language model, a comprehensive power operation and maintenance knowledge base module, a problem understanding module, a search and reorder module and an answer generation module are built to build a comprehensive power operation and maintenance knowledge base to realize semantic understanding and accurate retrieval of user problems .
It realizes rapid positioning of relevant information, supports natural language question-and-answer, multiple rounds of dialogue, intention recognition and other functions, reduces the knowledge acquisition cost of operation and maintenance personnel, and improves fault diagnosis and processing efficiency.
Smart Images

Figure CN119396975A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of artificial intelligence and question answering system, and in particular relates to a knowledge question answering system based on a large language model. Background Art
[0002] The rapid development of smart grids has put forward higher requirements for the safe and stable operation of power systems, and power operation and maintenance work faces many challenges. The amount of data involved in power operation and maintenance is huge and diverse, including equipment manuals, operating procedures, maintenance records, fault reports, etc. These data are scattered in various departments and systems and are difficult to integrate and utilize. The power system operation and maintenance scenarios are complex and changeable, requiring operation and maintenance personnel to have rich experience and professional knowledge to deal with various emergencies. Traditional knowledge acquisition methods require operation and maintenance personnel to consult a large amount of information and consult experts when encountering problems, which consumes a lot of time and energy, affects the efficiency of fault handling, and may even delay the best time for emergency repairs, causing greater losses.
[0003] The Q&A system can provide a variety of operation and maintenance functions for operation and maintenance personnel with different needs. Task scenario is the core function of the Q&A system, which supports operation and maintenance personnel to complete specific operation and maintenance operations through one or more rounds of dialogue, such as "system health analysis", "create fault groups", "execute XX system operations", etc.
[0004] For example, when equipment failure occurs, operation and maintenance personnel need to quickly query information such as failure phenomenon, cause analysis, and treatment methods in order to quickly locate the fault point and handle it. During daily inspection and maintenance, operation and maintenance personnel need to check equipment parameters, operating procedures, safety regulations and other information to ensure the standardization and safety of operations. Operation and maintenance personnel need to constantly learn new power operation and maintenance knowledge and skills, and the knowledge question and answer system can provide them with personalized learning materials and question-answering services.
[0005] How to efficiently acquire and utilize power operation and maintenance knowledge has become a key issue that needs to be urgently addressed in the digital and intelligent transformation of the power industry. Summary of the invention
[0006] In order to solve the deficiencies in the prior art, the present invention provides a knowledge question and answer system based on a large language model to solve the technical problems that there are many and complex power operation and inspection scenarios, the knowledge channels for distribution network operation and inspection are limited, and operation and maintenance personnel need an efficient knowledge question and answer system.
[0007] In order to solve the above technical problems, the present invention adopts the following technical solutions.
[0008] The present invention first discloses a knowledge question answering system based on a large language model, the method comprising the following steps:
[0009] The power operation and maintenance knowledge base module is used to obtain data from predefined data sources and perform preprocessing, construct a knowledge graph in the field of power operation and maintenance, and convert text content into semantic vectors, use a vector database to store the semantic vectors and the knowledge graph, and integrate them to form a power operation and maintenance knowledge base;
[0010] The question understanding module is used to perform question recognition analysis, identify the user's intention, and convert the user's question into a semantic vector;
[0011] A retrieval and re-ranking module, used to perform semantic retrieval in the power operation and maintenance knowledge base, recall knowledge information related to the semantics of the problem, and then rank the retrieval results based on semantic relevance, knowledge confidence and information importance;
[0012] The answer generation module is used to integrate the most relevant knowledge information and user questions as the input of the large language model, generate prompt information suitable for processing by the large language model, and use the large language model fine-tuned based on data in the power operation and maintenance field to generate answers in natural language form according to the prompt information.
[0013] The present invention further includes the following preferred embodiments:
[0014] The predefined data sources include internal enterprise information and external professional knowledge, wherein the internal enterprise information includes internal documents of the power enterprise, and the internal documents of the power enterprise include equipment manuals, operating procedures, maintenance records, fault case libraries, work tickets, technical standards, and accident reports; the external professional knowledge includes the State Grid professional knowledge base, power industry standardization documents and academic literature.
[0015] The electric power operation and maintenance knowledge base module is further used to convert files in various formats into processable texts, extract information from the texts using natural language processing technology, and extract key entities and their relationships.
[0016] The semantic relevance refers to the degree of matching between the question and the answer at the semantic level; the knowledge confidence refers to the reliability and credibility of the source of the answer; and the information importance refers to the importance of the answer to solving the problem.
[0017] The problem understanding module is further used to:
[0018] Perform word segmentation and part-of-speech tagging on the questions input by the user to identify the keywords in the questions. Identify the entities related to power operation and maintenance in the questions and extract the relationships between the entities. According to the results of the question analysis, identify the user's intentions, rewrite the questions input by the user according to the terminology standards in the field of power operation and maintenance, convert the colloquial expressions into professional terms, and finally convert the processed questions into semantic vectors for retrieval in the knowledge base.
[0019] The system further includes a system management module, which is further used to implement session management, prompt word management, plug-in management and log management;
[0020] The session management further includes saving the user's historical question and answer records to conduct multiple rounds of dialogue and context understanding based on the historical question and answer records;
[0021] The prompt word management further includes configuring different prompt word information according to different question-answering scenarios and user needs to guide the model to generate answers;
[0022] The plug-in management further includes integrating external plug-ins, including fault diagnosis tools, expert systems, knowledge graphs, and enhancing system functions;
[0023] The log management further includes recording system operation logs for performance monitoring, model optimization and case analysis.
[0024] The large model is a pre-trained large model ChatGLM3. Based on the LLaMA-Factory fine-tuning basic framework, the LoRA fine-tuning scheme is used to perform instruction supervision fine-tuning on the ChatGLM3 large model; the fine-tuning process further includes:
[0025] In the process of constructing the dataset, industry data is collected, data is segmented, question-answer pairs are established based on the segmented data blocks, and then fine-tuning parameters are configured and fine-tuning is performed. After configuring the fine-tuning parameters, the fine-tuned model is evaluated; in the process of merging LoRA weights, a new model is generated, the new model is deployed, and the new model is applied in the project to perform reasoning.
[0026] The answer generation module is further used to dynamically repeat the retrieval and generation process multiple times according to the complexity of the task, so that the model can continuously refine its output.
[0027] Accordingly, the present application also discloses a terminal, including a processor and a storage medium;
[0028] The storage medium is used to store instructions;
[0029] The processor is used to operate according to the instructions to execute the aforementioned knowledge question answering system based on the large language model.
[0030] Correspondingly, the present application also discloses a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the aforementioned knowledge question-answering system based on a large language model is implemented.
[0031] The beneficial effect of the present invention is that, compared with the prior art, the present invention provides a knowledge question and answer system based on a large language model. By constructing a comprehensive power operation and maintenance knowledge base, deep learning technology is used to understand the semantics of user questions, and accurate retrieval is performed in the knowledge base to quickly locate relevant information; natural language question and answer, multi-round dialogue, intention recognition and other functions are supported to provide users with a friendly and efficient intelligent interactive experience; according to the fault information provided by the user, combined with the knowledge base and expert experience, the operation and maintenance personnel are assisted in fault cause analysis, solution recommendation, etc.; the knowledge acquisition cost of the operation and maintenance personnel is effectively reduced, the efficiency of fault diagnosis and processing is improved, and strong support is provided for building a safer, more reliable and efficient power system. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is the overall technical architecture diagram of the knowledge question answering system in the present invention.
[0033] Figure 2 It is a large model framework diagram of the fusion instruction adjustment and alignment optimization in the present invention.
[0034] Figure 3 This is the large model architecture diagram combined with intelligent retrieval RAG in the present invention.
[0035] Figure 4 It is the loss graph of fine-tuning in the present invention.
[0036] Figure 5 It is a schematic diagram of the effect of the evaluation in the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present invention more clear, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0038] The embodiments described in this application are only some embodiments of the present invention, not all embodiments. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the protection scope of the present invention.
[0039] There are many and complex power operation and maintenance scenarios, and the knowledge channels for distribution network operation and maintenance are limited. Based on the need for large language models to provide knowledge acquisition channels for operation and maintenance personnel, an intelligent operation and maintenance knowledge question and answer model system is established. The emergence of large language models (LLMs) has brought new opportunities to solve the above problems. Large models have powerful natural language understanding and generation capabilities, can process massive text data, and extract, integrate, and infer knowledge from them, providing a technical foundation for building an intelligent and efficient power operation and maintenance knowledge question and answer system.
[0040] In view of the shortcomings of the existing technology, the present invention proposes a knowledge question-answering system based on a large language model. Aiming at the demand for efficient acquisition of professional knowledge in the field of power operation and maintenance, the knowledge question-answering system is developed around the power operation and maintenance business needs reported by the marketing department, aiming to achieve the improvement from data to knowledge and from perception to cognition. A construction scheme of an intelligent knowledge question-answering system based on a large language model (LLM) is proposed, which breaks through the limitations of traditional methods in terms of knowledge coverage, reasoning ability and human-computer interaction experience. The intelligent operation and maintenance knowledge question-answering system integrates and displays the data of the entire life cycle of power equipment, and realizes efficient analysis and query involving equipment, manufacturers, quality and events.
[0041] In order to support accurate knowledge question and answer, the present invention integrates the full life cycle data of power equipment and the professional knowledge base of power operation and maintenance, and adopts efficient data processing and semantic retrieval technology to build a knowledge base of power operation and maintenance with wide coverage and high retrieval efficiency. In order to improve the model's understanding and reasoning ability of professional knowledge in the field of power operation and maintenance, a large model framework integrating instruction adjustment and alignment optimization, as well as a large model architecture combined with intelligent retrieval RAG are proposed to achieve a deep integration of the model and power operation and maintenance knowledge. Based on the above framework, the present invention adopts advanced large model fine-tuning technology to construct a professional knowledge question and answer model for the field of power operation and maintenance, which achieves accurate understanding of user questions and generation of high-quality answers, and significantly improves the efficiency and accuracy of knowledge acquisition in the field of power operation and maintenance.
[0042] The overall technical architecture of the knowledge question answering system based on the large language model is shown in the figure below. Figure 1 As shown, it is mainly composed of the following modules:
[0043] The power operation and maintenance knowledge base module is used to obtain data from predefined data sources and perform preprocessing to integrate and form a power operation and maintenance knowledge base. The enterprise knowledge base stores various documents of the enterprise, such as word documents, PDF documents, etc., as the basic data source for the system to extract knowledge and answer questions. The data source includes internal enterprise information and external professional knowledge. Internal enterprise information includes internal documents of power enterprises, such as equipment manuals, operating procedures, maintenance records, fault case libraries, work tickets, technical standards, accident reports, etc. External professional knowledge includes access to professional knowledge bases such as the State Grid, power industry standardization documents (such as national standards GB, IEC) and academic literature. In data preprocessing, format conversion is performed first. Tools such as Tika and PaddleOCR are used to convert files in various formats such as Word, PDF, pictures, scans, etc. into processable text. Then, natural language processing technology (NLP) is used to extract information from the text to extract key entities (such as equipment name, model, parameters, fault type, solution, etc.) and their relationships. The extracted information is structured to construct a knowledge graph in the field of power operation and maintenance to better express the relationship between entities and support deeper semantic understanding and reasoning. Use the pre-trained text embedding model in the field of power operation and maintenance to convert text content into semantic vectors to capture its semantic information. Use a vector database (such as the pgvector plug-in of PostgreSQL) to store semantic vectors and knowledge graphs to build a knowledge base for power operation and maintenance;
[0044] The question understanding module is used to perform question recognition analysis, identify the user's intention, and convert the user's question into a semantic vector. First, the question entered by the user is segmented and tagged with parts of speech to identify the keywords in the question. Entities related to power operation and maintenance in the question, such as equipment name, fault type, etc., are identified, and the relationship between entities, such as equipment ownership, fault causal relationship, etc., are extracted. Based on the results of the problem analysis, the user's intention is identified, such as querying information, seeking solutions, requesting operational guidance, etc. According to the terminology specifications in the field of power operation and maintenance, the questions entered by the user are rewritten, and colloquial expressions are converted into professional terms to improve the accuracy of retrieval. Finally, the processed questions are converted into semantic vectors for retrieval in the knowledge base;
[0045] The retrieval and re-ranking module is used for semantic retrieval and sorting of retrieval results. First, based on the query vector, a semantic search is performed in the power operation and maintenance knowledge base to recall knowledge information related to the semantics of the question, such as manual paragraphs, fault case descriptions, operating procedure clauses, etc. The retrieval results are sorted through the re-ranking model, and the most relevant knowledge information is screened by comprehensively considering semantic relevance, knowledge confidence and information importance. The semantic relevance refers to the degree of match between the question and the answer at the semantic level. The knowledge confidence refers to the reliability and credibility of the source of the answer. The information importance refers to the importance of the answer to solving the problem;
[0046] The semantic relevance uses cosine similarity to measure the degree of match between the question and the answer at the semantic level. Assuming q represents the semantic vector of the question and a represents the semantic vector of the answer, the semantic relevance is expressed as:
[0047] SemanticRelevance(q,a)=cos(q,a)=(q·a) / (||q||||a||)
[0048] Among them, · represents the vector dot product; ||q|| represents the modulus of the question vector q; ||a|| represents the modulus of the answer vector a.
[0049] The knowledge confidence is evaluated based on the source of the answer. If the answer comes from an expert knowledge base, the expert's score for the answer can be used as the knowledge confidence. Different weights can be set for different data sources. For example, a higher weight can be set for data sources from authoritative institutions such as the State Grid. If multiple data sources provide the same answer, the confidence of the answer can be improved.
[0050] Assuming s represents the source of the answer, w(s) represents the weight of source s, and v(a,s) represents the score or support of answer a in source s, the knowledge confidence can be expressed as:
[0051] KnowledgeConfidence(a,s)=w(s)*v(a,s)
[0052] The information importance is evaluated based on the contribution of the answer to solving the problem. If the answer contains more keywords in the question, it can be considered to be more important. The answer containing more useful information has higher importance. The importance of the answer is evaluated based on the user's evaluation of the answer (such as likes, favorites, etc.).
[0053] Assuming f(a,q) represents the keyword coverage of answer a for question q, g(a) represents the amount of information in answer a, and h(a) represents the user's evaluation of answer a, the information importance is expressed as:
[0054] InformationImportance(a,q)=α*f(a,q)+β*g(a)+γ*h(a)
[0055] Among them, α, β, and γ are weight coefficients, which can be adjusted according to actual conditions.
[0056] Finally, semantic relevance, knowledge confidence, and information importance are integrated into a final score that is used to rank the retrieved answers:
[0057] FinalScore(q,a,s)=w1*SemanticRelevance(q,a)+w2*
[0058] KnowledgeConfidence(a,s)+w3*InformationImportance(a,q)
[0059] Among them, w1, w2, and w3 are weight coefficients, which can be adjusted according to actual conditions to control the influence of different factors on the final score.
[0060] The answer generation module is used to generate prompt information for processing by the large language model. The most relevant knowledge information and user questions are integrated as the input of the large model to generate prompt information (Prompt) suitable for processing by the large language model. For example, the question and related knowledge fragments are provided to the large model as context information, and clear instructions are given to guide the large model to generate answers in a specific format. The large language model ChatGLM3, which is fine-tuned based on data from the power operation and maintenance field, is used to generate answers in natural language form based on the prompt information. For complex questions, the large model is used to perform multi-step reasoning based on the knowledge base to generate more comprehensive and accurate answers. Based on the prompt information and reasoning results, a natural language answer that conforms to grammatical rules, has clear logic, and is fluent in expression is generated;
[0061] The system management module is further used to implement session management, prompt word management, plug-in management, and log management. For session management, the user's historical question and answer records are saved to conduct multiple rounds of dialogue and context understanding based on the historical question and answer records. For example, the device, fault and other information that the user has previously asked about are recorded to facilitate subsequent questions and answers. For prompt word management, different prompt word information is configured for different question and answer scenarios and user needs to guide the model to generate more accurate answers. For plug-in management, it supports the integration of external plug-ins, such as fault diagnosis tools, expert systems, knowledge graphs, etc., to enhance system functions. For log management, the system operation log is recorded for performance monitoring, model optimization, and case analysis.
[0062] Among them, in response to the specific needs of power operation and maintenance knowledge question and answer, a pre-trained large model ChatGLM3 with strong language comprehension and knowledge reasoning capabilities was selected. ChatGLM3 is a pre-trained large language model based on Chinese. It performs well in Chinese semantic understanding and text generation. It is easy to fine-tune and deploy, which reduces project development costs. It has certain knowledge reasoning capabilities and can serve as the basis for building a knowledge question and answer system. Figure 3 , adopts mainstream large model fine-tuning technology and RAG technology, and builds a power operation and maintenance knowledge question and answer system based on a large language model.
[0063] Using the professional knowledge base and corpus in the field of power operation and maintenance, the pre-trained large model is fine-tuned to enable it to better understand the concepts, terms, rules and logic related to power operation and maintenance, and generate more accurate and professional answers. Figure 4 In order to enable ChatGLM3 to better understand the professional knowledge in the field of power operation and maintenance, the fine-tuning techniques adopted by the present invention include:
[0064] Prompt Engineering: Design effective prompts to guide ChatGLM3 to generate answers that are consistent with power operation and maintenance scenarios. For example, when asking about the cause of a fault, you can use the following prompts: "Please analyze the possible causes of [fault phenomenon]?";
[0065] Fine-tuning: Using the professional corpus in the field of power operation and maintenance, ChatGLM3 is parameter-adjusted to achieve better results in the power operation and maintenance knowledge question-answering task. Specifically, ChatGLM3 is fine-tuned using the collected power operation and maintenance question-answer pairs to enable it to better understand the concepts, terms, rules, and logic related to power operation and maintenance.
[0066] In order to further improve the accuracy and completeness of the answers, this paper introduces RAG technology, combines the power operation and maintenance knowledge base with ChatGLM3, and constructs a knowledge question-answering system based on retrieval-augmented generation. RAG (Retrieval-Augmented Generation) is a technology that combines information retrieval and text generation to generate more accurate and context-related answers. The specific steps are:
[0067] Collect and organize professional knowledge related to power operation and maintenance, including equipment information, operating procedures, fault diagnosis, safety regulations, etc. Build this knowledge into a structured knowledge graph, and index unstructured text to build a power operation and maintenance knowledge base;
[0068] Use keyword- and semantic-based retrieval methods to quickly and accurately retrieve relevant knowledge fragments from the knowledge base based on the user's questions to improve the accuracy and recall of retrieval;
[0069] The retrieved knowledge fragments are used as the input of the ChatGLM3 model, and combined with ChatGLM3's language understanding ability and knowledge reasoning ability, more complete and accurate answers are generated. For example, the retrieved fault phenomenon, cause analysis, treatment method and other information are integrated together to generate a complete fault diagnosis report.
[0070] In order to evaluate the question-answering effect of the system, the present invention further designs scientific evaluation indicators and test sets to evaluate the question-answering effect of the system and continuously optimize the system performance. The following evaluation indicators are used:
[0071] Accuracy: The ratio of the number of correct answers generated by the model to the total number of questions.
[0072] Recall: The ratio of the number of correct answers generated by the model to the number of all relevant answers.
[0073] F1 value: The harmonic mean of precision and recall, used to comprehensively evaluate the performance of the model.
[0074] In a further embodiment, the user intent recognition algorithm integrates two technical routes, rule matching and deep semantic understanding, and introduces a confidence assessment mechanism to ultimately output reliable user intent for the power operation and maintenance knowledge question-and-answer system. First, the user inputs a question, and the question is preprocessed, including cleaning, word segmentation, part-of-speech tagging, etc.; the predefined rule library is used for matching, and the confidence is calculated, and the ChatGLM-6B model is used to generate the semantic vector of the question to achieve deep semantic understanding; the trained SVM classifier is used to classify the semantic vector and calculate the confidence; the results of rule matching and SVM classifier are integrated to output the final intent recognition result and confidence.
[0075] The rule matching is used to quickly identify simple questions and answers with high frequency and obvious intentions. The process includes:
[0076] (1) Power operation and maintenance intention rule base: This rule base contains keywords and regular expression rules for different user intentions, such as:
[0077] ① Query information: Keywords: "definition", "introduction", "explanation", etc.; regular expression: "....What is it?"
[0078] ② Seek solutions: Keywords: "cause", "analysis", "solution", "what to do", etc.; regular expression: "(how)? (solve|handle)....?"
[0079] ③Request operation guidance: Keywords: "step", "process", "method", "operation", etc.; regular expression: "(how)? .... (step|process|method)?"
[0080] (2) Matching process: For the preprocessed user questions, keyword matching is first performed. If the match is successful and the confidence reaches the threshold, the recognition result is directly returned; otherwise, regular expression matching is continued.
[0081] (3) Confidence calculation: The confidence of keyword matching is calculated based on the number of matching keywords and preset weights; the confidence of regular expression matching can be preset with a fixed value.
[0082] The deep semantic understanding is used to extract the deep semantic information of user questions using the pre-trained large model (ChatGLM-6B) to make up for the shortcomings of rule matching. The process includes:
[0083] The preprocessed user question is input into the ChatGLM-6B model, and the vector corresponding to the special token at the beginning of the sentence is extracted as the semantic vector representation of the question, which contains the model's understanding of the semantics of the entire sentence.
[0084] The process of accurately classifying user intent based on semantic vectors includes:
[0085] (1) Training Dataset:
[0086] ① Collect real user question and answer data in the field of power operation and maintenance, and manually annotate them to mark the corresponding intent category for each question.
[0087] ② Input the labeled questions into the ChatGLM-6B model, obtain their semantic vector representation, and construct a training dataset.
[0088] (2) SVM classifier:
[0089] ①Support vector machine (SVM) is used as the intent classifier, which performs well in processing high-dimensional and sparse data.
[0090] ② Use the training data set to train the SVM classifier so that it can predict the category of user intent based on the input semantic vector.
[0091] The process of confidence assessment and result integration includes:
[0092] (1) Confidence Assessment:
[0093] ① Rule matching: Confidence is calculated based on the type and number of matching rules.
[0094] ②SVM classifier: Use the Platt Scaling method to convert the decision value output by the SVM into a probability value as the confidence level of the intent classification.
[0095] (2) Results integration:
[0096] ① If the confidence of the rule match is higher than the preset threshold, the intent recognition result of the rule match is directly returned.
[0097] ② Otherwise, the confidence of the rule match and the confidence of the SVM classifier are weighted averaged to obtain the final confidence score, and the intent category with the highest confidence is returned as the final recognition result.
[0098] In a further embodiment, the power operation and maintenance knowledge base module uses the content analysis tool Tika to extract text content from documents during the data preprocessing stage. Supports multiple document formats, such as PDF, Word, etc. Unstructured is used to ingest and preprocess images and text documents, simplifying and optimizing the data processing workflow of the large language model (LLM). The OCR tool library PaddleOCR is used to support text detection and recognition in multiple languages, suitable for a variety of image text processing scenarios, and used for optical character recognition (OCR), which can extract text content from scanned documents or images. The text embedding model acge_text_embedding is used to convert text content into a vector representation for similarity search and other machine learning tasks. The PostgreSQL database PostgreSQL pgvector with enhanced vector data type support is used. Vector data can be used for efficient similarity search.
[0099] The acge_text_embedding model uses MRL technology to achieve multi-granularity text embedding:
[0100] E(t)=[E1(t),E2(t),E3(t)]
[0101] E1(t) is the average word vector representation:
[0102]
[0103] w i represents the i-th word in text t, v(w i ) represents word w i The pre-trained word vector of ; n represents the number of words in the text t.
[0104] E2(t) is the CNN text representation:
[0105] E2(t)=CNN(t)
[0106] E3(t) is the BERT text representation:
[0107] E3(t)=BERT [CLS] (t).
[0108] In a further embodiment, the question understanding module is further used to convert the question into a vector representation through a text embedding model after the user enters the question. The retrieval and re-ranking module uses the ReRank model bge-reranker-large to re-rank the retrieved results to ensure that the answers returned to the user are relevant and accurate. The deep learning framework PyTorch is used to train and run models such as embedding models and re-ranking models. LangChain is used to build a language model chain to combine multiple models and tools. The data framework LlamaIndex for large language model (LLM) applications is built to ingest, build and access private or domain-specific data. The container technology Docker is used to deploy and manage different components of the system to ensure the consistency of its operating environment.
[0109] In the construction of the intelligent question-answering system of the present invention, a large model development framework is proposed, which redefines the entire life cycle from pre-training to practical application. Figure 2 The traditional pre-training stage is demonstrated, and advanced instruction adjustment and alignment optimization techniques are also integrated.
[0110] In each training phase, the present invention introduces a dynamic prompt mechanism, which enables the model to generate customized responses according to different needs and scenarios. This method significantly improves the flexibility, adaptability and practicality of the model.
[0111] The present invention integrates reinforcement learning (RL) into the training framework, adopts the policy gradient reinforcement learning (PPO) algorithm, and combines reward modeling (RM) and human feedback reinforcement learning (RLHF) to optimize the model, which improves the performance of the model and enhances its understanding and alignment with human values.
[0112] The PPO algorithm is used to train the agent to learn to generate high-quality text:
[0113]
[0114] in:
[0115] θ k Represents the strategy parameters at the kth iteration; represents the expectation of the empirical data at time step t; r t (θ) represents the probability ratio of the new and old strategies; It represents the estimated value of the advantage function at time step t, which is used to measure how good the current action is relative to the average action; clip(x,a,b) means limiting the value of x to the interval [a,b]; ε is a hyperparameter used to control the amplitude of the policy update.
[0116] The Reward Modeling (RM) uses a reward model To predict the reward value. Consider factors such as text fluency, semantic relevance, and task completion:
[0117]
[0118] Where: t represents the text generated by the model; t ref Represents the reference text; Similarity(t,t ref ) indicates that t and t are calculated using the pre-trained semantic similarity model. ref The semantic similarity score between them; Perplexity(t) represents the perplexity score of text t calculated using the language model; α and β are weight coefficients used to balance the importance of semantic relevance and text fluency.
[0119] The perplexity score is used to measure the prediction performance of a language model for a given text t:
[0120]
[0121] P(ω i |ω1,ω2,...,ω i-1 ) is the language model in the generated word sequence ω1,ω2,...,ω i-1 The probability of generating the i-th word under the condition where N is the number of words in the text.
[0122] The RLHF collects human evaluators’ preference data on model-generated text and uses this data to fine-tune the reward model. Parameters. Use pairwise ranking loss to train the reward model:
[0123]
[0124] Where: D represents the collected preference dataset; (t1, t2, y) represents a data sample, t1 and t2 are the texts output by the two models, and y represents the preference label of the manual evaluator for the two texts (1 means t1 is better than t2, -1 means t2 is better than t1); t ref Represents the reference text, which is used to calculate the semantic relevance score.
[0125] The present invention proposes a retrieval-enhanced large model architecture. Figure 2 It demonstrates a dynamic and iterative information retrieval and generation process, improving the knowledge acquisition capability and output quality of large models. The intelligent retriever accurately extracts contextual information related to the input and flexibly adjusts the retrieval strategy according to task requirements.
[0126] The present invention introduces a dual-mode information transmission mechanism. The retrieved information can be directly input through simple language, and can also be encoded through the decoder fusion technology optimized by the present invention.
[0127] Depending on the complexity of the task, the retrieval and generation process is dynamically repeated multiple times, allowing the model to continuously refine its output, producing more precise and in-depth results.
[0128] This system adopts an iterative development model to gradually realize various functions. The specific steps are as follows:
[0129] First, construct the power operation and maintenance knowledge base to realize the basic question and answer function. Specifically, analyze the power operation and maintenance business scenarios and user needs, build a power operation and maintenance knowledge system, and clarify the knowledge scope and classification. Collect and organize internal documents of power companies and external professional knowledge bases, and perform data format conversion, deduplication, and denoising to ensure data quality. Use natural language processing technology to extract key entities, relationships, and attributes from text data, build a power operation and maintenance knowledge graph, and perform semantic vectorization. Select a vector database, create a database and table structure, import semantic vectors and knowledge graph data into the database, and optimize the index to improve retrieval efficiency. Implement simple questions and answers based on keyword matching and semantic similarity calculation, support users to ask questions in natural language, and return the most relevant answers.
[0130] Based on the LLaMA-Factory fine-tuning basic framework, the LoRA fine-tuning scheme is used to perform instruction supervision fine-tuning on the ChatGLM3 large model.
[0131] LLaMA-Factory includes multiple models such as LLaMA, LLaVA, Mistral, Mixtral-MoE, Qwen, Yi, Gemma, Baichuan, ChatGLM, Phi, etc., integrating (incremental) pre-training, (multimodal) instruction supervision fine-tuning, reward model training, PPO training, DPO training, KTO training, ORPO training, etc., and supports multiple precisions, including 32-bit full parameter fine-tuning, 16-bit frozen fine-tuning, 16-bit LoRA fine-tuning and 2 / 4 / 8-bit QLoRA fine-tuning based on AQLM / AWQ / GPTQ / LLM.int8, and supports Galore, BAdam, DoRA, LongLoRA, LLaMA Pro, Mixture-of-Depths, LoRA+, LoftQ and Agent fine-tuning algorithms.
[0132] The fine-tuning process further includes building a dataset, performing fine-tuning, performing evaluation, merging LoRA weights, and using the new model for inference.
[0133] In the process of constructing the data set, industry data is collected, data is segmented, and question-answer pairs are established based on the segmented data blocks.
[0134] The dataset is in Sharegpt format, and the sample snippet is as follows:
[0135]
[0136]
[0137] After simplification, the constructed dataset sample is:
[0138]
[0139]
[0140] The construction methods include:
[0141] Collect existing question-answer pairs and organize them into Sharegpt format; or
[0142] Manually create question-answer pairs and organize them into Sharegpt format; or
[0143] Relying on the large model capabilities, question-answer pairs are generated based on existing documents and organized into Sharegpt format. During the fine-tuning process, you need to configure the fine-tuning parameters and perform fine-tuning.
[0144] The following is an example of configuring fine-tuning parameters:
[0145]
[0146]
[0147] After configuring the fine-tuning parameters, perform an evaluation of the fine-tuned model. The configuration example is as follows:
[0148]
[0149]
[0150] Then deploy the new model and apply it to perform inference in your project.
[0151] Label the question-and-answer data in the field of power operation and maintenance, train the question understanding model, and identify information such as user intent, key entities and relationships. Collect data such as user clicks and feedback, train the re-ranking model, and optimize the ranking of search results to improve the accuracy and reliability of answers. Based on the dialogue management mechanism, record the user's historical question and answer information, identify the context, and support multiple rounds of question and answer and follow-up functions.
[0152] Integrate and deploy the system through the system management module. Perform integration tests on each module of the system to ensure the integrity and stability of the system functions. Select the appropriate deployment method, deploy the system to the cloud server or the enterprise internal server, and perform performance tuning to ensure stable operation of the system. Perform daily operation and maintenance of the system, collect user feedback, and continuously optimize system functions and performance based on user needs and technology development trends.
[0153] In a specific embodiment, a scenario example of fault diagnosis and troubleshooting is given. For example, the operator receives an alarm message: "The oil temperature of the No. 1 main transformer of the 110kV substation is too high, the protection is activated, and it has tripped." The operator enters a question in the system: "What are the reasons for the 110kV main transformer tripping due to excessive oil temperature?" The system identifies key information based on the question: equipment type (main transformer), voltage level (110kV), and fault phenomenon (excessive oil temperature, tripping). Retrieve relevant knowledge, such as the reason why the main transformer oil temperature is too high, the action mechanism of the protection device, etc. Generate answers: List possible reasons, such as cooling system failure, oil pump failure, excessive load, etc., and give corresponding troubleshooting suggestions. Quickly locate the cause of the fault and shorten the fault handling time. Provide professional troubleshooting suggestions to improve fault handling efficiency.
[0154] In a specific embodiment, a scenario example of operation guidance and risk warning is given. For example, the operation and maintenance personnel need to perform a power outage maintenance operation on a 10kV line. The operation and maintenance personnel enter the question in the system: "What are the operating steps for power outage maintenance on the 10kV XX line?" The system identifies key information: operation task (power outage maintenance), target equipment (10kVXX line). Retrieve relevant knowledge: operating procedures and safety precautions for power outage maintenance of 10kV lines. Generate answers: Provide detailed operation steps, and give safety tips and risk warnings, such as reminding operators to pay attention to which safety distances, which operations may be risky, etc. Standardize operating procedures and reduce the risk of human error. Provide safety tips to ensure personal and equipment safety.
[0155] In a specific embodiment, a scenario example of knowledge learning and skills training is given. For example, a newly hired operation and maintenance personnel needs to learn the basic knowledge of transformers. The operation and maintenance personnel enter the question in the system: "What is the structure of the transformer? What are the common faults?". The system identifies key information: learning objectives (transformer), knowledge requirements (structure, faults). Retrieve relevant knowledge: introduction to the structure of the transformer, common fault types, fault phenomena, etc. Generate answers: Use a combination of pictures and text to clearly display the structure of the transformer and explain the causes and phenomena of common faults. Provide structured knowledge to facilitate learning and understanding.
[0156] The beneficial effect of the present invention is that, compared with the prior art, the present invention provides a knowledge question and answer system based on a large language model. By constructing a comprehensive power operation and maintenance knowledge base, deep learning technology is used to understand the semantics of user questions, and accurate retrieval is performed in the knowledge base to quickly locate relevant information; natural language question and answer, multi-round dialogue, intention recognition and other functions are supported to provide users with a friendly and efficient intelligent interactive experience; according to the fault information provided by the user, combined with the knowledge base and expert experience, the operation and maintenance personnel are assisted in fault cause analysis, solution recommendation, etc.; the knowledge acquisition cost of the operation and maintenance personnel is effectively reduced, the efficiency of fault diagnosis and processing is improved, and strong support is provided for building a safer, more reliable and efficient power system.
[0157] Through Tika and PaddleOCR, the system can process documents in various formats and extract text content. Using text embedding models and pgvector, the system can convert text into vector representations and perform efficient similarity searches. Combined with PostgreSQL pgvector and bge-reranker, the system can find the most relevant content from massive data and ensure the accuracy of the answers. Using ChatGLM3, the large language model can generate natural language answers and improve the user experience. The system uses a variety of programming languages and tools, making full use of their respective advantages to implement different functional modules. Through Docker containerization, the consistency of various components of the system in different environments can be ensured, which is convenient for deployment and expansion.
[0158] Based on the spirit of the present invention, those skilled in the art can easily think that a computer program product can be obtained based on the aforementioned knowledge question answering system based on a large language model. The computer program product may include a computer-readable storage medium, which carries computer-readable program instructions for enabling a processor to implement various aspects of the present disclosure. That is, the present application also includes a terminal, including a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the aforementioned knowledge question answering system based on a large language model.
[0159] Computer readable storage medium can be a tangible device that can keep and store the instructions used by the instruction execution device. Computer readable storage medium can be, for example, - but not limited to - electrical storage device, magnetic storage device, optical storage device, electromagnetic storage device, semiconductor storage device or any suitable combination of the above. More specific examples (non-exhaustive list) of computer readable storage medium include: portable computer disk, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, for example, punch card or groove protrusion structure with instructions stored thereon and any suitable combination of the above. Computer readable storage medium used here is not interpreted as instantaneous signal itself, such as radio wave or other free propagating electromagnetic wave, electromagnetic wave propagated by waveguide or other transmission medium (for example, light pulse by optical fiber cable) or electrical signal transmitted by wire.
[0160] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0161] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages-such as Smalltalk, C++, etc., and conventional procedural programming languages-such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network-including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) may be personalized by utilizing the state information of a computer-readable program instruction, and the electronic circuit may execute a computer-readable program instruction, thereby realizing various aspects of the present disclosure.
[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A knowledge question answering system based on a large language model, characterized in that: include: The power operation and maintenance knowledge base module is used to obtain data from predefined data sources and perform preprocessing, construct a knowledge graph in the field of power operation and maintenance, and convert text content into semantic vectors, use a vector database to store the semantic vectors and the knowledge graph, and integrate them to form a power operation and maintenance knowledge base; The question understanding module is used to perform question recognition analysis, identify the user's intention, and convert the user's question into a semantic vector; A retrieval and re-ranking module, used to perform semantic retrieval in the power operation and maintenance knowledge base, recall knowledge information related to the semantics of the problem, and then rank the retrieval results based on semantic relevance, knowledge confidence and information importance; The answer generation module is used to integrate the most relevant knowledge information and user questions as the input of the large language model, generate prompt information suitable for processing by the large language model, and use the large language model fine-tuned based on data in the power operation and maintenance field to generate answers in natural language form according to the prompt information.
2. The knowledge question answering system based on a large language model according to claim 1, characterized in that: The predefined data sources include internal enterprise information and external professional knowledge, wherein the internal enterprise information includes internal documents of the power enterprise, and the internal documents of the power enterprise include equipment manuals, operating procedures, maintenance records, fault case libraries, work tickets, technical standards, and accident reports; the external professional knowledge includes the State Grid professional knowledge base, power industry standardization documents and academic literature.
3. The knowledge question answering system based on a large language model according to claim 2, characterized in that: The electric power operation and maintenance knowledge base module is further used to convert files in various formats into processable texts, extract information from the texts using natural language processing technology, and extract key entities and their relationships.
4. The knowledge question answering system based on a large language model according to claim 3 is characterized in that: The semantic relevance refers to the degree of matching between the question and the answer at the semantic level; the knowledge confidence refers to the reliability and credibility of the source of the answer; and the information importance refers to the importance of the answer to solving the problem.
5. The knowledge question answering system based on a large language model according to claim 4, characterized in that: The problem understanding module is further used to: Perform word segmentation and part-of-speech tagging on the questions input by the user to identify the keywords in the questions; identify the entities related to power operation and maintenance in the questions, and extract the relationships between the entities. Based on the results of the question analysis, identify the user's intentions, rewrite the questions input by the user according to the terminology standards in the field of power operation and maintenance, convert colloquial expressions into professional terms, and finally convert the processed questions into semantic vectors for retrieval in the knowledge base.
6. The knowledge question answering system based on a large language model according to claim 5, characterized in that: Further including: System management module, which is further used to implement session management, prompt word management, plug-in management and log management; The session management further includes saving the user's historical question and answer records to conduct multiple rounds of dialogue and context understanding based on the historical question and answer records; The prompt word management further includes configuring different prompt word information according to different question-answering scenarios and user needs to guide the model to generate answers; The plug-in management further includes integrating external plug-ins, including fault diagnosis tools, expert systems, knowledge graphs, and enhancing system functions; The log management further includes recording system operation logs for performance monitoring, model optimization and case analysis.
7. The knowledge question answering system based on a large language model according to claim 6, characterized in that: The large model is a pre-trained large model ChatGLM3, which is fine-tuned by instruction supervision using the LoRA fine-tuning scheme based on the LLaMA-Factory fine-tuning basic framework; The fine-tuning process further includes: In the process of constructing the dataset, industry data is collected, data is segmented, question-answer pairs are established based on the segmented data blocks, and then fine-tuning parameters are configured and fine-tuning is performed. After configuring the fine-tuning parameters, the fine-tuned model is evaluated; in the process of merging LoRA weights, a new model is generated, the new model is deployed, and the new model is applied in the project to perform reasoning.
8. The knowledge question answering system based on a large language model according to claim 7, characterized in that: The answer generation module is further used to dynamically repeat the retrieval and generation process multiple times according to the complexity of the task, so that the model can continuously refine its output.
9. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is used to operate according to the instructions to execute the knowledge question answering system based on the large language model according to any one of claims 1-8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the knowledge question answering system based on a large language model described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement
CN117573843A
Electric power professional knowledge intelligent question answering system construction method based on large language model
CN117609421A
LLM-based intelligent questioning and answering method, system and equipment in power field and medium
CN118277521A
Text2SQL semantic parsing method for domain large language model
CN118377796A
Cited By
Open type problem implicit intention recognition method and system based on multi-agent reasoning
CN119621916A
Document information extraction processing method and device based on power lexical element structure
CN119646116A
Intelligent workflow interaction configuration method and system based on large model
CN119692954A
Large model deployment method and system based on multi-level cache mechanism
CN119739809A
Domain knowledge supplement and SQL generation optimization method and device based on large model
CN119938891A