Large Model Retrieval-Augmented Generation Method for Electricity Price Field Policies

By building a knowledge base for electricity price policy and using the RAG framework, the problem of users obtaining and understanding electricity price policies is solved, the professionalism and practicality of the big model in the field of electricity price is realized, and accurate policy support answers are generated.

CN119940512BActive Publication Date: 2025-08-01ZHEJIANG POWER (NINGBO BEILUN) SMART ENERGY CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510423281.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-08-01
Estimated Expiration
2045-04-07

AI Technical Summary

Technical Problem

It is difficult for ordinary users to obtain electricity price policy information, understand documents, and find it difficult to keep up with policy trends. The existing large models are not professional and practical in the field of electricity price.

Method used

Build a professional electricity price policy knowledge base, use a tree structure to store documents, combine it with the RAG framework, and retrieve relevant information from the knowledge base through keyword matching, semantic understanding and RRF algorithms, enhancing the ability to generate large models.

Benefits of technology

An answer was generated that accurately matched the current policy background, supporting decision-making in the power industry, and improving the accuracy and real-time nature of the understanding and application of electricity price policies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940512B_ABST
    Figure CN119940512B_ABST
Patent Text Reader

Abstract

The present invention discloses a large model retrieval enhanced generation method for electricity price field policies. The method of the present invention first constructs a specialized knowledge base, constructs a tree structure according to the hierarchical relationship between file titles, and realizes the structured storage of documents; then performs enhanced retrieval. For a question, relevant information is retrieved from the knowledge base according to the requirements of the large model to integrate internal and external knowledge and improve the accuracy of decision-making output; the large model is used to integrate external knowledge and internal model knowledge to process problems related to electricity prices, and the large model answers professional questions related to electricity prices. The method of the present invention constructs a specialized knowledge base. When solving professional problems in the electricity price field, it answers questions based on the large model, and uses the RAG framework to retrieve the most relevant document fragments from the knowledge base to prompt the final answer of the large model, generating an accurate answer that conforms to the current policy background, providing technical support for decision-making support in the power industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical fields of computer science and artificial intelligence, and particularly relates to a large model retrieval augmented generation method for electricity price field policies. Background Art

[0002] Electricity price policies play a decisive role in the setting and adjustment of electricity prices. However, due to problems such as scattered information, access restrictions, and technical barriers, it is difficult for ordinary users to conveniently and accurately obtain electricity price policy information. At the same time, since electricity price policy documents often use professional terms and usually contain a large amount of background information, technical details, and appendices, users also have many difficulties in understanding the documents and accurately calculating electricity prices after obtaining them. In addition, due to the rapid changes in electricity price policies and market environments, policy documents are often updated, and it is difficult for ordinary users to keep up with the latest policy trends. Therefore, building a detailed and complete electricity price knowledge base and strengthening the accuracy of question answering relying on this knowledge base have become key issues for this method.

[0003] Large language models have learned deep patterns and rich knowledge of language through training on a large amount of text data, and have the ability to understand and generate across domains. However, in specific domain applications such as electricity price policies, to achieve professional-level accuracy and practicality, the model needs to deeply understand domain-specific professional knowledge. Researchers have explored various strategies, including domain adaptation training, continuous learning, and integration with external knowledge bases.

[0004] The development of prompt engineering can help users better use large models in various scenarios and research fields. Traditional prompt engineering methods are templated prompts, but for problems of complex domain knowledge, more precise prompts are needed to improve the model's understanding ability and generation quality. In recent years, prompt engineering has gradually entered the data-driven and context-aware stage. Using machine learning algorithms to select the best prompt words, adjust the prompt structure, and using techniques such as reinforcement learning and genetic algorithms, and combining context information, considering the dynamic adjustment of prompts in different contexts, improves the relevance and accuracy of the generated results.

[0005] RAG (Retrieval-Augmented Generation) is a technology that combines information retrieval and natural language generation, aiming to enhance the model's generation ability by retrieving relevant information from an external database in real time. In application scenarios in specific fields, the RAG method can retrieve the most relevant document fragments from a pre-constructed knowledge base of electricity price policies, provide prompts for the final answers of large models, and generate answers or strategic suggestions that are both accurate and in line with the current policy background. RAG not only improves the accuracy of the model in answering professional questions but also ensures the timeliness and effectiveness of the suggestions provided, providing technical support for decision-making in the power industry. Summary of the Invention

