Rule base dynamic construction method and device based on large language model and medium
Through the dynamic construction method based on large language model, the problems of high labor costs and insufficient real-time in rule database construction are solved, dynamic optimization and full-process automation of rule databases are realized, and the logical completeness and real-time nature of rule generation are improved.
Patent Information
- Application Number
- CN202510645596.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2045-05-20
AI Technical Summary
The existing rule library construction technology has problems such as high labor costs, long iteration cycles, semantic faults of rules, and insufficient real-time performance. It is difficult to achieve full-process automation of rule generation, verification, and optimization, especially when processing unstructured text.
A dynamic construction method based on a large language model is adopted, and dynamic optimization and update of the rule base is achieved through multi-source data input, feature normalization, domain knowledge graph injection, semantic triple enhancement, symbolic processing and dynamic update, combined with aging attenuation factor and user feedback factor.
It realizes dynamic management of the rule base throughout the life cycle, improves the logical completeness and real-timeness of rule generation, ensures the interpretability and dynamic adaptability of the system, and supports multi-objective optimization and rapid response.
Smart Images

Figure CN120179811A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rule base construction, and specifically to a method, device, and medium for dynamically constructing a rule base based on a large language model. Background Art
[0002] Currently, rule base construction technology faces multiple technical bottlenecks in the general field.
[0003] The mainstream solutions in traditional schemes can be divided into two categories: manual-driven and data-driven. Manual-driven technology relies on domain experts to manually write rule logic. Although it can ensure the accuracy of rules, the average time-consuming for a single manually written rule even exceeds 30 minutes. It has the defects of high labor cost, long iteration cycle, and is difficult to cover the implicit logic in complex scenarios. Data-driven technology automatically extracts rules from labeled data through machine learning methods such as decision trees and association rule mining. However, the generated rules often lack semantic coherence, and there may be a phenomenon of "rule semantic discontinuity". Especially when dealing with unstructured text (such as contract terms and technical documents), the practicality of rules decreases due to the difficulty in deeply analyzing context associations. Summary of the Invention
[0004] To solve the above problems, this application proposes a method for dynamically constructing a rule base based on a large language model, including: Receiving heterogeneous data input from multiple sources and performing feature normalization to obtain standard data; Based on a pre-set hierarchical template structure, injecting meta-knowledge through the domain knowledge graph corresponding to the standard data to generate dynamic prompt words; Using the large language model, taking the dynamic prompt words as input, outputting corresponding semantic triples, performing semantic enhancement on the semantic triples, and calculating the confidence of the semantic triples; Performing symbolic processing and vectorization processing on the semantic triples to obtain rule vectors, and generating corresponding specified rules according to the rule vectors and the corresponding confidence, and adding them to the rule base; Based on the trigger of a preset event, through the data update of an external specified knowledge base, locally dynamically updating the rule subset in the rule base, and dynamically updating the rule weights of the specified rules determined by the confidence according to the time decay factor and user feedback factor.
[0005] In one example, based on a pre-set hierarchical template structure, injecting meta-knowledge through the domain knowledge graph corresponding to the standard data to generate dynamic prompt words specifically includes: Determining a pre-set hierarchical template structure; wherein, the hierarchical template structure includes an atomic rule layer, a composite rule layer, and a constraint condition layer; Through the atomic rule layer, set the field units included in the prompt; and through the composite rule layer, set the logical relationships between the field units; and through the constraint condition layer, add constraint conditions on the basis of the field units to generate a prompt template; Through the domain knowledge graph corresponding to the standard data, obtain the metadata corresponding to the field unit, and through the metadata, supplement the content of the prompt template to obtain the corresponding dynamic prompt.
[0006] In one example, semantic enhancement is performed on the semantic triple, and confidence calculation is performed on the semantic triple, specifically including: For the semantic triple, uniformly map the entity information included therein; Perform syntactic structure analysis on the standard data, extract the corresponding modification information, and perform semantic enhancement on the semantic triple based on the modification information; Determine the corresponding conditional trigger probability, and calculate the confidence of the semantic triple based on the semantic similarity between the semantic triple and the corresponding domain knowledge graph, the structural integrity of the semantic triple, and the context coherence of the semantic triple.
[0007] In one example, symbolize and vectorize the semantic triple to obtain a rule vector, specifically including: Convert the semantic triple into an abstract syntax tree for symbolic processing; Encode the abstract syntax tree through a graph neural network to obtain a rule vector; Among them, in the graph neural network, during the update process of the rule vector, perform mean pooling operation based on the embedding vectors of the child nodes in the previous layer iteration, and splice with the rule vector obtained in the previous layer to obtain the rule vector of the next layer.
[0008] In one example, perform local dynamic update on the rule subset in the rule base through data update of an external specified knowledge base, specifically including: Determine the specified knowledge base corresponding to the multi-source input, monitor the specified knowledge base, and extract the updated event feature vector; Based on the event feature vector, perform similarity matching with each rule vector in the rule base to obtain the corresponding first rule subset; Obtain user feedback data, and determine the corresponding second rule subset based on the feedback satisfaction corresponding to the user feedback data and / or the rule trigger times corresponding to the user feedback data; Perform local dynamic updates for the specified rules included in the first rule subset and / or the second rule subset; During the local dynamic update process, if the rule library is in an online state, compare and test the updated specified rule with the specified rule before the update to obtain the corresponding difference in execution effects; if the rule library is in an offline state and the difference in execution effects is higher than the preset minimum gain threshold, sort the specified rules according to the updated rule weights.
[0009] In one example, dynamically update the rule weights of the specified rules determined by the confidence according to the aging decay factor and the user feedback factor, which specifically includes: Determine the initial rule weight corresponding to the specified rule according to the confidence, and determine the specified domain corresponding to the specified rule; Determine the first update coefficient according to the update frequency of the associated policy text in the specified domain, and determine the second update coefficient according to the user feedback data; Determine the corresponding aging decay coefficient according to the first update coefficient, the second update coefficient, and the domain adaptation weight coefficient corresponding to the specified domain, and determine the corresponding aging decay factor according to the aging decay coefficient and the current rule weight; Determine the user feedback factor according to the user feedback gain coefficient and the user feedback data; Determine the vector update factor according to the update result of the rule vector corresponding to the specified rule and the semantic similarity gain coefficient; Dynamically update the rule weights according to the aging decay factor, the user feedback factor, and the vector update factor.
[0010] In one example, the method further includes: Extract the attention matrices of each layer of the large language model and determine the attention heads corresponding to the specified rules; Based on the attention heads, determine the influence scores corresponding to each token unit in the standard data; According to the influence scores, associate each node of the abstract syntax tree with the token units to obtain the importance weights corresponding to the nodes of the abstract syntax tree; Obtain and display the rule traceability graph by rendering; where the node size in the rule traceability graph is positively correlated with the importance weights, and the color depth of the edges reflects the logical dependence strength.
[0011] In one example, the method further includes: Parse according to the abstract syntax tree to obtain a sequence of logical units; Generate corresponding explanatory text according to the structured template based on the sequence of logical units; Generate adjustment instructions based on the local dynamic update.
[0012] On the other hand, the present application also proposes a device for dynamically constructing a rule base based on a large language model, including: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for dynamically constructing a rule base based on a large language model as described in any of the above examples.
[0013] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions are set to: the method for dynamically constructing a rule base based on a large language model as described in any of the above examples.
[0014] The method for dynamically constructing a rule base based on a large language model proposed by the present application can bring the following beneficial effects: The deep collaboration between the large language model and the symbol system, introducing a logical verification layer through local dynamic update to formally constrain the generation results of the large language model, while retaining the generation ability and ensuring the completeness of the rule logic.
[0015] Through a dynamic closed-loop management mechanism, a real-time closed loop of "generation-verification-feedback-optimization" is constructed, and the rule weights are dynamically adjusted according to the time decay factor and the user feedback factor.
[0016] Information is exchanged between layers through a unified data bus, where the control bus monitors external knowledge change events in real time (such as policy and regulation updates), and when a preset trigger condition is detected, the incremental update process of the rule base is automatically started. The service interface layer provides a rule version comparison function, supporting the backtracking of historical rule states through timestamps to ensure that the system has the ability to quickly roll back in case of faults.
[0017] An interpretability enhancement design is set up, combining attention weight visualization and rule dependency graphs to realize a traceable inference chain from the original text to the generated rules. Description of the Drawings
[0018] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings: Figure 1Schematic flowchart of the method for dynamically constructing a rule base based on a large language model in an embodiment of the present application; Figure 2 Schematic architecture diagram of a rule base dynamic construction system in a certain situation in an embodiment of the present application; Figure 3 Schematic diagram of the method for dynamically constructing a rule base based on a large language model in a certain situation in an embodiment of the present application; Figure 4 Schematic diagram of the device for dynamically constructing a rule base based on a large language model in an embodiment of the present application. Detailed implementation manners
[0019] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0020] The following will detail the technical solutions provided in each embodiment of the present application in conjunction with the drawings.
[0021] For the above technical problems, rule generation can be based on reinforcement learning. However, its rule generation framework requires a preset reward mechanism and is difficult to adapt to the dynamic requirements of multi-objective complex scenarios. Rule verification can also be based on a knowledge graph. However, although this verification method can establish rule associations, its graph construction depends on manual maintenance and lacks real-time performance, making it difficult to meet the business environment with high-frequency updates.
[0022] Generally speaking, the core defect of the traditional solution mainly stems from the limitations of the underlying architecture.
[0023] Traditional rule generation methods highly rely on structured data input and manual feature engineering, making it difficult to capture implicit logical relationships in natural language and resulting in insufficient rule generalization ability. For example, when policies and regulations are updated, a static rule base requires a large amount of manpower to recheck logical consistency. Although manual writing and static templates can ensure logical controllability, they sacrifice response speed and generalization ability.
[0024] Solutions based on knowledge graphs and the like attempt to establish rule associations through graph neural networks, but their graph construction still depends on manual annotation and has weak real-time update capabilities. Data-driven and deep learning solutions have improved the degree of automation, but are limited by insufficient semantic understanding depth. This contradiction is more prominent in the digital environment with high-frequency policy iterations and fragmented business scenarios.
[0025] Traditional solutions are either restricted by the rigidity of preset conditions or troubled by overloaded resource consumption. It is difficult to achieve full-process automation of rule generation, verification, and optimization, and it is difficult to balance the interpretability and dynamic adaptability of rules, which has become a key obstacle restricting the implementation of intelligent rule base technology.
[0026] As Figure 1 shown, the embodiments of the present application provide a method for dynamically constructing a rule base based on a large language model, which is applied in a rule base dynamic construction system (hereinafter referred to as the system).
[0027] As Figure 2 shown, the system includes a data perception layer, a semantic parsing layer, a dynamic update layer, and a service interface layer, forming a full-process closed loop from multi-source data input to rule service output. The system adopts a hierarchical decoupling design, and through the deep cooperation of the semantic understanding ability of the large language model (Large Language Model, LLM) and the symbolic logic verification mechanism, it realizes the dynamic management of the entire life cycle of rule generation, verification, optimization, and deployment.
[0028] At the system architecture level, the data perception layer includes a heterogeneous data access module and a feature normalization module, which support the unified structured processing of multi-modal inputs such as policy texts, user behavior logs, and business work orders. The semantic parsing layer deploys a context-aware rule extraction engine, which uses a multi-level attention mechanism to enhance the large language model's ability to capture implicit logic and converts unstructured text into weighted semantic triples (Subject-Predicate-Object, SPO). The dynamic update layer adopts an incremental learning framework and designs a dynamic rule weight adjustment algorithm based on a time decay factor and a feedback gain coefficient. The service interface layer realizes microservice deployment through a rule API gateway, and at the same time provides a visual interpretation platform for the rule traceability graph, supporting the reverse traceability of the decision path.
[0029] As Figure 1 shown, the method includes: S101: Receive heterogeneous data input from multiple sources and perform feature normalization to obtain standard data.
[0030] The heterogeneous data access module is used to receive heterogeneous data input from multiple sources. The sources of the multiple-source input can include different websites, databases, articles, manuals, etc. The data obtained from different sources may have structural differences, pattern incompatibilities, encoding representation differences, file format differences, etc., which are called heterogeneous data.
[0031] For heterogeneous data, it is difficult to process directly. At this time, feature normalization is performed through a feature normalization module. Among them, feature normalization can include basic data format normalization, numerical feature normalization, categorical feature normalization, etc., which are respectively used to convert the same feature from different sources into a consistent data type (for example, convert a numerical value in string format to a floating point type, convert "yes / no" to a boolean type, etc.), scale the data to a fixed range or fixed value, select an appropriate feature encoding to encode the data (for example, unique encoding, label encoding, target encoding, etc.).
[0032] S102: Based on a pre-set hierarchical template structure, perform meta-knowledge injection through the domain knowledge graph corresponding to the standard data to generate dynamic prompt words.
[0033] As Figure 3 shown, the rule generation process mainly includes the following several stages: In the rule extraction stage and the rule generation stage, it is mainly used to drive the extraction of atomic rules and composite rules from the original text of the large language model based on the dynamically generated domain adaptation Prompt template, and generate a candidate rule set with confidence scores.
[0034] In the rule verification stage and the dynamic optimization stage, according to the real-time feedback data stream (such as user behavior, external knowledge update), trigger the recalculation of rule weights, and use a multi-objective optimization algorithm with constraint conditions to update the rule base.
[0035] In the service deployment stage, convert the verified rule base into executable code, and provide low-latency inference services externally through the API gateway.
[0036] In the rule extraction stage and the rule generation stage, based on the semantic parsing ability of the large language model, the semantic parsing layer adopts multi-level dynamic prompt (Prompt) engineering and structured representation technology to realize the automatic conversion from unstructured text to executable rules. Through the dynamic generation mechanism of domain-adapted multi-level Prompt templates, drive the large language model to extract semantic triples (Subject-Predicate-Object, SPO) from the input text.
[0037] Determine the pre-set hierarchical template structure; among them, the hierarchical template structure includes an atomic rule layer, a composite rule layer, and a constraint condition layer. Among them, the three layers included in the hierarchical template structure are fixed, however, the content included in each layer may be different in different scenarios and domains, thus obtaining a dynamic prompt word template. Improve this dynamic prompt word template according to the meta-knowledge of the knowledge graph to obtain the final dynamic prompt word.
[0038] In a hierarchical template structure, there are at least three levels of prompt word hierarchies. The first level is the atomic rule layer, which is used to extract atomic rules. Here, an atomic rule is the smallest description unit in the prompt word, usually referring to the field unit contained in the prompt word. The second level is the composite rule layer, which expresses the logical relationships between the atomic rule layers. The third level is the constraint condition layer, which is used to add corresponding constraint conditions. For example, adding a domain constraint condition to describe the domain to which the currently obtained standard data belongs, and corresponding constraint conditions can also be added to the existing atomic rule layer and composite rule layer.
[0039] Based on this, through the atomic rule layer, the field units contained in the prompt word are set; through the composite rule layer, the logical relationships between the field units are set; and through the constraint condition layer, constraint conditions are added on the basis of the field units to generate a prompt word template.
[0040] For example, in the legal field, the field units set in the atomic rule layer may include "subject type", "trigger condition", "legal consequence", etc. The composite rule layer represents the logical relationships among these field units. In the legal field, this logical relationship is usually a same-level logical relationship, while in other fields, the logical relationships may include dependency relationships, inclusion and being included relationships, etc. In the constraint condition layer, domain constraint conditions can be added through role definition, and other constraint conditions can be added based on requirements (such as word count limitations, context information recognition limitations, etc.).
[0041] Through the domain knowledge graph corresponding to the standard data, the metadata corresponding to the field units is obtained, and through the metadata, the content of the prompt word template is supplemented to obtain the corresponding dynamic prompt word.
[0042] The dynamic generation of the prompt word template depends on the injection of meta-knowledge of the domain knowledge graph. The domain core concepts are extracted through a graph neural network (such as "constituent elements", "exemption circumstances", etc. in legal provisions), and embedded into the prompt word context (such as being embedded as a constraint condition in the constraint condition layer, or improving the field unit) to enhance the ability of the large language model to capture implicit logical relationships.
[0043] Taking the legal field as an example, the hierarchical template structure can be: [Role Definition] As a legal expert, extract the rights and obligations relationships from the following clauses: [Input Text] {Legal provisions to be parsed} [Output Format] Subject(Subject)-Predicate(Predicate)-Object(Object): - Subject Type: <Legal Person / Natural Person> - Trigger condition: <Time / Event Constraint> - Legal consequence: <Description of the consequence of the act> S103: Using a large language model, take the dynamic prompt as input, output the corresponding semantic triple, perform semantic enhancement on the semantic triple, and calculate the confidence level for the semantic triple.
[0044] In the rule verification stage, the semantic parsing layer receives the dynamic prompt generated based on the current domain and calls the large language model to output the corresponding semantic triple. For example, when the input text is "If the lessee fails to pay the rent without justifiable reason for a cumulative period of 30 days, the lessor may terminate the lease contract and claim damages.", the output semantic triple can be: Subject: lessee, Predicate: fails to pay rent, Object: lessor.
[0045] This semantic triple is an intermediate representation form of the rule. However, directly using this triple to generate the rule may result in an inaccurate rule description due to the relatively weak semantic content contained in the triple.
[0046] Based on this, perform semantic enhancement processing on the original semantic triple SPO output by the large language model.
[0047] For the semantic triple, uniformly map the entity information contained therein. For example, based on the joint model of BERT - BiLSTM - CRF for entity disambiguation and linking, uniformly map entities with different expressions (such as "Party A" and "lessee") to the canonical nodes in the knowledge graph.
[0048] Perform syntactic structure analysis on the standard data, extract the corresponding modification information, and perform semantic enhancement on the semantic triple based on the modification information. For example, identify modification information such as conditional adverbials and time constraints through dependency syntax analysis, so as to perform semantic enhancement on the semantic triple and add corresponding time constraints, conditional constraints, etc.
[0049] According to the time constraint in the modification information, determine the corresponding rule effective time interval, and within this time constraint, according to the conditional constraint of the conditional adverbial, determine the number of trigger times in the rule effective time interval, and combine domain knowledge to obtain the conditional trigger probability.
[0050] At the same time, calculate the confidence level of the semantic triple based on the semantic similarity between the semantic triple and the corresponding domain knowledge graph, the structural integrity of the semantic triple, and the context coherence of the semantic triple.
[0051] At this time, according to the conditional trigger probability and the obtained confidence level, they can be used as supplements after semantic enhancement of the semantic triple, and added to the semantic enhancement process together for subsequent rule generation. Its expression can be as shown in Formula 1: Formula 1; Among them, is the original semantic triple, is the semantic triple after semantic enhancement, are the start and end points of the rule effective time respectively, used to represent the rule effective time interval, is the conditional trigger probability, is the confidence level.
[0052] And the calculation expression of the confidence level can be as shown in Formula 2: Formula 2; Among them, is the semantic similarity between the semantic triple and the domain knowledge base (which can be calculated based on the cosine similarity of Sentence-BERT), is the structural integrity of the semantic triple (verifying the field completeness according to the preset grammar rules ), is the context coherence of the semantic triple (determined by quantifying the logical consistency through the entropy value of the self-attention weights of the large language model), is a configurable weight coefficient, and the sum of them is 1.
[0053] In the semantic triple after semantic enhancement in this way, it not only contains the effective content in the conditional adverbial, time constraint and other modification information, but also contains the corresponding conditional trigger probability and confidence level, so as to facilitate the subsequent implementation of functions such as priority sorting and iteration of the rule according to the conditional trigger probability and confidence level after the rule is generated.
[0054] S104: Perform symbolic processing and vectorization processing on the semantic triple to obtain a rule vector, and generate a corresponding specified rule according to the rule vector and the corresponding confidence level, and add it to the rule library.
[0055] The semantic triple obtained at this time can actually be used as a new rule. However, for the convenience of storing and referencing the rule, it can be symbolically processed and vectorized, and the confidence level obtained above is added to the obtained rule vector to improve the rule. For the convenience of description here, the newly obtained rule is called the specified rule. After the specified rule is generated, it can be added to the rule library to realize the construction of the rule library.
[0056] Specifically, at the symbolic level, semantic triples are converted into an abstract syntax tree for symbolic processing.
[0057] Define the ANTLR grammar rules to Convert to an abstract syntax tree (AST). For example, the original standard data is "If the lessee fails to pay the rent without justifiable reasons for a cumulative period of 30 days, the lessor may terminate the lease contract and claim damages.", and the result is "If the lessee fails to pay the rent overdue for more than 30 days, the lessor has the right to terminate the contract". Through corresponding symbolic processing, the parsed AST can be: IF (the lessee overdue pays the rent) WITH Duration>30d THEN (the lessor executes to terminate the contract).
[0058] At the vectorization level, through a graph neural network, the abstract syntax tree is encoded to obtain a rule vector. Among them, the GraphSAGE graph neural network can be used to encode the AST to generate a rule vector .
[0059] Among them, in the graph neural network, in order to gradually capture and fuse the multi-level dependency relationships and complex semantic associations between rules, the rule vector usually needs to be iteratively generated. During the update process of the rule vector, a mean pooling operation is performed based on the embedding vectors of the child nodes in the previous layer iteration, and concatenated with the rule vector obtained in the previous layer to obtain the rule vector of the next layer. Its update formula can be as shown in Formula 3: Formula 3; Among them, is the embedding vector of the child nodes during the k-th layer iteration, The function adopts a mean pooling operation, is vector concatenation, is a trainable parameter matrix, The rule vector of the k-th layer (corresponding to the previous layer in the above text), is the rule vector of the k + 1-th layer (corresponding to the next layer in the above text).
[0060] The specified rules obtained at this time can be stored through a dual-engine of a Neo4j graph database and a relational database. The graph database stores the logical dependency relationships between rules (for example, the causal relationship between the "terminate the contract" rule and the "rent payment" rule), and the relational database records the metadata of the specified rules (including confidence , effective time , version number, etc.). The two are associated for query and joint reasoning through a unique rule ID.
[0061] Through this technology collaboration, the system solves the semantic discontinuity problem in traditional rule generation. For example, when parsing the clause "Failure to pay the deposit within 10 working days after the contract is signed shall be regarded as an automatic waiver", the system not only extracts the triple (contract signatory, non-payment, deposit), but also attaches a time constraint ( ) and an action modifier (automatic waiver), and finally generates an executable rule with a complete logical chain. Moreover, the confidence is recorded in the database as the initial value of the rule weight and passed to the dynamic update layer to form an internal consistency closed loop of the technical solution.
[0062] S105: Based on the trigger of a preset event, through the data update of an external specified knowledge base, locally dynamically update the rule subset in the rule base, and dynamically update the rule weight of the specified rule determined by the confidence according to the time decay factor and the user feedback factor.
[0063] In the dynamic optimization stage, during the use of the rule base after it is built, it is also possible to dynamically update each specified rule in the rule base based on the actual situation. The dynamic update module realizes the continuous optimization and adaptive adjustment of the rule base based on the incremental learning framework and the real-time feedback mechanism.
[0064] The preset event can be set based on requirements. For example, the preset event includes that the content of the monitored external knowledge base has been updated, the satisfaction of the user feedback data does not meet the expectation, the trigger rate of the rules in the rule base is abnormal, etc. At this time, the dynamic update of the rule base can be triggered.
[0065] During the dynamic update process, it can include two levels of updates, namely, updating the rule weight of the added specified rule and updating the content of the specified rule.
[0066] During the process of updating the content of the specified rule, the incremental learning process is triggered through dual-channel event listening.
[0067] Determine the specified knowledge base corresponding to the multi-source input, monitor the specified knowledge base, and extract the updated event feature vector. The specified knowledge base is pre-determined. According to the different specified domains to which the specified rules belong, screen the corresponding authoritative specified knowledge bases as the monitoring objects. For example, it can be the specified knowledge bases corresponding to policies and regulations, industry standards. When the specified knowledge base is updated, the corresponding updated event feature vector is extracted .
[0068] Based on the event feature vector, perform similarity matching with each rule vector in the rule base to obtain the corresponding first rule subset. Expand the similarity matching between the event feature vector and the rule base, and filter out the affected rule subset as the first rule subset. For example, select the specified rules with a similarity higher than a certain value but not 100% similarity to form the first rule subset.
[0069] Meanwhile, obtain the user feedback data, and determine the corresponding second rule subset based on the feedback satisfaction corresponding to the user feedback data and / or the rule trigger times corresponding to the user feedback data. The user feedback data can be obtained by analyzing the user interaction logs, obtaining the call records of the rules in the rule base to determine the trigger times of each rule, and corresponding user satisfaction questionnaires can also be set to obtain the user's satisfaction with the use of the rule base.
[0070] When the trigger times of a certain rule within a time window exceed the adaptive threshold, or the user satisfaction score is continuously lower than the threshold times, add this rule to the second rule subset. Among them, the adaptive threshold can be as shown in Formula Four: Formula Four; Among them, is the adaptive threshold, is the historical average trigger times, is a preset constant value.
[0071] At this time, the specified rules in the first rule subset and the second rule subset respectively represent the rules for updating the original content, or the rules that are frequently triggered recently and the users are not satisfied with. Therefore, local dynamic updates are performed on the specified rules included in the first rule subset and / or the second rule subset.
[0072] During the local dynamic update process, incremental learning adopts an online-offline hybrid mode to ensure the continuity of the service. Among them, the online status and offline status of the rule base indicate whether the rule base is being used.
[0073] When the rule base is in the online state, compare and test the updated specified rules with the specified rules before the update to obtain the corresponding execution effect difference. For example, in the online state, put the rule set to be updated (corresponding to the union of the first rule subset and the second rule subset) into the shadow rule base, and compare the execution effect differences between the new and old rule sets through A / B testing. And the execution effect difference can be as shown in Formula Five: Formula Five; Among them, For the execution effect difference, is the rule effect index, which can be selected and set manually. For example, it can include the customer service problem-solving rate, rule trigger frequency, etc. , respectively represent the values of the rule effect index corresponding to the kth specified rule after and before the update.
[0074] When the rule library is in an offline state and the execution effect difference is higher than the preset minimum gain threshold, that is ( is the preset minimum gain threshold), it is considered that the current update is effective, and the specified rules are sorted according to the updated rule weights. The higher the updated rule weight, the higher its priority, and the more forward it is sorted. The calculation process of the rule weight can use a multi-objective optimization algorithm with constraints to solve the optimal weight combination. Among them, the constraint conditions can include the rule effect index, and the objectives of the multi-objective optimization algorithm can include the optimal solution achieved by each index in the rule effect index.
[0075] After this local update, the rule library is hot-deployed to the production environment through the version control gateway, and the old version is retained in the rollback buffer.
[0076] While updating the content included in the specified rule, the rule weight of the specified rule can also be updated.
[0077] During the update process of the rule weight, through the dynamic coupling calculation of the time decay factor and the user feedback factor, combined with the rule weight adjustment algorithm, it is ensured that the rule library evolves accurately with the change of the external environment.
[0078] In the above text, when generating the specified rule, its corresponding confidence level has been obtained. At this time, according to the confidence level, the initial rule weight corresponding to the specified rule is determined, and the specified domain corresponding to the specified rule is determined. Here, the obtained confidence level can be directly , as the initial rule weight . Among them, the rule weight represents the reliability and importance of the specified rule. The higher the rule weight, the more reliable and important the rule is.
[0079] Determine the first update coefficient according to the update frequency of the associated policy text in the specified domain, and determine the second update coefficient according to the user feedback data. The associated policy text in the specified domain can be determined through a specific knowledge base in this domain, and this knowledge base can be pre-marked manually. And the user feedback data can be obtained by analyzing the user interaction log.
[0080] Generally speaking, for convenience of description, it can be set that the update frequency of the associated policy text is positively correlated with the first update coefficient, and the user satisfaction in the user feedback data is positively correlated with the second update coefficient.
[0081] According to the first update coefficient, the second update coefficient, and the domain adaptation weight coefficient corresponding to the specified domain, the corresponding aging attenuation coefficient is determined. The domain adaptation weight coefficient is set based on different domains and is used to describe the weights of the first update coefficient and the second update coefficient. The sum of the domain adaptation weight coefficients corresponding to the first update coefficient and the second update coefficient is 1.
[0082] The formula for the aging attenuation coefficient can be as shown in Formula Six: Formula Six; Among them, is the aging attenuation coefficient of the i-th specified rule, is the domain adaptation weight coefficient, is the first update coefficient, is the second update coefficient, represents the update frequency of the associated policy text, is the length of the monitoring time window, is the variance of the user feedback data (covering the number of rule trigger times etc.) of the i-th specified rule, is the maximum value of the variances of the user feedback data of all specified rules.
[0083] The aging attenuation coefficient is used to describe the attenuation speed of the rule weight of each rule as time increases. At this time, according to the aging attenuation coefficient and the current rule weight, the corresponding aging attenuation factor is determined.
[0084] At the same time, the user feedback factor can also be determined according to the user feedback gain coefficient and the user feedback data. The user feedback gain coefficient is pre-set and is positively correlated with the effective trigger rate of the rules in the user behavior data stream, and is used to represent the correlation degree between the update speed of the rule weight and the user feedback data.
[0085] According to the update result of the rule vector corresponding to the specified rule and the semantic similarity gain coefficient, the vector update factor is determined. The update result of the rule vector represents the semantic similarity degree of the current specified rule after update and before update. The semantic similarity gain coefficient is pre-set and is used to represent the correlation degree between the update speed of the rule weight and the semantic similarity degree.
[0086] Based on this, the aging attenuation factor, the user feedback factor, and the vector update factor have been obtained. According to these three factors, the dynamic update of the rule weight can be realized, and it can be as shown in Formula Seven: Formula Seven; Wherein, and are the rule weights of the i-th specified rule after and before the update, respectively, is the time decay factor, is the user feedback factor, is the vector update factor, is the time decay coefficient, is the time difference between before and after the weight rule update, is the user feedback gain coefficient, is the number of times the i-th specified rule is triggered before the update, is the maximum number of times all specified rules are triggered, is the semantic similarity gain coefficient, The function is based on the rule vector and the real-time updated text vector (corresponding to the updated rule vector) for cosine similarity calculation.
[0087] The dynamic update layer and the semantic parsing layer form a closed-loop feedback. For example, when the user behavior log shows that the trigger rate of a certain risk control rule increases abnormally, the system will automatically increase and increase its weight , and at the same time trigger the semantic street west village to re-parse the associated policy text to verify the effectiveness of the rule. The rule vector is used for similarity matching and semantic gain calculation at the same time in this process, achieving the joint optimization of data-driven and semantic-driven.
[0088] The deep collaboration between the large language model and the symbol system introduces a logical verification layer through local dynamic updates to formally constrain the generation results of the large language model, ensuring the completeness of the rule logic while retaining the generation ability.
[0089] Through the dynamic closed-loop management mechanism, a real-time closed-loop of "generation - verification - feedback - optimization" is constructed, and the rule weights are dynamically adjusted according to the time decay factor and the user feedback factor.
[0090] Information interaction between each layer is carried out through a unified data bus. Among them, the control bus monitors external knowledge change events in real time (such as policy and regulation updates). When a preset trigger condition is detected, the incremental update process of the rule library is automatically started. The service interface layer provides a rule version comparison function, supporting the backtracking of historical rule states through timestamps to ensure that the system has the ability to quickly roll back in case of failures.
[0091] An interpretability enhancement design is set up, combined with attention weight visualization and rule dependency graphs, to realize a traceable inference chain from the original text to the generated rules.
[0092] In one embodiment, as Figure 2 shown, in the service deployment phase, in the service interface layer, a rule API gateway and a rule traceability graph (also known as an interactive traceability graph) can also be set up. Among them, the rule API gateway is set for the API gateway of the specified rule, including functions such as import, export, routing, invocation, and coordination of the specified rule, and corresponding API gateways are set respectively. The rule traceability graph is a traceability graph used to visualize the specified rule, realizing the visual traceability of the rule decision-making process, and constructing a multi-granularity interpretation path from the original text to the generated rule.
[0093] In the construction of the rule generation traceability graph, the attention matrices of each layer of the large language model are extracted, and the attention heads corresponding to the specified rule are determined. Among them, the attention heads corresponding to the specified rule can include the attention heads corresponding to logical connectives and conditional adverbs.
[0094] Based on the attention heads, the influence scores corresponding to each tokenization unit in the standard data are determined, that is, the influence scores of each tokenization unit (token) in the input text on rule generation are calculated, which can be as shown in Formula VIII: Formula VIII; Among them, is the influence score corresponding to the j-th tokenization unit in the standard data, is the weight of the j-th tokenization unit in the k-th attention head of the l-th layer, is the predefined set of rule-related attention heads, is the k-th attention head, n is the total number of attention heads, and L is the total number of layers of the large language model.
[0095] Based on this, according to the influence scores, the nodes of the abstract syntax tree are associated with the tokenization units, and the importance weights corresponding to the nodes of the abstract syntax tree are obtained, which can be as shown in Formula IX: Formula IX; Among them, is the importance weight of the m-th node of the abstract syntax tree, is all the tokenization units associated with the m-th node, is the current j-th tokenization unit, is the context weight of the j-th tokenization unit, is the term frequency-inverse document frequency value of the j-th tokenization unit.
[0096] Generate and display a rule traceability graph through rendering. For example, render an interactive rule traceability graph through a force-directed graph layout algorithm. Among them, the size of the nodes in the rule traceability graph is positively correlated with the importance weight, and the color depth of the edges reflects the logical dependence strength, intuitively displaying the key logical path generated by the rules.
[0097] At the same time, it is also possible to generate a natural language explanation corresponding to a specified rule. The system parses according to the abstract syntax tree (the rule AST corresponding to the specified rule) to obtain a sequence of logical units. Based on the sequence of logical units, the corresponding explanation text is generated according to a structured template. For example, for the rule "terminate the contract after 30 days of overdue", the explanation is generated: IF the lessee fails to pay the rent overdue for more than 30 days THEN the lessor has the right to terminate the contract BECAUSE of Article 5.2 of the contract terms and the historical case
[2023] Min Zhong Zi No. X. Among them, No. X here is an exemplary description, which is determined based on actual documents in actual work. The semantic faithfulness of the explanation is verified by the cosine similarity between the rule vector and the explanation text vector to ensure that the explanation content is consistent with the original rule logic.
[0098] Moreover, based on local dynamic updates, an adjustment description is generated. In the dynamic update scenario, the explanation content is updated synchronously: when the rule weight changes by more than the threshold, an adjustment description is generated (for example, "the weight decays due to policy updates"). The service interface layer and the semantic parsing layer cooperate deeply, and the attention weights in the traceability graph are fed back to optimize the Prompt template, strengthening the guidance of key fields, forming a closed-loop interpretability enhancement system.
[0099] As Figure 4 shown, the embodiment of the present application also provides a device for dynamically constructing a rule base based on a large language model, including: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for dynamically constructing a rule base based on a large language model as described in any of the above embodiments.
[0100] The embodiment of the present application also provides a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions are set to: the method for dynamically constructing a rule base based on a large language model as described in any of the above embodiments.
[0101] The various embodiments in this application are described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiments.
[0102] The devices and media provided in the embodiments of this application correspond one by one to the methods. Therefore, the devices and media also have beneficial technical effects similar to those of their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be elaborated here.
[0103] The above are only the embodiments of this application and are not intended to limit this application. For those skilled in the art, this application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included within the scope of the claims of this application.
Claims
1. A method for dynamically constructing a rule base based on a large language model, characterized in that: The method comprises: Receive heterogeneous data from multiple sources and normalize the features to obtain standard data; Based on a preset hierarchical template structure, meta-knowledge is injected through the domain knowledge graph corresponding to the standard data to generate dynamic prompt words; Using a large language model, the dynamic prompt word is used as input, a corresponding semantic triple is output, semantic enhancement is performed on the semantic triple, and confidence calculation is performed on the semantic triple; The semantic triples are symbolized and vectorized to obtain rule vectors, and corresponding designated rules are generated according to the rule vectors and corresponding confidences, and added to the rule base; Based on the triggering of preset events, the rule subset in the rule base is locally dynamically updated through the data update of the external designated knowledge base, and the rule weight of the designated rule determined by the confidence is dynamically updated according to the time decay factor and the user feedback factor.
2. The method for dynamically constructing a rule base based on a large language model according to claim 1, characterized in that: Based on the preset hierarchical template structure, meta-knowledge is injected through the domain knowledge graph corresponding to the standard data to generate dynamic prompt words, specifically including: Determine a preset hierarchical template structure; wherein the hierarchical template structure includes an atomic rule layer, a composite rule layer and a constraint condition layer; The field units included in the prompt word are set through the atomic rule layer; the logical relationship between the field units is set through the composite rule layer; and the constraint condition layer is used to add constraint conditions on the basis of the field units to generate a prompt word template; The metadata corresponding to the field unit is obtained through the domain knowledge graph corresponding to the standard data, and the prompt word template is supplemented with content through the metadata to obtain the corresponding dynamic prompt word.
3. The method for dynamically constructing a rule base based on a large language model according to claim 1, characterized in that: The semantic enhancement is performed on the semantic triple, and the confidence calculation is performed on the semantic triple, specifically including: For the semantic triples, uniformly mapping the entity information contained therein; Performing grammatical structure analysis on the standard data to extract corresponding modification information, and performing semantic enhancement on the semantic triple based on the modification information; Determine the corresponding conditional trigger probability, and calculate the confidence of the semantic triple based on the semantic similarity between the semantic triple and the corresponding domain knowledge graph, the structural completeness of the semantic triple, and the contextual coherence of the semantic triple.
4. The method for dynamically constructing a rule base based on a large language model according to claim 1, characterized in that: The semantic triples are symbolized and vectorized to obtain rule vectors, which specifically include: Convert the semantic triples into an abstract syntax tree for symbolic processing; Encoding the abstract syntax tree through a graph neural network to obtain a rule vector; Among them, in the graph neural network, during the updating process of the rule vector, a mean pooling operation is performed based on the embedding vector of the child node during the iteration of the previous layer, and the vector is concatenated with the rule vector obtained in the previous layer to obtain the rule vector of the next layer.
5. The method for dynamically constructing a rule base based on a large language model according to claim 1, characterized in that: By updating the data of the external designated knowledge base, the rule subset in the rule base is locally and dynamically updated, specifically including: Determine a designated knowledge base corresponding to the multi-source input, monitor the designated knowledge base, and extract an updated event feature vector; Based on the event feature vector, similarity matching is performed with each rule vector in the rule base to obtain a corresponding first rule subset; Acquire user feedback data, and determine a corresponding second rule subset based on feedback satisfaction corresponding to the user feedback data and / or the number of rule triggering times corresponding to the user feedback data; Performing local dynamic update on designated rules included in the first rule subset and / or the second rule subset; During the local dynamic update process, if the rule base is online, the updated specified rules are compared with the specified rules before the update to obtain the corresponding execution effect difference; if the rule base is offline and the execution effect difference is higher than the preset minimum gain threshold, the specified rules are sorted according to the updated rule weights.
6. The method for dynamically constructing a rule base based on a large language model according to claim 1, characterized in that: According to the time decay factor and the user feedback factor, the rule weight of the specified rule determined by the confidence is dynamically updated, specifically including: Determine an initial rule weight corresponding to the specified rule according to the confidence level, and determine a specified field corresponding to the specified rule; Determining a first update coefficient according to an update frequency of the associated policy text in the specified field, and determining a second update coefficient according to user feedback data; Determine a corresponding time decay coefficient according to the first update coefficient, the second update coefficient, and the field adaptation weight coefficient corresponding to the specified field, and determine a corresponding time decay factor according to the time decay coefficient and the current rule weight; Determining a user feedback factor according to a user feedback gain coefficient and the user feedback data; Determine a vector update factor according to an update result of a rule vector corresponding to the specified rule and a semantic similarity gain coefficient; The rule weight is dynamically updated according to the time decay factor, the user feedback factor, and the vector update factor.
7. The method for dynamically constructing a rule base based on a large language model according to claim 4, characterized in that: The method further comprises: Extracting the attention matrices of each layer of the large language model, and determining the attention heads corresponding to the specified rule; Determine, based on the attention head, an influence score corresponding to each word segmentation unit in the standard data; According to the influence score, each node of the abstract syntax tree is associated with the word segmentation unit to obtain an importance weight corresponding to the node of the abstract syntax tree; A rule tracing graph is obtained and displayed through rendering; wherein the node size in the rule tracing graph is positively correlated with the importance weight, and the color depth of the edge reflects the strength of the logical dependency.
8. The method for dynamically constructing a rule base based on a large language model according to claim 4, characterized in that: The method further comprises: Parsing the abstract syntax tree to obtain a logic unit sequence; Based on the logic unit sequence, generating corresponding explanation text according to the structured template; Based on the local dynamic update, an adjustment description is generated.
9. A device for dynamically building a rule base based on a large language model, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for dynamically constructing a rule base based on a large language model as described in any one of claims 1 to 8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured to implement the method for dynamically constructing a rule base based on a large language model as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Knowledge representation method combining logic rules and confidence
CN111144570A
Method for carrying out data enhancement by utilizing large model and cooperative training
CN117407532A
Large model enhanced semi-open knowledge extraction method and system
CN118966203A
Knowledge sharing method and system based on block chain and knowledge graph
CN119149508A
Constrained large model patent atlas construction method
CN119415707A
Cited By
High-quality intelligent data labeling method
CN120873192A
Intelligent approval rule modeling method oriented to process automation
CN120875792A
Intelligent approval rule modeling method for process automation
CN120875792B
Automatic official document generation method based on dynamic rules
CN120975050A
A dynamic rule-based official document automation generation method
CN120975050B
