Drools rule dynamic generation method and system based on commodity knowledge base
By building a product knowledge base and AI large-scale model parsing logic, Drools rule files are generated and verified, solving the problems of low development efficiency and insufficient business adaptability of the rule engine, and realizing efficient and flexible rule generation and deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN NEWLAND SOFTWARE ENGINEERING CO LTD
- Filing Date
- 2025-11-24
- Publication Date
- 2026-05-05
AI Technical Summary
In the existing enterprise digital operation system, the rule engine Drools has low development efficiency, high dependence on manual labor, difficulty in quickly responding to changes in business needs, and limited ability to process complex logic, resulting in insufficient accuracy and flexibility in rule generation.
By building a product knowledge base, using AI big data models to analyze the logic of product relationships, generating Drools rule files, and performing asynchronous verification, including syntax, logic conflict and business adaptability verification, the automatic generation and deployment of rules are achieved.
It significantly improves the accuracy, flexibility, and responsiveness of rule generation, reduces manual writing and debugging time, ensures rule quality and system stability, and adapts to rapidly changing business needs.
Smart Images

Figure CN121979508A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of rule engine and artificial intelligence intersection technology, and in particular to a Drools rule dynamic generation method and system based on product knowledge base. Background Technology
[0002] In an enterprise's digital operations system, the relationship between product and commodity data is a critical infrastructure supporting business decisions. This includes the relationships between products and commodities, the relationship between products and organizational structure, the mapping logic between product pricing and attributes, the dependencies between commodity attributes, and the matching mechanism between business rules and products. Currently, Drools, as a widely adopted rule engine in the industry, typically requires the definition of business logic using rule files (such as .drl files). However, in such application scenarios, traditional rule development methods face the following significant bottlenecks: 1. High degree of reliance on manual labor: The writing of rule files depends entirely on manual logical construction based on the relationship between product data. The development efficiency is low, and the rules are prone to failure due to human negligence (such as logical omissions or incorrect parameter configurations). The cost of troubleshooting and repairing problems later is high.
[0003] 2. Insufficient business adaptability: When the relationship between product data changes (such as adding product attributes, adjusting product association strategies, updating attribute matching conditions, etc.), developers need to manually modify or rewrite the rule files, resulting in slow response and difficulty in supporting rapidly changing business needs.
[0004] 3. Limited ability to handle complex logic: When faced with multi-dimensional and cross-level product-product relationships (such as nested logic such as "product A is associated with product B, which must satisfy attribute C and simultaneously match the joint conditions of attribute E and attribute F of product D"), manually writing rules is prone to problems such as logical conflicts and incomplete coverage of boundary scenarios, and debugging and traceability are difficult.
[0005] Although existing technologies have attempted to generate rules in batches using templates to improve development efficiency, such methods generally lack the ability to understand and analyze the deep semantics of product-product relationships, making it difficult to accurately handle complex relational logic, and they have not introduced artificial intelligence technology to achieve intelligent optimization and dynamic adaptation of rules.
[0006] Therefore, how to provide a dynamic rule generation method and system for Drools based on a product knowledge base, and improve the accuracy, flexibility and response efficiency of rule generation, has become an urgent technical problem to be solved. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a method and system for dynamic generation of Drools rules based on a product knowledge base, so as to improve the accuracy, flexibility and response efficiency of rule generation.
[0008] In a first aspect, the present invention provides a method for dynamically generating Drools rules based on a product knowledge base, comprising the following steps: Step S1: Based on the entities of products, define entity attributes and relationships between entities, and construct a product relationship model based on the entity attributes and relationships. Step S2: Collect basic product data, and perform preprocessing on each product's basic data, including at least data cleaning and data normalization, based on the product relationship model. Construct a product knowledge base based on the preprocessed basic product data. Step S3: Set the rule template based on Drools rule syntax; Step S4: Create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions in the prompt word library; Step S5: The AI big model parses the product relationship logic based on the product knowledge base and the prompt word library, and generates a Drools rule file by matching the corresponding rule template based on the product relationship logic. Step S6: Perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file; Step S7: Publish the verified Drools rule file to the rule engine for deployment and testing.
[0009] Furthermore, in step S1, the relationships include mutually exclusive relationships, dependency relationships, linkage relationships, cancellation and modification relationships, and special and no relationships.
[0010] Furthermore, step S2 specifically includes: The database client collects basic product data from the database table via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning and data normalization. The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge, thereby constructing a product knowledge base.
[0011] Furthermore, step S3 specifically includes: Based on the Drools rule syntax, rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters, additional identifiers of participating products, relationship direction and modifiers, action type and action parameters, condition context parameters, and rule metadata parameters.
[0012] Furthermore, in step S6, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts in the generated Drools rule files through the AI large model and the product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.
[0013] Secondly, this invention provides a Drools rule dynamic generation system based on a product knowledge base, comprising the following modules: The product-product relationship model construction module is used to define entity attributes and relationships between entities based on product entities, and to construct a product-product relationship model based on the entity attributes and relationships. The product knowledge base construction module is used to collect basic product data, perform preprocessing on the basic product data based on the product relationship model, including at least data cleaning and data normalization, and construct a product knowledge base based on the preprocessed basic product data. The rule template setting module is used to set rule templates based on Drools rule syntax; The prompt word library creation module is used to create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions into the prompt word library; The Drools rule file generation module is used by the AI large model to parse the product relationship logic based on the product knowledge base and prompt word library, and generate Drools rule files by matching the corresponding rule templates based on the product relationship logic. The Drools rule file verification module is used to perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file. The Drools rule file deployment module is used to publish the verified Drools rule file to the rule engine for deployment and testing.
[0014] Furthermore, in the product relationship model construction module, the relationships include mutually exclusive relationships, dependency relationships, linkage relationships, cancellation and modification relationships, and special and no relationships.
[0015] Furthermore, the product knowledge base construction module is specifically used for: The database client collects basic product data from the database table via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning and data normalization. The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge, thereby constructing a product knowledge base.
[0016] Furthermore, the rule template setting module is specifically used for: Based on the Drools rule syntax, rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters, additional identifiers of participating products, relationship direction and modifiers, action type and action parameters, condition context parameters, and rule metadata parameters.
[0017] Furthermore, in the Drools rule file verification module, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts in the generated Drools rule files through the AI large model and the product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.
[0018] The advantages of this invention are: 1. Based on product entities, define entity attributes and relationships between entities. Construct a product relationship model based on these attributes and relationships. Perform preprocessing on the collected basic product data, including data cleaning and data normalization, based on this product relationship model. Construct a product knowledge base based on the preprocessed basic product data. Next, set rule templates based on Drools rule syntax, define prompt words to guide the AI model based on rule scenarios, and store these prompt words in a created prompt word library. The AI model parses the product relationship logic based on the product knowledge base and prompt word library, matches the corresponding rule templates based on the product relationship logic to generate Drools rule files, and performs asynchronous syntax validation on the Drools rule files. The process includes logical conflict verification and business adaptability verification. The verified Drools rule files are then published to the rule engine for deployment and testing. This involves building a structured product knowledge base to provide a rich semantic foundation for the AI model, enabling it to deeply analyze complex product relationship logic and replace manual drafting of core rules, thus significantly improving response efficiency. Furthermore, parameterized rule templates transform changes in business logic into dynamic parameter filling, achieving flexibility in rule generation and rapid adaptation to changing business needs. Finally, the AI model itself performs automated logical conflict verification and business scenario coverage verification on the generated rule files, forming a quality closed loop that ultimately greatly improves the accuracy, flexibility, and response efficiency of rule generation.
[0019] 2. By automatically parsing the product relationship logic through the AI big model and matching the rule template to generate Drools rule files, the time and cost of manually writing and debugging rules are greatly reduced. Traditional rule generation often relies on manual coding by experts, which is prone to errors and time-consuming. However, this invention uses a knowledge base and prompt word library to guide AI, realizing full automation from data collection to rule deployment, which significantly improves work efficiency and is especially suitable for large-scale or frequently changing business scenarios.
[0020] 3. By building a product knowledge base and cleaning and organizing the data, the quality of the basic data was ensured. At the same time, after the rules were generated, asynchronous verification steps (including syntax, logical conflict and business adaptability verification) were introduced. AI large models were used to simulate business scenarios for verification, which effectively avoided rule errors or contradictions. This multi-level verification mechanism reduced the risk of human negligence, ensured the logical rigor and business reliability of the rules, and improved system stability.
[0021] 4. By adopting a dynamic generation method based on rule templates and replaceable parameters (such as product ID, attribute constraints, etc.), the rules can be quickly adapted to business changes, such as adding new product types or adjusting relationships. In addition, the design of the prompt word library allows non-technical users to guide the AI through natural language commands, which lowers the usage threshold. This modular structure facilitates the updating of the knowledge base and templates, supports future business expansion, and enhances the long-term applicability of the technology.
[0022] 5. By deploying asynchronous validation and rule engines, computing resources are allocated reasonably, avoiding performance bottlenecks that may be caused by real-time rule generation; at the same time, the automated process reduces reliance on professional rule engineers and lowers labor costs.
[0023] 6. High degree of automation: It changes the traditional rule script development model, eliminating the need for manual rule script writing. Instead, developers directly express their requirements, and the system tools have integrated intelligent agents. Through large-scale model capabilities, it automatically generates rules end-to-end based on product-product relationship data analysis; Strong dynamic adaptability: Developers can trigger rule updates at any time based on changes in product-product relationships to adapt to rapid business iterations; Improved rule quality: The AI large-scale model can parse complex relationship logic and complete implicit rules. Combined with simulation verification, it reduces logical conflicts and improves rule accuracy and business coverage; Good external scalability: By creating a product-product knowledge base, it can be quickly expanded to adapt to the rule generation needs of different industries (such as communications, retail, and manufacturing).
[0024] 7. From "Template Filling" to "Intelligent Parsing": Breaking Through the Bottleneck of Deep Understanding of Rule Logic: Existing technologies (such as batch rule generation methods based on fixed templates) can only handle structured, explicitly defined product-product relationships (such as "attribute B=X of product A"), relying on manually preset template parameters. They cannot parse complex, implicit, or cross-level relationship logic (such as "sub-product B of product A must satisfy attribute C≥X, and attribute E≤Y of associated product D to take effect"). This invention, through deep parsing of the product-product knowledge base using an AI large-scale model, can automatically identify multi-dimensional logic types (inclusion, constraint, dependency, etc.), extract implicit business rules (such as completing "special constraints in promotional scenarios" based on industry common sense), and handle cross-level relationships (such as generating nested rules from the three-level association of "product-goods-attribute"), thereby achieving a leap from "mechanical filling" to "intelligent understanding" and covering more complex business scenarios.
[0025] 8. From "Manual Maintenance" to "Dynamic Linkage," Achieving Real-Time Adaptation of Rules and Business: Existing technologies require manual modification of templates or rule files when product relationships change (e.g., adding new products or adjusting attribute constraints), which carries risks of response delays, omissions, and errors. While some technologies support rule updates, they rely on manual triggering and lack assessment of the impact of changes. This invention, through a "knowledge base + intelligent analysis" mechanism, allows a large AI model to assess the impact of changes on existing rules (e.g., whether adding attributes leads to rule conflicts) and simultaneously optimize associated rules, achieving "real-time linkage" between rules and business data, adapting to the needs of high-frequency iterative business processes.
[0026] 9. From "Single Validation" to "End-to-End Optimization": Improving Rule Quality and Reliability: Existing rule validation technologies are mostly limited to syntax compliance (such as checking for Drools syntax errors), lacking in-depth validation of logical conflicts and business adaptability. This can lead to "logical contradictions" (such as conflicting attribute constraints for the same product) or "missed scenarios" (such as not covering unsubscription scenarios) after rules are deployed. This invention combines syntax validation, logical conflict validation, and business adaptability validation. When validation fails, the AI model re-analyzes the logic based on the feedback, iteratively optimizing the rules until they are qualified. This upgrades from "only ensuring the rules can run" to "ensuring the rules run correctly and well," significantly reducing business risks.
[0027] 10. From "Industry-Specific" to "Generalized Adaptation," Expanding the Scope of Technology Application: Existing technologies mainly rely on manual programming, while this invention uses "structured modeling of product data + dynamic generation of large AI models + intelligent verification" to construct a rule development system of "data-driven - intelligent generation - automatic verification - release and update." The core advantage lies in transforming rule generation from "relying on human experience" to "relying on intelligent decision-making based on data and AI," achieving a qualitative improvement in efficiency, adaptability, and complexity handling capabilities. Attached Figure Description
[0028] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0029] Figure 1 This is a flowchart of a method for dynamically generating Drools rules based on a product knowledge base, according to the present invention.
[0030] Figure 2 This is a schematic diagram of the structure of a Drools rule dynamic generation system based on a product knowledge base according to the present invention.
[0031] Figure 3 This is a schematic diagram of the product relationship model of the present invention. Detailed Implementation
[0032] The overall approach of the technical solution in this application is as follows: By constructing a structured product knowledge base, a rich semantic foundation is provided for the AI large model, enabling it to deeply analyze complex product relationship logic and replace manual drafting of core rules, thereby significantly improving response efficiency. On this basis, parameterized rule templates are used to transform changes in business logic into dynamic filling of template parameters, achieving flexibility in rule generation and quickly adapting to changes in business needs. Finally, the AI large model itself is used to automatically perform logical conflict verification and business scenario coverage verification on the generated rule files, forming a quality closed loop, thereby improving the accuracy, flexibility, and response efficiency of rule generation.
[0033] Please refer to Figures 1 to 3 As shown, a preferred embodiment of the Drools rule dynamic generation method based on a product knowledge base of the present invention includes the following steps: Step S1: Based on the entities of products, define entity attributes and relationships between entities, and construct a product relationship model based on the entity attributes and relationships. Step S2: Collect basic product data, and perform preprocessing on each product's basic data, including at least data cleaning and data normalization, based on the product relationship model. Construct a product knowledge base based on the preprocessed basic product data. Step S3: Set the rule template based on Drools rule syntax; Step S4: Create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions in the prompt word library; Step S5: The AI big model parses the product relationship logic based on the product knowledge base and the prompt word library, and generates a Drools rule file by matching the corresponding rule template based on the product relationship logic; that is, the parameters are filled into the rule template to generate the Drools rule file. Step S6: Perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file; output the verification results in a list format and persist them. Step S7: Publish the verified Drools rule file to the rule engine for deployment and testing. In practice, the deployed Drools rule file is tested and verified according to the actual scenario.
[0034] In step S1, the relationships include mutually exclusive relationships, dependency relationships, linkage relationships, cancellation and modification relationships, and special and no relationships.
[0035] Mutual exclusion refers to a logical conflict where goods and services cannot coexist or be claimed simultaneously. This includes: (1) Product application B is logically mutually exclusive and automatically cancels product A. Relationship: When a user applies for product B, the system automatically cancels the existing product A. This applies to priority scenarios, such as when B is a new product and A is an older product; applying for B will forcibly replace A.
[0036] Business Example: When upgrading a telecommunications plan, if you apply for a new plan B, the old plan A will automatically become invalid.
[0037] (2) Product applications are absolutely mutually exclusive (two-way) and product relationships are not allowed to be applied for: Products A and B are mutually exclusive and cannot be applied for simultaneously. Regardless of whether A or B is applied for first, the other product will be prohibited.
[0038] Business Example: Two basic insurance packages (such as A and B) cannot be ordered at the same time because their coverage overlaps.
[0039] (3) Product application B is absolutely mutually exclusive (one-way) and does not allow product application relationships: This is a one-way mutual exclusion mechanism, which only prohibits the request for A when B already exists, but may allow the request for B in the reverse direction. For example, if B already exists, A cannot be requested, but if A already exists, requesting B may be allowed.
[0040] Business Example: Premium Membership B includes basic features. After applying for B, you cannot apply for Basic Version A, but if you already have A, you can upgrade to B.
[0041] (4) The application for commodity B is not allowed to be related to the commodity relationship: When applying for product B, it may also trigger a ban on applications for certain other products. The focus is on the impact of the application for product B on other products.
[0042] Business Example: After applying for preferential package B, you are not allowed to apply for limited-time promotional product C at the same time to avoid conflicts.
[0043] Dependency refers to the preconditions for applying for or canceling a product, emphasizing the logical order of events. It includes: (1) If product application A depends on product B, product application A is not allowed if product B does not exist: Application A depends on the existence of B, but the dependency relationship is "OR" logic (i.e., it may depend on other goods). If B does not exist, application A is prohibited.
[0044] Business example: To apply for cloud server A, you must first purchase network security service B or storage service C; otherwise, you cannot apply for A.
[0045] (2) If product application A depends on product B, product relationship applications are not allowed: Application A must simultaneously satisfy the dependency on B (AND logic); neither can be omitted. If B is absent, application A is prohibited.
[0046] Business Example: Applying for a high-end mobile phone A requires purchasing accessory B (such as insurance) at the same time; applying for A alone is invalid.
[0047] (3) Product application A (within the order) or dependent product relationship not allowed: Within the same order, application A must depend on a specific product ("OR" logic); otherwise, the entire order is invalid. This emphasizes order-level constraints.
[0048] Business example: When an order contains product A, it must contain at least one of B or C; otherwise, the order submission will fail.
[0049] (4) Cancellation of product B or dependence on product A is not allowed: When canceling product B, if B is a dependency of A ("OR" logic), then canceling A is prohibited to ensure the stability of A.
[0050] Business example: Before canceling basic service B, it is necessary to ensure that value-added service A, which depends on B, has been canceled; otherwise, the cancellation of B should be prevented.
[0051] (5) Product B is cancelled or product A is automatically cancelled due to dependency: When B is cancelled, if B is a dependency of A, the system will automatically cancel A to prevent A from being in an invalid state.
[0052] Business example: After canceling network package B, the data package A that depends on B will automatically become invalid.
[0053] Association refers to mandatory or optional associated actions triggered when a product is applied for or cancelled. This includes: (1) Relationship between product application A and (mandatory) order of product B: When applying for A, users are forced to subscribe to B at the same time; this cannot be skipped.
[0054] Business example: If you apply for broadband service A, you must be bound to router B.
[0055] (2) Relationship between application for product A (conditional) and (optional) order for product B: When applying for A, ordering B may be recommended under certain conditions (such as user choice), but it is not mandatory.
[0056] Business example: When applying for flight A, you can choose to add baggage allowance B.
[0057] (3) Relationship between product application A (conditional) and (mandatory) ordering of product B: When certain conditions are met (such as user attributes), request A to force B to subscribe.
[0058] Business example: When an enterprise user applies for software A, they are forced to purchase maintenance service B.
[0059] (4) Relationship between product application A and (optionally) ordering product B: When applying for A, you are prompted that you can choose to order B, but there is no mandatory requirement.
[0060] Business example: When applying for video membership A, purchasing cloud storage B is recommended but not mandatory.
[0061] (5) The relationship between product A and product B is cancelled: When A is cancelled, ordering B is automatically triggered as compensation or a transition.
[0062] Business Example: After canceling the old package A, the system automatically subscribes to a temporary package B to ensure service continuity.
[0063] (6) Cancellation of the relationship between product A (conditional) and product B: Order B will only be placed if A is cancelled under specific conditions (such as user confirmation).
[0064] Business example: If the user agrees to cancel insurance A, then an alternative insurance B will be ordered.
[0065] The "Cancellation & Change" relationship refers to the automated actions triggered by the cancellation or change of a product. This includes: (1) The order of product A is automatically cancelled along with the order of product B. When product A is cancelled, all products B that depend on product A will be automatically cancelled to avoid leaving any invalid services.
[0066] Example of a service: If the main mobile plan A is cancelled, the secondary data plan B will be automatically cancelled.
[0067] (2) Change of product grade B (from) product A: Changes to the grade (such as specifications or version) of product B are based on adjustments to product A, reflecting hierarchical relationships.
[0068] Business example: Configuration changes for cloud server B must refer to the level of basic service A.
[0069] (3) Relationship between commodity application A and commodity B: After applying for A, the service period of B will be extended (e.g., postponed) for the lifecycle management of related products.
[0070] Business Example: After renewing Package A, the validity period of the free gift B will be extended.
[0071] Special and No Relation: (1) No relation: There are no logical constraints between the products, and each product can be applied for or cancelled independently.
[0072] Business example: Products of different categories (such as mobile phones and headphones) are not directly related.
[0073] Step S2 specifically involves: The database client collects basic product data from the database tables via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning (cleaning unnecessary records such as null values and other invalid data) and data normalization (organizing into question-and-answer pairs, as shown below: {"query": "Relationship between product A and product B", "answer": "They are mutually exclusive, ordering B requires canceling A"}, {"query": "Relationship between product A and product C", "answer": "They are mutually exclusive, ordering A does not allow ordering B"}). The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge (entity 1-relationship-entity 2), thereby constructing a product knowledge base.
[0074] Step S3 specifically involves: Based on Drools rule syntax (such as the condition part `when` and the action part `then`), rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters (indicating the specific type of relationship between products, such as mutual exclusion, dependency, linkage, cancellation and change relationships, etc.), additional identifiers of participating products (in addition to the product ID, it may also include the product name, type, code or other business identifiers), relationship direction and modifiers (indicating the directionality of the relationship or other modifiers, used to handle one-way, two-way or conditional associations), action type and action parameters (indicating the action executed when the rule is triggered, such as application, cancellation, automatic operation, etc., and action-related parameters), condition context parameters (indicating the business context or scope to which the rule applies, such as order level, user level, time range, etc.), and rule metadata parameters (parameters used for rule management and optimization, such as rule priority, rule description, and error handling method).
[0075] In step S6, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts (such as "product S1 attribute A>10" and "product S1 attribute A<5") in each of the generated Drools rule files through the AI large model and product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.
[0076] If the verification fails, the problem will be output. After further human judgment on whether it should be considered a problem, a prompt word will be generated and fed back to the AI model. The AI model will then re-parse the relational logic, optimize it, and regenerate the Drools rule file until the verification passes.
[0077] A preferred embodiment of the Drools rule dynamic generation system based on a product knowledge base of the present invention includes the following modules: The product-product relationship model construction module is used to define entity attributes and relationships between entities based on product entities, and to construct a product-product relationship model based on the entity attributes and relationships. The product knowledge base construction module is used to collect basic product data, perform preprocessing on the basic product data based on the product relationship model, including at least data cleaning and data normalization, and construct a product knowledge base based on the preprocessed basic product data. The rule template setting module is used to set rule templates based on Drools rule syntax; The prompt word library creation module is used to create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions into the prompt word library; The Drools rule file generation module is used by the AI large model to parse the product relationship logic based on the product knowledge base and prompt word library, and generate Drools rule files by matching the corresponding rule templates based on the product relationship logic; that is, filling parameters into the rule templates to generate Drools rule files. The Drools rule file verification module is used to perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file; after verification, the results are displayed in list form and persistently stored. The Drools rule file deployment module is used to publish the validated Drools rule files to the rule engine for deployment and testing. In practice, the deployed Drools rule files are tested and verified according to the actual scenario.
[0078] In the product relationship model construction module, the relationships include mutual exclusion, dependency, linkage, cancellation and modification, and special and no relationship.
[0079] Mutual exclusion refers to a logical conflict where goods and services cannot coexist or be claimed simultaneously. This includes: (1) Product application B is logically mutually exclusive and automatically cancels product A. Relationship: When a user applies for product B, the system automatically cancels the existing product A. This applies to priority scenarios, such as when B is a new product and A is an older product; applying for B will forcibly replace A.
[0080] Business Example: When upgrading a telecommunications plan, if you apply for a new plan B, the old plan A will automatically become invalid.
[0081] (2) Product applications are absolutely mutually exclusive (two-way) and product relationships are not allowed to be applied for: Products A and B are mutually exclusive and cannot be applied for simultaneously. Regardless of whether A or B is applied for first, the other product will be prohibited.
[0082] Business Example: Two basic insurance packages (such as A and B) cannot be ordered at the same time because their coverage overlaps.
[0083] (3) Product application B is absolutely mutually exclusive (one-way) and does not allow product application relationships: This is a one-way mutual exclusion mechanism, which only prohibits the request for A when B already exists, but may allow the request for B in the reverse direction. For example, if B already exists, A cannot be requested, but if A already exists, requesting B may be allowed.
[0084] Business Example: Premium Membership B includes basic features. After applying for B, you cannot apply for Basic Version A, but if you already have A, you can upgrade to B.
[0085] (4) The application for commodity B is not allowed to be related to the commodity relationship: When applying for product B, it may also trigger a ban on applications for certain other products. The focus is on the impact of the application for product B on other products.
[0086] Business Example: After applying for preferential package B, you are not allowed to apply for limited-time promotional product C at the same time to avoid conflicts.
[0087] Dependency refers to the preconditions for applying for or canceling a product, emphasizing the logical order of events. It includes: (1) If product application A depends on product B, product application A is not allowed if product B does not exist: Application A depends on the existence of B, but the dependency relationship is "OR" logic (i.e., it may depend on other goods). If B does not exist, application A is prohibited.
[0088] Business example: To apply for cloud server A, you must first purchase network security service B or storage service C; otherwise, you cannot apply for A.
[0089] (2) If product application A depends on product B, product relationship applications are not allowed: Application A must simultaneously satisfy the dependency on B (AND logic); neither can be omitted. If B is absent, application A is prohibited.
[0090] Business Example: Applying for a high-end mobile phone A requires purchasing accessory B (such as insurance) at the same time; applying for A alone is invalid.
[0091] (3) Product application A (within the order) or dependent product relationship not allowed: Within the same order, application A must depend on a specific product ("OR" logic); otherwise, the entire order is invalid. This emphasizes order-level constraints.
[0092] Business example: When an order contains product A, it must contain at least one of B or C; otherwise, the order submission will fail.
[0093] (4) Cancellation of product B or dependence on product A is not allowed: When canceling product B, if B is a dependency of A ("OR" logic), then canceling A is prohibited to ensure the stability of A.
[0094] Business example: Before canceling basic service B, it is necessary to ensure that value-added service A, which depends on B, has been canceled; otherwise, the cancellation of B should be prevented.
[0095] (5) Product B is cancelled or product A is automatically cancelled due to dependency: When B is cancelled, if B is a dependency of A, the system will automatically cancel A to prevent A from being in an invalid state.
[0096] Business example: After canceling network package B, the data package A that depends on B will automatically become invalid.
[0097] Association refers to mandatory or optional associated actions triggered when a product is applied for or cancelled. This includes: (1) Relationship between product application A and (mandatory) order of product B: When applying for A, users are forced to subscribe to B at the same time; this cannot be skipped.
[0098] Business example: If you apply for broadband service A, you must be bound to router B.
[0099] (2) Relationship between application for product A (conditional) and (optional) order for product B: When applying for A, ordering B may be recommended under certain conditions (such as user choice), but it is not mandatory.
[0100] Business example: When applying for flight A, you can choose to add baggage allowance B.
[0101] (3) Relationship between product application A (conditional) and (mandatory) ordering of product B: When certain conditions are met (such as user attributes), request A to force B to subscribe.
[0102] Business example: When an enterprise user applies for software A, they are forced to purchase maintenance service B.
[0103] (4) Relationship between product application A and (optionally) ordering product B: When applying for A, you are prompted that you can choose to order B, but there is no mandatory requirement.
[0104] Business example: When applying for video membership A, purchasing cloud storage B is recommended but not mandatory.
[0105] (5) The relationship between product A and product B is cancelled: When A is cancelled, ordering B is automatically triggered as compensation or a transition.
[0106] Business Example: After canceling the old package A, the system automatically subscribes to a temporary package B to ensure service continuity.
[0107] (6) Cancellation of the relationship between product A (conditional) and product B: Order B will only be placed if A is cancelled under specific conditions (such as user confirmation).
[0108] Business example: If the user agrees to cancel insurance A, then an alternative insurance B will be ordered.
[0109] The "Cancellation & Change" relationship refers to the automated actions triggered by the cancellation or change of a product. This includes: (1) The order of product A is automatically cancelled along with the order of product B. When product A is cancelled, all products B that depend on product A will be automatically cancelled to avoid leaving any invalid services.
[0110] Example of a service: If the main mobile plan A is cancelled, the secondary data plan B will be automatically cancelled.
[0111] (2) Change of product grade B (from) product A: Changes to the grade (such as specifications or version) of product B are based on adjustments to product A, reflecting hierarchical relationships.
[0112] Business example: Configuration changes for cloud server B must refer to the level of basic service A.
[0113] (3) Relationship between commodity application A and commodity B: After applying for A, the service period of B will be extended (e.g., postponed) for the lifecycle management of related products.
[0114] Business Example: After renewing Package A, the validity period of the free gift B will be extended.
[0115] Special and No Relation: (1) No relation: There are no logical constraints between the products, and each product can be applied for or cancelled independently.
[0116] Business example: Products of different categories (such as mobile phones and headphones) are not directly related.
[0117] The product knowledge base construction module is specifically used for: The database client collects basic product data from the database tables via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning (cleaning unnecessary records such as null values and other invalid data) and data normalization (organizing into question-and-answer pairs, as shown below: {"query": "Relationship between product A and product B", "answer": "They are mutually exclusive, ordering B requires canceling A"}, {"query": "Relationship between product A and product C", "answer": "They are mutually exclusive, ordering A does not allow ordering B"}). The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge (entity 1-relationship-entity 2), thereby constructing a product knowledge base.
[0118] The rule template setting module is specifically used for: Based on Drools rule syntax (such as the condition part `when` and the action part `then`), rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters (indicating the specific type of relationship between products, such as mutual exclusion, dependency, linkage, cancellation and change relationships, etc.), additional identifiers of participating products (in addition to the product ID, it may also include the product name, type, code or other business identifiers), relationship direction and modifiers (indicating the directionality of the relationship or other modifiers, used to handle one-way, two-way or conditional associations), action type and action parameters (indicating the action executed when the rule is triggered, such as application, cancellation, automatic operation, etc., and action-related parameters), condition context parameters (indicating the business context or scope to which the rule applies, such as order level, user level, time range, etc.), and rule metadata parameters (parameters used for rule management and optimization, such as rule priority, rule description, and error handling method).
[0119] In the Drools rule file verification module, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts (such as "product S1 attribute A>10" and "product S1 attribute A<5") in each of the generated Drools rule files through the AI large model and product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.
[0120] If the verification fails, the problem will be output. After further human judgment on whether it should be considered a problem, a prompt word will be generated and fed back to the AI model. The AI model will then re-parse the relational logic, optimize it, and regenerate the Drools rule file until the verification passes.
[0121] In summary, the advantages of this invention are: 1. Based on product entities, define entity attributes and relationships between entities. Construct a product relationship model based on these attributes and relationships. Perform preprocessing on the collected basic product data, including data cleaning and data normalization, based on this product relationship model. Construct a product knowledge base based on the preprocessed basic product data. Next, set rule templates based on Drools rule syntax, define prompt words to guide the AI model based on rule scenarios, and store these prompt words in a created prompt word library. The AI model parses the product relationship logic based on the product knowledge base and prompt word library, matches the corresponding rule templates based on the product relationship logic to generate Drools rule files, and performs asynchronous syntax validation on the Drools rule files. The process includes logical conflict verification and business adaptability verification. The verified Drools rule files are then published to the rule engine for deployment and testing. This involves building a structured product knowledge base to provide a rich semantic foundation for the AI model, enabling it to deeply analyze complex product relationship logic and replace manual drafting of core rules, thus significantly improving response efficiency. Furthermore, parameterized rule templates transform changes in business logic into dynamic parameter filling, achieving flexibility in rule generation and rapid adaptation to changing business needs. Finally, the AI model itself performs automated logical conflict verification and business scenario coverage verification on the generated rule files, forming a quality closed loop that ultimately greatly improves the accuracy, flexibility, and response efficiency of rule generation.
[0122] 2. By automatically parsing the product relationship logic through the AI big model and matching the rule template to generate Drools rule files, the time and cost of manually writing and debugging rules are greatly reduced. Traditional rule generation often relies on manual coding by experts, which is prone to errors and time-consuming. However, this invention uses a knowledge base and prompt word library to guide AI, realizing full automation from data collection to rule deployment, which significantly improves work efficiency and is especially suitable for large-scale or frequently changing business scenarios.
[0123] 3. By building a product knowledge base and cleaning and organizing the data, the quality of the basic data was ensured. At the same time, after the rules were generated, asynchronous verification steps (including syntax, logical conflict and business adaptability verification) were introduced. AI large models were used to simulate business scenarios for verification, which effectively avoided rule errors or contradictions. This multi-level verification mechanism reduced the risk of human negligence, ensured the logical rigor and business reliability of the rules, and improved system stability.
[0124] 4. By adopting a dynamic generation method based on rule templates and replaceable parameters (such as product ID, attribute constraints, etc.), the rules can be quickly adapted to business changes, such as adding new product types or adjusting relationships. In addition, the design of the prompt word library allows non-technical users to guide the AI through natural language commands, which lowers the usage threshold. This modular structure facilitates the updating of the knowledge base and templates, supports future business expansion, and enhances the long-term applicability of the technology.
[0125] 5. By deploying asynchronous validation and rule engines, computing resources are allocated reasonably, avoiding performance bottlenecks that may be caused by real-time rule generation; at the same time, the automated process reduces reliance on professional rule engineers and lowers labor costs.
[0126] 6. High degree of automation: It changes the traditional rule script development model, eliminating the need for manual rule script writing. Instead, developers directly express their requirements, and the system tools have integrated intelligent agents. Through large-scale model capabilities, it automatically generates rules end-to-end based on product-product relationship data analysis; Strong dynamic adaptability: Developers can trigger rule updates at any time based on changes in product-product relationships to adapt to rapid business iterations; Improved rule quality: The AI large-scale model can parse complex relationship logic and complete implicit rules. Combined with simulation verification, it reduces logical conflicts and improves rule accuracy and business coverage; Good external scalability: By creating a product-product knowledge base, it can be quickly expanded to adapt to the rule generation needs of different industries (such as communications, retail, and manufacturing).
[0127] 7. From "Template Filling" to "Intelligent Parsing": Breaking Through the Bottleneck of Deep Understanding of Rule Logic: Existing technologies (such as batch rule generation methods based on fixed templates) can only handle structured, explicitly defined product-product relationships (such as "attribute B=X of product A"), relying on manually preset template parameters. They cannot parse complex, implicit, or cross-level relationship logic (such as "sub-product B of product A must satisfy attribute C≥X, and attribute E≤Y of associated product D to take effect"). This invention, through deep parsing of the product-product knowledge base using an AI large-scale model, can automatically identify multi-dimensional logic types (inclusion, constraint, dependency, etc.), extract implicit business rules (such as completing "special constraints in promotional scenarios" based on industry common sense), and handle cross-level relationships (such as generating nested rules from the three-level association of "product-goods-attribute"), thereby achieving a leap from "mechanical filling" to "intelligent understanding" and covering more complex business scenarios.
[0128] 8. From "Manual Maintenance" to "Dynamic Linkage," Achieving Real-Time Adaptation of Rules and Business: Existing technologies require manual modification of templates or rule files when product relationships change (e.g., adding new products or adjusting attribute constraints), which carries risks of response delays, omissions, and errors. While some technologies support rule updates, they rely on manual triggering and lack assessment of the impact of changes. This invention, through a "knowledge base + intelligent analysis" mechanism, allows a large AI model to assess the impact of changes on existing rules (e.g., whether adding attributes leads to rule conflicts) and simultaneously optimize associated rules, achieving "real-time linkage" between rules and business data, adapting to the needs of high-frequency iterative business processes.
[0129] 9. From "Single Validation" to "End-to-End Optimization": Improving Rule Quality and Reliability: Existing rule validation technologies are mostly limited to syntax compliance (such as checking for Drools syntax errors), lacking in-depth validation of logical conflicts and business adaptability. This can lead to "logical contradictions" (such as conflicting attribute constraints for the same product) or "missed scenarios" (such as not covering unsubscription scenarios) after rules are deployed. This invention combines syntax validation, logical conflict validation, and business adaptability validation. When validation fails, the AI model re-analyzes the logic based on the feedback, iteratively optimizing the rules until they are qualified. This upgrades from "only ensuring the rules can run" to "ensuring the rules run correctly and well," significantly reducing business risks.
[0130] 10. From "Industry-Specific" to "Generalized Adaptation," Expanding the Scope of Technology Application: Existing technologies mainly rely on manual programming, while this invention uses "structured modeling of product data + dynamic generation of large AI models + intelligent verification" to construct a rule development system of "data-driven - intelligent generation - automatic verification - release and update." The core advantage lies in transforming rule generation from "relying on human experience" to "relying on intelligent decision-making based on data and AI," achieving a qualitative improvement in efficiency, adaptability, and complexity handling capabilities.
[0131] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for dynamically generating Drools rules based on a product knowledge base, characterized in that: Includes the following steps: Step S1: Based on the entities of products, define entity attributes and relationships between entities, and construct a product relationship model based on the entity attributes and relationships. Step S2: Collect basic product data, and perform preprocessing on each product's basic data, including at least data cleaning and data normalization, based on the product relationship model. Construct a product knowledge base based on the preprocessed basic product data. Step S3: Set the rule template based on Drools rule syntax; Step S4: Create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions in the prompt word library; Step S5: The AI big model parses the product relationship logic based on the product knowledge base and the prompt word library, and generates a Drools rule file by matching the corresponding rule template based on the product relationship logic. Step S6: Perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file; Step S7: Publish the verified Drools rule file to the rule engine for deployment and testing.
2. The method for dynamically generating Drools rules based on a product knowledge base as described in claim 1, characterized in that: In step S1, the relationships include mutually exclusive relationships, dependency relationships, linkage relationships, cancellation and modification relationships, and special and no relationships.
3. The method for dynamically generating Drools rules based on a product knowledge base as described in claim 1, characterized in that: Step S2 specifically involves: The database client collects basic product data from the database table via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning and data normalization. The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge, thereby constructing a product knowledge base.
4. The method for dynamically generating Drools rules based on a product knowledge base as described in claim 1, characterized in that: Step S3 specifically involves: Based on the Drools rule syntax, rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters, additional identifiers of participating products, relationship direction and modifiers, action type and action parameters, condition context parameters, and rule metadata parameters.
5. The method for dynamically generating Drools rules based on a product knowledge base as described in claim 1, characterized in that: In step S6, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts in the generated Drools rule files through the AI large model and the product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.
6. A Drools rule dynamic generation system based on a product knowledge base, characterized in that: Includes the following modules: The product-product relationship model construction module is used to define entity attributes and relationships between entities based on product entities, and to construct a product-product relationship model based on the entity attributes and relationships. The product knowledge base construction module is used to collect basic product data, perform preprocessing on the basic product data based on the product relationship model, including at least data cleaning and data normalization, and construct a product knowledge base based on the preprocessed basic product data. The rule template setting module is used to set rule templates based on Drools rule syntax; The prompt word library creation module is used to create a prompt word library, define prompt word instructions for guiding the AI large model based on rule scenarios, and store each of the prompt word instructions into the prompt word library; The Drools rule file generation module is used by the AI large model to parse the product relationship logic based on the product knowledge base and prompt word library, and generate Drools rule files by matching the corresponding rule templates based on the product relationship logic. The Drools rule file verification module is used to perform asynchronous syntax verification, logical conflict verification, and business adaptability verification on the Drools rule file. The Drools rule file deployment module is used to publish the verified Drools rule file to the rule engine for deployment and testing.
7. The Drools rule dynamic generation system based on a product knowledge base as described in claim 6, characterized in that: In the product relationship model construction module, the relationships include mutual exclusion, dependency, linkage, cancellation and modification, and special and no relationship.
8. The Drools rule dynamic generation system based on a product knowledge base as described in claim 6, characterized in that: The product knowledge base construction module is specifically used for: The database client collects basic product data from the database table via API interface. Based on the product relationship model, the basic product data is preprocessed, including at least data cleaning and data normalization. The preprocessed basic product data is then imported into the intelligent agent to extract triple knowledge, thereby constructing a product knowledge base.
9. The Drools rule dynamic generation system based on a product knowledge base as described in claim 6, characterized in that: The rule template setting module is specifically used for: Based on the Drools rule syntax, rule templates are set to generate Drools rule files, and the correspondence between each rule template and the product relationship logic is defined. The rule template contains replaceable parameters. The replaceable parameters include at least the product ID, attribute constraints, relationship type parameters, additional identifiers of participating products, relationship direction and modifiers, action type and action parameters, condition context parameters, and rule metadata parameters.
10. The Drools rule dynamic generation system based on a product knowledge base as described in claim 6, characterized in that: In the Drools rule file verification module, the syntax verification specifically involves: detecting whether the Drools rule file satisfies the Drools rule syntax; The logical conflict verification specifically involves verifying whether there are logical conflicts in the generated Drools rule files through the AI large model and the product knowledge base. The business compatibility verification specifically involves: using an AI large-scale model to simulate business scenarios and perform coverage verification on the Drools rule file.