[0006] The purpose of the present invention is to provide a large model retrieval enhancement generation method for electricity price domain policies.

[0007] The method of the present invention is as follows:

[0008] Step (1): Construct a professional knowledge base; according to the hierarchical relationship between file titles, construct a tree structure to achieve structured storage of documents.

[0009] Step (2): Enhance retrieval; for a question, retrieve relevant information from the knowledge base according to the requirements of the large model to integrate internal and external knowledge and improve the accuracy of decision-making output.

[0010] Step (3): Use the large model to integrate external knowledge and internal model knowledge, process questions related to electricity prices, and have the large model answer professional questions related to electricity prices.

[0011] Furthermore, the method for constructing the knowledge base in step (1) is as follows:

[0012] (1-1) Initialize the knowledge base structure: Define the document set , for each document set the root node, , is the total number of documents, initialized as a dictionary of basic attributes, including the current node name and the set of child nodes , each child node has the same structure as the corresponding root node;

[0013] (1-2) Document content analysis: Regard the document as a set of paragraphs, , represents the th paragraph, , is the number of paragraphs of the document ; use regular expressions right Make a judgment, if If the match is successful The value of , otherwise : ;

[0014] The value of When calculating the level of the title, a new structure is created. Same nodes; control of the node hierarchy is done by the stack The push and pop operations are implemented according to the last-in-first-out principle; the top element of the stack is popped up according to the level until the current processing level, and then the new node is added to the child node list of the current top node of the stack, and the new node is pushed onto the stack;

[0015] when The value of and When it is not empty, it means that the current content is the non-text part of the file. Traverse the text of this part and add the reference list according to the sequence number and the key value of the reference content. In the corresponding root node attributes; after processing is completed, the tree structured file is returned;

[0016] After completing the structured storage of knowledge base documents, extract the file content and vectorize the text data; Split into multiple words, map to high-dimensional vector space, and transform the document All words in are defined as word set , for each word Find the corresponding row in the predefined embedding matrix E and get The corresponding embedding vector , whose value is , Indicates the words, , For Documents The number of words.

[0017] Furthermore, the method for enhancing the retrieval in step (2) is as follows:

[0018] (2-1) Measure the importance of a word based on its frequency in the document and its inverse document frequency; In the documentation Matching score , Expressive words In the documentation The frequency of occurrence in Expressive words The inverse document frequency of , represents the number of documents containing the word ; arranging in descending order of the matching scores, the top results are obtained, and the corresponding words are used as the first result set , which is the keyword set;

[0019] (2-2) The semantic similarity between two keyword vectors is calculated by using the cosine similarity method. The semantic similarity between keyword and keyword is , and respectively represent the word vectors of keyword and word ; represents the vector dimension; arranging in descending order of the semantic similarity, the top results are obtained, and the corresponding keywords are used as the second result set ;

[0020] (2-3) The RRF algorithm is used to re-rank the first result set and the second result set : For the word vector of keyword , if it ranks th in the other result set, its inverse rank score is , if it is not in the other result set, the inverse rank score is 0. The inverse rank scores of each keyword in the two sets are respectively denoted as and ; the fusion score of each document is calculated, and respectively represent the relative importance of keyword matching and semantic understanding, and ; finally, sorting in descending order of the fusion score, the top results are obtained, denoted as the result set .

[0021] Furthermore, step (3) is specifically: combining all the word embedding vectors after splitting and mapping the document into a document vector , and the large model generates the best answer according to the document vector and the result set , represents the probability that the large model generates the answer given the question and after retrieval, .

[0022] The method of the present invention constructs a highly specialized knowledge base, widely collecting legal provisions and policy documents related to energy pricing, providing great convenience for retrieval and in-depth analysis. When solving professional problems in the field of electricity prices, it answers questions based on a large model and uses the RAG framework to retrieve the most relevant document fragments from the constructed electricity price policy knowledge base to prompt the final answer of the large model, generating accurate answers that conform to the current policy background and providing technical support for decision-making support in the power industry. Description of the Drawings

