A method and apparatus for automatically generating electricity marketing volume and fee reports.
By constructing a lightweight semantic foundation and dynamic query generation technology, the problems of template rigidity and inaccurate understanding of professional terms in the generation of electricity marketing reports have been solved, enabling fast, agile, and personalized queries of electricity marketing volume and fee reports, and improving query accuracy and data analysis efficiency.
Patent Information
- Application Number
- CN202611322273.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2046-08-28
AI Technical Summary
Existing technologies in the power marketing field suffer from problems such as fixed report generation templates, inconsistent definitions, delayed response, inaccurate understanding of professional terminology, lack of business rules, and weak ability to interpret complex intents, making it difficult to meet the needs of highly complex queries.
A lightweight semantic foundation is constructed, which obtains the mapping relationship between business terms and physical fields through metadata parsing and semantic matching. Combined with a lightweight business semantic network and field combination rules, structured query statements are dynamically generated. An attention-enhanced bidirectional LSTM time series analysis model is used to quantify attribution, so as to realize the rapid and agile generation of electricity marketing volume and fee reports.
It enables fast, agile, and personalized queries of electricity marketing volume and fee reports, improves the accuracy of complex business queries and data analysis efficiency, reduces the cost of building and maintaining a domain knowledge base, and supports business personnel in customizing report styles and adjusting statistical dimensions.
Smart Images

