Intelligent Billing Method and System Based on Multi-Source Heterogeneous Data
By using an intelligent billing method based on multi-source heterogeneous data and employing target recognition models and expression tree processing, the problems of low efficiency and poor accuracy in cost calculation in existing technologies are solved, achieving automated and accurate cost calculation.
Patent Information
- Application Number
- CN202610908654.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-23
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies are inefficient and prone to errors in cost calculation, especially when dealing with complex billing rules, making automation and accuracy difficult.
An intelligent billing method based on multi-source heterogeneous data is adopted. It utilizes an attention module and a target recognition model trained on multimodal data to automatically identify billing rules and calculate costs, including expression tree processing and linear interpolation smoothing, combined with incremental learning and multi-source data fusion.
It achieves a leap from passive rule execution to proactive intelligent decision-making, improves the efficiency and accuracy of cost calculation, avoids errors caused by manual parsing, and supports the automated processing of complex billing rules.
Smart Images

Figure CN123118192A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of automatic cost calculation, specifically relating to an intelligent billing method and system based on multi-source heterogeneous data. Background Technology
[0002] In related technologies, when calculating costs, it is necessary to consult relevant documents in advance, such as contracts; the final cost is calculated by manually analyzing the terms in the contract. This method is inefficient and prone to errors. Summary of the Invention
[0003] In view of the above problems, a smart billing method and system based on multi-source heterogeneous data is proposed to overcome or at least partially solve the above problems, including: A smart billing method based on multi-source heterogeneous data, the method comprising: Identify the target items to be billed, and the billing rule documents for those target items; The billing rule file is identified to determine the target billing rule for the target project; According to the target billing rules, the cost of the target item to be billed is calculated.
[0004] In some embodiments, identifying the billing rule file to determine the target billing rule for the target project includes: Obtain the target recognition model for the target item to be billed; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using a corner loss function; Based on the target identification model, the billing rule file is identified to obtain the target billing rules for the target project.
[0005] In some embodiments, the method further includes: Acquire training data and extract multimodal data from the training data; the multimodal data includes text content, page layout, and image areas; The target recognition model is obtained by training the model based on the multimodal data.
[0006] In some embodiments, the method further includes: When an update event is triggered for the target recognition model, the newly labeled training data is obtained; The target recognition model is fine-tuned based on the newly labeled training data.
[0007] In some embodiments, the target billing rule includes an expression tree, and the method further includes: Obtain the target formula and perform lexical and syntactic analysis on the target formula; The expression tree is generated based on the lexical and syntactic analysis of the target formula.
[0008] In some embodiments, the method further includes: Obtain information on the impact of cost calculation; Based on the cost calculation impact information, the costs of the target items to be billed are corrected.
[0009] In some embodiments, the target billing rule includes a tiered billing rule, which includes multiple billing rules, and adjacent billing tiers are smoothed using linear interpolation.
[0010] This application also provides an intelligent billing system, the system comprising: The first determination module is used to determine the target item to be billed, and the billing rule file for the target item to be billed; The second determining module is used to identify the billing rule file in order to determine the target billing rule for the target project; The billing module is used to calculate the cost of the target item to be billed according to the target billing rules.
[0011] In some embodiments, the second determining module is used to obtain a target recognition model for the target item to be billed; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using a corner loss function; and the billing rule file is recognized according to the target recognition model to obtain target billing rules for the target item.
[0012] In some embodiments, the second determining module is further configured to acquire training data and extract multimodal data from the training data; the multimodal data includes text content, page position, and image area; and to train the model based on the multimodal data to obtain the target recognition model.
[0013] In some embodiments, the second determining module is further configured to, when an update event for the target recognition model is triggered, acquire newly labeled training data; and fine-tune the target recognition model based on the newly labeled training data.
[0014] In some embodiments, the target billing rule includes an expression tree, a second determining module, and is further configured to obtain a target formula and perform lexical and syntactic analysis on the target formula; and generate the expression tree based on the lexical and syntactic analysis of the target formula.
[0015] In some embodiments, the billing module is further configured to obtain cost calculation impact information and, based on the cost calculation impact information, correct the cost of the target item to be billed.
[0016] In some embodiments, the target billing rule includes a tiered billing rule, which includes multiple billing rules, and adjacent billing tiers are smoothed using linear interpolation.
[0017] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-described intelligent billing method based on multi-source heterogeneous data.
[0018] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described intelligent billing method based on multi-source heterogeneous data.
[0019] The embodiments of this application have the following advantages: In this embodiment, the target item to be billed and the billing rule file for that target item can be determined first. Then, the billing rule file is identified to determine the target billing rule for the target item. Next, the cost of the target item to be billed can be calculated according to the target billing rule. This embodiment achieves a leap from "passive rule execution" to "proactive intelligent decision-making," enabling automatic cost calculation. Compared to manually parsing files for cost calculation, this application improves the efficiency of cost calculation and avoids errors. Attached Figure Description
[0020] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart illustrating the steps of an intelligent billing method based on multi-source heterogeneous data according to an embodiment of this application. Figure 2 This is a flowchart illustrating another intelligent billing method based on multi-source heterogeneous data according to an embodiment of this application. Figure 3 This is a flowchart illustrating the steps of model training according to an embodiment of this application; Figure 4 This is a flowchart illustrating the steps for calculating costs according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an intelligent billing system according to an embodiment of this application. Detailed Implementation
[0021] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0022] Reference Figure 1 The diagram illustrates a flowchart of a smart billing method based on multi-source heterogeneous data according to an embodiment of this application, which may include the following steps: Step 101: Determine the target item to be billed and the billing rule document for the target item to be billed.
[0023] In some embodiments, the target item to be billed may refer to the item for which the current cost needs to be calculated, such as: the item for calculating electricity costs, the item for calculating parking fees, the item for calculating the costs of cooperation agreed upon in the contract, etc.
[0024] Billing rule documents can refer to the documents that record the billing rules for the items that currently require billing, such as the "Basic Rules for the Operation of the Electricity Market" and contracts.
[0025] In this embodiment of the application, after determining the target item to be billed, a billing rule file for the target item to be billed can also be obtained.
[0026] Step 102: Identify the billing rule file to determine the target billing rule for the target project.
[0027] After obtaining the billing rule document for the target item to be billed, this application can automatically identify the billing rule document, understand and analyze it, and thus automatically identify the target billing rule for the target item. This target billing rule can refer to the rules for calculating the cost of the target item, such as: "tiered pricing" threshold, unit price, calculation formula, etc.
[0028] Step 103: Calculate the cost of the target item to be billed according to the target billing rules.
[0029] In some embodiments, when calculating the cost of a target item to be billed, the current status of the target item can also be obtained, such as the current usage amount and the current duration.
[0030] After determining the target billing rules, the cost of the target project to be billed can be calculated based on the target billing rules and the current status of the target project, thereby obtaining the current cost of the target project to be billed.
[0031] In this embodiment, the target item to be billed and the billing rule file for that target item can be determined first. Then, the billing rule file is identified to determine the target billing rule for the target item. Next, the cost of the target item to be billed can be calculated according to the target billing rule. This embodiment achieves a leap from "passive rule execution" to "proactive intelligent decision-making," enabling automatic cost calculation. Compared to manually parsing files for cost calculation, this application improves the efficiency of cost calculation and avoids errors.
[0032] Reference Figure 2 The diagram illustrates a flowchart of another intelligent billing method based on multi-source heterogeneous data according to an embodiment of this application, which may include the following steps: Step 201: Determine the target item to be billed and the billing rule document for the target item to be billed.
[0033] In some embodiments, the target item to be billed can be determined first, and then the billing rule file for the target item to be billed can be determined.
[0034] For example, when it is necessary to bill a target item, the billing rule file for the target item to be billed can be determined, or the step of determining the billing rule file for the target item to be billed can be performed in advance for the target item. This application embodiment does not limit this.
[0035] Step 202: Obtain the target recognition model of the target item to be billed; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using the corner loss function.
[0036] Before determining the target billing rules for the target project, a target identification model for the target project to be billed can be obtained. This target identification model for the target project to be billed can be trained from different labeled billing rule files.
[0037] In some embodiments, the target identification model may include an attention module to automatically analyze and quantify the correlation weights between billing elements scattered across different paragraphs in the billing rule file, using its attention mechanism. For example, the target identification model can identify complex cross-clause logic such as "if the monthly electricity consumption exceeds the peak threshold, the excess portion will be billed at a specific rate, affecting the subsequent apportionment base."
[0038] In some embodiments, the target identification model may include multiple identification heads, such as: entity identification head, relationship classification head, and clause type head; wherein, the entity identification head can be used to locate key fields such as threshold, rate, and number of days; the relationship classification head can be used to determine the logical relationship between fields, such as a certain threshold corresponding to a certain rate; the clause type head can be used to classify paragraphs, such as belonging to tiered pricing, late payment fees, or exemption clauses.
[0039] In some embodiments, to address the imbalance between positive and negative samples in billing terms, the target recognition model can be trained using a corner loss function; introducing FocalLoss (focus loss) instead of standard cross-entropy loss can make the model focus more on training difficult samples.
[0040] In some embodiments of this application, the target recognition model can be trained through the following steps: Acquire training data and extract multimodal data from it; the multimodal data includes text content, page layout, and image regions; train the model based on the multimodal data to obtain the target recognition model.
[0041] In some embodiments, to improve the resolution accuracy of the target recognition model, the training process can consider not only text but also tables, images, etc., within the file. Specifically, training data can be acquired first, and multimodal data can be extracted from this training data. This multimodal data may include text content, page layout, and image regions. The training data may include annotated billing rule files. Specifically, billing formulas, billing rules, etc., in the billing rule files can be annotated to generate the training data.
[0042] For example, the text content can be obtained by recognizing the training data using OCR (Optical Character Recognition); the layout position can include the bounding box (coordinates) returned by OCR; the image area can include local image blocks (such as stamped pages or handwritten annotation areas) in the scanned document of the training data.
[0043] After obtaining multimodal data, the model can be trained using the multimodal data to obtain a target recognition model with the ability to recognize billing rule documents.
[0044] Step 203: Based on the target identification model, identify the billing rule file to obtain the target billing rules for the target project.
[0045] After obtaining the billing rule document for the target project to be billed, this application can automatically identify the billing rule document, understand and analyze the billing rule document, and thus automatically identify the target billing rule for the target project.
[0046] For example, a pre-trained target recognition model can be used to identify the billing rule file; specifically, the billing rule file can be input into the target recognition model; the target recognition model understands and analyzes the billing rule file to obtain the target billing rules for the target project.
[0047] Step 204: Calculate the cost of the target item to be billed according to the target billing rules.
[0048] In some embodiments, when calculating the cost of a target item to be billed, the current status of that target item can also be obtained.
[0049] After determining the target billing rules, the cost of the target project to be billed can be calculated based on the target billing rules and the current status of the target project, thereby obtaining the current cost of the target project to be billed.
[0050] In some embodiments of this application, the above method may further include the following steps: When an update event for the target recognition model is triggered, the newly labeled training data is obtained; the target recognition model is then fine-tuned based on the newly labeled training data.
[0051] Among them, an update event can refer to an event that requires updating the target recognition model; for example, when a user raises an objection to the calculated fee, an update event can be determined to be triggered; in another example, when the calculated fee is inconsistent with the fee that is manually reviewed, an update event can be determined to be triggered.
[0052] When an event triggering an update for the target recognition model is detected, for biased cases, only the erroneous segments can be labeled, while the rest retain the original labels, thus obtaining training data with new labels.
[0053] Then, the newly labeled training data can be used to retrain the target recognition model to fine-tune it.
[0054] In some embodiments of this application, the target billing rule includes an expression tree, and the above method may further include the following steps: Obtain the target formula and perform lexical and syntactic analysis on it; generate an expression tree based on the lexical and syntactic analysis of the target formula.
[0055] In some embodiments, for complex nested calculations involving "apportionment + tiered pricing + late fees" in industries such as property management and electricity, a parallel computing algorithm based on expression tree decomposition can be designed. This algorithm parses complex formulas into expression trees, automatically distributes subtree tasks to cloud computing nodes for parallel computation, and finally aggregates the results, thereby achieving millisecond-level response times for billing requests and resolving the performance bottleneck caused by complex calculations.
[0056] Specifically, you can first obtain the target formula, which can be either input by the user or extracted from the billing rules file.
[0057] After obtaining the target formula, it can be parsed using a lexical analyzer and a syntax analyzer, and then converted into a computer-executable expression tree structure.
[0058] During the calculation process, a post-order traversal of the expression tree can be used to calculate the result from the leaf node to the parent node.
[0059] In some embodiments of this application, the above method may further include the following steps: Obtain information on the impact of cost calculation; based on this information, adjust the costs of the target items to be billed.
[0060] In some embodiments, billing can be upgraded from "mechanical execution" to "context-aware intelligent decision-making," improving the practicality and robustness of automated billing. Specifically, after calculating the cost of the target item, information affecting the cost calculation can be obtained. For example, if the target item has late fees, weather data, government data, etc., can be obtained as information affecting the cost calculation.
[0061] Then, when a natural disaster or an officially announced grace period is detected during the overdue period, the late payment fee reduction rule can be automatically triggered to correct the charges for the target project, thereby reducing the late payment fee for that project. An audit log can be recorded during the reduction process.
[0062] In some embodiments of this application, the target billing rule includes a tiered billing rule, which includes multiple billing rules, and linear interpolation is used to smooth the adjacent billing tiers.
[0063] In some embodiments, there may be boundary cases when calculating the cost. For example, in the tiered electricity pricing rules, the first tier is for electricity consumption ≤ 260 kWh, with a unit price of 0.5 yuan / kWh; the second tier is for electricity consumption ≤ 600 kWh (i.e., the portion from 260 to 600 kWh), with a unit price of 0.6 yuan / kWh; and the third tier is for electricity consumption exceeding 600 kWh (float('inf') represents infinity, i.e., the last tier has no upper limit), with a unit price of 0.8 yuan / kWh.
[0064] In the embodiments of this application, the target billing rule may include a tiered billing rule, and the tiered billing rule includes multiple billing rules; for example, in the tiered electricity price rule, the first tier: electricity consumption ≤ 260 kWh, unit price 0.5 yuan / kWh; the second tier: electricity consumption ≤ 600 kWh (i.e., the 260~600 part), unit price 0.6 yuan / kWh; the third tier: electricity consumption exceeding 600 kWh (float('inf') represents infinity, i.e., the last tier has no upper limit), unit price 0.8 yuan / kWh.
[0065] When the usage is at the boundary of the tier, a linear interpolation algorithm can be used to smooth the transition (allowing the unit price to change linearly within the range), avoiding cost jumps and improving fairness and user experience.
[0066] In this embodiment, the target item to be billed and the billing rule file for the target item are determined; a target recognition model for the target item to be billed is obtained; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using a corner loss function; based on the target recognition model, the billing rule file is recognized to obtain the target billing rule for the target item; and based on the target billing rule, the cost of the target item to be billed is calculated. This embodiment enables a leap from passive rule execution to proactive intelligent decision-making, achieving automatic cost calculation. Compared to manually parsing files for cost calculation, this application improves the efficiency of cost calculation and avoids errors.
[0067] The above embodiments will be further illustrated below with specific examples: Traditional billing methods rely on manual parsing of contract terms and manual data input, resulting in low efficiency, error-proneness, and difficulty in adapting to complex rules such as tiered pricing / allocation calculations. To address this, this application overcomes the technical bottlenecks of automated billing technologies (such as those relying on fixed templates or simple NLP parsing) by integrating a series of technologies, innovating algorithms, and designing an architecture that achieves a leap from passive rule execution to proactive intelligent decision-making. Specifically, this is reflected in: (i) Closed-loop intelligence of semantic understanding and rule execution.
[0068] 1. In-depth understanding and correlation analysis of billing rule documents (such as contract terms) based on attention mechanisms.
[0069] Existing technologies (such as simply using BERT (Bidirectional Encoder Representations from Transformers) for classification) can only identify clause types and cannot understand the complex logical relationships between clauses (such as the implicit correlation between tiered pricing thresholds and late payment penalty triggering conditions). This application performs deep optimization of pre-trained NLP models (such as BERT) for billing scenarios, utilizing their attention mechanism to automatically analyze and quantify the correlation weights between billing elements scattered across different sections of the contract. For example, the model can identify complex cross-clause logic such as if monthly electricity consumption exceeds a peak threshold, the excess portion will be billed at a specific rate, affecting the subsequent apportionment base.
[0070] Model details for context understanding: I. Model Structure Design: The model adopts a three-level structure of encoding, understanding, and decoding: 1. Multimodal input coding layer.
[0071] The system receives three types of information from the OCR engine output: text content, page layout (the coordinates of each word on the page (x, y, width, height)), and image regions. These three parts are converted into vectors of the same dimension through word embedding, linear coordinate mapping, and a lightweight convolutional network, respectively, and then weighted and fused. The text is the core, while the page layout and image regions are introduced with smaller weights to ensure that they can still assist in judgment when the text is blurred or obscured, without interfering with the main semantic meaning.
[0072] 2. Understanding the main points of the context.
[0073] The system is initialized based on Chinese BERT-base and consists of 12 layers. To balance general language capabilities with domain adaptability, only the last 6 layers (layers 7–12) are fine-tuned during training, while the parameters of the first 6 layers are frozen. This preserves the basic language understanding capabilities gained from pre-training while allowing the higher layers to focus on learning billing-specific expressions, such as conditional structures like "billing for amounts exceeding X by Y".
[0074] 3. Multi-task decoding head.
[0075] Three light quantum networks are connected in parallel above the main output: Entity recognition head: used to locate key fields such as thresholds, rates, and number of days; Relationship classification header: Determines the logical relationship between fields (e.g., a certain threshold corresponds to a certain rate); Terms type header: Classifies paragraphs (e.g., tiered pricing, late fees, or waiver clauses). The three-head shared backbone means joint training, with gradient backpropagation to the trainable high-level backbone.
[0076] II. Training: The training data consists of two parts: Real Contracts: Electricity and property contracts meticulously annotated by humans, covering common and peripheral scenarios; Synthetic data: Simulated samples generated based on business rule templates, with a focus on supplementing low-frequency but critical clauses (such as force majeure exemptions) and adding ambiguous expressions (such as approximately 500 degrees) to improve robustness.
[0077] Training will be conducted in phases: 1. Cold start phase: Freeze the backbone and train only the decoder head to quickly establish basic recognition capabilities; 2. Joint Fine-tuning Phase: After unfreezing the main trunk for 6 layers, the three tasks are jointly optimized; 3. Hard Example Reinforcement Stage: Targeted retraining based on erroneous samples from the validation set.
[0078] The loss function is designed differently according to the characteristics of the task: FocalLoss is used for entity recognition to alleviate the long-tail distribution problem; label smoothing is introduced for clause classification to prevent overfitting.
[0079] By upgrading from clause recognition to understanding business intent, an accurate semantic foundation is provided for the subsequent generation of executable code.
[0080] 2. Code self-generation capability of the rule engine Traditional rule engines require manually predefined rule templates. This application designs a dynamic code generator that can receive semantically rich structured data (such as JSON-formatted rule relationship graphs) output by an NLP module and automatically compile it into executable billing code (such as Python functions). For example, after the system identifies an area allocation rule, it can automatically generate a standard function containing parameter validation, calculation logic, and exception handling. This achieves a fundamental shift from configuring rules to generating rules, enabling it to adapt to new business scenarios and significantly reducing secondary development costs.
[0081] In this embodiment, the NLP module parses the contract into structured data (such as tiered thresholds, rates, late payment fee percentages, etc.), and then matches this data with a preset security code template (such as tiered billing, apportionment, late payment fees, etc.), automatically filling in specific parameters to generate an executable billing function. The entire process does not rely on AI to freely generate code; instead, it uses structured extraction and template filling to ensure correct code logic, security, and controllability, and supports complex rule combinations.
[0082] (ii) In terms of algorithms, solving the core challenges of complex billing scenarios: 1. A distributed parallel computing framework for complex nested formulas.
[0083] This application addresses the complex nested calculations involving apportionment, tiered pricing, and late fees in industries such as property management and electricity. It designs a parallel computing algorithm based on expression tree decomposition. The algorithm parses custom complex formulas into expression trees, automatically distributes subtree tasks to cloud computing nodes for parallel computation, and finally aggregates the results.
[0084] Specifically, it includes: Construct an expression tree: Represent the billing logic in the contract (such as tiered electricity pricing, building energy consumption allocation, and late payment fees for cross-month periods) as tree nodes of a specific type. Each node clearly identifies its business attributes (such as unit, whether it depends on historical data, etc.).
[0085] Intelligent splitting based on business semantics: Each user's bill is treated as an independent subtree and calculated in parallel; If different billing items for the same user (such as basic electricity fees and late fees) have no dependency relationship, they will be further processed in parallel. When aggregation operations such as apportionment by building are involved, they will be automatically split into two-stage tasks: first calculating by household and then summarizing by building. If the billing logic references the previous month's bill, a time sequence dependency will be automatically established to ensure that the previous month's bill is calculated before the current month's bill is calculated.
[0086] Dynamic scheduling and efficient execution: Computational resources are automatically allocated based on task type. Ordinary billing items are processed in batches using vectorization, while amortized tasks are aggregated and accelerated. Failed tasks are strictly isolated to avoid impacting the overall performance. This application's implementation achieves millisecond-level response times for massive billing requests, resolving performance bottlenecks caused by complex calculations.
[0087] 2. Intelligent processing and decision-making mechanism for boundary conditions.
[0088] Step-by-step smoothing algorithm: When the usage is at the step boundary, a linear interpolation algorithm is used to smooth the transition (so that the unit price changes linearly within the range), avoiding cost jumps and improving fairness and user experience.
[0089] Business semantics driven: Deeply integrate mathematical interpolation with billing policies, and smooth half-width δ can be determined by contract terms or operational strategies; Supports multiple boundary overlays: capable of handling complex contracts with more than three steps; End-to-end automation: from contract text -> smoothing strategy -> generation of billing function with interpolation, no manual coding is required throughout the entire process.
[0090] Specific details of achieving a smooth transition using linear interpolation: ① Key parameters are shown in Table 1: Table 1:
[0091] ②Effective unit-price function r(x):
[0092] The function is continuous at x = T ± δ, and in [T It changes linearly on δ,T+δ.
[0093] ③ Cost calculation; Since the unit price varies with the usage, the total cost is the integral of the unit price function: .
[0094] ④ Main parameters of the code function: Function header: defsmooth_tiered_charge(usage:float,tiers:list,delta:float=5.0)->float: """ Parameter: usage: actual consumption (e.g., 263.5 kWh) :tiers: A list of tiers [(upper_bound, rate), ...], where upper_bound is in ascending order, and the last item can be float('inf'). :delta: smooth half-width (unit consistent with usage) :return:Total cost (yuan) """ ⑤ Usage example: tiers=[(260,0.5),(600,0.6),(float('inf'),0.8)] print(smooth_tiered_charge(261,tiers,delta=5)) Tiers: Defines tiered electricity pricing rules. Tier 1: Electricity consumption ≤ 260 kWh, price 0.5 yuan / kWh; Second tier: Electricity consumption ≤ 600 kWh (i.e., the portion from 260 to 600 kWh), unit price 0.6 yuan / kWh; Tier 3: Electricity consumption exceeding 600 kWh (float('inf') represents infinity, meaning the last tier has no upper limit), with a unit price of 0.8 yuan / kWh.
[0095] The `smooth_tiered_charge()` function is called to calculate the electricity cost for a consumption of 261 kWh. 261: The user's monthly electricity consumption (exactly 1 kWh more than the first-tier upper limit of 260 kWh); tiers: The ladder rules defined above; delta=5: The smoothing buffer width is 5 kWh, indicating that linear interpolation is used within a 5-degree range before and after each step boundary (e.g., 255-265) to smoothly increase the unit price from 0.5 to 0.6, avoiding sudden changes in cost. The final output is the total electricity cost after smoothing (unit: yuan).
[0096] Dynamic late payment fee waiver: The intelligent billing method based on multi-source heterogeneous data proposed in this application can be applied to a system that can integrate external APIs (such as weather data and policy databases). When the system detects a natural disaster or an officially issued grace period during the overdue period, it can automatically trigger the late payment fee reduction rule and record it in the audit log. This upgrades the billing system from mechanical execution to context-aware intelligent decision-making, improving the system's practicality and robustness.
[0097] (iii) An adaptive system with continuous evolutionary capabilities.
[0098] 1. Model self-optimization pipeline based on incremental learning.
[0099] This application constructs a continuous model optimization closed loop. The system records the deviation between billing results and expectations. When the deviation exceeds a threshold or a new contract type appears, the system automatically initiates the incremental learning process of the NLP model, using newly labeled data for fine-tuning, enabling the model to continuously evolve and adapt to business changes. Specifically, it can be driven by a business closed loop: using "billing deviation," "user complaints," and "term drift" as iteration signals, operational feedback is transformed into model optimization instructions; it also has a precise repair mechanism, achieving efficient parameter and data local updates through minimum repair samples and adversarial obfuscation pairs; in addition, this application can have a layered fine-tuning architecture, freezing the general layer, fine-tuning the adaptation layer, and selectively retraining task heads to avoid catastrophic forgetting; a secure deployment system: gray-scale deployment + automatic rollback + full-link traceability, ensuring that iteration does not affect production stability.
[0100] Update and iteration details: ① Iteration triggering mechanism, as shown in Table 2: Table 2:
[0101] ② Construct a minimum repair sample: For deviation cases, only the erroneous segments are labeled, and the rest retain the original labels.
[0102] ③ Adversarial Sample Confusion: Automatically generates easily confused pairs to enhance boundary discrimination capabilities. Correct example: "Above 500 degrees, it is charged at 0.8 yuan"; Counterexample: "Buy 500 units and get 50 units free"; Use contrastive learning loss to widen the distance between the two class representations.
[0103] ④ Use a layered fine-tuning strategy to update only the affected modules. The update strategy is shown in Table 3: Table 3:
[0104] ⑤ Deployment control: Canary release + automatic rollback.
[0105] Gradual rollout strategy: The new model will first be applied to 1% of newly signed contracts, and monitored for 24 hours; Rollback conditions (automatic rollback will occur if any of these conditions are triggered): Bill generation failure rate > 0.1%; User dispute rate increases by > 15% month-on-month.
[0106] 2. A unified real-time fusion architecture for multi-source heterogeneous data.
[0107] A microservice-based data fusion layer was designed, which can simultaneously connect to multiple data sources such as APIs, IoT devices (smart meters), and blockchain, and perform real-time data cleaning, alignment, and standardization to provide high-quality and timely input data for the billing engine.
[0108] IV. Technical Solution: (a) Contract parsing module; 1. Setting hyperparameters for the pre-trained NLP model (BERT).
[0109] Learning rate: Initially set to 2e-5. During training, a learning rate decay strategy is adopted. After each epoch of training, the learning rate is multiplied by 0.9 to balance the convergence speed of the model and prevent overfitting.
[0110] Number of training rounds: Determined based on the size and complexity of the training data. If the training data contains 5,000-10,000 contract texts, the number of training rounds is set to 5; if the dataset contains less than 5,000 texts, 3 rounds are trained; if it contains more than 10,000 texts and the contract terms are complex, 10 rounds are trained.
[0111] Hidden Layer Settings: The optimization scheme based on the BERT large model improves model performance by introducing an adjustable intelligent transformation layer. While retaining the original 768-dimensional feature extraction capability, this scheme adds two new configuration modes: a 512-dimensional simplified mode and a 1024-dimensional enhanced mode, achieving different levels of feature recombination through feature compression and expansion, respectively. Using the same validation dataset, both the 512-dimensional (simplified) and 1024-dimensional (enhanced) configurations are run; accuracy, inference speed, memory usage, and other metrics are automatically calculated; based on business requirements, the configuration with the higher score is automatically selected according to preset rules. After comparative testing and evaluation of the performance of the two configurations on the same task, the optimal implementation scheme is adopted, achieving performance optimization while maintaining the core capabilities of the model.
[0112] 2. Model fine-tuning strategy.
[0113] Transfer learning: We collected annotated data in the legal / contract text domain, covering different types of contracts (such as lease agreements, service contracts, sales contracts, etc.), and annotated the content including key contract clauses (such as fee standards, payment methods, service periods, etc.). This annotated data was then divided into a training set (80%), a validation set (10%), and a test set (10%).
[0114] Loss Function and Optimization Algorithm: The cross-entropy loss function was chosen to measure the difference between the model's predictions and the true labels. The AdamW optimizer was used for optimization, with parameters set to β1=0.9, β2=0.999, and a weight decay coefficient of 0.01 to effectively prevent overfitting and accelerate model convergence.
[0115] Model Training Details: Building upon the existing hyperparameters, we emphasize the innovative application of the loss function. To address the imbalance between positive and negative samples in billing terms, we introduce FocalLoss (focus loss) to replace the standard cross-entropy loss, allowing the model to focus more on training difficult samples. To address the sparse sample size of key clauses in billing contracts (such as waiver conditions and late payment rules), we use FocalLoss as the loss function in the span extraction task, setting its focus parameter γ to 2 and its balance factor α to 0.75. This allows the model to automatically reduce the weight of high-frequency, easily distinguishable samples during training, enhancing its ability to learn low-frequency, difficult-to-distinguish but crucial business segments.
[0116] formula: ; Where pt: the model's predicted probability of the true category (such as the probability of the "late payment fee ratio" label). γ (focusing parameter): set to 2 to control the intensity of weight adjustment for easy and difficult samples; α (Balance Factor): Set to 0.75 to further reduce the weight of negative samples (non-billing terms).
[0117] This setup references best practices in the field of object detection (such as RetinaNet) and has been proven effective for long-tail entity recognition in billing text.
[0118] 3. Model performance evaluation.
[0119] The model is evaluated using a manually labeled test set, and accuracy, recall, and F1 score are calculated. For example, in a test set with 1000 contract terms labeled, if the model correctly predicts 850, incorrectly predicts 100, and misses 50, then accuracy = 850 / (850+100) ≈ 0.895, recall = 850 / (850+50) = 0.944, and F1 score = 2 × (accuracy × recall) / (accuracy + recall) ≈ 0.919. The model's performance is evaluated monthly; if the F1 score drops by more than 5%, the model is fine-tuned.
[0120] Forecasting refers to the precise location and classification of specific billing elements within the contract text. "Forecasting" encompasses two levels: 1. Spatial Extraction: The model needs to identify the start and end points of key segments in the original contract text.
[0121] For example: Original text: "Electricity consumption exceeding 500 kWh will be charged at 0.8 yuan / kWh." Correct predictions should be marked: "500" --> Type: Stepped threshold; "0.8 yuan / kWh" --> Type: Tiered rate; 2. Classification (Clause Typing / Relation Labeling): For each extracted segment, determine its semantic category or logical relationship.
[0122] For example: The rule that "0.5% will be added for each day of overdue payment" falls under the late payment fee rule rather than a penalty for breach of contract. Determine if there is a threshold-rate trigger relationship between "500" and "0.8 yuan".
[0123] In the assessment, “annotation items” refer to each manually annotated instance of a structured billing element, including its text location, type label, and relationships.
[0124] Evaluation criteria (strictly matched): Correct prediction (TruePositive, TP=850): The fragment position extracted by the model is completely correct + the class label is correct; False Positive (FP=100): The model predicted a segment, but the location or category was wrong (e.g., misclassifying "0.5%" as "basic rate"). False Negative (FN=50): The manually labeled segment exists, but the model fails to predict it at all.
[0125] 4. Contract parsing algorithm process.
[0126] Multimodal data fusion: It not only processes text, but also integrates OCR technology to extract tables and images (such as stamped supplementary clauses) from contracts, and uses multimodal BERT variants for joint understanding to improve parsing accuracy.
[0127] ①Details of the BERT variants are shown in Table 4: Table 4:
[0128] ②Detailed Explanation of the Joint Mechanism: Step 1: Each modality is encoded independently; this mainly includes text embedding, layout embedding, and image embedding.
[0129] Step 2: Cross-modal attention fusion; Introduce a lightweight cross-attention module, allowing text to take the lead, with images and layout as auxiliary elements, ultimately resulting in a text-enhanced representation that includes images and layout.
[0130] Step 3: Feed the fused representation into the transformer encoder; the fused representation is then used as input to the BERT editor. The subsequent 12 layers of Transformer simultaneously model language semantics and multimodal context.
[0131] (ii) Rules Engine Module; 1. Design of underlying syntax rules for the visual formula editor: The structure of user-input formulas is defined using the syntax rules of EBNF (Extended Backus Normal Form): <Formula>::=<Term>{("+"|"-")<Term>} <item>::=<factor>{("*"|" / "|"%")<factor>} <Factor>::=<Numerical Value> |<variable> |"("<formula>")" |"-"<Factor> <numerical value>::=[0-9]+("."[0-9]*)?(*Supports 5, 3.14, 10, etc.*) <Variable>::=[a-zA-Z_][a-zA-Z0-9_]*(*such as usage_kwh,rate1*) <operator>::="+"|"-"|"*"|" / "|"% For example: (Electricity consumption - 500) * 0.8 + 500 * 0.6; Note: This applies to the two-tier pricing: "the first 500 kWh is charged at 0.6 yuan, and the excess is charged at 0.8 yuan"; electricity consumption is a variable (matching <variable>); 500, 0.8, and 0.6 are numerical values (matching <numerical value>); operators (,-,), *, and + are all allowed.
[0132] Parse according to syntax rules: 1. The whole is a formula → composed of the addition of two terms: Item 1: (Electricity consumption - 500) * 0.8; Item 2: 500 * 0.6; 2. Analysis of Item 1: Factor 1: (Electricity consumption - 500) → The part in parentheses is a sub-formula (variable minus value); Operator: *; Factor 2: 0.8 (numerical value).
[0133] 3. Analysis of Item 2: Factor 1: 500, Factor 2: 0.6, Operator: *.
[0134] 4. Calculation order is automatically correct: First calculate the following (in parentheses): electricity consumption - 500; Calculate two more multiplications; Finally, add them together.
[0135] The formulas entered by the user must conform to the above grammatical rules. The system parses the formulas through lexical analysis and syntax analyzer, and converts them into a computer-executable expression tree structure.
[0136] Complex nested formula parsing and calculation algorithm flow: Lexical analysis splits the formula into units such as numbers, variables, operators, and parentheses according to characters. Syntax analysis constructs an expression tree according to rules. The calculation process adopts a post-order traversal of the expression tree, calculating from the leaf node to the parent node to obtain the result.
[0137] When calculating formulas, the system recursively evaluates the expression tree using a post-order traversal (Left->Right->Root) to ensure that each sub-expression is calculated before its parent expression.
[0138] The specific process is as follows: Recursively traverse from the root node: If the current node is a numeric node (such as 500, 0.8), return its value directly; If it is a variable node (such as usage_kwh), retrieve the corresponding value from the context (such as user electricity consumption); If it is an operator node (such as +, *), then its left and right subtrees are calculated recursively first, and then the two results are calculated according to the operator.
[0139] Taking the formula (usage_kwh-500)*0.8 as an example (assuming usage_kwh=620): First, traverse the left subtree: The left subtree usage_kwh returned 620; Right subtree 500 -> Return 500; Execute 620-500=120; Then traverse the right subtree -> 0.8; Finally, execute the following at the root node: 120 × 0.8 = 96.0.
[0140] The results converge from the bottom up: All intermediate results are passed up the tree from the leaf nodes, and the final result is obtained at the root node.
[0141] 5. Complex calculation algorithms and boundary condition handling.
[0142] Property management fee allocation calculation: The formula for allocating property management fees to tenants based on area is: Tenant's allocated fee = Tenant's usable area / Total usable area × Total property management fee. Boundary condition handling: When the tenant's usable area is 0, the tenant's allocated fee is 0; when a negative area appears (considered a data error), the system will prompt an error and refuse to calculate, requiring the administrator to correct the data.
[0143] Tiered pricing: The logic for handling data boundaries between different tiers is that when the electricity consumption is exactly at the tier boundary, the total electricity cost is calculated according to the unit price of that tier.
[0144] Late payment fees are calculated automatically: The exact number of overdue days is calculated from the day following the due date to the actual payment date, including all calendar days (including holidays). Handling cases spanning multiple months: Calculated based on the actual number of calendar days elapsed. For example, if the due date is August 31st and the actual payment date is September 5th, the overdue days are 6 days.
[0145] Reference Figure 3 The following is a flowchart illustrating the steps of model training according to an embodiment of this application: First, you can input the billing rules file and perform data preprocessing, such as noise removal and word segmentation. Then, you can load the pre-trained BERT model and set hyperparameters (learning rate, number of training epochs, etc.).
[0146] Additionally, the training data can be divided into training, validation, and test sets. The training set can be used to fine-tune the model, the validation set to adjust hyperparameters, and the test set to evaluate model performance. If the model performance meets the requirements, the target recognition model is output; otherwise, the hyperparameters are reset.
[0147] Reference Figure 4The following is a flowchart illustrating one step of calculating costs according to an embodiment of this application: First, the user inputs a custom rule formula. The system applying this application can perform lexical analysis to segment lexical units and perform syntax analysis to construct an expression tree. Next, it can determine whether the formula contains complex calculations; if not, the final result is calculated directly and output. If complex components are included, the corresponding complex calculation algorithm is invoked, boundary conditions are handled, and the final result is calculated and output.
[0148] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0149] Reference Figure 5 The diagram shows a structural schematic of an intelligent billing system according to an embodiment of this application, which may include the following modules: The first determination module 501 is used to determine the target item to be billed and the billing rule file for the target item to be billed. The second determining module 502 is used to identify the billing rule file in order to determine the target billing rule for the target project; The billing module 503 is used to calculate the cost of the target item to be billed according to the target billing rules.
[0150] In some embodiments, the second determining module 502 is used to obtain a target recognition model for the target item to be billed; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using a corner loss function; and the billing rule file is identified according to the target recognition model to obtain target billing rules for the target item.
[0151] In some embodiments, the second determining module 502 is further configured to acquire training data and extract multimodal data from the training data; the multimodal data includes text content, page position and image area; and perform model training based on the multimodal data to obtain a target recognition model.
[0152] In some embodiments, the second determining module 502 is further configured to, when an update event for the target recognition model is triggered, obtain newly labeled training data; and fine-tune the target recognition model based on the newly labeled training data.
[0153] In some embodiments, the target billing rule includes an expression tree. The second determining module 502 is further configured to obtain a target formula and perform lexical and syntactic analysis on the target formula; and generate an expression tree based on the lexical and syntactic analysis of the target formula.
[0154] In some embodiments, the billing module 503 is further configured to obtain cost calculation impact information and, based on the cost calculation impact information, correct the cost of the target item to be billed.
[0155] In some embodiments, the target billing rule includes a tiered billing rule, which includes multiple billing rules, and adjacent billing tiers are smoothed using linear interpolation.
[0156] In this embodiment, the target item to be billed and the billing rule file for that target item can be determined first. Then, the billing rule file is identified to determine the target billing rule for the target item. Next, the cost of the target item to be billed can be calculated according to the target billing rule. This embodiment achieves a leap from "passive rule execution" to "proactive intelligent decision-making," enabling automatic cost calculation. Compared to manually parsing files for cost calculation, this application improves the efficiency of cost calculation and avoids errors.
[0157] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-mentioned intelligent billing method based on multi-source heterogeneous data.
[0158] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described intelligent billing method based on multi-source heterogeneous data.
[0159] As the system implementation is basically similar to the method implementation, it is described in a relatively simple way. For relevant details, please refer to the description of the method implementation.
[0160] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0161] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented 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.
[0162] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should 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 terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0163] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate 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.
[0164] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal 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.
[0165] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0166] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0167] The above provides a detailed description of the intelligent billing method and system based on multi-source heterogeneous data. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A smart billing method based on multi-source heterogeneous data, characterized in that, The method includes: Identify the target items to be billed, and the billing rule documents for those target items; The billing rule file is identified to determine the target billing rule for the target project; According to the target billing rules, the cost of the target item to be billed is calculated.
2. The method according to claim 1, characterized in that, The step of identifying the billing rule file to determine the target billing rule for the target project includes: Obtain the target recognition model for the target item to be billed; the target recognition model includes an attention module and multiple recognition heads; the target recognition model is trained using a corner loss function; Based on the target identification model, the billing rule file is identified to obtain the target billing rules for the target project.
3. The method according to claim 2, characterized in that, The method further includes: Acquire training data and extract multimodal data from the training data; the multimodal data includes text content, page layout, and image areas; The target recognition model is obtained by training the model based on the multimodal data.
4. The method according to claim 2, characterized in that, The method further includes: When an update event is triggered for the target recognition model, the newly labeled training data is obtained; The target recognition model is fine-tuned based on the newly labeled training data.
5. The method according to claim 1, characterized in that, The target billing rule includes an expression tree, and the method further includes: Obtain the target formula and perform lexical and syntactic analysis on the target formula; The expression tree is generated based on the lexical and syntactic analysis of the target formula.
6. The method according to claim 1, characterized in that, The method further includes: Obtain information on the impact of cost calculation; Based on the cost calculation impact information, the costs of the target items to be billed are corrected.
7. The method according to claim 1, characterized in that, The target billing rule includes a tiered billing rule, which includes multiple billing rules. Adjacent billing tiers are smoothed using linear interpolation.
8. An intelligent billing system, characterized in that, The system includes: The first determination module is used to determine the target item to be billed, and the billing rule file for the target item to be billed; The second determining module is used to identify the billing rule file in order to determine the target billing rule for the target project; The billing module is used to calculate the cost of the target item to be billed according to the target billing rules.
9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the intelligent billing method based on multi-source heterogeneous data as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the intelligent billing method based on multi-source heterogeneous data as described in any one of claims 1 to 7.
