Data processing method, data processing device, electronic equipment, medium and product
By performing logical parsing, simplification, and deduplication on JSON text, simplified logical expressions are generated, solving the token consumption problem when large models process JSON text and improving inference speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2026-03-31
- Publication Date
- 2026-06-26
AI Technical Summary
Large models consume a large number of tokens when processing business rules in JSON text, which slows down the inference speed.
Before inputting JSON text into the large model, it is preprocessed, including logical parsing, simplification and deduplication, merging duplicate content, and generating simplified logical expressions to reduce the number of tokens.
By reducing the number of tokens, the inference speed and efficiency of large models are improved.
Smart Images

Figure CN122287899A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large model intelligent agent technology, and more specifically, to a data processing method, data processing device, electronic device, medium, and product in the field of large model intelligent agent technology. Background Technology
[0002] With the rapid development of artificial intelligence (AI) technology, various agents built based on large pre-trained models (hereinafter referred to as "large models") have been widely used in various fields, such as finance, retail, office, and education.
[0003] For example, in the financial sector, large-scale models can combine risk control rules (i.e., business rules) to promptly identify transaction risks and violations during financial transactions, thereby triggering alarms.
[0004] Currently, business rules for large models are often represented in JavaScript Object Notation (JSON) text. When large models read business rules based on JSON text, they need to consume a large number of tokens, which slows down the inference speed of large models.
[0005] Therefore, when processing business rules based on JSON text in large models, how to minimize the number of tokens and improve the processing speed of large models has become an urgent problem to be solved. Summary of the Invention
[0006] This application provides a data processing method, data processing apparatus, electronic device, medium, and product. The method can preprocess JSON text before inputting it into a large model, merge duplicate content in the JSON text, and simplify the JSON text, effectively reducing the number of tokens processed by the large model, thereby improving the inference speed of the large model.
[0007] Firstly, a data processing method is provided, comprising: logically parsing a target JSON text to obtain a Boolean logical expression for the target JSON text, wherein the target JSON text is used to describe the business logic of a target business, the target business corresponds to M business rules, and the Boolean logical expression includes the logical conditions of each business rule, where M is an integer greater than or equal to 1; simplifying the Boolean logical expression based on the logical conditions of the M business rules to obtain a simplified logical expression; and deduplicating the simplified logical expression to obtain the target logical expression of the target JSON text.
[0008] The above technical solution provides a data processing method. In its implementation, when a target JSON text is received, it is logically parsed to obtain a Boolean logic expression. This process removes redundant information from the target JSON text, including only content relevant to business logic. Furthermore, the Boolean logic expression is simplified to reduce its length. Finally, deduplication of the simplified expression yields the target logic expression, preventing the same logic from appearing repeatedly and further reducing its length. Therefore, by preprocessing the JSON text before inputting it into the large model, merging duplicate content, and simplifying the JSON text, the number of tokens processed by the large model is effectively reduced, thereby improving the inference speed of the large model.
[0009] In conjunction with the first aspect, in some possible implementations, the logical parsing of the target JSON text to obtain the Boolean logical expression of the target JSON text includes: logically parsing the target JSON text to determine the rule combination logic corresponding to the M business rules, the logical conditions of the M business rules, and the condition combination logic corresponding to the logical conditions of any business rule; and generating the Boolean logical expression based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule.
[0010] In the above technical solution, when processing the target JSON text, the target JSON text is first logically parsed to determine the rule combination logic, condition combination logic, and all logical conditions contained in the target JSON text. This can remove redundant information in the complex target JSON text and retain only the information related to the actual business, thus avoiding the complexity of processing the target JSON text and simplifying the target JSON text from the source.
[0011] Combining the first aspect and the above implementation methods, in some possible implementation methods, the Boolean logic expression is generated based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule, including: for any business rule among the M business rules, converting the logical conditions of the business rule into a condition triplet; and generating the Boolean logic expression based on the condition triplets of the M business rules, the rule combination logic, and the condition combination logic of any business rule.
[0012] In the above technical solution, Boolean logic expressions are constructed by combining rules between business rules, combining conditions within business rules, and using structured condition triples. This ensures that the generated Boolean logic expressions fully conform to the actual business logic in the target JSON text, guaranteeing the integrity of the original business logic during the generation process.
[0013] Combining the first aspect and the above implementation methods, in some possible implementation methods, the Boolean logic expression based on the logical conditions of the M business rules is simplified to obtain a simplified logic expression, including: for any first logical condition among the logical conditions of the M business rules, the first logical condition is symbolized, the symbol identifier corresponding to the first logical condition is determined, and the symbol identifier corresponding to the second logical condition is determined to be the same as the symbol identifier corresponding to the first logical condition, wherein the second logical condition is the same as the first logical condition among the logical conditions of the M business rules; the first logical condition in the Boolean logic expression is replaced with the symbol identifier corresponding to the first logical condition to obtain the simplified logic expression.
[0014] In the above technical solution, the simplification of Boolean logic expressions specifically involves symbolizing the logical conditions within the expressions to obtain corresponding symbolic identifiers. This process simplifies complex and lengthy logical conditions into simple symbolic identifiers, significantly reducing the memory resources occupied by these conditions. Furthermore, using the same symbolic identifier for identical logical conditions during symbolization ensures the global uniqueness and consistency of these conditions, preventing errors in large-scale model reasoning caused by using different symbolic identifiers for the same logical conditions.
[0015] Combining the first aspect and the above implementation methods, in some possible implementation methods, the process of deduplicating the simplified logical expression to obtain the target logical expression of the target JSON text includes: determining the simplified logical expression as the first logical expression; determining the occurrence count of each of the at least one symbol in the first logical expression; determining the maximum occurrence count of the first logical expression based on the occurrence count of the at least one symbol; and deduplicating the first logical expression based on the maximum occurrence count to obtain the target logical expression.
[0016] In the above technical solution, during the deduplication process of simplified logical expressions, by counting the number of times each symbol appears in the simplified logical expression and deduplicating the simplified logical expression based on the maximum number of occurrences, redundant information in the simplified logical expression can be eliminated to the greatest extent and the length of the simplified logical expression can be optimized.
[0017] Combining the first aspect and the above implementation methods, in some possible implementation methods, the process of deduplicating the first logical expression based on the maximum occurrence count corresponding to the first logical expression to obtain the target logical expression includes: when the maximum occurrence count corresponding to the first logical expression is greater than or equal to a preset count, determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among the at least one symbol identifiers, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of the at least one business rule, and deleting the target symbol identifier from the at least one business rule to obtain the second logical expression; in the... If the maximum occurrence count of the second logical expression is greater than or equal to the preset count, the second logical expression is updated to the first logical expression, and the steps of determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among the at least one symbol identifier, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of the at least one business rule, and deleting the target symbol identifier from the at least one business rule to obtain the second logical expression are repeated until the maximum occurrence count of the second logical expression is less than the preset count, at which point the second logical expression is determined as the target logical expression.
[0018] In the above technical solution, during the deduplication process of simplified logical expressions, the target symbol identifier corresponding to the maximum number of occurrences is used as the common symbol identifier. Business rules containing the target symbol identifier are then compressed, achieving a good compression effect. Based on this, the common symbol identifier only needs to appear once, without repetition, effectively reducing the length of the logical expression and thus reducing the number of tokens consumed by large models.
[0019] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the data processing method further includes: if the maximum number of occurrences corresponding to the first logical expression is less than the preset number, determining the first logical expression as the target logical expression.
[0020] Combining the first aspect and the above implementation methods, in some possible implementation methods, after obtaining the target logical expression of the target JSON text, the data processing method further includes: generating target prompt text based on the logical conditions of the M business rules, the symbol identifiers corresponding to the logical conditions of the M business rules, and the target logical expression; and inputting the target prompt text into a large language model so that the large language model can determine the triggering conditions and business intent corresponding to the target business based on the target prompt text.
[0021] Secondly, a data processing apparatus is provided, comprising: a parsing module for logically parsing a target JSON text to obtain a Boolean logical expression of the target JSON text, wherein the target JSON text describes the business logic of a target business, the target business corresponds to M business rules, and the Boolean logical expression includes the logical conditions of each business rule, where M is an integer greater than or equal to 1; a simplification module for simplifying the Boolean logical expression based on the logical conditions of the M business rules to obtain a simplified logical expression; and a deduplication module for deduplicating the simplified logical expression to obtain the target logical expression of the target JSON text.
[0022] In conjunction with the second aspect, in some possible implementations, the parsing module is specifically used to: logically parse the target JSON text, determine the rule combination logic corresponding to the M business rules, the logical conditions of the M business rules, and the condition combination logic corresponding to the logical conditions of any business rule; and generate the Boolean logical expression based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule.
[0023] Combining the second aspect and the above implementation methods, in some possible implementation methods, the parsing module is specifically used to: for any business rule among the M business rules, convert the logical condition of the business rule into a condition triplet; and generate the Boolean logic expression based on the condition triplets of the M business rules, the rule combination logic, and the condition combination logic of any business rule.
[0024] Combining the second aspect and the above implementation methods, in some possible implementation methods, the simplification module is specifically used for: for any first logical condition among the logical conditions of the M business rules, symbolizing the first logical condition, determining the symbol identifier corresponding to the first logical condition, and determining that the symbol identifier corresponding to the second logical condition is the same as the symbol identifier corresponding to the first logical condition, wherein the second logical condition is the logical condition among the logical conditions of the M business rules that is the same as the first logical condition; replacing the first logical condition in the Boolean logical expression with the symbol identifier corresponding to the first logical condition to obtain the simplified logical expression.
[0025] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the deduplication module is specifically used to: determine the simplified logical expression as the first logical expression; for at least one symbol identifier in the first logical expression, determine the occurrence count of the at least one symbol identifier in the first logical expression; based on the occurrence count of the at least one symbol identifier, determine the maximum occurrence count corresponding to the first logical expression; based on the maximum occurrence count corresponding to the first logical expression, deduplicate the first logical expression to obtain the target logical expression.
[0026] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the deduplication module is specifically used to: when the maximum number of occurrences corresponding to the first logical expression is greater than or equal to a preset number, determine the target symbol identifier corresponding to the maximum number of occurrences corresponding to the first logical expression among the at least one symbol identifiers, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; use the target symbol identifier as the common symbol identifier of the at least one business rule, and delete the target symbol identifier from the at least one business rule to obtain a second logical expression; when the maximum number of occurrences corresponding to the second logical expression is greater than or equal to the preset number, update the second logical expression to the first logical expression, and repeatedly execute the steps of determining the target symbol identifier corresponding to the maximum number of occurrences corresponding to the first logical expression among the at least one symbol identifiers, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of the at least one business rule, and deleting the target symbol identifier from the at least one business rule to obtain a second logical expression, until the maximum number of occurrences corresponding to the second logical expression is less than the preset number, and then determine the second logical expression as the target logical expression.
[0027] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the deduplication module is also used to: determine the first logical expression as the target logical expression when the maximum number of occurrences corresponding to the first logical expression is less than the preset number of occurrences.
[0028] Combining the second aspect and the above implementation methods, in some possible implementation methods, after obtaining the target logical expression of the target JSON text, the deduplication module is further used to: generate target prompt text based on the logical conditions of the M business rules, the symbol identifiers corresponding to the logical conditions of the M business rules, and the target logical expression; input the target prompt text into the large language model so that the large language model can determine the triggering conditions and business intent corresponding to the target business based on the target prompt text.
[0029] Thirdly, an electronic device is provided, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, causing the electronic device to perform the data processing method in the first aspect or any possible implementation thereof.
[0030] Fourthly, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to perform the data processing method described in the first aspect or any possible implementation thereof.
[0031] Fifthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the data processing method described in the first aspect or any possible implementation thereof. Attached Figure Description
[0032] Figure 1 This is a schematic flowchart illustrating a data processing method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of a Boolean logic expression tree provided in an embodiment of this application; Figure 3 This is a schematic flowchart of another data processing method provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0033] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0034] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0035] Before introducing the solutions of the embodiments of this application, the following is a definition of the technical terms that may be involved in the embodiments of this application.
[0036] JSON text: A lightweight text-based data exchange format consisting of key-value pairs ("key (i.e., attribute name)": "value (i.e., attribute value)") and arrays, used for structured data storage and transmission. In the application scenarios of this application embodiment, JSON text specifically refers to a carrier used to carry business rule logic.
[0037] Large Language Model (LLM): An AI model based on the Transformer architecture and trained on massive amounts of text data. Its core function is to understand natural language and perform logical reasoning.
[0038] Token: The smallest unit of text processed by the LLM model, that is, the smallest segment after the LLM model has divided the text.
[0039] Agent: With the LLM model as its core brain, it is essentially an intelligent software entity that can perceive the environment, make decisions, and execute actions to achieve specific goals.
[0040] Disjunctive Normal Form (DNF): refers to a logical expression that can connect multiple conjunction clauses through a logical "OR" operation, where each conjunction clause is a product of a set of propositions.
[0041] After explaining the technical terms that may be involved in the embodiments of this application, the application scenarios of the embodiments of this application are described below.
[0042] With the rapid development of AI technology, various agents built based on large models (mainly LLM models) have been widely applied in various fields, such as finance, retail, office work, and education. For example, in the retail sector, major retail platforms are gradually replacing traditional store management models based on human experience with intelligent store management models implemented using AI agents. Specifically, AI agents possess the capabilities of automatic perception, autonomous decision-making, and closed-loop execution, greatly facilitating merchants' store management.
[0043] For example, in the financial field, large models, relying on their powerful semantic understanding and logical reasoning capabilities, can combine risk control rules (i.e., business rules) to promptly identify transaction risks and violations in the financial transaction process, thereby triggering alarms.
[0044] Currently, business rules in large-scale models are typically represented as JSON text. In related technologies, when processing business rules from JSON text through large-scale models, the usual approach is to directly construct prompt text for the large-scale model based on the original JSON text business rules and input this prompt text into the large-scale model. This allows the large-scale model to perform reasoning and analysis, thereby obtaining a natural language description that humans can directly understand.
[0045] The problem with the above approach is that JSON text is essentially structured text, containing a large number of non-semantic structural symbols, such as parentheses, quotation marks, and redundant keys. In complex business rules, these structural symbols and repeated keys often account for a large portion of the JSON text's length. These characters, which do not carry any business rules, also consume tokens when input into a large model, causing a sharp increase in the number of tokens consumed by the large model, ultimately slowing down its inference speed and increasing its inference cost. Furthermore, business rules often involve complex, multi-layered nested logic. When a large model directly maps deeply nested JSON text into natural language descriptions, it often produces lengthy, convoluted descriptions that do not conform to human reading habits.
[0046] In view of this, embodiments of this application provide a data processing method that can preprocess JSON text before inputting it into a large model, merge duplicate content in the JSON text and simplify the JSON text, effectively reducing the number of tokens processed by the large model, thereby improving the inference speed of the large model.
[0047] As can be seen, the methods in related technologies directly input JSON text into a large model for parsing. The method in this application, however, performs a series of preprocessing steps on the JSON text before inputting it into the large model, thereby avoiding the large model consuming more tokens during input.
[0048] The following are some common preprocessing methods before inputting JSON text into a large model.
[0049] The first method uses a general text compression algorithm to compress the JSON text. Specifically, before inputting the JSON text into the large model, a compression algorithm from a standard compression library (such as Gunzip (Gzip)) is called to compress the JSON text, and then the prompt text for the large model is constructed based on the compressed binary data and input into the large model.
[0050] The problem with the above approach is that general compression algorithms like Gzip are lossless, and their output is binary gibberish. To restore the original data, the exact same decompression algorithm must be used. However, the large model does not have any Gzip decompression module. Therefore, when the compressed binary data is input into the large model, the model cannot extract the key business rules, causing the inference process to fail.
[0051] Compared to the first method, the method in this embodiment does not require the large model to have decoding capabilities during the JSON text compression process. This method does not directly perform physical compression of the JSON text, but rather simplifies and deduplicates the original JSON text at the semantic level. Therefore, the business rules carried by the final result are consistent with the original JSON text, enabling the large model to fully understand it.
[0052] The second method involves converting the JSON text into a logical execution tree, then converting the logical execution tree into a linear text string, which is then used as part of the prompt text for the large model and input into the large model.
[0053] The problem with the above approach is that the converted logic execution tree still cannot resolve the issue of a large amount of duplicate content in the JSON text. For example, in a complex rule-based JSON text, the corresponding logic execution tree may contain multiple duplicate nodes, causing the business content corresponding to that node to be repeated multiple times in the resulting text string. Ultimately, this problem results in a large amount of redundant information in the input of large models, leading to a still enormous token consumption for large models.
[0054] Compared to the second method, the method in this embodiment first simplifies the JSON text to reduce its length. Then, it removes duplicate information from the JSON text, further reducing its length and effectively decreasing the token consumption of large models.
[0055] After introducing the application scenarios of the embodiments of this application, the following will be conducted through... Figure 1 The specific implementation process of the method in the embodiments of this application is described in detail.
[0056] Figure 1This is a schematic flowchart illustrating a data processing method provided in an embodiment of this application. It should be understood that the method in this embodiment uses business rules represented by JSON text as the direct processing object, and is applied to at least one business that requires parsing the business rules into natural language descriptions. For example, in the financial field, at least one business could be credit approval, transaction anti-fraud, or compliance testing; in the insurance field, at least one business could be claims settlement; and in the e-commerce and retail field, at least one business could be promotional discount review, etc. Correspondingly, the executing entity of this method is a smart device configured with a rule engine. This smart device refers to various smart terminals or server-side devices with data processing and model reasoning capabilities, including but not limited to cloud servers, personal computers, mobile smart terminals, and smart wearable devices. The core component of this rule engine is an intelligent agent based on an LLM model. When executing this method, the rule engine can use the LLM model to convert the business rules from JSON text into natural language descriptions, thereby realizing the parsing process of the business rules.
[0057] For example, such as Figure 1 As shown, the data processing method 100 includes the following steps S101 to S103.
[0058] S101, perform logical parsing on the target JSON text to obtain the Boolean logical expression of the target JSON text. The target JSON text is used to describe the business logic of the target business. The target business corresponds to M business rules. The Boolean logical expression includes the logical conditions of each business rule, where M is an integer greater than or equal to 1.
[0059] The target business is any business to which the method in this application embodiment is applied. A business refers to a specific business process that actually occurs in an enterprise or system and needs to be managed, controlled, or executed. The business rules corresponding to the target business are represented by target JSON text. Business rules refer to a series of logical conditions, judgment criteria, and execution instructions used to guide, constrain, judge, or determine how the target business is executed; that is, the target JSON text is used to describe the business logic of the target business.
[0060] Optionally, for a target business, there may be M business rules, where M is an integer greater than or equal to 1.
[0061] It should be understood that during the execution of a target business, different business branch paths will correspond to different scenarios, and each business branch path corresponds to different business rules. Therefore, a business function is not limited to one business rule. For example, for the large-value cross-regional transaction interception business, the corresponding scenarios include high-value QR code scanning scenarios and large-value transfer scenarios. Among them, the high-value QR code scanning scenario corresponds to business rule 1, and the large-value transfer scenario corresponds to business rule 2. In this example, the target business corresponds to two business rules.
[0062] The following example, taking the target business as the interception of large-value cross-regional transactions, and the corresponding business rules for the target business, including business rule 1 for high-value QR code scanning scenarios and business rule 2 for large-value transfer scenarios, illustrates the possible forms of expression of the target JSON text.
[0063] Specifically, the original target JSON text can be as follows: { "ruleMeta":{ "traceId":"67890-abcdef-12345", "lastModified":"2025-12-23T10:00:00Z", "operator":"risk_admin_01", "version":"v1.2.5", "description": "Logic for intercepting large-value cross-regional transactions" }, "logicConfig":{ "combinationType":"OR", "rules":[ { "name":"High-value QR code scanning scenarios", "conditions":[ {"field":"f_pay_amount","operator":">","value":5000}, {"field":"f_trade_type","operator":"==","value":"SCAN_CODE}, {"field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025"}, {"field": "f_device_city", "operator": "!=", "value": "f_user_home_city"} }, { "name": "Large-amount transfer scenario", "conditions": {"field": "f_pay_amount", "operator": ">", "value": 5000}, {"field": "f_trade_type", "operator": "==", "value": "TRANSFER"}, {"field": "f_user_id", "operator": "not_in", "value": "List_VIP_WhiteList_2025"}, {"field": "f_device_city", "operator": "!=", "value": "f_user_home_city"} } }, "uiConfig": { "canvasX": 120, "canvasY": 450, "color": "red" } } As seen in the example of the target JSON text above, the content relevant to the actual business logic is all within "logicConfig," including the two business rules corresponding to the target business. Furthermore, the target JSON text contains a lot of redundant information unrelated to the actual business logic, such as parts of "ruleMeta" and all of "uiConfig" in the example above. The ruleMeta section contains rule lifecycle management information. Here, traceId refers to the system's internal tracking identity document (ID), used for log analysis. lastModified records the last modification time of the business rule. operator refers to the account of the operator who last modified the business rule. version refers to the version number of the business rule configuration. These fields are all unrelated to the business logic implementation. The uiConfig section contains configuration information for the front-end presentation layer. Here, canvasX refers to the X coordinate when drawing; canvasY refers to the Y coordinate when drawing; color refers to the color displayed on the interface, used for visual cues. These fields are also unrelated to the business logic implementation.
[0064] The aforementioned business logic refers to the specific logical conditions corresponding to the business rules. In the target JSON text, each business rule is constrained by many logical conditions.
[0065] For example, taking the target JSON text as the example text mentioned above, the logical conditions of business rule 1 are multiple logical conditions contained in the conditions in the high-value QR code scanning scenario. The logical conditions of business rule 2 are multiple logical conditions contained in the conditions in the large-value transfer scenario. Each logical condition is a condition object. In the target JSON text above, a condition object refers to a combination of {field, operator, value}. Here, field represents the target field to be detected, and the corresponding attribute value is the field identifier of the business data; value represents the comparison benchmark, and the corresponding attribute value is a threshold or preset value used to compare with the extracted business data. operator represents the operator, which means the comparison logic to be executed between the business data and the preset value, and the corresponding attribute values include greater than, equal to, contain, less than, etc.
[0066] Based on this, the conditions in the aforementioned high-value QR code scanning scenario contain four combinations of {field, operator, value}, that is, four condition objects, corresponding to four logical conditions, namely: {"field":"f_pay_amount","operator":">","value":5000}; {"field":"f_trade_type","operator":"==","value":"SCAN_CODE"}; {"field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025"}; {"field":"f_device_city","operator":"!=","value":"f_user_home_city"}.
[0067] Similarly, the conditions in the above large-amount transfer scenario contain four combinations of {field, operator, value}, that is, four condition objects, corresponding to four logical conditions, namely: {"field":"f_pay_amount", "operator":">","value":5000}; {"field":"f_trade_type","operator":"==","value":"TRANSFER"}; {"field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025"}; {"field":"f_device_city","operator":"!=","value":"f_user_home_city"}.
[0068] In addition, the target JSON text also includes the combination logic between the two business rules, namely the attribute value "OR" corresponding to the combinationType in the example text above, which indicates that the two business rules are in an OR relationship, and it is sufficient to satisfy the logical condition of one of the business rules.
[0069] In this embodiment, to remove redundant information from the target JSON text and simplify it to the greatest extent possible, the smart device, after obtaining the target JSON text, can first perform logical parsing on it, extracting the key business logic and discarding the non-key business logic. Extracting the key business logic from the target JSON text refers to extracting the logical conditions of all business rules within the target JSON text. Furthermore, after obtaining the logical conditions of all business rules, the smart device can construct a Boolean logical expression for the target JSON text based on each logical condition. Therefore, the Boolean logical expression necessarily contains the logical conditions of each business rule corresponding to the target business.
[0070] A Boolean logical expression, also known as a Boolean expression, is a code declaration that ultimately has only two values: true and false. All Boolean expressions, regardless of length, can only ultimately take the value either true or false.
[0071] It should be understood that the reason why the JSON text after removing non-critical business logic can construct Boolean logical expressions is that, as shown in the previous example, business rules are specifically constrained by logical conditions. In other words, the essence of business rules is logical judgment. No matter how complex the business rules are, their final result can be reduced to a yes or no judgment, which is exactly consistent with the function of Boolean expressions.
[0072] The following section will discuss the specific process of obtaining Boolean logic expressions.
[0073] One possible implementation involves logically parsing the target JSON text to obtain a Boolean logical expression for the target JSON text, including: Perform logical parsing on the target JSON text to determine the rule combination logic corresponding to M business rules, the logical conditions of M business rules, and the condition combination logic corresponding to the logical conditions of any business rule; Based on the rule combination logic, the logical conditions of M business rules, and the condition combination logic of any business rule, generate a Boolean logic expression.
[0074] It should be understood that the process of logically parsing the target JSON text to obtain Boolean logical expressions involves three tasks: determining the rule combination logic corresponding to M business rules, the logical conditions of the M business rules, and the condition combination logic of each logical condition within the business rules. Here, rule combination logic refers to the combination relationship between multiple business rules, such as AND, OR, etc. Similarly, condition combination logic refers to the combination relationship between logical conditions, such as AND, OR, etc.
[0075] Specifically, before performing logical parsing on the target JSON text, technical personnel can create a whitelist containing key business logic for various types of transactions, based on different business needs. This involves adding the key fields or attribute names (i.e., keys) to be extracted during the logic extraction process to the whitelist. For example, when the target business is the large-value cross-regional transaction interception business (as shown in the example), the key fields added to the whitelist for this business include, but are not limited to, field, operator, value, conditions, and combinationType. Based on this, when the smart device performs logical parsing on the target JSON text, it first determines the key fields corresponding to the target business from the whitelist, and then iterates through the target JSON text layer by layer based on these key fields to extract the key fields and their corresponding attribute values.
[0076] Based on key fields and their corresponding attribute values, smart devices can identify the `combinationType` field corresponding to the rule combination logic, as well as the attribute values corresponding to `combinationType`, such as OR, AND, etc. Specifically, when a business function corresponds to only one business rule, the JSON text of that business function may not contain a `combinationType` field; in this case, it can be understood that the rule combination logic is empty.
[0077] Furthermore, based on the target JSON text, the smart device can further extract the `conditions` field, and then extract the individual `condition` objects contained within each `conditions`, namely, each field and its corresponding attribute value, each operator and its corresponding attribute value, and each value and its corresponding attribute value. These `condition` objects constitute the logical conditions. Each `conditions` corresponds to a business rule, and the smart device can iterate through these rules to extract the logical conditions corresponding to each business rule.
[0078] Finally, regarding the condition combination logic corresponding to the logical conditions of any business rule, in this embodiment of the application, in most risk control or rule engine systems, a business rule corresponds to a set of logical condition combinations that must all be satisfied, i.e., conditions. At the same condition level, it is assumed that all parallel logical conditions must be satisfied simultaneously; that is, the condition combination logic between logical conditions under the same business rule is always AND. Alternatively, when the target JSON text does not explicitly specify the condition combination logic between each logical condition, the smart device also defaults to using AND for all condition combination logic.
[0079] In the target JSON text of the above example, the smart device can obtain the rule combination logic as OR, the condition combination logic as AND, and the eight logical conditions corresponding to the two business rules through logical parsing.
[0080] Of course, in some special scenarios, under the same business rule, the combination logic between various logical conditions may also include OR. For example, business rule 1 corresponds to logical conditions 1, 2, 3, and 4. The combination logic between logical conditions 1 and 2 is OR; the two logical conditions first form a sub-logical condition, and the combination logic between this sub-logical condition set and logical conditions 3 and 4 is AND. Alternatively, the combination logic between various business rules may also be AND instead of OR. These two special cases will be discussed in the subsequent introduction.
[0081] After obtaining the rule combination logic, the logical conditions of M business rules, and the condition combination logic of any business rule, the intelligent device can generate a Boolean logic expression based on this.
[0082] In the above technical solution, when processing the target JSON text, the target JSON text is first logically parsed to determine the rule combination logic, condition combination logic, and all logical conditions contained in the target JSON text. This can remove redundant information in the complex target JSON text and retain only the information related to the actual business, thus avoiding the complexity of processing the target JSON text and simplifying the target JSON text from the source.
[0083] Specifically, the process by which a smart device generates a Boolean logic expression based on the above three types of information is as follows.
[0084] In one possible implementation, a Boolean logic expression is generated based on the rule combination logic, the logical conditions of M business rules, and the condition combination logic of any business rule, including: For any business rule among the M business rules, convert the logical conditions of the business rule into condition triples; Generate a Boolean logic expression based on the condition triples of M business rules, the rule combination logic, and the condition combination logic of any business rule.
[0085] The specific form of the above condition triple is (left value, operator, right value). Here, the left value is the attribute value corresponding to the field in the logical condition, the right value is the attribute value corresponding to the value, and the operator is the attribute value corresponding to the operator in the logical condition. The purpose of converting each logical condition of the business rule into a condition triple when generating the Boolean logical expression is that different logical conditions have different representations in JSON text. Converting the logical conditions into condition triples unifies the representation of logical conditions in different forms, reduces the complexity of the execution logic, and also simplifies the logical conditions by removing the key.
[0086] For example, the four logical conditions in the aforementioned high-value QR code scanning scenario are as follows: {"field":"f_pay_amount","operator":">","value":5000}; {"field":"f_trade_type","operator":"==","value":"SCAN_CODE"}; {"field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025"}; {"field":"f_device_city","operator":"!=","value":"f_user_home_city"}.
[0087] The smart device converts the above four logical conditions into their respective condition triples, as follows: (f_pay_amount>5000), (f_trade_type==SCAN_CODE), (f_user_id not_in List_VIP_WhiteList_2025), (f_device_city!=f_user_home_city).
[0088] Similarly, the four logical conditions in the above large-amount transfer scenario are as follows: {"field":"f_pay_amount","operator":">","value":5000}; {"field":"f_trade_type","operator":"==","value":"TRANSFER"}; {"field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025"}; {"field":"f_device_city","operator":"!=","value":"f_user_home_city"}.
[0089] The smart device converts the above four logical conditions into their respective condition triples, as follows: (f_pay_amount>5000), (f_trade_type==TRANSFER), (f_user_id not_in List_VIP_WhiteList_2025), (f_device_city!=f_user_home_city).
[0090] Based on the transformed condition triples of various logical conditions, the intelligent device uses condition combination logic to aggregate multiple condition triples through logical operators, and then uses rule combination logic to associate multiple business rules, thereby constructing a complete Boolean logic expression.
[0091] For example, in conjunction with the foregoing examples, a Boolean logic expression can specifically be: {(f_pay_amount>5000) and (f_trade_type==SCAN_CODE) and (f_user_idnot_in List_VIP_WhiteList_2025) and (f_device_city!=f_user_home_city)} or{(f_pay_amount>5000) and (f_trade_type==TRANSFER) and (f_user_id not_in List_VIP_WhiteList_2025) and (f_device_city!=f_user_home_city)}.
[0092] In addition, in some scenarios, in order to parse and execute logical judgments more efficiently, smart devices can first construct a Boolean logical expression tree during the process of generating Boolean logical expressions, and then obtain the Boolean logical expressions through linearization.
[0093] Specifically, the intelligent device first maps each condition triple to a leaf node in a Boolean logic expression tree. Then, it creates internal logic nodes based on condition combination logic, aggregating multiple leaf nodes belonging to the same business rule into a subtree. For example, in the previous example, this step refers to attaching all logical conditions that must be satisfied simultaneously to the same AND node. Next, the intelligent device creates a root node based on rule combination logic, logically connecting the generated subtrees to form a complete Boolean logic expression tree. Finally, the intelligent device generates the aforementioned Boolean logic expression by traversing the Boolean logic expression tree.
[0094] The following is through Figure 2 The structure of the Boolean logic expression tree described above will be introduced.
[0095] Figure 2 This is a schematic diagram of the structure of a Boolean logic expression tree provided in an embodiment of this application.
[0096] For example, such as Figure 2 As shown, in conjunction with the previous example, the smart device first establishes eight leaf nodes based on eight condition triples: (f_pay_amount>5000), (f_trade_type==SCAN_CODE), (f_user_id not_in List_VIP_WhiteList_2025), (f_device_city!=f_user_home_city), (f_pay_amount>5000), (f_trade_type==TRANSFER), (f_user_id not_in List_VIP_WhiteList_2025), and (f_device_city!=f_user_home_city). The first four leaf nodes belong to the same business rule and all their condition combinations use AND logic; therefore, they can be aggregated into the first subtree. The last four leaf nodes also belong to the same business rule and all their condition combinations use AND logic; therefore, they can be aggregated into the second subtree. In other words, each subtree corresponds to one business rule.
[0097] Furthermore, the rule combination logic between the two business rules is OR. The smart device can create a root node based on this rule combination logic and logically connect the first and second subtrees to obtain... Figure 2 The Boolean logic expression tree shown.
[0098] Smart devices can generate Boolean logic expressions by traversing a Boolean logic expression tree.
[0099] It should be understood that the Boolean logic expression above is actually a disjunctive normal form. Disjunctive normal form specifically refers to the disjunction (or OR) of several conjunctions (i.e., AND terms). In simpler terms, it connects multiple sets of AND logical relations using OR. The standard structural form of disjunctive normal form is: (A1∧A2∧…)∨(B1∧B2∧…)∨(C1∧C2∧…)…. Here, “∨” is the logical symbol OR, the outermost connector used to connect the various large groups. “∧” is the logical symbol AND, the connector within each large group.
[0100] For example, in the aforementioned Boolean logic expression, the first combination of terms is {(f_pay_amount>5000)and (f_trade_type==SCAN_CODE) and (f_user_id not_in List_VIP_WhiteList_2025)and (f_device_city!=f_user_home_city)}. The second combination of terms is {(f_pay_amount>5000)and (f_trade_type==TRANSFER) and (f_user_id not_in List_VIP_WhiteList_2025)and (f_device_city!=f_user_home_city)}. Each combination of terms is connected internally by the logical AND symbol, and two combinations of terms are connected by the logical OR symbol, which fully conforms to the disjunctive normal form.
[0101] As mentioned earlier, the conditional combination logic between various logical conditions under the same business rule may contain OR, or the rule combination logic between various business rules may be AND instead of OR. In these two cases, if a Boolean logic expression is directly generated based on the condition triples of each logical condition, the rule combination logic, and the condition combination logic of any business rule, the Boolean logic expression will not conform to the disjunctive normal form and will present a confusing logical structure. To address these two cases, the intelligent device can first construct an initial logical structure based on the condition triples of each logical condition, the rule combination logic, and the condition combination logic. Then, using the distributive and associative laws of Boolean algebra, the initial logical structure can be converted into a standard disjunctive normal form structure, thus obtaining the final Boolean logic expression. In other words, the final Boolean logic expression obtained in this embodiment fully conforms to the disjunctive normal form.
[0102] In the above technical solution, Boolean logic expressions are constructed by combining rules between business rules, combining conditions within business rules, and using structured condition triples. This ensures that the generated Boolean logic expressions fully conform to the actual business logic in the target JSON text, guaranteeing the integrity of the original business logic during the generation process.
[0103] S102, based on the logical conditions of M business rules, simplifies the Boolean logic expression to obtain a simplified logic expression.
[0104] After obtaining the Boolean logic expression, refer to the example of the Boolean logic expression mentioned above. Since the logical conditions in the Boolean logic expression are quite long, in order to reduce the length of the Boolean logic expression, the smart device can simplify the Boolean logic expression to obtain the simplified Boolean logic expression, that is, the simplified logic expression.
[0105] In one possible implementation, based on the logical conditions of M business rules, the Boolean logic expression is simplified to obtain a simplified logic expression, including: For any first logical condition among the logical conditions of M business rules, the first logical condition is symbolized, the symbol identifier corresponding to the first logical condition is determined, and the symbol identifier corresponding to the second logical condition is the same as the symbol identifier corresponding to the first logical condition. The second logical condition is the logical condition among the logical conditions of M business rules that is the same as the first logical condition. By replacing the first logical condition in the Boolean logic expression with the symbol corresponding to the first logical condition, a simplified logical expression is obtained.
[0106] The simplification process described above is essentially a symbolic mapping of the logical conditions in Boolean logic expressions, replacing complex logical symbols with simple symbolic identifiers.
[0107] Optionally, symbols may include, but are not limited to, letters, numbers, or graphics.
[0108] As described above, the logical conditions of the M business rules are represented in Boolean logic expressions using condition triples. The intelligent device symbolizes (i.e., maps symbols) the first logical condition to determine the symbolic identifier corresponding to it. Specifically, this process refers to the intelligent device symbolizing the first condition triple to obtain the symbolic identifier corresponding to the first condition triple, which is also the symbolic identifier corresponding to the first logical condition.
[0109] The symbolization process essentially refers to table lookup and registration operations. In this embodiment, technicians can pre-establish a globally shared symbol mapping table for the logical conditions (or condition triples) of different business rules. For a first condition triple, the intelligent device can determine whether the first condition triple exists in the symbol mapping table. If it exists, the symbol identifier corresponding to the first condition triple in the symbol mapping table is directly determined as the symbolization result. If it does not exist, the intelligent device reassigns a symbol identifier to the first condition triple and updates the symbol mapping table based on the first condition triple and its symbol identifier.
[0110] After symbolizing the first logical condition, in order to maintain a one-to-one correspondence between the logical condition and the symbol identifier, the intelligent device can also determine whether the logical conditions of the M business rules contain a second logical condition that is exactly the same as the first logical condition.
[0111] In Boolean logic expressions, where condition triples represent logical conditions, the first logical condition in a Boolean expression refers to the first condition triple corresponding to the first logical condition. Determining whether the logical conditions of M business rules include a second logical condition that is identical to the first logical condition essentially means determining whether the condition triples of the M business rules include a second condition triple that is identical to the first condition triple. The second logical condition in a Boolean logic expression refers to the second condition triple corresponding to the second logical condition. The conditions for the first and second condition triples to be identical are: the left-hand side (lvalue) of the first condition triple is the same as the left-hand side of the second condition triple; the operator of the first condition triple is the same as the operator of the second condition triple; and the right-hand side (rvalue) of the first condition triple is the same as the right-hand side of the second condition triple.
[0112] It should be noted that, since the embodiments of this application specify a fixed structure for condition triples, where the left value is the attribute value corresponding to the field or attribute name, and the right value is the attribute value corresponding to the comparison benchmark, all condition triples conform to the above situation, thus effectively avoiding the situation where two identical condition triples are misjudged as different. For example, if the condition triple does not specify a fixed structure, that is, the order of the left value, operator, and right value can be reversed. The first condition triple is: f_pay_amount>5000, and the second condition triple is 5000<f_pay_amount. According to the above conditions, the smart device may determine that the left value (f_pay_amount) of the first condition triple is different from the left value (5000) of the second condition triple, the operator (>) of the first condition triple is different from the operator (<) of the second condition triple, and the right value (5000) of the first condition triple is different from the right value (f_pay_amount) of the second condition triple, thus leading to misidentification.
[0113] When a smart device determines that a second condition triple exists in a Boolean logic expression, it determines that the logical conditions of M business rules include the second logical condition. When the logical conditions of the M business rules include the second logical condition, the smart device can also determine that the symbol of the second logical condition is the same as the symbol of the first logical condition.
[0114] The following table 1 illustrates an illustrative symbolized result of an embodiment of this application.
[0115] Table 1
[0116] For example, as shown in Table 1, the Boolean logic expression {(f_pay_amount>5000) and (f_trade_type==SCAN_CODE) and (f_user_id not_in List_VIP_WhiteList_2025) and (f_device_city!=f_user_home_city)} or {(f_pay_amount>5000) and (f_trade_type==TRANSFER) and (f_user_id not_in List_VIP_WhiteList_2025) and (f_device_city!=f_user_home_city)} contains a total of 8 condition triples, among which there are three pairs of identical condition triples, namely (f_pay_amount>5000), (f_user_id not_in List_VIP_WhiteList_2025), and (f_device_city!=f_user_home_city). Therefore, when symbolizing the eight condition triples, the symbolic representations of any pair of identical condition triples are exactly the same.
[0117] Among them, the symbolic identifiers corresponding to the two condition triples (f_pay_amount>5000) are both A; the symbolic identifiers corresponding to the two condition triples (f_user_id not_in List_VIP_WhiteList_2025) are both C; and the symbolic identifiers corresponding to the two condition triples (f_device_city!=f_user_home_city) are both D.
[0118] For two conditional triples that do not have duplicates, (f_trade_type==SCAN_CODE) has a corresponding symbol identifier of B1, and (f_trade_type==TRANSFER) has a corresponding symbol identifier of B2.
[0119] The symbols in Table 1 above are merely illustrative examples. In other scenarios, condition triples can also be represented by other forms of symbols. For example, the number "1" can be used as the symbol for the two (f_pay_amount>5000) condition triples. This application does not limit this.
[0120] Finally, after obtaining the symbolic identifiers of each condition triplet, the smart device can replace the corresponding condition triplet in the Boolean logic expression with the symbolic identifier of each condition triplet to obtain a simplified logic expression.
[0121] For example, the simplified logical expression corresponding to the aforementioned Boolean logical expression is specifically represented as: (A and B1 and C and D) or (A and B2 and C and D).
[0122] In another scenario, during the process of obtaining the Boolean logic expression, the intelligent device may not convert the logical conditions of the business rules into condition triples, but instead directly generate the Boolean logic expression based on the logical conditions of the M business rules, the rule combination logic, and the condition combination logic of the business rules.
[0123] In this scenario, the Boolean logic expression is slightly longer than the Boolean logic expression converted to a condition triple. Specifically: {("field":"f_pay_amount","operator":">","value":5000)and("field":"f_trade_type","operator":"==","value":"SCAN_CODE")an d("field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025")and("field":"f_device_city","operator":"!= ","value":"f_user_home_city")}or{("field":"f_pay_amount","operator":">","value":5000)and("field":"f_trade_type","opera tor":"==","value":"TRANSFER")and("field":"f_user_id","operator":"not_in","value":"List_VIP_WhiteList_2025")and("field": "f_device_city","operator":"!=","value":"f_user_home_city")}.
[0124] Therefore, when smart devices simplify Boolean logic expressions, they essentially symbolize the logical conditions themselves, rather than symbolizing the logical conditions represented by condition triples. Finally, during the replacement process, the logical conditions in the Boolean logic expression are directly replaced with their corresponding symbolic identifiers, rather than replacing the condition triples with symbolic identifiers.
[0125] In the above technical solution, the simplification of Boolean logic expressions specifically involves symbolizing the logical conditions within the expressions to obtain corresponding symbolic identifiers. This process simplifies complex and lengthy logical conditions into simple symbolic identifiers, significantly reducing the memory resources occupied by these conditions. Furthermore, using the same symbolic identifier for identical logical conditions during symbolization ensures the global uniqueness and consistency of these conditions, preventing errors in large-scale model reasoning caused by using different symbolic identifiers for the same logical conditions.
[0126] S103, deduplicatize the simplified logical expression to obtain the target logical expression of the target JSON text.
[0127] After obtaining the simplified logical expression, it is easy to see from the aforementioned simplified logical expression (A and B1 and C and D) or (A and B2 and C and D) that the same symbol may appear repeatedly in different business rules of the simplified logical expression (for example, A, C, and D appear twice). To solve this problem and achieve the effect of simplifying the logical expression to the greatest extent, the intelligent device can further deduplicate the simplified logical expression to obtain the target logical expression.
[0128] Specifically, the process of deduplicating simplified logical expressions by intelligent devices is as follows.
[0129] One possible implementation involves deduplicating the simplified logical expression to obtain the target logical expression for the target JSON text, including: The simplified logical expression is determined as the first logical expression; For at least one symbol identifier in the first logical expression, determine the number of times each at least one symbol identifier appears in the first logical expression; Based on the number of occurrences of at least one symbol identifier, determine the maximum number of occurrences corresponding to the first logical expression; Based on the maximum number of occurrences corresponding to the first logical expression, the first logical expression is deduplicated to obtain the target logical expression.
[0130] When deduplicating simplified logical expressions, the intelligent device first determines the simplified logical expression as the first logical expression (i.e., the logical expression to be processed). Specifically, the deduplication process in this embodiment mainly employs a greedy algorithm. A greedy algorithm, also known as a deliberate algorithm, is an algorithmic strategy that adopts the best or most advantageous choice in each step to obtain a globally optimal result. Therefore, in practical problem-solving, the greedy algorithm is a continuously iterative process.
[0131] In the context of the problem described in this application, the preferred or advantageous choice in a greedy algorithm refers to the choice that yields the maximum compression or optimal deduplication effect. It is easy to understand that the choice that yields the maximum compression or optimal deduplication effect is to merge the most frequently occurring common symbol identifiers. Therefore, when using a greedy algorithm to process simplified logical expressions, specifically, in each iteration, the most frequently occurring common symbol identifiers are extracted or merged and deduplicated until no further merging is possible.
[0132] Based on the idea of the greedy algorithm in processing simplified logical expressions, for at least one symbol in the first logical expression, the intelligent device first determines the number of times each symbol appears in the first logical expression.
[0133] Specifically, for any symbol identifier among at least one symbol identifier, the intelligent device can progressively traverse the first logical expression, counting the occurrences of that symbol identifier to obtain the maximum occurrence count of that symbol identifier in the first logical expression. Once the counts for all symbol identifiers in the first logical expression are complete, the occurrence count of at least one symbol identifier can be obtained. Furthermore, the intelligent device can determine the maximum occurrence count corresponding to the first logical expression from the occurrence counts of the at least one symbol identifier, and finally, based on the maximum occurrence count corresponding to the first logical expression, remove duplicates from the first logical expression to obtain the target logical expression.
[0134] In the above technical solution, during the deduplication process of simplified logical expressions, by counting the number of times each symbol appears in the simplified logical expression and deduplicating the simplified logical expression based on the maximum number of occurrences, redundant information in the simplified logical expression can be eliminated to the greatest extent and the length of the simplified logical expression can be optimized.
[0135] Specifically, when deduplicating the first logical expression based on its maximum occurrence count, the smart device first needs to determine whether deduplication is necessary, i.e., whether there are duplicate items that need to be merged. The smart device can obtain a comparison result by comparing the maximum occurrence count of the first logical expression with a preset number. Optionally, the preset number is 2.
[0136] Based on the comparison results, the process of determining the target logical expression can be divided into two cases.
[0137] In one scenario, if the maximum number of occurrences corresponding to the first logical expression is less than a preset number, the smart device directly determines the first logical expression as the target logical expression without the need for deduplication.
[0138] In one possible implementation, the data processing method also includes: If the maximum number of occurrences corresponding to the first logical expression is less than the preset number, the first logical expression is determined as the target logical expression.
[0139] For example, if the simplified logical expression is (A and B1 and C and D) or (B2 and E), where at least one symbol appears once and the maximum number of times it appears is also once, meaning there are no duplicate symbols in the first logical expression, the intelligent device directly determines that either the simplified logical expression or the first logical expression is the target logical expression.
[0140] In another scenario, when the maximum number of occurrences corresponding to the first logical expression is greater than or equal to the preset number, the smart device determines that the first logical expression needs to be deduplicated. The specific process is as follows.
[0141] In one possible implementation, the first logical expression is deduplicated based on the maximum number of occurrences corresponding to it, resulting in the target logical expression, which includes: If the maximum number of occurrences corresponding to the first logical expression is greater than or equal to a preset number, determine at least one symbol identifier, the target symbol identifier corresponding to the maximum number of occurrences corresponding to the first logical expression, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression. The target symbol identifier is used as the common symbol identifier of at least one business rule, and the target symbol identifier is deleted from at least one business rule to obtain the second logical expression; If the maximum occurrence count corresponding to the second logical expression is greater than or equal to a preset count, the second logical expression is updated to the first logical expression, and the steps of determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among at least one symbol identifier, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of at least one business rule, and deleting the target symbol identifier from at least one business rule to obtain the second logical expression, are repeated until the maximum occurrence count corresponding to the second logical expression is less than the preset count, at which point the second logical expression is determined as the target logical expression.
[0142] If the maximum number of occurrences corresponding to the first logical expression is greater than or equal to the preset number, it indicates that there are repeated symbols in the first logical expression. In this case, the smart device determines that deduplication is required, and thus enters the first round of iteration.
[0143] In the first round of iteration, based on at least one symbol identifier in the first logical expression, the intelligent device first determines the target symbol identifier corresponding to the maximum number of occurrences of the first logical expression, and determines at least one business rule among the M business rules of the first logical expression that includes the target symbol identifier.
[0144] For example, if the first logical expression is (A and B1 and C and D) or (A and B2 and C and D), the smart device determines that A appears twice, B1 appears once, B2 appears once, C appears twice, and D appears twice by counting the number of times each symbol appears.
[0145] The maximum number of occurrences is 2, and the target symbols corresponding to these 2 occurrences include A, C, and D. Correspondingly, at least one business rule including A, C, and D is Business Rule 1—(A and B1 and C and D), and Business Rule 2—(A and B2 and C and D).
[0146] Furthermore, the intelligent device can extract the target symbol identifier as a common symbol identifier of at least one business rule from the at least one business rule, and delete the target symbol identifier from the at least one business rule to obtain the second logical expression. Here, deleting the target symbol identifier from the symbol identifiers of at least one business rule refers to deleting the target symbol identifier from the symbol identifiers of at least one business rule.
[0147] It should be noted that using the target symbol identifier as the common symbol identifier for at least one business rule is actually the inverse process of the Boolean algebra distributive law. Specifically, the inverse process of the Boolean algebra distributive law can be expressed as: (A∧B)∨(A∧C)=A∧(B∨C). Since Boolean logic expressions are standard disjunctive normal form structures, the logical symbol between the extracted common symbol identifier and the remaining parts should be "and", and the internal logical symbol between the remaining parts should be "or".
[0148] For example, after taking the target symbols A, C and D as common symbols and deleting at least one target symbol from a business rule, the resulting second logical expression is A and C and D and (B1 or B2).
[0149] Therefore, after obtaining the second logical expression, the first round of iteration ends. The smart device then calculates the maximum number of occurrences corresponding to the second logical expression again. The calculation process is the same as that for the maximum number of occurrences corresponding to the first logical expression, and will not be repeated here.
[0150] When the maximum number of occurrences corresponding to the second logical expression is less than the preset number, the smart device directly determines the second logical expression as the target logical expression, and the iteration process ends.
[0151] For example, the second logical expression is A and C and D and (B1 or B2). The smart device determines that each symbol appears once, that is, the maximum number of occurrences is 1. The smart device does not repeat the iteration process and directly determines the second logical expression as the target logical expression.
[0152] When the maximum occurrence count corresponding to the second logical expression is still greater than or equal to the preset count, the intelligent device immediately updates the second logical expression to the first logical expression and enters the second iteration process. In the second iteration process, the intelligent device repeatedly executes the steps of determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression from at least one symbol identifier of the first logical expression, and at least one business rule including the target symbol identifier from the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of at least one business rule, and deleting the target symbol identifier from at least one business rule to obtain the second logical expression, until the maximum occurrence count corresponding to the second logical expression is less than the preset count, at which point the intelligent device determines the second logical expression at this point as the target logical expression.
[0153] In the above technical solution, during the deduplication process of simplified logical expressions, the target symbol identifier corresponding to the maximum number of occurrences is used as the common symbol identifier. Business rules containing the target symbol identifier are then compressed, achieving a superior compression effect. Based on this, the common symbol identifier only needs to appear once, eliminating the need for repetition and effectively reducing the length of the logical expression, thereby reducing the number of tokens consumed by large models.
[0154] It should be understood that the purpose of the method in this application embodiment is to enable the LLM model to be parsed based on the target JSON text. Therefore, after obtaining the target logical expression, the smart device can further generate the input text of the LLM model based on the target logical expression, so that the LLM model can be parsed.
[0155] In one possible implementation, after obtaining the target logical expression for the target JSON text, the data processing method further includes: Based on the logical conditions of M business rules, the symbol identifiers corresponding to the logical conditions of M business rules, and the target logical expression, generate the target prompt text; The target prompt text is input into the large language model so that the large language model can determine the triggering conditions and business intent corresponding to the target business based on the target prompt text.
[0156] After obtaining the target logical expression, the intelligent device can construct a two-layered prompt text when determining the target prompt text. The two layers mean that they include symbolic mapping relationships and logical rules. The intelligent device uses the symbolic mapping relationships as the first layer of text and the logical rules as the second layer of text. The two layers of text constitute the final target prompt text input into the LLM model.
[0157] Specifically, the first-level text consists of various logical conditions (or condition triples) and their corresponding symbolic identifiers. The second-level text consists of the final target logical expression.
[0158] Example text of the target prompt word is as follows: Context 1 (Condition Definition): A: Payment amount > 5000 C: The user is not in [VIP Whitelist_2025]. D: A transaction occurred in a different location (current city != permanent city). B1: Transaction type is "QR code payment" B2: Transaction type is "transfer" Context 2 (Rule-based logical expression): Rule = A&C&D&(B1|B2) Input (User Input): Based on the above symbol definitions and logical expressions, please summarize the core intent of this risk control rule and indicate the main risk scenarios it targets.
[0159] Therefore, after the smart device inputs the aforementioned target prompt text into the LLM model, the LLM model, based on its powerful reasoning and language understanding capabilities developed during training, generates the core intent of the aforementioned risk control rule. For example, the output of the LLM model could be: The core intent of this rule is to intercept large-amount, abnormal transactions from non-whitelisted users. The specific logic is: when a user is not on the whitelist and is in a different location, if they perform a "scan" or "transfer" operation exceeding 5000 yuan, the rule will be triggered. This primarily targets scenarios involving fraudulent transactions or large-scale money laundering.
[0160] Therefore, the above is the overall implementation process of the embodiments of this application.
[0161] Next, we will proceed through... Figure 3 The entire implementation process of the method in the embodiments of this application will be described.
[0162] Figure 3 This is a schematic flowchart of another data processing method provided in the embodiments of this application.
[0163] For example, such as Figure 3 As shown, the data processing method 300 includes the following steps S301 to S318.
[0164] S301, retrieve the target JSON text.
[0165] S302, perform logical parsing on the target JSON text to determine the rule combination logic corresponding to the M business rules, the logical conditions of the M business rules, and the condition combination logic corresponding to the logical conditions of any business rule.
[0166] S303: For any business rule among M business rules, convert the logical conditions of the business rule into a condition triplet.
[0167] S304 generates a Boolean logic expression based on the condition triples of M business rules, the rule combination logic, and the condition combination logic of the business rules.
[0168] S305, Symbolize the first logical condition and determine the symbol identifier corresponding to the first logical condition.
[0169] S306, Does the logical condition of M business rules include a second logical condition that is the same as the first logical condition?
[0170] When the logical conditions of M business rules include the second logical condition, proceed to step S308 after executing step S307. When the logical conditions of M business rules do not include the second logical condition, proceed to step S308.
[0171] S307, determine that the symbol identifier corresponding to the second logical condition is the same as the symbol identifier corresponding to the first logical condition.
[0172] S308 replaces the first logical condition in the Boolean logic expression with the symbol corresponding to the first logical condition to obtain a simplified logical expression.
[0173] S309, the simplified logical expression is determined as the first logical expression.
[0174] S310, whether the maximum number of occurrences of the first logical expression is less than the preset number.
[0175] When the maximum number of occurrences of the first logical expression is less than the preset number, proceed to step S311; When the maximum number of occurrences of the first logical expression is greater than or equal to the preset number, proceed to step S312.
[0176] S311, determine the first logical expression as the target logical expression, and proceed to step S317.
[0177] S312, determine the target symbol identifier and at least one business rule.
[0178] S313, using the target symbol identifier as the common symbol identifier, delete the target symbol identifier from at least one business rule to obtain the second logical expression.
[0179] S314, whether the maximum number of occurrences of the second logical expression is less than the preset number.
[0180] When the maximum number of occurrences of the second logical expression is greater than or equal to the preset number, proceed to step S315; When the maximum number of occurrences of the second logical expression is less than the preset number, proceed to step S316.
[0181] S315, update the second logical expression to the first logical expression, and proceed to steps S312 to S314.
[0182] S316, determine the second logical expression as the target logical expression.
[0183] S317. Generate target prompt text based on the logical conditions of M business rules, the symbol identifiers corresponding to the logical conditions of M business rules, and the target logical expression.
[0184] S318, Input the target prompt text into the large language model to determine the triggering conditions and business intent corresponding to the target business.
[0185] Steps S301 to S318 in the above data processing method 300 have the same inventive concept as steps S101 and S103 in the data processing method 100. Please refer to the foregoing description for details, which will not be repeated here.
[0186] In summary, this application provides a data processing method. When a target JSON text is received, the method performs logical parsing to obtain a Boolean logical expression. This process removes redundant information from the target JSON text, including only content relevant to business logic. Furthermore, by simplifying the Boolean logical expression, its length can be reduced. Finally, by deduplicating the simplified logical expression to obtain the target logical expression, the same logic is avoided from appearing repeatedly in the logical expression, further reducing its length. Therefore, by preprocessing the JSON text before inputting it into the large model, merging duplicate content, and simplifying the JSON text, the number of tokens processed by the large model is effectively reduced, thereby improving the inference speed of the large model.
[0187] Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application.
[0188] For example, such as Figure 4 As shown, the data processing device 400 includes: Parsing module 401 is used to perform logical parsing on the target JSON text to obtain the Boolean logical expression of the target JSON text. The target JSON text is used to describe the business logic of the target business. The target business corresponds to M business rules. The Boolean logical expression includes the logical conditions of each business rule, where M is an integer greater than or equal to 1. The simplification module 402 is used to simplify the Boolean logic expression based on the logical conditions of the M business rules to obtain a simplified logic expression; The deduplication module 403 is used to deduplicat the simplified logical expression to obtain the target logical expression of the target JSON text.
[0189] In one possible implementation, the parsing module 401 is specifically used to: perform logical parsing on the target JSON text, determine the rule combination logic corresponding to the M business rules, the logical conditions of the M business rules, and the condition combination logic corresponding to the logical conditions of any business rule; and generate the Boolean logical expression based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule.
[0190] In one possible implementation, the parsing module 401 is specifically used to: for any business rule among the M business rules, convert the logical condition of the business rule into a condition triplet; and generate the Boolean logical expression based on the condition triplets of the M business rules, the rule combination logic, and the condition combination logic of any business rule.
[0191] In one possible implementation, the simplification module 402 is specifically used to: for any first logical condition among the logical conditions of the M business rules, symbolize the first logical condition, determine the symbol identifier corresponding to the first logical condition, and determine that the symbol identifier corresponding to the second logical condition is the same as the symbol identifier corresponding to the first logical condition, wherein the second logical condition is the logical condition among the logical conditions of the M business rules that is the same as the first logical condition; replace the first logical condition in the Boolean logical expression with the symbol identifier corresponding to the first logical condition to obtain the simplified logical expression.
[0192] In one possible implementation, the deduplication module 403 is specifically used to: determine the simplified logical expression as a first logical expression; for at least one symbol identifier in the first logical expression, determine the number of times the at least one symbol identifier appears in the first logical expression; based on the number of times the at least one symbol identifier appears, determine the maximum number of times the first logical expression appears; based on the maximum number of times the first logical expression appears, deduplicate the first logical expression to obtain the target logical expression.
[0193] In one possible implementation, the deduplication module 403 is specifically configured to: when the maximum occurrence count corresponding to the first logical expression is greater than or equal to a preset count, determine the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among the at least one symbol identifiers, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; use the target symbol identifier as the common symbol identifier of the at least one business rule, and delete the target symbol identifier from the at least one business rule to obtain a second logical expression; when the maximum occurrence count corresponding to the second logical expression is greater than or equal to the preset count, update the second logical expression to the first logical expression, and repeatedly execute the steps of determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among the at least one symbol identifiers, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of the at least one business rule, and deleting the target symbol identifier from the at least one business rule to obtain a second logical expression, until the maximum occurrence count corresponding to the second logical expression is less than the preset count, and then determine the second logical expression as the target logical expression.
[0194] In one possible implementation, the deduplication module 403 is further configured to: determine the first logical expression as the target logical expression if the maximum number of occurrences corresponding to the first logical expression is less than the preset number of occurrences.
[0195] In one possible implementation, after obtaining the target logical expression of the target JSON text, the deduplication module 403 is further configured to: generate target prompt text based on the logical conditions of the M business rules, the symbol identifiers corresponding to the logical conditions of the M business rules, and the target logical expression; and input the target prompt text into a large language model so that the large language model can determine the triggering conditions and business intent corresponding to the target business based on the target prompt text.
[0196] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. This electronic device is the aforementioned smart device.
[0197] For example, such as Figure 5 As shown, the electronic device 500 includes a memory 501 and a processor 502. The memory 501 stores executable program code 5011, and the processor 502 is used to call and execute the executable program code 5011 to perform a data processing method.
[0198] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each module can correspond to a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0199] When each functional module is divided according to its corresponding function, the electronic device may include: a parsing module, a simplification module, and a deduplication module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0200] The electronic device provided in this embodiment is used to execute the above-described data processing method, and therefore can achieve the same effect as the above-described implementation method.
[0201] When using integrated units, the electronic device may include a processing module and a storage module. The processing module is used to control and manage the operation of the electronic device. The storage module is used to support the execution of relevant program code and data by the electronic device.
[0202] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits shown in conjunction with the disclosure of this application. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.
[0203] This embodiment also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the aforementioned related method steps to implement a data processing method in the above embodiment.
[0204] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement a data processing method described in the above embodiment.
[0205] In addition, the electronic device provided in the embodiments of this application may specifically be a chip, component or module. The electronic device may include a connected processor and a memory. The memory is used to store instructions. When the electronic device is running, the processor may call and execute the instructions to make the chip perform a data processing method in the above embodiments.
[0206] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0207] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0208] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0209] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data processing method, characterized in that, The data processing method includes: The target JSON text is logically parsed to obtain a Boolean logical expression of the target JSON text. The target JSON text is used to describe the business logic of the target business. The target business corresponds to M business rules. The Boolean logical expression includes the logical conditions of each of the business rules, where M is an integer greater than or equal to 1. Based on the logical conditions of the M business rules, the Boolean logic expression is simplified to obtain a simplified logic expression; The simplified logical expression is deduplicated to obtain the target logical expression of the target JSON text.
2. The method of claim 1, wherein, The logical parsing of the target JSON text to obtain the Boolean logical expression of the target JSON text includes: The target JSON text is logically parsed to determine the rule combination logic corresponding to the M business rules, the logical conditions of the M business rules, and the condition combination logic corresponding to the logical conditions of any business rule. The Boolean logic expression is generated based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule.
3. The method of claim 2, wherein, The step of generating the Boolean logic expression based on the rule combination logic, the logical conditions of the M business rules, and the condition combination logic of any business rule includes: For any of the M business rules, the logical conditions of the business rule are converted into condition triples; The Boolean logic expression is generated based on the condition triples of the M business rules, the rule combination logic, and the condition combination logic of any business rule.
4. The method of claim 1, wherein, The Boolean logic expression is simplified based on the logical conditions of the M business rules to obtain a simplified logical expression, including: For any first logical condition among the logical conditions of the M business rules, the first logical condition is symbolized, the symbol identifier corresponding to the first logical condition is determined, and the symbol identifier corresponding to the second logical condition is the same as the symbol identifier corresponding to the first logical condition. The second logical condition is the logical condition among the logical conditions of the M business rules that is the same as the first logical condition. The simplified logical expression is obtained by replacing the first logical condition in the Boolean logical expression with the symbol identifier corresponding to the first logical condition.
5. The method of claim 4, wherein, The process of deduplicating the simplified logical expression to obtain the target logical expression for the target JSON text includes: The simplified logical expression is determined as the first logical expression; For at least one symbol identifier in the first logical expression, determine the number of times the at least one symbol identifier appears in the first logical expression; Based on the number of occurrences of the at least one symbol identifier, determine the maximum number of occurrences corresponding to the first logical expression; Based on the maximum number of occurrences corresponding to the first logical expression, the first logical expression is deduplicated to obtain the target logical expression.
6. The method of claim 5, wherein, The step of deduplicating the first logical expression based on the maximum occurrence count corresponding to the first logical expression to obtain the target logical expression includes: If the maximum number of occurrences corresponding to the first logical expression is greater than or equal to a preset number, determine the target symbol identifier corresponding to the maximum number of occurrences corresponding to the first logical expression among the at least one symbol identifier, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression. The target symbol identifier is used as the public symbol identifier of the at least one business rule, and the target symbol identifier is deleted from the at least one business rule to obtain the second logical expression; If the maximum occurrence count corresponding to the second logical expression is greater than or equal to the preset count, the second logical expression is updated to the first logical expression, and the steps of determining the target symbol identifier corresponding to the maximum occurrence count of the first logical expression among the at least one symbol identifier, and at least one business rule including the target symbol identifier among the M business rules of the first logical expression; using the target symbol identifier as the common symbol identifier of the at least one business rule, and deleting the target symbol identifier from the at least one business rule to obtain the second logical expression, are repeated until the maximum occurrence count corresponding to the second logical expression is less than the preset count, at which point the second logical expression is determined as the target logical expression.
7. The method of claim 6, wherein, The data processing method further includes: If the maximum number of occurrences corresponding to the first logical expression is less than the preset number, the first logical expression is determined as the target logical expression.
8. The method according to claim 4, characterized in that, After obtaining the target logical expression of the target JSON text, the data processing method further includes: Based on the logical conditions of the M business rules, the symbol identifiers corresponding to the logical conditions of the M business rules, and the target logical expression, generate the target prompt text; The target prompt text is input into a large language model so that the large language model can determine the triggering conditions and business intent corresponding to the target business based on the target prompt text.
9. A data processing apparatus, characterized in that, The data processing device includes: The parsing module is used to perform logical parsing on the target JSON text to obtain the Boolean logical expression of the target JSON text. The target JSON text is used to describe the business logic of the target business. The target business corresponds to M business rules. The Boolean logical expression includes the logical conditions of each of the business rules, where M is an integer greater than or equal to 1. The simplification module is used to simplify the Boolean logic expression based on the logical conditions of the M business rules to obtain a simplified logic expression; The deduplication module is used to deduplicat the simplified logical expression to obtain the target logical expression of the target JSON text.
10. An electronic device, comprising: The electronic device includes: Memory, used to store executable program code; A processor is configured to call and run the executable program code from the memory, causing the electronic device to perform the data processing method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program code, which, when executed, implements the data processing method as described in any one of claims 1 to 8.
12. A computer program product, characterised in that, The computer program product includes: computer program code, which, when executed, implements the data processing method as described in any one of claims 1 to 8.