[0023] Figure 1 It is a schematic diagram of the overall method of the present invention;

[0024] Figure 2 It is a schematic diagram of the tree structure of the knowledge base;

[0025] Figure 3 It is a schematic diagram of retrieval enhancement;

[0026] Figure 4 It is a schematic diagram of the usage interface of the mini-program. Detailed Implementation Manner

[0027] A large model retrieval enhancement generation method for electricity price field policies. This method constructs a specialized knowledge base and constructs a tree structure according to the hierarchical relationship between document titles to achieve structured storage of documents. When solving electricity price problems, the RAG framework is introduced. According to the requirements of the large model, keyword matching, semantic understanding, and the RRF algorithm are used to retrieve relevant information from the knowledge base immediately, integrating internal and external knowledge to give the final answer. The overall method is as Figure 1 shown:

[0028] Step (1) Construct a specialized knowledge base; the knowledge base is constructed by systematically integrating and analyzing relevant policy documents, covering legal provisions and policy guidance. According to the hierarchical relationship between document titles, a tree structure is constructed to achieve structured storage of documents. The method for constructing the knowledge base is as follows:

[0029] (1-1) Initialize the knowledge base structure: Define the document set , for each document set the root node, , is the total number of documents, initialized as a dictionary of basic attributes, including the current node name and the child node set , and each child node has the same structure as the corresponding root node.

[0030] (1-2) Document content analysis: Regard the document as a collection of paragraphs, , represents the th paragraph, , for the document ; use regular expressions to judge. If matches successfully, then the value of is : ;

[0031] When the value of is , calculate the level where the title is located, and at the same time create a new structure with the same nodes; the control of the node level is realized by the push and pop operations of the stack

[0032] When the value of and is not empty, it means that the current content is the non-text part of the file. Traverse this part of the text, and add the reference list according to the serial number and the key value of the reference content, and add it to the corresponding root node attribute. After processing, return the tree-structured file, as Figure 2 shown.

[0033] After completing the structured storage of the knowledge base document, extract the file content and vectorize the text data; split the document into multiple words, map them to a high-dimensional vector space, and define all the words in the document as the word set . For each word , find the corresponding row in the predefined embedding matrix E to obtain the corresponding embedding vector , whose value is , representing the th word, , for the document the number of words.

[0034] Step (2) Enhanced retrieval; for a question, relevant information needs to be retrieved from the above knowledge base immediately according to the requirements of the large model to integrate internal and external knowledge and improve the accuracy of the decision-making output. As Figure 3 shown, the method of enhanced retrieval is as follows:

[0035] (2-1) Measure the importance of a word according to its frequency of occurrence in the document and the inverse document frequency. The word in the document matching score , represents the frequency of occurrence of the word in the document , represents the inverse document frequency of the word , , represents the number of documents containing the word . Arrange in descending order according to the matching score and obtain the top results. The corresponding words are used as the first result set , which is the keyword set.

[0036] (2-2) Calculate the semantic similarity between two keyword vectors using the cosine similarity method. The semantic similarity between keyword and keyword , and respectively represent the word vectors of keyword and word , represents the vector dimension. Arrange in descending order according to the semantic similarity and obtain the top results. The corresponding keywords are used as the second result set .

[0037] (2-3) Rearrange the first result set using the RRF algorithm: For the word vector of keyword , if it ranks th in another result set, then its inverse ranking score is . If it is not in another result set, then the inverse ranking score is 0. The inverse ranking scores of each keyword in the two sets are denoted as and respectively; Calculate the fusion score of each document , and respectively represent the relative importance of keyword matching and semantic understanding, and . Finally, sort in descending order according to the fusion score and obtain the top results, denoted as the result set .

[0038] Step (3) uses a large model to fuse external knowledge and internal model knowledge to handle issues related to electricity prices. The large model answers professional questions related to electricity prices; the document After segmentation and mapping, all word embedding vectors are combined into a document vector , and the large model generates the best answer according to the document vector and the result set . , Indicates the probability that the large model generates an answer after a given question and retrieval. .

