Policy document intelligent rule extraction and change comparison method for electricity charge verification
By designing core statement recognition and rule extraction Prompt templates, combining large language models and agents, the problem of rules extraction and comparison in electricity bill verification is solved, and the intelligent analysis and efficient change comparison of electricity bill policy documents are realized, which improves the intelligence and response efficiency of electricity bill verification.
Patent Information
- Application Number
- CN202510953695.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-07-11
AI Technical Summary
During the electricity bill verification, it is difficult for the existing technology to extract business rules from complex electricity bill policy documents efficiently and accurately, and realize automatic comparison and update of new and old rules, resulting in response lag and rule omissions.
Design core statement recognition Prompt templates and rule extraction conversion Prompt templates, build policy rule extraction agents, combine large language models, and identify core statements and transform them into standardized rule descriptions through file analysis and structured reconstruction; build historical policy rule description knowledge base and policy rule comparison agents to realize in-depth semantic comparison and change analysis of new and old rules.
It improves the accuracy and efficiency of rule extraction, significantly reduces the cost of manual intervention, realizes intelligent matching and rapid response between new and old rules, and improves the intelligence of electricity bill verification.
Smart Images

Figure CN120449861A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power document rule extraction and change comparison, and specifically relates to a policy document intelligent rule extraction and change comparison method for electricity fee verification. Background Art
[0002] In key businesses such as electricity fee verification and preferential policy implementation in the power industry, policy documents are an important basis for formulating verification logic and implementation rules. Various verification rules must be defined for electricity fee-related policy documents to check whether each link complies with the requirements of the relevant policy documents.
[0003] With the continuous updating of policies of national and local government departments, it is necessary to continuously convert newly released policy clauses into executable business rules to ensure the rapid implementation of policies and system compliance. However, policy documents related to electricity charges are usually highly professional, logically complex, and have ambiguous clauses. In order to formulate relevant verification rules in a targeted manner, it is necessary to rely on front-line business experts to interpret relevant policy documents, extract key points, and write rule descriptions. In addition, it is necessary to compare and verify them one by one with the verification rules in the original information system to identify the scope of impact of the implementation of policy documents on electricity verification business. This process is time-consuming, labor-intensive, and cumbersome, and it is inevitable that problems such as omissions in rules and logical loopholes will occur. There is a significant lag in the response to the implementation of policy documents, which reduces the intelligence level of the power system and the responsiveness of enterprises.
[0004] In recent years, with the rise of large language model technology, its technical advantages in natural language understanding and complex semantic extraction have provided new solutions for the automatic parsing and rule generation of policy documents. However, the relevant policy documents for electricity fee verification are generally long, highly specialized in the field, and contain a lot of implicit business logic. Directly using a general large model to parse electricity fee-related policy documents often lacks a deep integration of business text understanding and business rule requirements, resulting in unsatisfactory results. For example, the positioning of rule statements is inaccurate, rule content information is omitted, and the understanding and extraction of rule content are incorrect, making it difficult to use directly in business systems. In addition, the direct application of large models still lacks systematic technical links and capabilities for the automatic acquisition, recognition, and semantic alignment between old and new rules. It also requires a lot of review and proofreading work, which makes it difficult to meet the high requirements of timely updates. Summary of the Invention
[0005] In order to overcome the problems in the prior art, the present invention proposes a policy document intelligent rule extraction and change comparison method for electricity fee verification.
[0006] The technical solution of the present invention to solve the above technical problems is as follows: The present invention provides a method for intelligent rule extraction and change comparison of policy documents for electricity fee verification, comprising the following steps: Parse electricity fee-related policy documents, retain the contextual hierarchy and logical structure information of the original electricity fee-related policy documents during the parsing process, and optimize the parsed content; Design a core sentence recognition prompt template and build a policy rule extraction agent to identify core sentences from the optimized content, extract rule-related elements, convert them into standardized policy rule descriptions, and output them in correspondence with the original content. Construct a historical policy rule description knowledge base, and based on the standardized policy rule description and the original content, search for historically similar policy rule descriptions from the historical policy rule description knowledge base. Then, by constructing a policy rule comparison agent, conduct in-depth semantic comparison and change analysis on the current standardized policy rule description and historically similar policy rule descriptions, identify new and modified policy clauses, and output structured change details.
[0007] Furthermore, the electricity fee-related policy documents are analyzed, including: Read the content of the electricity fee-related policy document, design a document content and structure parsing method, and parse the electricity fee-related policy document; wherein the design document content and structure parsing method includes: For Word documents, we use a parsing module based on python-docx to identify and decompose the text content structure of Word documents. The recognition results retain the original heading level and numbering structure of the Word documents, assign different type identifiers to the text content, and store the reading results in the order of the original Word documents as a collection containing document style attributes and corresponding content. For PDF format documents, the PaddleOCR tool is used for alignment and recognition, and the page elements are semantically segmented using layout analysis technology to obtain the spatial position, text content and text type of each page's text blocks. The text is also stored as a parsed content collection in the order of the original PDF format document.
[0008] Furthermore, the parsed content is optimized, specifically including: For each body paragraph in the parsed content, its title content and type are spliced into the body paragraph to form a new body paragraph. Paragraphs longer than the preset length are divided into blocks according to the maximum block length; Each paragraph block is divided into sentences, and each sentence is numbered and then merged into paragraph text, that is, the numbered paragraph blocks.
[0009] Furthermore, the core sentence recognition prompt template is designed, including: The core statement recognition prompt template is defined as P R, expressed as: ; In the above formula, G Indicates the description of the set goal; Represents a numbered block of paragraph text entered; S Indicates the recognition step prompts given to guide the large language model to think and judge; I Indicates important matters that need to be paid special attention to; O R Indicates the output format of the core sentence recognition task, which is in JSON format and contains the number identifier, judgment result, and thinking process of each sentence.
[0010] Furthermore, we construct a policy rule extraction agent, including: Create a core statement screening tool based on the core statement identification prompt template T : ; Based on the filtered core statements, design rule extraction and conversion prompt template P E : ; Combine core sentence screening tools, rule extraction conversion prompt templates and large language models to build a policy rule extraction agent A E : ; in, M Represents a large language model; F Represents the sentence filtering process; c f Indicates the paragraph text after being filtered by the core sentence filtering tool; O E Indicates the output format of the rule extraction and transformation task; E X Indicates an example of rule extraction results, which is provided to the large language model for reference.
[0011] Furthermore, the element information related to the rules is extracted and converted into a standardized policy rule description, and output corresponding to the original content, including: The numbered paragraph blocks are input into the policy rule extraction agent. The core sentence screening tool is used to identify the core sentences with rule characteristics. The agent is then used to extract specific rule elements from the core sentences and output them as standardized, element-clear policy rule expressions and corresponding original text numbers. The original text content is obtained from the paragraph block text according to the original text number, and the original text content corresponding to each policy rule description is obtained to form a mapping relationship between the rule and the original text.
[0012] Furthermore, a historical policy rule description knowledge base is constructed, and based on the standardized policy rule description and the original content, similar historical policy rule descriptions are searched from the historical policy rule description knowledge base, including: Extract the description information and corresponding identification ID of the historical power verification rules from the table of historical power verification rules to build a historical rule description knowledge base; Based on the policy rule descriptions extracted from policy documents and the corresponding original content, the similarity retrieval method is used to retrieve and obtain similar historical rule descriptions from the knowledge base, taking into account the similarity differences of different expressions.
[0013] Furthermore, a policy rule comparison agent is constructed, including: Design a policy rule comparison and analysis prompt template based on historical similar policy rule descriptions P C : ; Build a policy rule comparison agent based on the constructed policy rule comparison analysis prompt template and large language model A C : ; in, G Indicates the description of the set goal; S Indicates the recognition step prompts given to guide the large language model to think and judge; I Indicates important matters in the settings; r Represents the current policy rule description of the input, R S for r Retrieve similar historical policy rules; O C Indicates the output format of the policy rule comparison analysis task, which includes the analysis description of historical rules, the similarity judgment results of historical rules, the judgment thinking process, and the content of the change analysis results; E C This shows an example output of rule comparison analysis results.
[0014] Furthermore, we identify new and modified policy clauses and output structured change details. The process is as follows: ; ; In the above formula, and Respectively represent the description of policy rules r i The policy rule description is similar to a historical one. The policy rule comparison agent outputs the policy change type and change details analysis results. Change types include modification and addition. CR Indicates the comparison and analysis results of all rules; R Si Indicates that the current policy rule description retrieves similar historical policy rules.
[0015] Compared with the prior art, the present invention has the following technical effects: (1) The present invention designs a document content structured parsing method for extracting policy rules for electricity bill verification. It can read, parse and restructure policy documents in Word and PDF formats, effectively retain the original context and logical hierarchy information, and enhance the hierarchical structure representation method, thereby improving the large language model's ability to understand the document's semantics and structural logic. At the same time, the parsing results are optimized by performing block merging and other processing operations to avoid model misjudgment caused by context truncation or redundant content, thereby laying a corpus foundation for subsequent rule extraction and rule comparison.
[0016] (2) This paper designs a core statement recognition prompt template and a rule extraction and conversion prompt template, and constructs a policy rule extraction agent based on a large language model. It identifies core rule statements from the parsed input paragraph text, extracts rule elements, and converts them into structured policy rule descriptions, thus achieving intelligent conversion from policy documents to structured rules. This method significantly reduces the cost of manual intervention and effectively improves the accuracy and processing efficiency of rule extraction.
[0017] (3) The present invention introduces a collaborative mechanism based on vector semantic retrieval and policy comparison agent, which can automatically match historical similar policy rules after the new policy rules are generated; by designing a comparison analysis prompt template and constructing a policy rule comparison agent, it can analyze and compare the similarities and differences in the content between the new and old policy rules, accurately identify the change types such as additions and modifications and the change details, realize the effective inheritance and evolution between the new and old policy rules, and significantly improve the response efficiency of rule updates. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 It is a schematic diagram of the process of the present invention; Figure 2 This is a diagram showing the results of parsing electricity price-related policy documents in the experiment of the present invention; Figure 3 This is the result diagram of the core sentence recognition in the experiment of the present invention; Figure 4 This is the result diagram of policy rule extraction in the experiment of the present invention; Figure 5 This is a comparison diagram of the method of the present invention and a general large language model; Figure 6 This is a graph showing the results of the historical policy comparison and analysis in the experiment of the present invention; Figure 7 Shows the specific content of the core statement recognition prompt template; Figure 8 Shows the specific content of the rule extraction conversion prompt template; Figure 9 The specific content of the policy rule comparison analysis prompt is displayed. DETAILED DESCRIPTION
[0020] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose of the invention, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation methods, structures, features, and effects of the technical solutions proposed by the present invention. Specific features, structures, or characteristics in one or more embodiments may be combined in any suitable form. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention belongs.
[0021] This paper proposes a method for intelligent rule extraction and change comparison of policy documents for electricity bill verification. This method utilizes a multi-stage processing strategy, integrates historical policy rule description knowledge resources, and constructs a policy rule extraction agent and a policy rule comparison agent through a document parsing method. This creates a "file parsing-rule extraction-rule comparison" policy interpretation and rule extraction chain. This method achieves the intelligent transformation of documents from unstructured text to rule extraction and change identification, improving the accuracy of policy rule interpretation and shortening the response cycle for rule implementation.
[0022] In one embodiment of the present invention, referring to Figure 1 ,A policy document intelligent rule extraction and change comparison method for electricity fee verification,,including the following steps: Step 100: Parse the electricity fee-related policy document, retain the context hierarchy and logical structure information of the original electricity fee-related policy document during the parsing process, and optimize the parsed content; Step 200: Design a core sentence recognition prompt template and build a policy rule extraction agent to identify core sentences from the optimized content, extract element information related to the rules, convert it into a standardized policy rule description, and output it in correspondence with the original content; Step 300: Construct a historical policy rule description knowledge base, and based on the standardized policy rule description and the original content, search for historically similar policy rule descriptions from the historical policy rule description knowledge base, and then construct a policy rule comparison agent to perform deep semantic comparison and change analysis on the current standardized policy rule description and historically similar policy rule descriptions, identify new and modified policy clauses, and output structured change details.
[0023] The following is a detailed explanation of each of the above steps: Step 100: Parse the electricity fee-related policy document, retain the context hierarchy and logical structure information of the original electricity fee-related policy document during the parsing process, and optimize the parsed content.
[0024] Unlike conventional large language models that segment input text into fixed lengths, this invention designs a method for parsing the content and structure of electricity-related policy documents. This method can parse the content of different types of electricity-related policy documents, retaining the contextual hierarchy and logical structure information of the original electricity-related policy documents during the parsing process, and processing the parsed results to ensure that the final obtained text block content has good readability and structural integrity, so that the large language model can accurately and completely understand its content. The specific steps are as follows: Step 110: Read the content of the electricity fee-related policy document, design a document content and structure parsing method, parse the electricity fee-related policy document, and retain the context hierarchy and logical structure information of the original electricity fee-related policy document during the parsing process.
[0025] Electricity rate-related policy documents are typically stored in Word or PDF formats. This embodiment designs differentiated parsing solutions for these two formats to ensure that electricity rate-related policy documents can be accurately read and structured, laying the foundation for subsequent agent-based content analysis and rule extraction.
[0026] For Word format documents, a parsing module based on python-docx is used to identify and disassemble the text content structure of Word format documents by parsing the style attributes of Word format documents, such as heading level, paragraph indentation, body content, numbered lists, etc. The original heading level and numbering structure of the Word format document are retained in the recognition result, and different type identifiers are assigned to the title, body paragraph, numbering structure and other contents. The reading results are stored in the order of the original Word format document. The result is expressed as: ; In the above formula, Represents all the content parsed in the Word format document. type m Indicates the identifier of the mth type, text m Indicates the m Types of text content.
[0027] For PDF documents, since PDF documents usually lack semantic tags when they are directly read, and there are PDF contents in the form of pictures, this paper uses the PaddleOCR tool to align and recognize them, and uses layout analysis technology to semantically segment the page elements of each page, obtaining the spatial position, text content and text type of each page text block, such as text, title, table, etc., and finally obtains the recognition results of the entire PDF document and stores them in the order of the original PDF document, which is expressed as: ; ; In the above formula, C p Represents all the parsed content in the PDF format document, p n Indicates the n The parsed content of the page, region m Indicates the position of the mth type of text content on the page.
[0028] Step 120: Optimize the parsed content, including title splicing, block merging, and numbering to obtain optimized content, i.e., numbered paragraph blocks.
[0029] In order to ensure that the large language model can efficiently and accurately understand the content when analyzing electricity price-related policy documents, and at the same time avoid affecting the extraction and generation effects due to context window limitations or redundant information interference, the present invention processes and optimizes the document content after parsing in step 110.
[0030] First, for C p or C w For each body paragraph, its title content and type are spliced into the body paragraph, such as "First-level title: xx<body paragraph content>", to form a new body paragraph to enhance the theme information of the body paragraph.
[0031] Secondly, the original electricity fee-related policy document is separated into new text paragraphs, and the length of each paragraph is determined. If the lengths of adjacent paragraphs are less than a preset threshold, it is determined whether the length of the adjacent paragraphs after merging is less than the set maximum block length threshold (set to 512 characters in the present invention). If the length of the adjacent paragraph blocks after merging is still less than the set maximum block length threshold, the adjacent paragraph blocks are merged to reduce the number of requests during model processing and avoid comprehension deviations caused by information fragmentation.
[0032] Among them, the results after block and merge C Expressed as: ; In the above formula, c l Represents the merged l A paragraph block.
[0033] Finally, each paragraph block is segmented into sentences, and each sentence is numbered and then merged into paragraph text, that is, numbered paragraph blocks, so that the core rule sentences can be identified later. Expressed as: ; In the above formula, c l ' The first number after the representative number l A paragraph block.
[0034] Step 200: Design a core sentence recognition prompt template, build a policy rule extraction agent, identify core sentences from the optimized content, extract element information related to the rules, convert it into a standardized policy rule description, and output it corresponding to the original content.
[0035] After parsing and optimizing the content of electricity fee-related policy documents, the present invention designs a core sentence recognition prompt template and a rule extraction and conversion prompt template, and constructs a policy rule extraction intelligent agent. Combining semantic analysis with rule expression features, the present invention guides the large model to understand and filter the paragraph block content sentence by sentence, identify the core sentences, ensure the accuracy and purity of the rule extraction, and then guides the large language model to extract the element information related to the rule from the identified core sentences, and further convert it into a standardized and readable policy rule description. At the same time, the original text is obtained based on the sentence number to form a mapping between the rule and the original text. The specific steps are as follows: Step 210: Design a core sentence recognition prompt template. By setting task objectives, important matters, and output formats, guide the large language model to accurately identify core sentences with regular properties in paragraph blocks.
[0036] Electricity rate policy documents contain a large amount of descriptive and background content, which can affect model extraction accuracy. Therefore, a dedicated core sentence identification prompt is required to guide and constrain the large language model to accurately identify core sentences with rule-based characteristics. By setting guidance steps and related reminders in the core sentence identification prompt, the large language model can quickly identify key information, analyze each sentence one by one, determine whether it contains the core content of the policy rules, and exclude irrelevant sentences.
[0037] The core statement recognition prompt template is defined as P R , expressed as: ; In the above formula, G Indicates the description of the set goal; Represents a numbered block of paragraph text entered; S Indicates the recognition step prompts given to guide the large language model to think and judge; I Indicates important matters that need to be paid special attention to; O R The output format of the core sentence recognition task is in json format, including the number of each sentence, the judgment result and the thinking process. Figure 7 .
[0038] Step 220: Create a core statement screening tool based on the core statement identification prompt template.
[0039] In conjunction with the core sentence identification prompt template constructed in step 210, a core sentence screening tool is further constructed to automatically filter non-regular sentences and accurately extract regular sentences from paragraph blocks. Based on the output of the large language model, the core sentence screening tool extracts the judgment results corresponding to each numbered identifier, then filters out sentences judged to be non-core, retaining only the content marked as key core sentences. This ensures that the text entering the subsequent extraction process is closely related to the policy content and clearly expressed, thus ensuring the text quality of the rule extraction process.
[0040] Core sentence filtering tool T The structure can be expressed as: ; in, P R Indicates the core statement recognition Prompt template constructed in step 210, M Represents a large language model, F Represents the sentence filtering process.
[0041] Step 230: Based on the filtered core statements, design a rule extraction conversion prompt template.
[0042] To accurately extract rule content from core statements, a rule extraction and conversion prompt template was designed to guide the large language model to extract and convert identified core statements into standardized, clearly defined policy rule expressions. This template combines the language characteristics of electricity rate-related policy documents with the conventions of rule expression, providing task guidance centered around the structure of rule content. Through a three-stage guidance process of element extraction, logical reconstruction, and standardized output, the large language model is guided to extract complete rule content and output clear, easy-to-understand rules. It also outputs the statement number of the original electricity rate-related policy document corresponding to the rule, allowing for access to the original policy document for comparison and review.
[0043] The rule extraction conversion prompt template is defined as P E , expressed as: ; in, G 、 S 、 I The meaning is the same as the core statement identification Prompt template in step 210, c f The paragraph text is filtered by the tool constructed in step 220. O E Indicates the output format of the rule extraction and transformation task, which includes the rule source, that is, the original document number identifier of the rule, the rule name, and the rule transformation result content; E X This is an example of rule extraction results, provided for reference by the large language model. For details on the rule extraction conversion prompt template, see Figure 8 .
[0044] Step 240: Combine the core sentence screening tool, the rule extraction conversion prompt template and the large language model to build a policy rule extraction agent.
[0045] Combine the rules constructed in step 230 to extract and transform the prompt template P E 、Tools built in step 220 T , and large language models M , build a policy rule extraction agent to automate the rule extraction process. A E The structure is represented as: ; in, A numbered block of paragraph text representing the input to the policy rule extraction agent.
[0046] The policy rule extraction agent converts the prompt template into a guide and calls the core statement screening tool through rule extraction T , using a large language model M Complete the screening of core statements, extraction of rule elements and standardized expression to form easy-to-understand rule expressions.
[0047] Step 250: Based on the numbered paragraph blocks, extract the element information related to the policy rules, convert it into a standardized policy rule description, and obtain the corresponding original content to form a mapping relationship between the rules and the original text.
[0048] First, for the numbered paragraph block text set in step 120 , and the numbered paragraph blocks c i ' Input them into the policy rule extraction agent in sequence to obtain the numbered paragraph blocks c i ' The standardized rule description and original number set extracted and transformed from the is expressed as: ; ; In the above formula, After the numbered paragraph block is input into the policy rule extraction agent, the rule description and the set of original text numbers to which it belongs are obtained; Indicates the first paragraph extracted from the numbered paragraph block. k Rule description; Indicates the k The original text number corresponding to the rule description. Since a rule description may come from multiple sentences, Represented as a set, possibly containing one or more numbers.
[0049] Then, according to the original text number, the original text content is obtained from the paragraph block text to obtain the text corresponding to each rule description. For example, for the original text number , expressed as: ; ; In the above formula, Indicates based on From the numbered paragraph block c i ' The complete text obtained from The corresponding text content is spliced together; Represents a collection of mappings between policy rule text and source text content.
[0050] Finally, the results of all paragraph block text output are integrated to obtain the policy rules and original text mapping set extracted from the entire electricity fee-related policy document. R Expressed as: ; In the above formula, rq Indicates the first q Policy rule descriptions, tq Indicates the first q The original content corresponding to the rules.
[0051] For example, i Rules ri The content is: "Electricity price for industrial and commercial users = on-grid electricity price + line loss cost in the on-grid link + transmission and distribution price + ..."
[0052] No. i Original content of the rules ti for: "The electricity price for industrial and commercial users is composed of the on-grid electricity price, line loss costs in the on-grid link, transmission and distribution prices, and system operating costs..."
[0053] Step 300: Construct a historical policy rule description knowledge base. Based on the standardized policy rule description and the original content, use a similarity retrieval method to search for historically similar policy rule descriptions from the historical policy rule description knowledge base. Then, by constructing a policy rule comparison agent, perform in-depth semantic comparison and change analysis on the current standardized policy rule description and the historically similar policy rule description, identify new and modified policy clauses, and output structured change details.
[0054] The electricity fee verification work is carried out based on relevant electricity fee-related policy documents, which are constantly evolving and updated. If the differences between the old and new policy documents cannot be identified in a timely manner and the rules cannot be updated, the implementation of the electricity fee verification work will be directly affected. In order to achieve effective inheritance and change analysis between the old and new policy rules, the present invention first establishes a historical policy rule description knowledge base, retrieves historical similar policy rule descriptions based on semantic similarity, constructs a policy rule comparison agent to achieve intelligent matching and change identification between current rules and historical rules, and outputs structured policy change comparison analysis results as an important basis for updating verification rules.
[0055] Step 310: Build a historical policy rule description knowledge base.
[0056] As an example, this step 310 may include: Step 311: extract the description information and corresponding identifier of the historical power verification rule from the table of historical power verification rules to obtain a historical policy rule record set.
[0057] Extract the description information and corresponding unique identifier of the historical power verification rules from the table that specifically stores the historical power verification rules in the power business database id , forming a complete set of historical policy rule records R t , expressed as: ; in, desc i Indicates the i The text description of the historical policy rule.
[0058] To improve semantic consistency and text processing efficiency, all description information will be standardized, including removing redundant punctuation and removing leading and trailing whitespace characters.
[0059] Step 312: Use the pre-trained vector embedding model to perform semantic encoding on the historical policy rule record set to obtain a historical policy rule description vector, which is stored in the historical policy rule description knowledge base.
[0060] Use the pre-trained vector embedding model to semantically encode the historical policy rule record set. Specifically, the text description content of each historical policy rule is encoded into desc i Input to the pre-trained vector embedding model, represented as: ; In the above formula, V i represents the historical policy rule description vector, BGE Indicates the pre-trained model used.
[0061] In this way, the textual descriptions of all historical policy rules are converted into multidimensional policy rule description vectors, which can be used for text retrieval. Subsequently, the policy rule description vectors are stored in a vector database (such as FAISS or ChromaDB) and indexed to support subsequent similarity retrieval.
[0062] Step 320: Based on the standardized policy rule description and the original content, a similarity retrieval method is used to search for historically similar policy rule descriptions stored in a historical policy rule description knowledge base.
[0063] In order to improve the accuracy and semantic coverage of historical similar policy rule retrieval, the present invention searches for historical policy rule descriptions based on the extracted policy rule descriptions and the corresponding original texts, taking into account the similarity calculation differences brought about by different expressions.
[0064] Specifically, for any rule and original content in the policy rule and original content mapping set R obtained in step 250, first convert it into a vector form in the same manner as step 312, and express it as: ; ; in, Indicates original content t i The embedding vector of Indicates policy rule description r i The embedding vector of .
[0065] Secondly, based on the cosine similarity, we calculate 、 The similarity between each historical policy rule description vector in the historical policy rule description knowledge base stored in step 312 is calculated, and the similarity score is used to extract the historical policy rule description vector. and The K most similar vectors.
[0066] Finally, get the and The historical rule text corresponding to the similarity vector is unified as the policy rule description r i Similar historical rules are expressed as: ; in, Represents a description of policy rules r i The most similar historical rules retrieved, Represents a description of policy rules r i The most similar historical rules retrieved, Indicates policy rule description r i A set of similar historical rules.
[0067] Step 330: Based on the historical similar policy rule descriptions, design a policy rule comparison and analysis prompt template.
[0068] In order to identify the differences and classify the changes between the current policy rules and similar historical policy rules, a policy rule comparison analysis prompt template is designed to guide the large language model to conduct a comparative analysis of the input similar historical policy rules on the basis of understanding the semantics of the rules, identify the changes and output structured comparison results. Three similarity judgment results are designed, including complete consistency, high similarity and dissimilarity, which correspond to the three types of rule changes, namely no change, modification and addition, and analyze the specific conditions or content of the modification. The policy rule comparison analysis prompt template is defined as P C , expressed as: ; in, G 、 S 、 I The meaning is the same as the Prompt template in step 230. r Represents the current policy rule description of the input, R S for r Retrieve similar historical policy rules; O C Indicates the output format of the policy rule comparison analysis task, which includes the analysis description of historical rules, the similarity judgment results of historical rules, the judgment thinking process, and the change analysis results. E C This shows an example of the output of the rule comparison analysis. Figure 9 .
[0069] Step 340: Combine the policy rule comparison analysis prompt template and the large language model to build a policy rule comparison agent.
[0070] Combined with the policy rule comparison analysis prompt template constructed in step 330 P C and large language models M , build a policy rule comparison agent to realize the automation process of rule comparison analysis. A C The structure is represented as: ; in, r and R S The meaning of is the same as described in step 330.
[0071] Step 350: Input the historical similar policy rule description into the policy rule comparison agent, obtain deep semantic comparison and change analysis with similar historical rules, identify new and modified policy clauses, and output structured change details.
[0072] For the policy rule and original text mapping set R obtained in step 250, the method described in step 320 is applied to each standardized policy rule description and original text content to obtain similar historical policy rules. These are then sequentially input into the policy rule comparison agent to obtain the comparison analysis results with the historical policies. Ultimately, the change types and change details of all policy rules are obtained. The process is represented as follows: ; ; In the above formula, and Respectively represent the description of policy rules r i The policy rule comparison agent outputs the policy change type and change details analysis results, which are similar to a historical policy rule description. The change type includes modification and addition. CR Indicates the comparison and analysis results of all rules in the policy file. For example, The output is 2, which means that the rule is a modification of the historical rule. The specific differences are included, such as adding "xx" condition to the rule, or changing "xx" condition to "yy" condition.
[0073] Method effect display: The present invention takes part of the content of the policy document related to "transmission and distribution prices and the implementation of power grid enterprises' agency power purchase" in a certain region as an example to demonstrate the effect of the present invention.
[0074] The result after parsing the policy document in step 100 is as follows Figure 2 As shown, it can be seen that after parsing, the original policy document is divided into paragraphs of moderate length, and the title information and sentence number information are added to them, retaining the original hierarchical structure.
[0075] Figure 3 This is the recognition result of core sentence recognition. It can be seen that based on the prompt of the core sentence recognition prompt, the large language model recognizes the input paragraph text and determines that the second sentence in the input is irrelevant. After recognition, only the sentence content related to the policy rules is retained.
[0076] Figure 4This is the result of policy rule extraction. It can be seen that for the input filtered text, after the policy rule comparison analysis prompt, two policy rules were successfully extracted, and the original text statement was converted into a standardized and easy-to-understand rule description.
[0077] Figure 5 The rule extraction method of the present invention is compared with the effect of directly using a general large language model, that is, directly inputting the original document into the large language model, and directly prompting it to extract rules from the data and output the extracted rule content. Figure 5 From the comparison, it can be seen that within the same input range, the rule expression extracted directly using the general large language model is relatively generalized, basically a repetition of the original content, and some conditional content is omitted or inaccurate, while the results of the present invention are relatively detailed, clear and more accurate.
[0078] Figure 6 The results of the comparative analysis with historical policy rules are displayed, including the input current policy rules, the retrieved set of historical similar policy rules, and the output results of the large language model. It can be seen that through the comparative analysis method of the present invention, it is successfully determined that this rule has modified the historical rules, and the new rule supplements the relevant description of "electricity capacity range and optional electricity price system".
[0079] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for extracting intelligent rules and comparing changes in policy documents for electricity fee verification, characterized by: The following steps are involved: Parse electricity fee-related policy documents, retain the contextual hierarchy and logical structure information of the original electricity fee-related policy documents during the parsing process, and optimize the parsed content; Design a core sentence recognition prompt template and build a policy rule extraction agent to identify core sentences from the optimized content, extract rule-related elements, convert them into standardized policy rule descriptions, and output them in correspondence with the original content. Construct a historical policy rule description knowledge base, and based on the standardized policy rule description and the original content, search for historically similar policy rule descriptions from the historical policy rule description knowledge base. Then, by constructing a policy rule comparison agent, conduct in-depth semantic comparison and change analysis on the current standardized policy rule description and historically similar policy rule descriptions, identify new and modified policy clauses, and output structured change details.
2. The method for extracting and comparing policy documents for electricity fee verification according to claim 1 is characterized in that: Parse electricity fee-related policy documents, including: Read the content of the electricity fee-related policy document, design a document content and structure parsing method, and parse the electricity fee-related policy document; wherein the design document content and structure parsing method includes: For Word documents, we use a parsing module based on python-docx to identify and decompose the text content structure of Word documents. The recognition results retain the original heading level and numbering structure of the Word documents, assign different type identifiers to the text content, and store the reading results in the order of the original Word documents as a collection containing document style attributes and corresponding content. For PDF documents, the PaddleOCR tool is used for alignment and recognition, and the page elements are semantically segmented using layout analysis technology to obtain the spatial position, text content and text type of each page's text blocks, and stored as a parsed content collection in the order of the original PDF document.
3. The method for extracting and comparing policy documents for electricity fee verification according to claim 1 is characterized in that: Optimize the parsed content, including: For each body paragraph in the parsed content, its title content and type are spliced into the body paragraph to form a new body paragraph. Paragraphs longer than the preset length are divided into blocks according to the maximum block length; Each paragraph block is divided into sentences, and each sentence is numbered and then merged into paragraph text, that is, the numbered paragraph blocks.
4. The method for extracting and comparing policy documents for electricity fee verification according to claim 3 is characterized in that: Design the core statement recognition prompt template, including: The core statement recognition prompt template is defined as P R , expressed as: ; In the above formula, G Indicates the description of the set goal; Represents a numbered block of paragraph text entered; S Indicates the recognition step prompts given to guide the large language model to think and judge; I Indicates important matters that need to be paid special attention to; O R Indicates the output format of the core sentence recognition task, which is in JSON format and contains the number identifier, judgment result, and thinking process of each sentence.
5. The method for extracting and comparing policy documents with intelligent rules for electricity fee verification according to claim 4 is characterized in that: Build a policy rule extraction agent, including: Create a core statement screening tool based on the core statement identification prompt template T : ; Based on the filtered core statements, design rule extraction and conversion prompt template P E : ; Combine core sentence screening tools, rule extraction conversion prompt templates and large language models to build a policy rule extraction agent A E : ; in, M Represents a large language model; F Represents the sentence filtering process; c f Indicates the paragraph text after being filtered by the core sentence filtering tool; O E Indicates the output format of the rule extraction and transformation task; E X Indicates an example of rule extraction results, which is provided to the large language model for reference.
6. The method for extracting and comparing changes in policy documents for electricity fee verification according to claim 5 is characterized in that: Extract rule-related element information, convert it into a standardized policy rule description, and output it in correspondence with the original content, including: The numbered paragraph blocks are input into the policy rule extraction agent. The core sentence screening tool is used to identify the core sentences with rule characteristics. The agent is then used to extract specific rule elements from the core sentences and output them as standardized, element-clear policy rule expressions and corresponding original text numbers. The original text content is obtained from the paragraph block text according to the original text number, and the original text content corresponding to each policy rule description is obtained to form a mapping relationship between the rule and the original text.
7. The method for extracting and comparing policy documents intelligent rules and changes for electricity fee verification according to claim 1 is characterized in that: Construct a historical policy rule description knowledge base, and search for similar historical policy rule descriptions from the historical policy rule description knowledge base based on the standardized policy rule descriptions and the original content, including: Extract the description information and corresponding identifier of the historical power verification rules from the table of historical power verification rules id ,construct a knowledge base of historical rule description; Based on the policy rule descriptions extracted from policy documents and the corresponding original content, the similarity retrieval method is used to retrieve and obtain similar historical rule descriptions from the knowledge base, taking into account the similarity differences of different expressions.
8. The method for extracting and comparing policy documents intelligent rules and changes for electricity fee verification according to claim 7 is characterized in that: Constructing a policy rule comparison agent, including: Design a policy rule comparison and analysis prompt template based on historical similar policy rule descriptions P C : ; Build a policy rule comparison agent based on the constructed policy rule comparison analysis prompt template and large language model A C : ; in, G Indicates the description of the set goal; S Indicates the recognition step prompts given to guide the large language model to think and judge; I Indicates important matters in the settings; r Represents the current policy rule description of the input, R S for r Retrieve similar historical policy rules; O C Indicates the output format of the policy rule comparison analysis task, which includes the analysis description of historical rules, the similarity judgment results of historical rules, the judgment thinking process, and the content of the change analysis results; E C This shows an example output of rule comparison analysis results.
9. The method for extracting and comparing policy documents for electricity fee verification according to claim 8 is characterized in that: Identify new and modified policy clauses and output structured change details. The process is as follows: ; ; In the above formula, and Respectively represent the description of policy rules r i The policy rule description is similar to a historical one. The policy rule comparison agent outputs the policy change type and change details analysis results. Change types include modification and addition. CR Indicates the comparison and analysis results of all rules; R Si Indicates that the current policy rule description retrieves similar historical policy rules.
Citation Information
Patent Citations
Statistical method for key policies of electricity price
CN112182248A
Policy text denoising and associated item extraction method and system based on large model
CN118820403A
Power field SQL intelligent agent construction method based on KMDI chain
CN119166662A
Electricity price policy knowledge base construction system and method based on artificial intelligence
CN119903904A
Policy mining and intelligent interaction platform based on AI large model
CN119963001A
Cited By
Hierarchical knowledge network construction and retrieval method for intelligent electric charge questions and answers
CN120744073A
Intelligent knowledge extraction and structuring method for modern assembly type historical literature
CN121580967A
Method and system for extracting ecological environment access list rule of intelligent agent
CN121615756A
Full-process automatic multi-type rule extraction and verification method
CN122242709A
A multi-type rule extraction and verification method with full-process automation
CN122242709B