Figure CN122819167B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interdisciplinary technology of electricity marketing informatization and artificial intelligence, and in particular to a method and apparatus for automatically generating electricity marketing volume and fee reports. Background Technology
[0002] As the digital transformation of electricity marketing continues to deepen, the scale of marketing volume and fee business data is growing rapidly, and the analysis dimensions are becoming increasingly complex. The demand for report generation is showing characteristics of high frequency, diversification, and personalization. The traditional report generation model mainly relies on fixed templates and manual development, which has obvious shortcomings: on the one hand, report templates are scattered, vary greatly from city to city, have low reuse rates, and are difficult to adapt to different business scenarios; on the other hand, the power industry has a lot of professional terminology, complex statistical standards, and heterogeneous data across databases, making it difficult for business personnel to complete flexible queries directly through the system. Report development requires technical personnel, resulting in high communication costs and long response cycles, which seriously restricts the efficiency of marketing data services.
[0003] Natural Language to SQL (NL2SQL) technology has become an important direction for intelligent data querying, with extensive research and product development both domestically and internationally. While international models such as SQL-PaLM and DIN-SQL perform well in general domains, they lack the ability to map to power industry terminology and have insufficient accuracy in recognizing industry-specific concepts such as "electricity bill collection rate," "line loss rate," and "peak electricity price," resulting in SQL accuracy rates below 60%, making them unsuitable for complex power marketing queries. Domestic tools like Chat2DB and OFA support basic queries but lack power business rule constraints, making it unable to parse multi-level intents such as "attribution of sudden increases in industrial and commercial arrears" and "time-series analysis of transformer line losses." This leads to missing dimensions, logical errors, and a lack of support for in-depth analysis needs such as time-series trends and fluctuation attribution, making it difficult to meet the high-complexity report generation scenarios in the power industry.
[0004] In summary, existing NL2SQL technology has core shortcomings in the power vertical industry, such as inaccurate understanding of terminology, lack of business rules, and weak ability to parse complex intents. Meanwhile, traditional reporting models face pain points such as fixed templates, inconsistent definitions, and delayed response. There is an urgent need to build a lightweight, highly adaptable, and strongly constrained intelligent report generation technology to support agile, accurate, and personalized queries of power marketing data. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide an automatic generation method and device for electricity marketing volume and fee reports. By constructing a lightweight semantic foundation, a rule-based dynamic generation technology with strong constraints, and a configuration-driven interaction paradigm, the invention enables the rapid and agile generation of electricity marketing volume and fee reports.
[0006] To achieve the above objectives, the present invention is implemented using the following technical solution:
[0007] In a first aspect, the present invention provides a method for automatically generating electricity marketing volume and fee reports, comprising:
[0008] The mapping relationship between business terms and physical fields is obtained from the marketing database through metadata parsing and semantic matching, and a lightweight business semantic network and field combination rules are constructed.
[0009] The system analyzes the user's natural language query intent, integrates retrieval enhancement generation technology, injects the lightweight business semantic network and the field combination rules into the dynamic prompt project, and adaptively transforms the user's natural language query intent into structured query statements and visual configuration descriptions.
[0010] The structured query statement is executed to obtain the target data, a standard rendering description is generated based on the visualization configuration description, and a report interface corresponding to the target data is generated through a general rendering engine.
[0011] Identify the fluctuations in the target data and quantify the causes, then overlay the analysis results onto the report interface.
[0012] Optionally, the metadata parsing of the marketing database includes:
[0013] Extract the table name, physical fields, physical field comments, and primary and foreign key relationships from the data table metadata in the marketing database;
[0014] The semantic matching process for obtaining the mapping relationship between business terms and physical fields includes:
[0015] For business terms in the marketing database, a domain-pre-trained language model fine-tuned with power industry corpus is invoked to annotate the business terms and the physical field as corresponding semantic vectors. Bidirectional matching is then performed using cosine similarity, as shown in the following expression:
[0016] ;
[0017] In the formula, These are semantic vectors for business terms and physical field annotations, respectively. for Cosine similarity;
[0018] The physical field corresponding to the physical field annotation with the highest cosine similarity value and the similarity value above the similarity threshold is selected to form a mapping relationship with the business term.
[0019] Optionally, constructing the lightweight business semantic network includes:
[0020] Based on the mapping relationship, the primary and foreign key relationships between data tables are extracted as network association edges to construct a lightweight business semantic network.
[0021] The lightweight business semantic network adopts a triple structure, with the format being business term-belongs-physical field;
[0022] The rules for combining generated fields include:
[0023] Based on the integrity of business logic, formulate business production constraint rules based on a first-order logical architecture;
[0024] When a user's natural language query intent is detected to contain keywords related to a specific business, the corresponding business production constraint rules are automatically triggered.
[0025] Optionally, the dynamic prompting project includes role definition, database constraints, business rule constraints, and small sample guidance;
[0026] Role definition: The identity of the large language model operator is defined as a power marketing data analysis specialist.
[0027] Database constraints, based on the lightweight business semantic network, only push database table structure information related to the user's query requirements to the large language model;
[0028] Business rule constraints convert the corresponding field combination rules into natural language constraint instructions, clearly defining the essential query fields, statistical dimensions, and filtering conditions for various business queries;
[0029] Small sample guidance uses a dense retrieval algorithm to retrieve the historical high-quality samples with the highest semantic similarity and automatically fills them into the prompt words to complete the example guidance;
[0030] In the dynamic suggestion project, a syntax verification and iterative correction mechanism is used to ensure that the query statements are compliant and the business logic is complete.
[0031] Optionally, identifying and quantifying the attribution of the target data fluctuations includes:
[0032] The influence factor contribution of the target data is quantified by an attention-enhanced bidirectional LSTM temporal analysis model. The attention-enhanced bidirectional LSTM temporal analysis model is constructed by introducing a bidirectional temporal coding structure, a multi-head temporal attention mechanism, a heterogeneous feature-gated fusion encoder and a residual jump connection on the basis of the LSTM model.
[0033] The quantitative attribution includes:
[0034] Identification and classification of impact factors;
[0035] Based on the attention-enhanced bidirectional LSTM time series analysis model, predict the baseline of business indicators for target data under no abnormal disturbances;
[0036] The contribution of the influencing factors is quantified based on Shapley value decomposition, and the contribution is normalized and its significance is verified.
[0037] The step of overlaying the analysis results onto the report interface includes:
[0038] Attribution data structure generation encodes the quantified attribution results into a standardized attribution data structure;
[0039] Mapping attribution results to visualization elements: Establishing the mapping relationship between each influencing factor in the attribution data structure and the visualization elements in the report;
[0040] Interactive annotation layer rendering and attribution drill-down linkage.
[0041] Optionally, it also includes closed-loop continuous optimization, wherein the closed-loop continuous optimization includes:
[0042] Collect user feedback information. After cleaning and reviewing the feedback information, supplement the corrected query samples in the feedback information into the retrieval enhancement knowledge base for periodic fine-tuning of the domain pre-trained language model. Analyze the common dimension missing or logical errors reflected in the feedback information to generate suggestions for adding or modifying rules. After review and confirmation by the administrator, update the lightweight business semantic network and field combination rules.
[0043] Secondly, the present invention provides an automatic generation device for electricity marketing volume and fee reports, comprising:
[0044] The mapping system construction module is configured to obtain the mapping relationship between business terms and physical fields from the marketing database through metadata parsing and semantic matching, build a lightweight business semantic network and generate field combination rules;
[0045] The dynamic query generation module is configured to parse the user's natural language query intent, integrate retrieval enhancement generation technology, inject the lightweight business semantic network and the field combination rules into the dynamic prompt project, and adaptively transform the user's natural language query intent into structured query statements and visual configuration descriptions.
[0046] The report generation module is configured to execute the structured query statement to obtain target data, generate a standard rendering description based on the visualization configuration description, and generate the report interface corresponding to the target data through a general rendering engine.
[0047] The intelligent attribution embedding module is configured to identify fluctuations in the target data and quantify the attribution, and then overlay the analysis results onto the report interface.
[0048] Thirdly, the present invention provides an electronic device, including a processor and a storage medium;
[0049] The storage medium is used to store instructions;
[0050] The processor is configured to operate according to the instructions to perform the steps according to the method described above.
[0051] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0052] Fifthly, the present invention provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0053] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:
[0054] This invention provides a method and apparatus for automatically generating electricity marketing volume and fee reports, which has the following technical features:
[0055] 1) Building a lightweight semantic foundation for power business, breaking through the barriers of vertical domain knowledge modeling. This invention adopts an automated modeling method that combines automatic metadata parsing with semantic similarity matching, replacing the traditional manual annotation mode. This effectively breaks down the language barriers between general large models and professional power marketing business, and significantly reduces the cost of building and maintaining the domain knowledge base.
[0056] 2) Employing a rule-based dynamic query generation mode significantly improves the accuracy of complex business queries. This invention integrates first-order logical business constraint rules into the dynamic suggestion engineering of large models, coupled with syntax tree compliance verification and iterative correction mechanisms, effectively suppressing the semantic illusion problem of large language models and comprehensively improving the accuracy of query statement generation in scenarios such as multi-dimensional combined statistics and complex business accounting.
[0057] 3) Enable configurable intelligent interaction to meet the needs of business personnel for autonomous and flexible data use. Based on a structured configuration description and declarative rendering architecture and a front-end state-driven interaction mode, a low-code, lightweight reporting system is built. Business personnel can customize report styles and adjust statistical dimensions without needing programming or database knowledge. Combined with drill-down analysis and intelligent data attribution functions, this effectively improves the efficiency of power marketing data analysis. Attached Figure Description
[0058] Figure 1 This is a flowchart illustrating the automatic generation method for electricity marketing volume and fee reports provided in an embodiment of the present invention. Detailed Implementation
[0059] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.
[0060] Example 1
[0061] like Figure 1 As shown in the figure, this embodiment of the invention provides a method for automatically generating electricity marketing volume and fee reports, including the following steps:
[0062] Step S1: Obtain the mapping relationship between business terms and physical fields in the marketing database through metadata parsing and semantic matching, construct a lightweight business semantic network and generate field combination rules.
[0063] Step S1.1, parsing the marketing database through metadata includes:
[0064] Extract table names, physical fields, physical field comments, and primary and foreign key relationships from the metadata of the data tables in the marketing database;
[0065] Step S1.2, semantic matching to obtain the mapping relationship between business terms and physical fields includes:
[0066] For business terms in the marketing database, a domain-pre-trained language model fine-tuned with power industry corpus is invoked to output business terms and physical field annotations as corresponding semantic vectors. Bidirectional matching is then performed using cosine similarity, as shown in the following expression:
[0067] ;
[0068] In the formula, These are semantic vectors for business terms and physical field annotations, respectively. for Cosine similarity;
[0069] The physical field annotations with the highest cosine similarity scores above the similarity threshold are selected, and the corresponding physical fields and business terms are mapped to each other.
[0070] Step S1.3, constructing a lightweight business semantic network includes:
[0071] Based on the mapping relationship, the primary and foreign key relationships between data tables are extracted as network association edges to construct a lightweight business semantic network.
[0072] The lightweight business semantic network adopts a triple structure, with the format being business term-belongs-physical field;
[0073] Step S1.4, generating field combination rules includes:
[0074] Based on the integrity of business logic, formulate business production constraint rules based on a first-order logical architecture;
[0075] When a user's natural language query intent is detected to contain keywords related to a specific business, the corresponding business production constraint rules are automatically triggered.
[0076] Step S1 aims to address the problem that general large models lack expertise in the field of electricity marketing and cannot understand the underlying database structure, by building a low-cost, highly adaptable domain semantic foundation through an automated process.
[0077] Based on the marketing business system of a power company, this paper identifies core report generation scenarios such as electricity bill collection analysis, electricity price fluctuation monitoring, and customer arrears risk assessment. It clarifies the required business thesaurus (e.g., "electricity bill collection rate," "large industrial customers," "peak-valley electricity price"), data indicator configuration information (e.g., electricity sales, line loss rate, average electricity price), report template definitions, and visualization models for these scenarios. Existing marketing knowledge base resources are reused as the starting point for semantic mapping.
[0078] The system automatically connects to the power marketing database via JDBC interface, collecting metadata from core data tables including the "Customer Information Table" (T_CUSTOMER_INFO), "Electricity Bill Table" (T_BILL_DETAIL), and "Electricity Consumption Data Table" (T_ENERGY_CONSUMPTION). It accurately extracts table names, field names, primary and foreign key relationships, and field comments. For example, the extracted comment for the physical field CUST_TYPE is "Customer Classification (1-Large Industrial, 2-General Industrial and Commercial)".
[0079] For the business term "electricity bill collection rate," the system calls the BERT-base-chinese pre-trained model, which has been fine-tuned and optimized using a massive corpus of electricity industry terminology, to encode it into a semantic vector. At the same time, the comments for relevant fields in the database (such as RECOVERY_RATE and PAYMENT_STATUS) are also encoded as vectors. Semantic vectors and The vectors were obtained separately using a BERT model with shared weights and fine-tuned for the electricity corpus, with a vector dimension of 768. The cosine similarity between the two vectors was calculated.
[0080] The similarity matching threshold was set to 0.85. The calculated similarity between "Electricity Bill Recovery Rate" and the field RECOVERY_RATE was 0.92, indicating a successful match. The system stored this mapping relationship "Electricity Bill Recovery Rate → Database: T_BILL_DETAIL.RECOVERY_RATE" in the Terminology-Physical Field Mapping Table.
[0081] Based on the mapping relationships generated in the previous step and the database foreign keys (such as CUST_ID connecting the customer information table and the electricity bill table), a lightweight semantic network is constructed. This network uses triples for storage, such as <electricity collection rate, belonging to, RECOVERY_RATE>, <large industrial customers, belonging to, CUST_TYPE>. Unlike a full knowledge graph, the lightweight semantic network stores mapping relationships and constraint rules only in two core relation tables (a terminology mapping table and a rule table).
[0082] To ensure the integrity of the business logic generated by SQL, production constraint rules based on first-order logic are established. For example:
[0083] Rule 1 (Electricity Price Analysis Constraint): The IF query intent includes "Electricity Price Analysis" or "Electricity Price Fluctuation" THEN clause, which mandates that the SQL SELECT and GROUPBY clauses must include the "Customer Type (CUST_TYPE)" and "Billing Cycle (BILL_CYCLE)" fields.
[0084] Rule 2 (Overdue Payment Attribution Constraint): IF query intent includes "Sudden Increase in Overdue Payments" or "Overdue Payment Attribution" THEN mandates that SQL query results must include "Time Series (Monthly)", "Region", and "Volatility" indicators.
[0085] All rules are encapsulated and stored in JSON format, forming a dynamically invoked business rule library for subsequent steps.
[0086] Step S2: Parse the user's natural language query intent, integrate retrieval enhancement generation technology, inject lightweight business semantic network and field combination rules into the dynamic prompt project, and adaptively transform the user's natural language query intent into structured query statements and visual configuration descriptions.
[0087] Dynamic prompting engineering includes role definition, database constraints, business rule constraints, and small sample guidance;
[0088] Role definition: The identity of the large language model operator is defined as a power marketing data analysis specialist.
[0089] Database constraints, based on a lightweight business semantic network, only push database table structure information related to user query requirements to the large language model;
[0090] Business rule constraints convert the corresponding field combination rules into natural language constraint instructions, clearly defining the necessary query fields, statistical dimensions, and filtering conditions for various business queries;
[0091] Small sample guidance uses a dense retrieval algorithm to retrieve the historical high-quality samples with the highest semantic similarity and automatically fills them into the prompt words to complete the example guidance;
[0092] In the dynamic suggestion project, a syntax check and iterative correction mechanism is used to ensure that query statements are compliant and business logic is complete.
[0093] Step S2 integrates the semantic mapping system built in step S1 with the Retrieval Enhancement Generation (RAG) technology, and guides the large model to generate accurate structured SQL queries and report configurations through multi-level dynamic prompting engineering.
[0094] When a user enters a natural language query into the system, such as "Analyze the electricity price fluctuations of large industrial customers in a certain province in the first quarter of this year and display the results by city," the system performs the following operations:
[0095] 1. Intent parsing and entity extraction: Based on the semantic understanding capabilities of the large model, the core intent is parsed as "electricity price fluctuation analysis", and the key entities include "time: first quarter of this year", "region: a certain province", "customer type: large industrial customer" and "output granularity: by city".
[0096] 2. Construct a four-segment dynamic prompt:
[0097] Role definition: "You are a professional electricity marketing data analysis expert, proficient in SQL queries."
[0098] Database architecture constraints: Based on the parsed entities, retrieve the structural information of "Customer Information Table", "Electricity Bill Table", "Electricity Consumption Data Table" and "Electricity Price Policy Table" from the term mapping table in step S1, and only push them to the large model, while filtering out irrelevant log tables, configuration tables, etc.
[0099] Business rule constraints: Upon recognizing "electricity price analysis", the aforementioned "electricity price analysis constraint" rule is automatically retrieved from the business rule base and converted into a natural language instruction: "Note: When generating SQL, the 'customer type' and 'billing cycle' fields must be included, and statistics must be grouped according to 'customer type'."
[0100] Few-shot example guidance: Use the DPR dense search algorithm to retrieve the three historical query statements and their corresponding standard SQL statements that are most similar to the current query semantically in the Milvus vector database, and add them as few-shot examples to the suggestion words.
[0101] Submit the complete prompts to the large model to generate a draft SQL statement.
[0102] SQL syntax tree constraint validation and iterative correction
[0103] The system calls the Calcite parser to build a syntax tree from the generated SQL draft and performs double validation:
[0104] Compliance verification: Check whether the table names (such as T_CUSTOMER_INFO) and field names (such as CUST_TYPE) referenced in the SQL are within the scope of the dynamic prompt project authorization.
[0105] Integrity verification: Checks whether the SQL statement meets business rule constraints. For example, for "electricity price fluctuation analysis," the verification logic includes:
[0106] Check if the SELECT clause contains the fields CUST_TYPE and BILL_CYCLE. If not, generate the error code ERR_MISSING_REQUIRED_COLUMN.
[0107] If the SELECT statement contains aggregate functions such as AVG(PRICE), then check if the GROUP BY clause is not empty. If it is empty, generate the error code ERR_MISSING_GROUP_BY.
[0108] Check if there is a time constraint (such as BILL_CYCLEBETWEEN...AND...) in the WHERE clause. If not, generate the warning code WARN_NO_TIME_RANGE.
[0109] If the validation finds that the SQL statement is missing the BILL_CYCLE field, the validation engine will generate an error message: "Error: Required 'Billing Cycle' grouping field is missing." This message, combined with the original query, forms a new prompt, driving the larger model to correct it. The maximum number of iterations is set to 3. If the validation still fails after reaching the maximum number of iterations, the system will revert to the general query mode or return a clear error message to the user, suggesting that the user simplify the query. The final output is the standard SQL statement S_final.
[0110] Simultaneously with generating S_final, the constraint model outputs JSON-formatted report configuration information (Config_json). An example of the Config_json content for the above query is as follows:
[0111] {
[0112] "chart_type": "line",
[0113] "dimensions": ["city", "billing period"],
[0114] "metrics": ["Average electricity price", "Electricity price volatility"],
[0115] "filters": [{"Time": "2024-Q1"}, {"Region": "A certain province"}, {"Customer Type": "Large industrial customer"}]
[0116] }
[0117] Among them, chart_type is automatically matched according to the data type of the query: time series data is matched with line charts, and categorical comparison data is matched with bar charts; dimensions extracts the grouping statistics fields in the SQL statement; metrics extracts aggregate operation fields such as SUM, AVG, and COUNT; and filters extract the conditional filtering statements.
[0118] Step S3: Execute a structured query statement to obtain the target data, generate a standard rendering description based on the visual configuration description, and generate the report interface corresponding to the target data through a general rendering engine.
[0119] Step S3 links the query results of S_final with Config_json, and realizes the visualization and dynamic interaction of the report through the front-end rendering engine.
[0120] Step S3.1: Declarative visual rendering based on JSONSchema.
[0121] The backend service executes the SQL statement S_final to retrieve the dataset Data_sql from the database. Subsequently, the system sends Data_sql and Config_json to the frontend. The frontend's general-purpose visualization rendering engine (based on visualization libraries such as ECharts and AntV) automatically parses the Config_json: recognizing the chart_type as "line," binding "billing period" in dimensions to the X-axis, binding "average electricity price" in metrics to the Y-axis, and automatically generating a legend and title based on filters. Finally, it renders a line chart showing the electricity price fluctuation trend of major industrial cities in a province during the first quarter.
[0122] Step S3.2: Front-end low-code interactive linkage and drill-down analysis.
[0123] The front-end page incorporates a lightweight state-driven interaction architecture and provides visual controls, allowing business users to:
[0124] Drag and drop to adjust dimensions: Remove the "City" dimension from the X-axis and add the "Voltage Level" dimension. Because the front-end uses a state-driven architecture, this operation only updates the front-end state tree to trigger a chart redraw, without needing to send a new request to the back-end, achieving a response time of seconds.
[0125] Data drill-down analysis: When a user clicks on the data point for "City A" in the chart, the front end automatically captures the event and assembles a new query statement: "Detailed analysis of the reasons for electricity price fluctuations of large industrial customers in City A in the first quarter of this year." This statement is sent back to the entry point of step S2, starting a new round of NL2SQL process, thereby displaying more granular reports (such as details of electricity price fluctuations in different districts and voltage levels of City A).
[0126] Step S4: Identify the fluctuations in the target data and quantify the causes, then overlay the analysis results onto the report interface.
[0127] If the Config_json contains the attribute_analysis:true flag, or if the user's original query contains keywords such as "attribution", "why", or "reason for fluctuation", the system will automatically push the SQL query result Data_sql to the built-in attribution analysis model, namely the attention-enhanced bidirectional LSTM time series analysis model.
[0128] An attention-enhanced bidirectional LSTM temporal analysis model is used to quantify the contribution of the impact factors of the target data. The attention-enhanced bidirectional LSTM temporal analysis model is constructed by introducing a bidirectional temporal coding structure, a multi-head temporal attention mechanism, a heterogeneous feature-gated fusion encoder, and a residual jump connection on the basis of the LSTM model.
[0129] (a) Bidirectional temporal coding structure: Parallel coding using forward and backward dual-path LSTM layers is adopted. The forward LSTM captures historical trend dependencies in forward time sequence, while the backward LSTM captures future feedback signals in reverse time sequence. The bidirectional hidden states are concatenated to form a complete temporal context representation. Taking electricity bill collection rate prediction as an example, the forward LSTM can capture the upward trend of "historical electricity bill collection rate increasing month by month", while the backward LSTM can capture the seasonal decline signal of "year-end collection rate usually falling". After concatenation, the model has both look-ahead and look-back capabilities, which significantly improves the modeling accuracy of periodic fluctuations (such as seasonal peak electricity consumption) compared to unidirectional LSTM.
[0130] (b) Multi-head temporal attention mechanism: A multi-head attention layer is introduced above the Bi-LSTM output layer. h independent attention heads are computed in parallel. Each attention head learns the dependency weights between time steps in different subspaces, enabling the model to adaptively focus on the historical time segment with the greatest impact on the prediction target, effectively suppressing interference from noisy time steps. Specifically, let the output of the Bi-LSTM at time step t be... The formula for calculating multi-head attention is:
[0131] ;
[0132] in:
[0133] ;
[0134] In the formula, These are respectively query, value, and key, all derived from... Obtained through linear transformation, For the output of the i-th attention, For splicing, For the number of attention heads, Both are weight matrices. This is the attention mechanism function.
[0135] (c) Heterogeneous Feature Gated Fusion Encoder: For three types of heterogeneous input features—environmental factors (temperature, precipitation), policy factors (electricity price adjustment range, subsidy coefficient), and behavioral factors (rate of change in user electricity consumption habits)—independent feature encoding sub-networks are designed for each. After extracting the deep semantic representation of each factor, the weight allocation of each factor channel is adaptively learned through a gated fusion mechanism. Let the encoding vectors of the three types of factors be... , , The formula for calculating the gating weight is:
[0136] ;
[0137] The fused output is:
[0138] ;
[0139] in, These are the ordinal numbers of the three types of factors, This is the weight matrix. These are bias parameters; Using the Sigmoid activation function, we achieve adaptive weighted fusion of heterogeneous features instead of simple concatenation.
[0140] (d) Residual Skip Connections: Residual connections are introduced between layers of deep Bi-LSTM networks to directly transfer shallow temporal features to deeper layers, alleviating the gradient vanishing problem in long sequence training and improving the model's ability to capture long-term dependencies and abrupt signals. The residual connection formula is:
[0141] ;
[0142] In the formula, They are respectively The output features of the layer For the first Transformation function of the layer.
[0143] Quantitative attribution includes:
[0144] a. Identification and classification of influencing factors.
[0145] Potential influencing factors are divided into three categories: environmental factors (including temperature, precipitation, extreme weather events, etc.), policy factors (including electricity price adjustment policies, peak-valley time-of-use electricity price changes, subsidy policies, etc.), and behavioral factors (including changes in user electricity consumption habits, industry capacity adjustments, changes in the proportion of new energy access, etc.). A multi-level factor system is constructed, and each factor is standardized to eliminate differences in dimensions.
[0146] b. Based on the attention-enhanced bidirectional LSTM time series analysis model, predict the business indicator baseline of the target data under no abnormal disturbance.
[0147] Using historical data from normal periods (times without significant abnormal fluctuations) as input, the aforementioned attention-enhanced bidirectional LSTM model is used to predict the baseline value y_base of business indicators under conditions without abnormal disturbances. In this embodiment, the LSTM model is trained using electricity bill collection rate data from a certain province from 2020 to 2025. Input features include temperature, electricity pricing policy, and industry indices. The output is the predicted value of the electricity bill collection rate. The model evaluation metrics are MAE (mean absolute error) = 0.8% and RMSE (root mean square error) = 1.2%.
[0148] c. Based on Shapley value decomposition, the contribution of the influencing factors is quantified, and the contribution is normalized and its significance is verified.
[0149] Factor contribution measurement based on Shapley values. The Shapley value decomposition method is used for any subset of N influence factors. The change in predicted values after adding factor i to subset S is calculated as the marginal contribution. :
[0150] ;
[0151] in, These are the model's predictions when only factors from subset S are used.
[0152] Shapley values satisfy efficiency (the sum of the contributions of each factor equals the total bias), symmetry, and dummy elements, ensuring the fairness and interpretability of the attribution results.
[0153] Step 4: Contribution Normalization and Significance Verification. Normalize the Shapley values and calculate the percentage contribution of each factor. :
[0154] ;
[0155] Ensure that the sum of the contributions of each factor equals 100%. This represents the marginal contribution of factor j. Simultaneously, the 95% confidence interval for each factor's contribution is calculated using a bootstrap method with 1000 repeated samplings. Factors with contributions below the significance threshold (default 2%) are marked as "insignificant impact" and weakened or merged into "other factors" in the attribution presentation.
[0156] Calculations revealed that the actual electricity bill collection rate was 11% lower than the baseline, showing a significant downward trend.
[0157] The results show that the contributions of each factor to the reduction of the bias are as follows: electricity price policy adjustment (policy factor) contributed 63%, which is the dominant factor leading to the decline in recovery rate; rising temperature (environmental factor) contributed 27%, which is a secondary factor; and industrial capacity recovery (behavioral factor) contributed 10%, which is an auxiliary factor.
[0158] Overlaying analysis results onto the report interface includes:
[0159] (1) Attribution data structure generation: The quantitative attribution results are encoded into a standardized attribution data structure;
[0160] The quantitative attribution results are encoded into a standardized attribution data structure, Attribution_json, which includes fields such as factor name, contribution percentage, direction of influence (positive / negative), confidence interval, and factor type (environment / policy / behavior).
[0161] (2) Mapping attribution results to visualization elements: Establishing the mapping relationship between each influencing factor in the attribution data structure and the visualization elements of the report;
[0162] Establish a mapping relationship between each attribution factor in Attribution_json and the report visualization elements (data points, intervals, chart areas). Based on the dimensions and filters fields in Config_json, the system determines which visualization element each attribution result should be overlaid on. For example, for the electricity price fluctuation attribution for "Nanjing City," the system maps the attribution data to the interval where the "Nanjing City" data point is located in the line chart.
[0163] (3) Interactive annotation layer rendering and attribution drill-down linkage.
[0164] Interactive annotation layer rendering: An attribution annotation layer is added to the front-end rendering engine. This layer is rendered independently of the main report layer and supports three interactive display methods: The first layer is a hover tooltip. When the user hovers the mouse over a data point with an attribution marker, a lightweight tooltip pops up displaying the factor name and contribution percentage. The second layer is click details. After the user clicks on a data point, a detailed attribution panel is expanded, displaying factor contribution bar charts, trend changes in the contribution of each factor, and confidence intervals. The third layer is an overall overview. An attribution summary bar is automatically generated at the top of the report, displaying the overall contribution percentage of various factors in the form of a stacked bar chart.
[0165] Attribution drill-down linkage: After a user clicks on a specific attribution factor, the front end automatically assembles attribution drill-down query instructions, sends them back to the large model processing entry, and initiates a new round of query generation, displaying a more granular attribution analysis of that factor. For example, after a user clicks on the "seasonal electricity consumption growth" factor, the front end automatically assembles the query "Analyze the specific reasons for the seasonal electricity consumption growth of large industrial customers in Nanjing." The system automatically generates a contribution decomposition report for each sub-dimension under this factor (such as rising temperature and increased air conditioning load), realizing multi-level progressive drill-down in attribution analysis.
[0166] Ultimately, the system overlays the quantitative attribution results onto the front-end visual report as an interactive annotation layer, upgrading electricity marketing data from basic numerical display to intelligent business data analysis and insights.
[0167] Specifically, in this embodiment, it also includes closed-loop continuous optimization, which includes:
[0168] Collect user feedback information. After cleaning and reviewing the feedback information, supplement the corrected query samples in the feedback information into the retrieval enhancement knowledge base for periodic fine-tuning of the domain pre-trained language model. Analyze the common dimension missing or logical errors reflected in the feedback information to generate suggestions for adding or modifying rules. After review and confirmation by the administrator, update the lightweight business semantic network and field combination rules.
[0169] For example:
[0170] The system was piloted in two typical scenarios: "electricity consumption statistics" and "electricity cost risk warning". The front-end page includes an "Error Feedback" button. When users find that the generated reports do not meet expectations (for example, the SQL query results omit a specific customer group, or the attribution results are significantly biased), they can click the button and select the error type (such as "data omission", "dimensional error", or "inaccurate attribution").
[0171] The system backend records the user's natural language input, generated SQL statement, JSON configuration, query results, and user-provided tags. During system downtime, these "negative samples" are cleaned and reviewed before being incorporated into the training data pool. This data is used for periodic fine-tuning of the domain-specific pre-trained language model (BERT), adding corrected query samples to the small sample example library in the Milvus vector database, and optimizing semantic mapping weights and the business rule base. For example, if multiple users report that a certain type of query lacks the "voltage level" dimension, the system will automatically analyze and suggest adding a new rule: "IF query intent includes 'large industrial customers' THEN recommend adding the 'voltage level' grouping dimension." All rule additions or modifications must be reviewed and confirmed by the administrator before taking effect, ensuring the authority and accuracy of the business rule base.
[0172] This mechanism forms a complete technical closed loop of "business rules - intent translation - agile generation - feedback optimization", which enables the accuracy of the system's NL2SQL conversion and user satisfaction to continuously improve with the increase of usage time, truly realizing personalized and flexible reporting services that are "personalized for each user and become more accurate with use".
[0173] This embodiment uses "attribution analysis of the sudden drop in electricity bill collection rate of large industrial customers in a certain province in the first quarter of 2024" as a specific business scenario to demonstrate in detail the specific implementation details of the technical solution of the present invention in the process of data processing, model calculation and parameter transmission.
[0174] Example 2
[0175] This invention provides an automatic generation device for electricity marketing volume and fee reports, comprising:
[0176] The mapping system construction module is configured to obtain the mapping relationship between business terms and physical fields from the marketing database through metadata parsing and semantic matching, build a lightweight business semantic network and generate field combination rules;
[0177] The dynamic query generation module is configured to parse the user's natural language query intent, integrate retrieval enhancement generation technology, inject lightweight business semantic network and field combination rules into the dynamic prompt project, and adaptively transform the user's natural language query intent into structured query statements and visual configuration descriptions.
[0178] The report generation module is configured to execute structured query statements to obtain target data, generate standard rendering descriptions based on the visual configuration descriptions, and generate report interfaces corresponding to the target data through a general rendering engine.
[0179] The intelligent attribution embedding module is configured to identify fluctuations in target data and quantify the attributions, then overlay the analysis results onto the report interface.
[0180] Example 3
[0181] Based on the automatic generation method of electricity marketing volume and fee report provided in Embodiment 1, this embodiment of the invention provides an electronic device, including a processor and a storage medium;
[0182] Storage media are used to store instructions;
[0183] The processor is used to perform operations according to instructions to execute the steps according to the method described above.
[0184] Example 4
[0185] Based on the automatic generation method of electricity marketing volume and fee report provided in Embodiment 1, this embodiment of the invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above method.
[0186] Example 5
[0187] Based on the automatic generation method of electricity marketing volume and fee report provided in Embodiment 1, this embodiment of the invention provides a computer program product, including a computer program / instruction, which implements the steps of the above method when executed by a processor.
[0188] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0189] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0190] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0191] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0192] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for automatically generating a power marketing volume tariff report, characterized by, include: The mapping relationship between business terms and physical fields is obtained from the marketing database through metadata parsing and semantic matching, and a lightweight business semantic network and field combination rules are constructed. The system analyzes the user's natural language query intent, integrates retrieval enhancement generation technology, injects the lightweight business semantic network and the field combination rules into the dynamic prompt project, and adaptively transforms the user's natural language query intent into structured query statements and visual configuration descriptions. The structured query statement is executed to obtain the target data, a standard rendering description is generated based on the visualization configuration description, and a report interface corresponding to the target data is generated through a general rendering engine. Identify the fluctuations in the target data and quantify the causes, then overlay the analysis results onto the report interface; The metadata parsing of the marketing database includes: Extract the table name, physical fields, physical field comments, and primary and foreign key relationships from the data table metadata in the marketing database; The semantic matching process for obtaining the mapping relationship between business terms and physical fields includes: For business terms in the marketing database, a domain-pre-trained language model fine-tuned with power industry corpus is invoked to annotate the business terms and the physical field as corresponding semantic vectors. Bidirectional matching is then performed using cosine similarity, as shown in the following expression: ; wherein are semantic vectors of business terms and physical field annotations, respectively, is cosine similarity; The physical field corresponding to the physical field annotation with the highest cosine similarity value and the similarity value above the similarity threshold is selected to form a mapping relationship with the business term; The construction of the lightweight business semantic network includes: Based on the mapping relationship, the primary and foreign key relationships between data tables are extracted as network association edges to construct a lightweight business semantic network. The lightweight business semantic network adopts a triple structure, with the format being business term-belongs-physical field; The rules for combining generated fields include: Based on the integrity of business logic, formulate business production constraint rules based on a first-order logical architecture; When the system detects that a user's natural language query intent contains keywords related to a specific business, the corresponding business production constraint rules are automatically triggered. The dynamic prompting project includes role definition, database constraints, business rule constraints, and small sample guidance. Role definition: The identity of the large language model operator is defined as a power marketing data analysis specialist. Database constraints, based on the lightweight business semantic network, only push database table structure information related to the user's query requirements to the large language model; Business rule constraints convert the corresponding field combination rules into natural language constraint instructions, clearly defining the essential query fields, statistical dimensions, and filtering conditions for various business queries; Small sample guidance uses a dense retrieval algorithm to retrieve the historical high-quality samples with the highest semantic similarity and automatically fills them into the prompt words to complete the example guidance; In the dynamic suggestion project, a syntax check and iterative correction mechanism is used to ensure that the query statements are compliant and the business logic is complete. The step of identifying and quantifying the attribution of the target data fluctuations includes: The influence factor contribution of the target data is quantified by an attention-enhanced bidirectional LSTM temporal analysis model. The attention-enhanced bidirectional LSTM temporal analysis model is constructed by introducing a bidirectional temporal coding structure, a multi-head temporal attention mechanism, a heterogeneous feature-gated fusion encoder and a residual jump connection on the basis of the LSTM model. The quantitative attribution includes: Identification and classification of impact factors; Based on the attention-enhanced bidirectional LSTM time series analysis model, predict the baseline of business indicators for target data under no abnormal disturbances; The contribution of the influencing factors is quantified based on Shapley value decomposition, and the contribution is normalized and its significance is verified. The step of overlaying the analysis results onto the report interface includes: Attribution data structure generation encodes the quantified attribution results into a standardized attribution data structure; Mapping attribution results to visualization elements: Establishing the mapping relationship between each influencing factor in the attribution data structure and the visualization elements in the report; Interactive annotation layer rendering and attribution drill-down linkage.
2. The method for automatically generating a power marketing volume charge report according to claim 1, wherein, It also includes closed-loop continuous optimization, which includes: Collect user feedback information. After cleaning and reviewing the feedback information, supplement the corrected query samples in the feedback information into the retrieval enhancement knowledge base for periodic fine-tuning of the domain pre-trained language model. Analyze the common dimension missing or logical errors reflected in the feedback information to generate suggestions for adding or modifying rules. After review and confirmation by the administrator, update the lightweight business semantic network and field combination rules.
3. An automatic generation device for electricity marketing volume and fee reports, characterized in that, The automatic generation device is configured to perform the steps of the method according to claim 1 or 2; the automatic generation device includes: The mapping system construction module is configured to obtain the mapping relationship between business terms and physical fields from the marketing database through metadata parsing and semantic matching, build a lightweight business semantic network and generate field combination rules; The dynamic query generation module is configured to parse the user's natural language query intent, integrate retrieval enhancement generation technology, inject the lightweight business semantic network and the field combination rules into the dynamic prompt project, and adaptively transform the user's natural language query intent into structured query statements and visual configuration descriptions. The report generation module is configured to execute the structured query statement to obtain target data, generate a standard rendering description based on the visualization configuration description, and generate the report interface corresponding to the target data through a general rendering engine. The intelligent attribution embedding module is configured to identify fluctuations in the target data and quantify the attribution, and then overlay the analysis results onto the report interface.
4. An electronic device, comprising: Including processor and storage media; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the steps of the method according to claim 1 or 2.
5. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the program is executed by the processor, it implements the steps of the method described in claim 1 or 2.
6. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in claim 1 or 2.
Citation Information
Patent Citations
Retrieval enhancement generation method based on APT knowledge graph embedding
CN119961413A
Query method and system for lightweight enterprise NL2SQL model, medium and equipment
CN120179758A