[0039] For the convenience of user experience, the large model retrieval enhanced generation method for electricity price domain policies is used in the WeChat mini-program. Users can log in to the mini-program and ask questions related to electricity prices. The user interface of the mini-program is as Figure 4 shown.

Claims

1. A retrieval-enhanced generation method of large model for electricity price field policies, characterized in that: Step (1) Construct a specialized knowledge base; the knowledge base is constructed by systematically integrating and analyzing relevant policy documents, covering legal provisions and policy guidance; according to the hierarchical relationship between document titles, a tree structure is constructed for structured storage of documents; the documents are segmented into multiple words and mapped to a high-dimensional vector space for vectorization of text data; specifically: (1-1) Initialize the knowledge base structure: Define the document set , for each document Set the root node, , Let be the total number of documents, initialized as a dictionary of basic attributes, including the current node name and the set of child nodes , each child node has the same structure as the corresponding root node; (1-2) Document content analysis: Regarding the document as a set of paragraphs, , indicating the th paragraph, , being the number of paragraphs in the document ; Using regular expressions to judge , if matches successfully, then the value of is , otherwise it is : The value is When calculating the level where the title is located, a new structure is created and the same nodes; The control of the node hierarchy is implemented by the push and pop operations of the stack and follows the last-in-first-out principle; pop the top element of the stack until the current processing level, then add the new node to the child node list of the current top node of the stack, and push the new node onto the stack; When has a value of and is non-empty, it indicates that the current content is a non-text part of the file. Traverse the text of this part, and according to the serial number and the key value of the reference content, add a reference list to the corresponding root node attribute; after processing, return the tree-structured file; ​ After completing the structured storage of the knowledge base documents, extract the file content and vectorize the text data; for the document split into multiple words, map them to a high-dimensional vector space, and define all the words in the document as a word set For each word look up the corresponding row in the predefined embedding matrix E to obtain the corresponding embedding vector whose value is , indicating the th word, , and is the number of words in the document Step (2) Enhance retrieval; For a problem, retrieve relevant information from the knowledge base according to the requirements of the large model to integrate internal and external knowledge and improve the accuracy of decision-making output. First, measure the importance of words based on the frequency of word occurrences in the document and the inverse document frequency to obtain a keyword set as the first result set. Then, use the cosine similarity method to calculate the semantic similarity between two keyword vectors to obtain a second result set. Finally, use the RRF algorithm to re-rank the first result set and the second result set to obtain the final result set ; Specifically: (2-1) Measure the importance of a word based on its frequency in the document and the inverse document frequency; the word in the document matching score , represents the frequency of the word in the document , represents the inverse document frequency of the word , , represents the number of documents containing the word ; sort by the matching score from high to low, and obtain the top results, and the corresponding words are used as the first result set , which is the keyword set; (2-2) Calculate the semantic similarity between two keyword vectors using the cosine similarity method. The keyword and the keyword 's semantic similarity , and respectively represent the word vectors of the keyword and the word . represents the vector dimension; sort them in descending order of semantic similarity and obtain the top results. The corresponding keywords are used as the second result set . (2-3) Using the RRF algorithm on the first result set and the second result set for rearrangement: For the word vector of the keyword , if it ranks in another result set, then its inverse ranking score is . If it is not in another result set, the inverse ranking score is 0. The inverse ranking scores of each keyword in the two sets are denoted as and respectively; Calculate the fusion score of each document , and respectively represent the relative importance of keyword matching and semantic understanding, and ; Finally, sort by the fusion score from high to low to obtain the top results, denoted as the result set ; Step (3) uses a large model to fuse external knowledge and internal model knowledge to process issues related to electricity prices, and the large model answers professional questions related to electricity prices; specifically, all the word embedding vectors after document segmentation and mapping are combined into a document vector , and the large model generates the best answer according to the document vector and the result set . represents the probability that the large model generates an answer after a given question and retrieval .

Citation Information

Patent Citations

  • Short text query expansion enhancement retrieval method based on knowledge base hierarchical tree structure

    CN118861088A