Rule generation method and related device

By expanding the sample set and having users label it, accurate data rules that meet preset conditions are generated, which solves the accuracy problem of the rule generation model in the case of few samples and improves efficiency and privacy protection.

CN120653979APending Publication Date: 2025-09-16HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410316331.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-15
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

Existing rule generation models are difficult to output accurate data rules when users provide fewer data samples, and writing regular expressions is time-consuming and labor-intensive.

Method used

By obtaining a sample set, using the rule generation model to generate initial data rules, expanding the sample set, generating samples to be labeled and handing them over to users for labeling, until accurate data rules that meet the preset conditions are generated, reducing the user's data collection pressure.

Benefits of technology

It improves the efficiency and accuracy of data rule generation, reduces the data collection pressure on users, and protects data privacy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653979A_ABST
    Figure CN120653979A_ABST
Patent Text Reader

Abstract

A rule generation method is applied to generating data rules, such as regular expressions. According to the method, after corresponding data rules are generated for samples in a sample set through a rule generation model, if the generated data rules do not meet preset conditions, some valuable samples continue to be generated based on original samples in the sample set, and the generated samples are delivered to a user for labeling. Then, the samples marked by the user are added into the sample set, sample expansion is achieved, the data rule continues to be generated based on the sample set with the samples added, till the generated data rule meets the preset condition, and therefore it is guaranteed that the accurate data rule can be generated. Moreover, the user does not need to provide a large number of samples in the generation process of the data rules, and valuable samples are automatically generated in the generation process of the data rules to be labeled by the user, so that the data collection pressure of the user can be effectively relieved, and the generation efficiency of the data rules is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a rule generation method and related devices. Background Art

[0002] Data privacy compliance has become a key focus in business operations. The core task of data privacy compliance is data organization and classification. Data rule generation is a key technology in this data organization process, widely used in tasks such as information extraction, sensitivity classification, and data desensitization. Furthermore, because business processes often involve the continuous and dynamic updating of data assets, pre-defined data rules often fail to cover all scenarios. Therefore, the data rule generation process also needs to be ongoing.

[0003] Currently, data rules are primarily implemented using regular expressions. By writing appropriate regular expressions, it is possible to match strings in text that conform to specific rules, thereby achieving data matching. However, writing regular expressions requires mastering certain syntax and rules, and for complex regular expressions, the writing and debugging process can be very time-consuming. Therefore, to improve development efficiency, data rule generation technology has emerged. The principle of data rule generation technology is based on machine learning and regular expression matching rules. It uses user-input samples to train the rule generation model, which then outputs the corresponding regular expression, thereby protecting data privacy and shortening the data rule development cycle.

[0004] However, the rule generation model itself is a data-driven algorithm. When users provide fewer data samples, the rule generation model often finds it difficult to output accurate data rules. Summary of the Invention

[0005] This application provides a rule generation method that can generate accurate data rules.

[0006] In a first aspect, the present application provides a rule generation method for generating data rules, such as regular expressions. The method comprises: obtaining a sample set, the sample set comprising at least one sample of a target entity. The target entity may be a named entity, such as a person's name, an organization's name, a place's name, and any other entity identified by a name, as well as text such as a number, a date, a currency, a proportional value, or the like. For example, in the financial field, the target entity may specifically be a mobile phone number, an email address, an ID number, a postal code, a taxpayer identification number, or the like.

[0007] The sample set is then input into a rule generation model to generate target data rules. The rule generation model is used to generate data rules that match the positive samples in the sample set and do not match the negative samples in the sample set. Specifically, a rule generation model is a model used to generate data rules. Essentially, it can be a machine learning model that can generate data rules that meet requirements by learning the rules of the input data.

[0008] Secondly, if the target data rule does not meet the preset conditions, it means that the target data rule generated by the rule generation model is not accurate. Therefore, based on the sample set, unlabeled samples are generated to expand the number of samples in the sample set. Among them, unlabeled samples are waiting to be labeled as positive samples or negative samples.

[0009] After obtaining the labeling results for the sample to be labeled, an enhanced sample labeled as a positive sample or a negative sample can be obtained. That is, after the user performs a labeling operation on the sample to be labeled, the user's labeling results for the sample to be labeled can be obtained. Then, based on the labeling results for the sample to be labeled, the labeling operation can be performed on the sample to be labeled, thereby converting the sample to be labeled into an enhanced sample.

[0010] Finally, the enhanced samples are added to the sample set to obtain an updated sample set. This updated sample set is then fed into the rule generation model to generate new data rules. Compared to the sample set before the update, the updated sample set contains more samples. Because the updated sample set contains more samples, it effectively constrains the process of generating data rules by the rule generation model. Therefore, the new data rules generated by the rule generation model are often more accurate than the previously generated data rules (i.e., the target data rules).

[0011] In this solution, after the rule generation model is used to generate corresponding data rules for the samples in the sample set, if the generated data rules do not meet the preset conditions, some valuable samples will be generated based on the original samples in the sample set, and these generated samples will be handed over to the user for labeling. Then, the user-labeled samples are added to the sample set to expand the samples, and data rules will continue to be generated based on the sample set after the added samples until the generated data rules meet the preset conditions, thereby ensuring that accurate data rules can be generated. In addition, the data rule generation process does not require the user to provide a large number of samples at once. Instead, valuable samples are automatically generated during the data rule generation process and handed over to the user for labeling. This can effectively reduce the user's data collection pressure, improve the efficiency of data rule generation, and protect data privacy.

[0012] In a possible implementation, at least one sample in the sample set is a character string, such as a string of numbers, letters, or special symbols, and the target data rule is a regular expression.

[0013] In one possible implementation, the process of generating samples to be labeled based on a sample set specifically includes: determining a first subset based on the sample set, the first subset including one or more positive samples of the same length in the sample set; determining the classification results of each character of the positive samples in the first subset, the classification results including numbers, lowercase letters, uppercase letters or special symbols; and then, generating each character of the sample to be labeled based on the classification results of each character.

[0014] In this scheme, by dividing the positive samples of the same length in the sample set into the same subset and analyzing and classifying each character of the positive samples in the subset, it is possible to accurately generate each character in the sample to be labeled, thereby improving the value of the generated samples and facilitating the output of accurate data rules at the lowest possible labeling cost.

[0015] In one possible implementation, when generating each character of the sample to be labeled based on the classification result of each character, the category selection probability of each character can be determined based on the classification result of each character. The category selection probability is used to indicate the probability of a character selecting its category from multiple categories, and the multiple categories include the classification results of the character. Then, based on the category selection probability of each character, the category to which each character belongs is determined, and a character is selected from the category to which each character belongs as the character of the sample to be labeled. For example, after determining that the category to which a certain character belongs is a number, a number can be selected from the 10 numbers 0-9 as the character of the sample to be labeled.

[0016] In this scheme, the probability of selecting the category of the character at the current position is determined based on the character classification result, which can ensure that characters of the same category and other categories can be selected in the generated samples. While ensuring the accuracy of the samples, it can also reasonably improve the diversity of the samples, which is conducive to quickly determining the boundaries between positive and negative samples.

[0017] In one possible implementation, a character is selected from the category to which each character belongs as the character of the sample to be labeled, specifically including: when the category to which the target character belongs is the same as the classification result of the target character, the character selection probability of the target character is determined based on the character hit by the positive sample in the first subset on the target character. The character selection probability is used to indicate the probability of selecting each character from the multiple characters in the category to which the target character belongs, and the target character is any character in the sample to be labeled. In this way, based on the character selection probability, a character can be selected from the category to which the target character belongs as the character of the sample to be labeled.

[0018] After determining the category of each character, since each category contains multiple characters, there may be multiple characters that can be selected from the category. To obtain more valuable samples to be labeled, this solution sets different selection probabilities for different characters in the category, ensuring that the characters ultimately selected constitute valuable samples to be labeled.

[0019] In one possible implementation, in the character selection probability, the probability of selecting a character that has hit the target character in the first subset of positive samples is lower than the probability of selecting a character that has not hit the target character in the first subset of positive samples. In other words, for the target character, the probability of selecting a character that has appeared on the target character in the first subset of positive samples is lower, while the probability of selecting a character that has not appeared on the target character in the first subset of positive samples is higher.

[0020] In this way, when generating samples to be labeled, each character in the samples to be labeled will be encouraged to avoid being repeated with characters that have already appeared in the positive sample as much as possible, so that the samples to be labeled will have a certain offset relative to the positive sample, to ensure that the generated samples to be labeled can be closer to the boundary between positive and negative samples, and to ensure that the restricted range of each character in the samples can be quickly determined after the samples to be labeled are handed over to the user for labeling, and ultimately to achieve the generation of accurate data rules based on as few samples as possible.

[0021] In one possible implementation, in the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, and the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position. In other words, since the hit character on the target position is already determined, the greater the distance between a certain character and the hit character, the greater the selection probability of this character; and the smaller the distance between a certain character and the hit character, the smaller the selection probability of this character.

[0022] In this scheme, when selecting the corresponding character for a certain character in the sample, ensure that the selected character is as far away as possible from the characters that have appeared in the sample, so that the characters in the sample to be labeled are more concentrated on the boundary of the category to which the characters belong, so that after the sample to be labeled is handed over to the user for labeling, the restriction range of each character in the sample can be quickly determined, and ultimately accurate data rules can be generated based on as few samples as possible.

[0023] In one possible implementation, in the probability of category selection, the probability of selecting the first category is greater than the probability of selecting the second category, the first category is the classification result of characters, and the second category is the classification result of non-characters. In other words, the probability of selecting the category corresponding to the classification result of characters is greater than the probability of selecting other categories, thereby ensuring that the generated samples to be labeled can be as close to the positive samples as possible, but there is also a certain probability that they are far away from the positive samples. Based on the above-mentioned probability setting method, the diversity of the samples to be labeled that are finally generated can be ensured, and the samples to be labeled can be as close to the positive samples and negative samples as possible, which is conducive to generating valuable samples to be labeled that can effectively improve the accuracy of the data rules generated by the rule generation model.

[0024] In one possible implementation, when the rule generation model is a model based on a genetic programming algorithm, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. The leaf nodes in the algorithm tree are used to represent data rules for one character. The character ranges covered by data rules at multiple different levels are different, and the character coverage range of the data rules is negatively correlated with the probability of selecting the data rules.

[0025] That is to say, based on the samples in the sample set, the specific characters that appear in each character in the sample can be summarized and summarized, thereby generating multiple different levels of data rules for each character. Among them, the character ranges covered by the multiple different levels of data rules are different. Moreover, if the character range covered by the data rules of a certain level is larger, it means that the characters included in the data rules of this level are closer to the characters that appear in the sample, and the probability of selecting the data rules of this level as the leaf nodes of the algorithm tree is also smaller; if the character range covered by the data rules of a certain level is larger, it means that the characters included in the data rules of this level are farther away from the characters that appear in the sample, and the probability of selecting the data rules of this level as the leaf nodes of the algorithm tree is also smaller.

[0026] In this scheme, in the process of generating an algorithm tree by the rule generation model, the leaf nodes of the algorithm tree are given multiple selectable data rules at different levels, and the character ranges covered by the data rules at different levels are different, so that the specificity and universality of the characters in the sample can be taken into account at the same time, and then a high-quality algorithm tree population that is accurate, reliable, diverse in expression and has a wide coverage is constructed, ensuring that accurate data rules can be quickly output based on the high-quality algorithm tree population.

[0027] In one possible implementation, before using the rule generation model to generate data rules, a preset number of editing operations may be performed on positive samples in the sample set to generate negative samples, where the editing operations include deleting characters, swapping characters, or inserting characters. The sample set and the generated negative samples are then input into the rule generation model, which is used to generate data rules based on the sample set and the generated negative samples.

[0028] That is to say, the generated negative samples can be added to the sample set as negative samples, thereby expanding the number of negative samples in the sample set and improving the accuracy of the data rules generated by the subsequent rule generation model.

[0029] In a possible implementation, the preset condition is that the matching rate between the target data rule and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rule and the negative samples in the sample set is not less than a second threshold.

[0030] A second aspect of the present application provides a rule generation device, comprising: an acquisition module for acquiring a sample set, the sample set including at least one sample of a target entity; a processing module for inputting the sample set into a rule generation model to obtain a target data rule, wherein the rule generation model is used to generate data rules that match positive samples in the sample set and do not match negative samples in the sample set; the processing module is also used to generate samples to be labeled based on the sample set when the target data rule does not meet a preset condition, the samples to be labeled are used to wait for labeling as positive samples or negative samples; the acquisition module is also used to obtain labeling results for the samples to be labeled, and obtain enhanced samples labeled as positive samples or negative samples; the processing module is also used to add the enhanced samples to the sample set to obtain an updated sample set, and the updated sample set is used to input the rule generation model so that the rule generation model generates new data rules.

[0031] In a possible implementation, at least one sample is a character string, and the target data rule is a regular expression.

[0032] In one possible implementation, the processing module is further used to: determine a first subset based on the sample set, the first subset including one or more positive samples of the same length in the sample set; determine a classification result for each character of the positive samples in the first subset, the classification result including numbers, lowercase letters, uppercase letters or special symbols; and generate each character of the sample to be labeled based on the classification result of each character.

[0033] In one possible implementation, the processing module is further used to: determine the category selection probability of each character based on the classification result of each character, the category selection probability is used to indicate the probability of a character selecting its category from multiple categories, and the multiple categories include the classification results of the character; determine the category to which each character belongs based on the category selection probability of each character, and select a character from the category to which each character belongs as the character of the sample to be labeled.

[0034] In one possible implementation, the processing module is also used to: when the category to which the target position character belongs is the same as the classification result of the target position character, determine the character selection probability of the target position character based on the character hit by the positive sample in the first subset on the target position character, the character selection probability is used to indicate the probability of selecting each character from multiple characters in the category to which the target position character belongs, and the target position character is any character in the sample to be labeled; based on the character selection probability, select a character in the category to which the target position character belongs as the character of the sample to be labeled.

[0035] In a possible implementation, in the character selection probability, the selection probability of the positive sample in the first subset having hit the character at the target position character is less than the selection probability of the positive sample in the first subset not having hit the character at the target position character.

[0036] In one possible implementation, in the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, and the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position.

[0037] In a possible implementation, in the category selection probability, the selection probability of the first category is greater than the selection probability of the second category, the first category is the classification result of characters, and the second category is the classification result of non-characters.

[0038] In one possible implementation, when the rule generation model is a model based on a genetic programming algorithm, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. The leaf nodes in the algorithm tree are used to represent data rules for one character. The character ranges covered by data rules at multiple different levels are different, and the character coverage range of the data rules is negatively correlated with the probability of selecting the data rules.

[0039] In one possible implementation, the processing module is further used to: perform a preset number of editing operations on positive samples in the sample set to generate negative samples, where the editing operations include deleting characters, swapping characters, or inserting characters; and input the sample set and the generated negative samples into a rule generation model, where the rule generation model is used to generate data rules based on the sample set and the generated negative samples.

[0040] In a possible implementation, the preset condition is that the matching rate between the target data rule and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rule and the negative samples in the sample set is not less than a second threshold.

[0041] A third aspect of the present application provides a computing device cluster, comprising at least one computing device, each computing device including a processor and memory. The processor of at least one computing device is configured to execute instructions stored in the memory of at least one computing device, causing the computing device cluster to perform the method described in the first aspect or any of the implementations of the first aspect. For details regarding the steps in each possible implementation of the first aspect performed by the computing device cluster, please refer to the first aspect and will not be repeated here.

[0042] In a fourth aspect, the present application provides a computer-readable storage medium having instructions stored therein. When the instructions are executed on a computer, the computer can execute any of the above methods.

[0043] A fifth aspect of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the methods described above.

[0044] In a sixth aspect, the present application provides a chip comprising a processor and a communication interface, wherein the communication interface is used to communicate with modules outside the chip, and the processor is used to run computer programs or instructions so that a device in which the chip is installed can execute any of the methods described above.

[0045] Among them, the technical effects brought about by any design method in the second to sixth aspects can refer to the technical effects brought about by different implementation methods in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 A schematic diagram of a system architecture 100 provided in an embodiment of the present application;

[0047] Figure 2 A flowchart of a rule generation method provided in an embodiment of the present application;

[0048] Figure 3A A schematic diagram of the relationship between the probability of a generated negative sample belonging to a negative sample and the edit distance provided in an embodiment of the present application;

[0049] Figure 3B A schematic diagram of a sample annotation interface provided in an embodiment of the present application;

[0050] Figure 4A schematic diagram of a system architecture used in a rule generation method provided in an embodiment of the present application;

[0051] Figure 5 A schematic diagram of a multi-level data rule provided in an embodiment of the present application;

[0052] Figure 6 A schematic diagram of an algorithm tree evolution operation provided in an embodiment of the present application;

[0053] Figure 7 A schematic diagram of performing subset division and bit-by-bit analysis on positive samples provided in an embodiment of the present application;

[0054] Figure 8 A schematic diagram of character selection probability provided in an embodiment of the present application;

[0055] Figure 9 A schematic diagram of a process for screening valuable characters based on a Gaussian mixture model provided in an embodiment of the present application;

[0056] Figure 10 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0057] Figure 11 A schematic diagram of the structure of a computing device 1100 provided in an embodiment of the present application;

[0058] Figure 12 A schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application;

[0059] Figure 13 A schematic diagram of the structure of another computing device cluster provided in an embodiment of the present application;

[0060] Figure 14 A schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solutions and advantages of this application more clear, the embodiments of this application are described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only embodiments of a part of this application, rather than all embodiments. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0062] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the descriptions used in this way can be interchangeable where appropriate so that the embodiments can be implemented in a sequence other than that illustrated or described in this application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or that are inherent to these processes, methods, products or devices. The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The named or numbered process steps can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of units in this application is a logical division. In actual application, there may be other division methods. For example, multiple units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, and the indirect coupling or communication connection between units can be electrical or other similar forms, which are not limited in this application. Moreover, the units or sub-units described as separate components may or may not be physically separated, may or may not be physical units, or may be distributed into multiple circuit units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this application.

[0063] To facilitate understanding, some technical terms involved in the embodiments of this application are first introduced below.

[0064] (1) Machine Learning

[0065] Machine learning is a method that allows computers to automatically learn patterns and rules from data to complete specific tasks.

[0066] (2) Machine Learning Model

[0067] A machine learning model is a mathematical model built by learning from existing data and extracting features from it. By building a machine learning model based on existing data, the model can learn the underlying patterns in the data and then output the corresponding processing results.

[0068] (3) Named Entities

[0069] Named entities are entities with specific meanings in text. They can include names of people, organizations, places, and all other entities identified by names, as well as text such as numbers, dates, currencies, and proportional values.

[0070] (4) Named Entity Recognition

[0071] Named entity recognition refers to the identification of entities with specific meanings in text (i.e. named entities). It is essentially a process of identifying specific types of names or symbols in text.

[0072] (5) Data rules

[0073] A data rule is a tool for matching and manipulating text. It is a pattern consisting of a series of characters and special characters that describes the text pattern to be matched.

[0074] (6) Regular Expression

[0075] A regular expression, also known as a regular expression, is a text pattern that uses a single string to describe and match a series of strings that conform to a certain syntactic rule. It is usually used to retrieve and replace text that conforms to a certain syntactic rule.

[0076] (7) Genetic Programming Algorithm

[0077] Genetic programming is a search algorithm for solving optimization problems and a type of evolutionary algorithm. It's a technique inspired by biological evolution to automatically generate and select computer programs to complete user-defined tasks. In theory, using genetic programming, humans only need to tell a computer "what to accomplish" rather than "how to accomplish it," potentially enabling true artificial intelligence: automated invention machines.

[0078] Specifically, genetic programming is a specialized machine learning technique that utilizes evolutionary algorithms. It begins with a population of millions of randomly generated computer programs. The fitness of individual programs is determined based on their ability to complete a given task, and Darwinian natural selection (survival of the fittest) is applied to determine the winning program. Furthermore, the winning programs are simulated through generations of evolution, including sexual pairing, mutation, gene duplication, and gene deletion, until a predetermined termination condition is met. The fundamental concept of genetic programming, also drawn from natural biological evolution theory and the principles of heredity, is a method for automatically generating random search programs. As a new global optimization search algorithm, genetic programming is simple, versatile, robust, and demonstrates strong ability to solve complex nonlinear problems. Consequently, it has been successfully applied in many diverse fields.

[0079] Generally speaking, the solution steps of the genetic programming algorithm can be summarized into the following steps.

[0080] Step 1: Determine how to express an individual. An individual is typically represented as an algorithm tree. When genetic programming is used to generate data rules, an algorithm tree can fully represent a data rule.

[0081] Step 2: Randomly generate an initial population, which includes multiple different individuals.

[0082] Step 3: Calculate the fitness of each individual in the population. When the genetic programming algorithm is used to generate data rules, the fitness of each individual can be characterized as the degree of match between the data rule represented by the individual and the sample.

[0083] Step 4: Select high-quality individuals based on their fitness and perform genetic operations on them, including replication, exchange, and mutation.

[0084] Step 5: Execute steps 3 and 4 repeatedly until the final individual meets the termination condition, such as the degree of matching between the data rule represented by the individual and the sample meets the requirements.

[0085] (8) String

[0086] A string is a series of characters consisting of numbers, letters, and special symbols.

[0087] (9) Active Learning

[0088] Active learning is a machine learning method that actively selects the most valuable examples for annotation. The goal of active learning is to annotate as few high-quality examples as possible, so that the model achieves the best possible performance.

[0089] Currently, data rule generation technology is primarily based on machine learning and regular expression matching rules. User-input samples are used to train the rule generation model, which then outputs the corresponding regular expressions, thereby protecting data privacy and shortening the data rule development cycle. However, the rule generation model itself is a data-driven algorithm. When users provide a small number of data samples, multiple solutions to the data rules may exist (i.e., multiple different data rules can match the limited data samples), making it difficult for the rule generation model to output accurate data rules.

[0090] Based on this, an embodiment of the present application provides a rule generation method, which generates corresponding data rules for samples in a sample set through a rule generation model. If the generated data rules do not meet the preset conditions, some valuable samples are continued to be generated based on the original samples in the sample set, and these generated samples are handed over to the user for labeling. Then, the samples labeled by the user are added to the sample set to expand the samples, and data rules are continued to be generated based on the sample set after the added samples until the generated data rules meet the preset conditions, thereby ensuring that accurate data rules can be generated. Moreover, the data rule generation process does not require the user to provide a large number of samples at one time, but automatically generates valuable samples during the data rule generation process and hands them over to the user for labeling, which can effectively reduce the user's data collection pressure and protect data privacy (that is, the user no longer needs to collect a large amount of private data as data samples).

[0091] See also Figure 1 , Figure 1 A schematic diagram of a system architecture 100 provided in an embodiment of the present application. Figure 1 As shown, in the system architecture 100, the execution device 110 can be implemented by at least one computing instance of a physical host (computing device), a virtual machine, or a container. When the execution device 110 is implemented by a virtual machine or a container, the execution device 110 actually exists in the form of a cloud computing product and can provide cloud services.

[0092] Optionally, in order to store data persistently, the system architecture 100 is further provided with a data storage system 120, which may be located outside the execution device 110 (e.g., Figure 2 As shown, the execution device 110 exchanges data with the execution device 110 via a network. Optionally, if the execution device 110 is a physical host, the data storage system 120 may be located within the execution device 110, such as if the data storage system 120 exchanges data with the processor via a bus. In this case, the data storage system 120 is represented by a hard disk. With the data storage system 120, the execution device 110 may use the data in the data storage system 120 or call program code in the data storage system 120 to implement the rule generation method provided in the embodiments of the present application.

[0093] Optionally, users can operate their respective user devices (such as local device 101 and local device 102) to interact with execution device 110. Each local device can represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a laptop computer, and a smart car.

[0094] Each user's local device can interact with the execution device 110 through a communication network of any communication mechanism / communication standard. The communication network can be a wide area network, a local area network, a point-to-point connection, etc., or any combination thereof.

[0095] In one implementation, the execution device 110 is used to implement the rule generation method provided in the embodiment of the present application, thereby outputting accurate and effective data rules. In addition, in the process where the local device 101 and the local device 102 need to use data rules to process data (for example, to identify specific data), the execution device 110 processes the request provided by the user based on the data rules, and then returns the corresponding processing results to the local device 101 and the local device 102. Optionally, in the process where the execution device 110 is used to implement the rule generation method provided in the embodiment of the present application, the local device 101 or the local device 102 can feedback the annotation results for the sample to be annotated to the execution device 110, so as to facilitate the annotation of the sample.

[0096] In another implementation, the execution device 110 is used to implement the rule generation method provided in the embodiment of the present application, output the corresponding data rules, and then send the data rules to the local device 101 and the local device 102. In this way, the local device 101 and the local device 102 can deploy the data rules locally, thereby processing data based on the data rules.

[0097] In another implementation, one or more aspects of the execution device 110 can be implemented by each local device. For example, the local device 101 can provide local data or feedback calculation results to the execution device 110, or execute the rule generation method provided in the embodiment of the present application.

[0098] In general, the rule generation method provided in the embodiments of the present application can be applied to electronic devices, such as the aforementioned execution device 110 , local device 101 , or local device 102 .

[0099] See also Figure 2 , Figure 2 This is a flow chart of a rule generation method provided in an embodiment of the present application. Figure 2 As shown, the rule generation method provided in the embodiment of the present application includes the following steps 201-205.

[0100] Step 201: Acquire a sample set, where the sample set includes at least one sample of a target entity.

[0101] In this embodiment, the target entity can be a named entity, such as a person's name, an organization's name, a place's name, and any other entity identified by a name, as well as text such as numbers, dates, currencies, and proportional values. For example, in the financial field, the target entity can be a mobile phone number, email address, ID number, zip code, taxpayer identification number, and other entities.

[0102] In addition, the sample of the target entity may refer to a positive sample of the target entity or a negative sample of the target entity. The positive sample of the target entity is a specific manifestation of the target entity. For example, when the target entity is a postal code, the postal code is usually composed of multiple digits, so the positive sample of the target entity can be specifically: 223300, 223335 or 210012 and other postal codes. That is to say, in the sample set, all positive samples of the target entity can represent the same target entity. The negative sample of the target entity refers to a sample that cannot represent the target entity, that is, some erroneous samples for the target entity. For example, when the target entity is a postal code, the negative sample of the target entity can be specifically: ACK300.

[0103] In general, a sample set typically includes one or more positive samples of the target entity. In some cases, the sample set may also include some negative samples of the target entity. That is, the sample set may include only positive samples of the target entity, or it may include both positive and negative samples of the target entity. This embodiment does not specifically limit this.

[0104] Step 202 : Input the sample set into a rule generation model to obtain target data rules, wherein the rule generation model is used to generate data rules that match positive samples in the sample set and do not match negative samples in the sample set.

[0105] In this embodiment, the rule generation model is specifically a model for generating data rules. Essentially, it can be a machine learning model that generates data rules that meet requirements by learning rules from input data. Specifically, the rule generation model can be implemented in a variety of ways, such as using genetic programming algorithms, exhaustive algorithms, or greedy algorithms. The rule generation model can also be a neural network model (such as a large language model). This embodiment does not specifically limit the implementation of the rule generation model.

[0106] It should be noted that, when the sample set includes only positive samples, the rule generation model can generate data rules based on the sample set that match the positive samples in the sample set as much as possible. When the sample set includes both positive and negative samples, the rule generation model can generate data rules that match the positive samples in the sample set as much as possible and do not match the negative samples.

[0107] Optionally, the samples in the sample set may be strings, such as strings consisting of numbers, lowercase letters, uppercase letters, or special characters. The target data rules generated by the rule generation model may be regular expressions that can match strings that meet specific syntactic rules.

[0108] Because in actual application scenarios, the sample set provided by the user may often only include a certain number of positive samples but not negative samples; or, the sample set may only include a small number of negative samples. However, when the rule generation model generates data rules, it generates data rules based on the principle that the data rules match the provided positive samples as much as possible but do not match the provided negative samples. Therefore, when the sample set includes only a small number of negative samples or does not include any negative samples, the accuracy of the data rules generated by the rule generation model will be affected. Based on this, in this embodiment, a part of negative samples can be automatically generated based on the original samples in the sample set, thereby improving the accuracy of the data rules generated by the final rule generation model.

[0109] For example, consider a regular expression ".*" that matches any string, where "." represents any character and "*" indicates matching the preceding expression one or more times. In this case, ".*" matches any sample, which is clearly not the desired regular expression. Therefore, negative samples are needed to narrow the scope of the regular expression. That is, the regular expression cannot match negative samples, resulting in a more accurate expression.

[0110] Exemplarily, before using the rule generation model to process the sample set, a preset number of editing operations can be performed on the positive samples in the sample set to obtain generated negative samples, where the editing operations include deleting characters, exchanging characters, or inserting characters. In other words, by performing a preset number of editing operations on a positive sample, a generated negative sample can be obtained. Each editing operation performed on the positive sample can be any one of deleting characters, exchanging characters, or inserting characters. Therefore, by performing multiple editing operations on the positive sample, a combination of different editing methods can be achieved, and ultimately a negative sample with a large difference from the positive sample is generated. For example, assuming that the positive sample is "gyiou", and the preset number of editing operations performed on the positive sample is 1, then the following generated negative samples can be obtained for the positive sample: "gyio", "ygiou", "gyiouh", etc.

[0111] Generally speaking, the number of times the editing operation is performed on the positive sample can also be called the edit distance of the positive sample. If the number of times the editing operation is performed on the positive sample is greater, the edit distance between the generated negative sample and the positive sample will be larger, and the probability that the generated negative sample obtained by editing is a true negative sample will be higher. Please refer to 3A, Figure 3AThis is a schematic diagram of the relationship between the probability of a generated negative sample belonging to a negative sample and the edit distance provided in an embodiment of the present application. Figure 3A As shown in Figure 1, when the edit distance between the generated negative sample and the positive sample is 5, the probability that the generated negative sample is a true negative sample is medium; when the edit distance between the generated negative sample and the positive sample is 5, the probability that the generated negative sample is a true negative sample is high.

[0112] However, when applying the rule generation model to process samples, if the provided negative samples are closer to the positive samples, the rule generation model can better learn the boundary between the negative samples and the positive samples, thereby being able to generate more accurate data rules. Therefore, when setting the edit distance (i.e., the number of times the edit operation is performed on the positive sample), it is necessary to comprehensively consider the impact of the edit distance on the probability of whether the generated negative sample is a true negative sample and the similarity between the generated negative sample and the positive sample, so as to select a suitable edit distance. Generally speaking, the higher the complexity of the positive sample, the more times the edit operation needs to be performed on the positive sample (i.e., the larger the preset number of times); the lower the complexity of the positive sample, the fewer times the edit operation needs to be performed on the positive sample (i.e., the smaller the preset number of times). For example, the above-mentioned preset number of times the edit operation is performed on the positive sample in the sample set can be 1, 2, 3, 5, 10, etc., and this embodiment does not make specific limitations on this.

[0113] In actual application, one or more positive samples can be selected from the sample set, and one or more rounds of editing operations can be performed on each positive sample, where each round of editing operation performs a preset number of editing operations on the positive sample, thereby obtaining the expected number of generated negative samples.

[0114] In this way, after obtaining the generated negative samples, the sample set and the generated negative samples can be simultaneously input into the rule generation model, which is then used to generate data rules based on the sample set and the generated negative samples. In other words, the generated negative samples can be added to the sample set as negative samples, thereby expanding the number of negative samples in the sample set and improving the accuracy of the data rules generated by the subsequent rule generation model.

[0115] Step 203: When the target data rule does not meet the preset conditions, a sample to be labeled is generated based on the sample set, and the sample to be labeled is used to wait for being labeled as a positive sample or a negative sample.

[0116] In this embodiment, after the rule generation model outputs the corresponding target data rule, it can be determined whether the target data rule meets the preset conditions. If the target data rule meets the preset conditions, it means that the target data rule generated by the rule generation model is already a relatively accurate data rule. If the target data rule does not meet the preset conditions, it means that the target data rule generated by the rule generation model is inaccurate, and therefore a new data rule needs to be generated.

[0117] Based on this, when the target data rule does not meet the preset conditions, this embodiment generates new samples to be labeled by referring to the original sample set. The samples to be labeled need to be further labeled by the user to determine whether they are positive samples or negative samples. In actual applications, one or more samples to be labeled can be generated based on the sample set, and all generated samples to be labeled need to be labeled by the user. This embodiment does not limit the number of samples to be labeled.

[0118] Optionally, the above-mentioned preset conditions are, for example, that the matching rate between the target data rules generated by the rule generation model and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rules and the negative samples in the sample set is not less than a second threshold. The first threshold and the second threshold can be adjusted according to actual conditions, for example, the first threshold is 90% and the second threshold is 99%, and this embodiment does not make specific limitations on this. In short, by setting preset conditions, the matching rate between the data rules and the positive samples and negative samples in the sample set meets certain requirements, which can effectively ensure the accuracy of the data rules and ensure that effective and accurate data rules can be output.

[0119] Step 204: Obtain the labeling results for the samples to be labeled, and obtain enhanced samples labeled as positive samples or negative samples.

[0120] After the samples to be labeled are generated, these samples to be labeled will be output (for example, the output will be displayed on the display screen of the electronic device) so that the user can obtain these generated samples to be labeled. Then, the user will label the samples to be labeled, such as checking the corresponding sample type (i.e., positive sample or negative sample) for each sample to be labeled on the electronic device, so as to realize the labeling of whether each sample to be labeled output is a positive sample or a negative sample. In this way, after the user performs the labeling operation on the sample to be labeled, the electronic device can obtain the user's labeling results for the sample to be labeled. Then, based on the labeling results for the sample to be labeled, the electronic device can implement the labeling operation on the sample to be labeled, thereby converting the sample to be labeled into an enhanced sample. Among them, each enhanced sample is labeled as a positive sample or a negative sample.

[0121] For example, see Figure 3B , Figure 3B This is a schematic diagram of a sample annotation interface provided in an embodiment of the present application. Figure 3B As shown in the figure, a plurality of samples to be labeled as positive samples or negative samples are displayed on the display screen of the electronic device, such as "525300", "AD2023", and "20Bn30". The user can mark the corresponding sample to be labeled as a positive sample or a negative sample by clicking the "Positive Sample" button or the "Negative Sample" button displayed after each sample to be labeled.

[0122] Step 205 : Add the enhanced sample to the sample set to obtain an updated sample set. The updated sample set is used to input into the rule generation model so that the rule generation model generates new data rules.

[0123] After obtaining the enhanced samples, the enhanced samples can be added to the sample set as expanded samples, thereby obtaining an updated sample set. Compared with the sample set before the update, the updated sample set has more samples.

[0124] In this way, the updated sample set can be re-input into the rule generation model, and the rule generation model generates new data rules based on the updated sample set. Because the updated sample set contains more samples, it can effectively constrain the process of the rule generation model in generating data rules. Therefore, the new data rules generated by the rule generation model are often more accurate than the previously generated data rules (i.e., the target data rules).

[0125] It should be noted that the above steps 201-205 describe the process of generating new samples to label the user, and using the labeled samples to expand the sample set before regenerating the data rules when the data rules generated by the rule generation model do not meet the preset conditions. In actual applications, after each data rule generated by the rule generation model, it can be determined whether the generated data rule meets the preset conditions. If the generated data rule does not meet the preset conditions, new ones will continue to be generated to label the user, and the labeled samples will be used to expand the sample set before regenerating the data rule. That is, the above steps 203-205 will be executed in a loop until the data rule finally generated by the rule generation model meets the preset conditions.

[0126] In addition, if the data rules output by the rule generation model still do not meet the above-mentioned preset conditions after a certain number of loop iterations, but the data rules output by the rule generation model no longer change, the loop can be stopped to execute the above-mentioned steps 203-205, thereby adopting the data rules finally output by the rule generation model.

[0127] In this embodiment, when the rule generation model is a model based on a genetic programming algorithm, the rule generation model generates a population consisting of a large number of algorithm trees during the execution of the genetic programming algorithm, and each algorithm tree can represent a data rule (such as a regular expression). By calculating the matching rate between the data rule represented by each algorithm tree and the samples in the sample set, the fitness of each algorithm tree can be determined. Then, the fitness of each algorithm tree is evaluated by applying a natural selection algorithm to the algorithm tree, and high-quality algorithm trees (i.e., algorithm trees with a high matching rate with the samples) are retained. New populations are generated through operations such as crossover and mutation between high-quality algorithm trees until the final algorithm tree can meet the preset conditions.

[0128] In other words, during the initial phase of executing the genetic programming algorithm, the rule generation model randomly generates a population of algorithm trees, then continuously iterates and evolves them to generate algorithm trees that meet preset conditions, thereby outputting corresponding data rules. Based on this, this embodiment provides a method for generating algorithm trees that can quickly generate a high-quality population of algorithm trees in the initial phase, improving the efficiency of the iterative evolution of the population and the quality of the ultimately output data rules.

[0129] Optionally, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. A leaf node in the algorithm tree is used to represent a data rule for a single character. Therefore, combining multiple leaf nodes included in the algorithm tree can represent data rules for multiple characters. The data rules at these multiple different levels cover different character ranges, and the character coverage of a data rule is negatively correlated with the probability of selection of the data rule.

[0130] That is to say, based on the samples in the sample set, the specific characters that appear in each character in the sample can be summarized and summarized, thereby generating multiple different levels of data rules for each character. Among them, the character ranges covered by the multiple different levels of data rules are different. Moreover, if the character range covered by the data rules of a certain level is larger, it means that the characters included in the data rules of this level are closer to the characters that appear in the sample, and the probability of selecting the data rules of this level as the leaf nodes of the algorithm tree is also smaller; if the character range covered by the data rules of a certain level is larger, it means that the characters included in the data rules of this level are farther away from the characters that appear in the sample, and the probability of selecting the data rules of this level as the leaf nodes of the algorithm tree is also smaller.

[0131] In this scheme, in the process of generating an algorithm tree by the rule generation model, the leaf nodes of the algorithm tree are given multiple selectable data rules at different levels, and the character ranges covered by the data rules at different levels are different, so that the specificity and universality of the characters in the sample can be taken into account at the same time, and then a high-quality algorithm tree population that is accurate, reliable, diverse in expression and has a wide coverage is constructed, ensuring that accurate data rules can be quickly output based on the high-quality algorithm tree population.

[0132] Specifically, given a certain number of positive and negative samples, there may be a large number of data rules that can meet the requirements of positive and negative samples. However, existing rule generation models often lack fine-grained analysis of samples, resulting in a failure to focus on a smaller solution space for search during algorithm initialization, which in turn consumes a lot of time for ineffective searches and increases the probability of generating incorrect data rules. However, this solution can determine the expression of each leaf node in the algorithm tree by performing a detailed analysis of the samples (i.e., pre-analyzing the length and character restrictions in the samples). This can effectively narrow the solution space while ensuring the diversity of the initialization rules, thereby improving the accuracy and efficiency of the rule generation model.

[0133] The above describes how to generate accurate data rules by processing a changing sample set based on a rule generation model. To facilitate understanding, the following details how to generate new samples based on existing samples in the sample set, thereby expanding the sample set.

[0134] Optionally, in the above step 203 , the process of generating samples to be labeled based on the sample set specifically includes the following steps 2031 - 2033 .

[0135] Step 2031: Determine a first subset based on the sample set, where the first subset includes one or more positive samples with the same length as the sample set.

[0136] Specifically, all positive samples in the sample set can be divided into subsets based on their length, so that positive samples of the same length are grouped into the same subset, and each positive sample is guaranteed to be grouped into a unique subset. In this way, the sample set can be divided into one or more subsets, and the first subset can be any subset into which the sample set is divided.

[0137] For example, suppose the sample set includes 10 samples, namely sample 1 to sample 10, where the length of sample 1 to sample 3 is 5 (i.e., the number of characters contained is 5), the length of sample 4 to sample 8 is 7, and the length of sample 9 to sample 10 is 10. Then, samples 1 to sample 3 can be divided into subset 1, samples 4 to sample 8 can be divided into subset 2, and samples 9 to sample 10 can be divided into subset 3.

[0138] Step 2032: Determine the classification result of each character in the positive sample in the first subset, where the classification result includes numbers, lowercase letters, uppercase letters, or special symbols.

[0139] Since the lengths of all positive samples in the first subset are the same, the number of character bits in the positive samples in the first subset is actually fixed, that is, each positive sample in the first subset includes the same number of characters. Assuming that the positive samples in the first subset include N-bit characters, then by traversing all positive samples in the first subset, it is possible to determine the characters that appear in the positive samples for each of the N-bit characters, thereby determining the classification result of each character. For example, if the characters that appear in a certain character include 0, 1, 5, and 6, then the classification result of this character can be considered to be a number; for another example, if the characters that appear in a certain character include a, h, g, and z, then the classification result of this character can be considered to be a lowercase letter.

[0140] It should be noted that for any character, the classification result of the character can include one category or multiple categories. For example, assuming that the characters appearing in a certain character include 0 and 1, the classification result of the character can be considered as a number, that is, the classification result only includes the category of numbers. For another example, assuming that the characters appearing in a certain character include 0, 1, a, and b, the classification result of the character can be considered as a number or a lowercase letter, that is, the classification result includes both categories of numbers or lowercase letters.

[0141] Step 2033: Generate each character of the sample to be labeled based on the classification result of each character.

[0142] Specifically, based on the classification result of each character, the category selection probability of each character can be determined. The category selection probability is used to indicate the probability of a character selecting the category to which it belongs from multiple categories, and the multiple categories include the classification results of the characters. That is, the multiple categories can specifically include numbers, lowercase letters, uppercase letters, and special symbols. Based on the classification result of any character, the probability of this character selecting each category of characters can be determined. For example, when it is determined that the classification result of a character is a number, it can be determined that the probability of this character selecting the number category is p, and the probability of selecting the lowercase letter category, the uppercase letter category, and the special symbol category are all (1-p) / 3.

[0143] Optionally, in the probability of category selection, the probability of selecting the first category is greater than the probability of selecting the second category, where the first category is the classification result of characters, and the second category is the classification result of non-characters. In other words, the probability of selecting the category corresponding to the classification result of characters is greater than the probability of selecting other categories, thereby ensuring that the generated samples to be labeled can be as close to the positive samples as possible, but there is also a certain probability that they are far away from the positive samples. Based on the above-mentioned probability setting method, the diversity of the samples to be labeled that are finally generated can be ensured, and the samples to be labeled can be as close to the positive samples and negative samples as possible, which is conducive to generating valuable samples to be labeled that can effectively improve the accuracy of the data rules generated by the rule generation model.

[0144] Then, based on the probability of selecting a category for each character, the category of each character can be determined, and a character from each character's category can be selected as the character to be labeled. For example, after determining that a character's category is a digit, a digit can be selected from the 10 digits 0-9 as the character to be labeled. For another example, after determining that a character's category is a lowercase letter, a letter can be selected from the 26 lowercase letters a-z as the character to be labeled.

[0145] It is understood that after determining the category to which each character belongs, since each category includes multiple characters, there may be multiple characters that can be selected from the category. To obtain more valuable samples to be labeled, this embodiment can set different selection probabilities for different characters in the category, thereby ensuring that the characters ultimately selected constitute valuable samples to be labeled.

[0146] Exemplarily, when the category to which the target position character belongs is the same as the classification result of the target position character, the character selection probability of the target position character is determined based on the characters hit by the positive sample in the first subset on the target position character (i.e., the characters that the positive sample has appeared on the target position character). The character selection probability of the target position character is used to indicate the probability of selecting each character from the multiple characters in the category to which the target position character belongs, and the target position character is any character in the sample to be labeled. For example, assuming that the target position character is the first character, and the characters hit by the positive sample in the first character in the first subset include the number 0, then the selection probability of each character in the numbers 0-9 can be determined.

[0147] Then, after obtaining the character selection probability of the target character, a character can be selected from the category to which the target character belongs as the character to be labeled based on the character selection probability. For example, assuming that the selection probability of character 0 is 55% and the selection probability of characters 1-9 is 5% each, then in actual application, there is a 55% probability of selecting character 0 as the character to be labeled, and a 5% probability of selecting characters 1-9 as the character to be labeled.

[0148] Optionally, in the character selection probability, the probability of selecting a character that has hit the target character in the first subset of positive samples is lower than the probability of selecting a character that has not hit the target character in the first subset of positive samples. In other words, for the target character, the probability of selecting a character that has appeared on the target character in the first subset of positive samples is lower, while the probability of selecting a character that has not appeared on the target character in the first subset of positive samples is higher.

[0149] In this way, when generating samples to be labeled, each character in the samples to be labeled will be encouraged to avoid being repeated with characters that have already appeared in the positive sample as much as possible, so that the samples to be labeled will have a certain offset relative to the positive sample, to ensure that the generated samples to be labeled can be closer to the boundary between positive and negative samples, and to ensure that the restricted range of each character in the samples can be quickly determined after the samples to be labeled are handed over to the user for labeling, and ultimately to achieve the generation of accurate data rules based on as few samples as possible.

[0150] Optionally, in the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, wherein the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position. In other words, since the hit character on the target position is already determined, the greater the distance between a certain character and the hit character, the greater the selection probability of this character; and the smaller the distance between a certain character and the hit character, the smaller the selection probability of this character.

[0151] In general, when selecting a corresponding character for a certain character in the sample, ensure that the selected character is as far away as possible from the characters that have appeared in the sample, so that the characters in the sample to be labeled are more concentrated on the boundary of the category to which the character belongs, so that after the sample to be labeled is handed over to the user for labeling, the restriction range of each character in the sample can be quickly determined, and ultimately accurate data rules can be generated based on as few samples as possible.

[0152] In addition, when the category to which the target character belongs is different from the classification result of the target character, the selection probabilities of all characters under the category to which the target character belongs are the same.

[0153] The above describes the execution process of a rule generation method provided by this embodiment. To facilitate understanding, the following will describe in detail the execution process of the rule generation method in a specific application scenario with reference to specific examples.

[0154] See also Figure 4 , Figure 4 A schematic diagram of the system architecture used in a rule generation method provided in an embodiment of the present application. Figure 4 As shown, in application scenarios such as information extraction, sensitivity classification, and data desensitization, the user has a certain number of samples of the target entity (for example, a small number of positive samples of the target entity). Based on the samples input by the user, the data rules of the target entity (such as regular expressions) are learned by the rule generation model, and after the rule generation model outputs the data rules, it is determined whether the termination condition is met. If the termination condition is not met, the active learning module selects the most valuable samples based on the labeled sample set and hands them over to the user for labeling. The positive and negative samples labeled by the user will be stored in the labeled sample set (that is, the sample set mentioned above), and the rule generation model will generate the corresponding data rules again until the termination condition is met. At this point, the data rules obtained when the termination condition is met will be used to generate the target named entity recognition model and stored in the entity recognition library to achieve applications such as information extraction, sensitivity classification, and data desensitization.

[0155] The following will introduce in detail Figure 4 The rule generation module and active learning module in the system architecture shown. The rule generation module can include the rule generation model described in the above embodiment, which can be used to output corresponding data rules based on the labeled sample set. Furthermore, the rule generation module can also include a negative sample generation module, which can automatically generate negative samples based on the positive samples in the labeled sample set to expand the amount of negative sample data.

[0156] Specifically, taking the case where the rule generation model is a model based on a genetic programming algorithm and the data rules generated by the rule generation model are regular expressions as an example, the working process of the rule generation module will be introduced in combination with multiple steps.

[0157] Step 1: Automatically generate negative samples based on the specified edit distance to expand the number of negative samples in the labeled sample set.

[0158] Because the rule generation model is trained using positive and negative samples, the optimal regular expression output by the rule generation model should satisfy the positive samples as much as possible while not satisfying the negative samples. However, in practical applications, users may only provide a small number of positive samples. Therefore, it is very important for the algorithm to automatically generate negative samples, which is related to the accuracy of the regular expression ultimately output by the rule generation model. Based on this, in this embodiment, negative samples are automatically generated through a negative sample generation module.

[0159] Specifically, given a positive sample, according to the preset edit distance, multiple editing operations can be performed on the random position of the positive sample, where each editing operation can be any one of deletion, exchange or insertion. In addition, the number of editing operations on the positive sample is related to the preset edit distance. For example, when the edit distance is 5, 5 editing operations are performed on the positive sample. For example, in a certain entity type, "gyiou" is a positive sample. If the edit distance is 1, multiple samples can be generated, such as "gyio", "ygiou", etc. When the edit distance is set to a larger value, the farther the generated sample is from the positive sample, the more likely it is to be a true negative sample. However, if the distance between the generated sample and the positive sample is too far, it is difficult to effectively determine the difference between the positive sample and the negative sample, which is not conducive to generating an effective and accurate regular expression. Therefore, in practical applications, the edit distance can be set according to the complexity of the positive sample, and no specific limitation is made here.

[0160] In general, automatically generating negative samples not only enables the rule generation model to be effectively trained, but also reduces the solution space of regular expressions, ensuring that the rule generation model ultimately outputs accurate regular expressions.

[0161] Step 2: Synthesize a high-quality initial algorithm tree population based on a multi-level abstraction method.

[0162] After sufficient negative samples are generated based on the negative sample generation module, the generated negative samples can be added to the labeled sample set, and the samples in the labeled sample set are input into the rule generation model, which generates corresponding regular expressions based on the genetic programming algorithm.

[0163] When the rule generation model generates corresponding data rules based on a genetic programming algorithm, it generates a population of algorithm trees and evaluates, screens, and iterates the algorithm trees in the population, ultimately obtaining an algorithm tree that can represent the optimal regular expression. When generating the initial population of algorithm trees, a fine-grained analysis of the positive samples in the labeled sample set can be performed to generate a high-quality initial population of algorithm trees.

[0164] Specifically, for a positive sample in the labeled sample set, the positive sample can be analyzed bit by bit, for example, analyzing the specific category of each character in the positive sample, such as numbers, uppercase and lowercase letters, special symbols, etc. Then, based on the results obtained from analyzing each character in each positive sample, the three levels of abstract relationships are divided into low-level data rules, mid-level data rules, and high-level data rules according to the hierarchical relationship of regular expressions. Among them, the lower the level of the data rule, the smaller the range of characters covered, and the closer it is to the existing positive sample; the higher the level of the data rule, the larger the range of characters covered, and the more it deviates from the existing positive sample.

[0165] For example, assuming the labeled sample set includes four positive samples, namely "g", "y", "w", and "l", then the low-level data rule can be represented by the regular expression [gywl], that is, the entity has only one character and can only be one of the four characters "g", "y", "w", and "l", which is an exhaustive representation of the four positive samples. The mid-level data rule can be represented by the regular expression [az] or [A-Za-z], where [az] represents a lowercase letter and [A-Za-z] represents a lowercase letter or an uppercase letter. The high-level data rule can be represented by the regular expression \w or wildcard, where \w represents a letter, number, or underscore, and wildcard represents any character.

[0166] For example, see Figure 5 , Figure 5 This is a schematic diagram of a multi-level data rule provided in an embodiment of the present application. Figure 5 As shown, low-level data rules can be derived by exhaustively enumerating different character categories, such as numbers [1, 2, 3], lowercase letters [a, b, c], uppercase letters [A, B, C], and special symbols [#, @]. Mid-level data rules are derived by generalizing character categories, such as "\d" representing any digit, "[az]" representing any lowercase letter, and "[AZ]" representing any uppercase letter. High-level data rules are derived by further generalizing all characters, such as "wildcard" representing any single character.

[0167] When constructing the algorithm tree population, since a leaf node in the algorithm tree represents a character, and each character in the sample corresponds to three levels of data rules, the leaf node can select one of the three levels of data rules as the data rule represented by the current leaf node based on the probability of each level of data rules. Specifically, since lower-level data rules are likely to be more accurate and more relevant to user needs, they can be assigned a higher selection probability. Higher-level data rules can be assigned a higher selection probability because they have less specificity but a wider scope. Correspondingly, mid-level data rules can be assigned a moderate selection probability. By dividing the data rules into multiple levels and setting corresponding selection probabilities, accurate and reliable selection is provided when constructing the algorithm's initial regular expression. Furthermore, by setting corresponding probabilities for selection within the multiple levels of data rules, a high-quality algorithm tree population with diverse expressions and coverage can be constructed. This approach reduces the solution space while ensuring the diversity of the initialization rules, ultimately improving the accuracy and efficiency of the rule generation model.

[0168] Step 3: Evaluate the algorithm trees in the population and iteratively generate new algorithm trees based on the high-quality algorithm trees obtained through evaluation until the data rules represented by the algorithm tree finally generated meet the termination conditions.

[0169] The algorithm trees in the population may be evaluated by determining the degree of match between the regular expression represented by the algorithm tree and the positive samples in the labeled sample set, and the degree of mismatch between the regular expression represented by the algorithm tree and the negative samples in the labeled sample set. If the regular expression represented by the algorithm tree has a high degree of match between the positive samples in the labeled sample set, and the regular expression represented by the algorithm tree has a low degree of match between the negative samples in the labeled sample set, then the quality of the algorithm tree is relatively high, and the algorithm tree may be retained and a genetic mutation operation may be performed on the retained algorithm tree to iteratively generate a new algorithm tree.

[0170] Nodes on the algorithm tree can be either branch nodes or leaf nodes. Branch nodes represent an operation applied to their child nodes, while leaf nodes represent a parameter or constant value. Regarding genetic variation, there are two types of evolutionary operations in genetic programming based on algorithm trees: mutation and crossover. Mutation operations come in two flavors (differentiated by the scope of the mutation): one randomly transforms symbols or operators within the tree, and the other randomly transforms subtrees. Crossover operations involve randomly swapping subtrees between two algorithm trees.

[0171] For example, see Figure 6 , Figure 6 This is a schematic diagram of the evolution operation of an algorithm tree provided in an embodiment of the present application. Figure 6As shown, when performing a crossover operation, the subtrees in the two algorithm trees can be exchanged, thereby adjusting the two algorithm trees at the same time and obtaining two new algorithm trees. After mutating the leaf nodes in the algorithm tree, the data rules represented by the leaf nodes in the algorithm tree can be changed, thereby achieving the mutation operation of the algorithm tree and changing the regular expression represented by the entire algorithm tree.

[0172] When evaluating population fitness, this embodiment uses accuracy (Precison, prec), true positive character rate (True Positive Character Rate, tpcr), true negative character rate (True Negative Character Rate, tncr) and simplicity of regular expression (Simplicity, simp) to evaluate the quality of an algorithm tree, as shown in the following formula.

[0173]

[0174] Among them, r * represents the quality of the algorithm tree, prec(r) represents the accuracy of the regular expression represented by the algorithm tree, tpcr(r) represents the positive sample matching rate of the regular expression represented by the algorithm tree, tncr(r) represents the negative sample matching rate of the regular expression represented by the algorithm tree, and simp(r) represents the simplicity of the regular expression represented by the algorithm tree. Ultimately, the goal of population mutation evolution is to make the quality of the algorithm tree as high as possible.

[0175] Specifically, assuming P is the positive sample set and N is the negative sample set, is the number of characters in string i (i.e., the length of sample i), then the formula for obtaining prec(r), tpcr(r), tncr(r), and simp(r) can be referred to.

[0176]

[0177]

[0178]

[0179]

[0180] in, and The method of obtaining is as follows.

[0181]

[0182]

[0183] The above introduces the main workflow of the rule generation module. The following introduces the main workflow of the active learning module.

[0184] Specifically, the role of the active learning module is to screen valuable samples, hand them over to the user for labeling, and add the labeled positive and negative samples to the labeled sample set, and then use the expanded sample set to retrain the rule generation model. This embodiment provides a multi-level sample screening solution based on a Gaussian mixture model, the process of which is as follows: (1) pre-analysis of the length and characters of the positive samples; (2) multi-level selection of the character classification results; (3) screening the most valuable samples based on the Gaussian mixture model for manual re-labeling, and iteratively optimizing the regular expression output by the rule generation model based on the labeling results. The above steps will be described in detail below.

[0185] (1) Preliminary analysis of the length and characters of the positive sample.

[0186] For the positive samples in the labeled sample set, we first analyze their length and divide them into different subsets according to their lengths. Then, we perform character type statistics on the positive samples in each subset.

[0187] For example, see Figure 7 , Figure 7 This is a schematic diagram of a method for performing subset division and bit-by-bit analysis on positive samples provided in an embodiment of the present application. Figure 7 As shown in the figure, by analyzing the length of the positive samples in the labeled sample set, the positive samples of different lengths can be divided into multiple different subsets, such as a subset with a length of L1, a subset with a length of L2, and so on. n Then, for any subset, each character of all positive samples in the subset can be analyzed to determine the characters appearing at each position. For example, after analyzing three positive samples in a subset, it is found that the characters appearing at position 1 include the numbers 1, 2, and 3, the characters appearing at position 2 include the special symbols # and * and the uppercase letter W, the characters appearing at position 3 include the uppercase letters A and U and the lowercase letter r, and the characters appearing at position 4 include the numbers 1 and 4 and the uppercase letter Z.

[0188] (2) Perform multi-level selection on the character classification results.

[0189] When generating a value sample, first determine the subset length, and then screen high-value characters at each position based on the character classification results of the subset. Specifically, when screening high-value characters, it is divided into local screening and cross-level screening, and different levels are set with different selection probabilities. For example, Figure 7In the subset shown, if the character at a certain position belongs to the character set {1, 2, 3}, then the current level is a number with a selection probability of p. The cross-level selection is from the level set {lowercase letters, uppercase letters, special symbols}, and the selection probability of each level is set to (1-p) / 3.

[0190] In general, the multiple levels can be divided into the digit level, lowercase letter level, uppercase letter level, and special symbol level. When selecting high-value characters for any position in the value sample, the character classification results at that position can be used to determine the level to which the current position belongs, and then determine the probability of selecting characters from each level.

[0191] (3) The most valuable samples are screened based on the Gaussian mixture model and manually annotated again, and the regular expression of the model output is generated by iteratively optimizing the rules based on the annotation results.

[0192] When determining at which level to perform value character screening, consider two scenarios: single-point probability modeling and multi-point probability modeling.

[0193] Single-point probability modeling: for a specific level X: {x1,x2,…x n}, if x k Hit, which means that the positive sample in the subset has already appeared in the current position of character x k For example, for the "number" level, which contains 10 numbers from 0 to 9, the positive sample has {1,2,3} at this position, which is expressed as 1,2,3 hits. Based on the range expansion idea, at this time, x in this level k The probability of characters near x being selected is low, while characters far away from x k The character with a high probability of being selected. Specifically, the concept of range expansion is understood as: users want to obtain the largest and most accurate representation range at the lowest annotation cost. For example, a position can be a number [0-9]. If the current positive example hits 0, then if the next positive example hits 1, then the maximum possible prediction is [0-1]. However, if the next positive example hits 9, then the maximum possible prediction is [0-9].

[0194] For example, see Figure 8 , Figure 8 This is a schematic diagram of the probability of character selection provided by an embodiment of the present application. Figure 8 As shown, at the digital level, if the currently hit characters are numbers 4 and 5, then the selection probability of numbers 4 and 5 themselves is the lowest, and the closer the characters are to numbers 4 and 5, the lower the selection probability, and the farther away from numbers 4 and 5, the higher the selection probability.

[0195] Based on this, we can set the inverse of the character selection probability M to obey the normal distribution in, The parameters of the normal distribution include the mean and variance, that is, x k is the sequence number of the hit character at this level (as the mean). is the variance, which is used to control the shape of the normal distribution and is set to 1 in the experiment.

[0196] Multi-point probability modeling: Consider the specific level X: {x1,x2,…x n}, if the current positive sample has hit multiple characters, the selection probability of other missed characters can be determined based on each hit character, and finally the selection probabilities of other missed characters determined each time are added and normalized to obtain the final selection probabilities of other missed characters.

[0197] Specifically, according to the k-th single point Gaussian distribution density function: Then the probability distribution of the Gaussian mixture model is F(x│θ). and satisfy At this time, the normalized probability of selecting the characters at each position is:

[0198] Among them, α k is the probability of occurrence of the kth single point probability model. k This means that if x k If it hits, its value is 1, otherwise it is 0.

[0199] In simple terms, when a character is hit, a probability is assigned to each character at that level using the Gaussian probability formula. When a different character is hit, the current probability value is added to the previous probability of the character, and then the overall value is normalized.

[0200] For example, see Figure 9 , Figure 9 A schematic diagram of a process for screening valuable characters based on a Gaussian mixture model is provided in an embodiment of the present application. Figure 9 As shown in the figure, when the character classification result for this level is only {4}, the selection probability of the digit boundaries (i.e., 0 and 9) is higher, because this allows the user to quickly determine the limit range of this level. When the user marks the filtered 1 as a positive example, the classification result becomes {4,1}, and the selection probability of each character changes. It can be seen that larger digits have a higher selection probability. When the user marks 9 as a positive example, the classification result becomes {4,1,9}, and the selection probability of each character changes again. It can be seen that the selection probability of each character is now similar, because the character boundaries of this level have been basically determined.

[0201] In general, active learning is a method that selects the most valuable examples for annotation. Its goal is to achieve the best possible model performance using the fewest high-quality example annotations. To save data annotation time and cost, this solution selects valuable examples from a vast amount of unlabeled data and then hands them over to the user for annotation. This allows the rule generation model to output accurate regular expressions after just a few iterations.

[0202] The above describes a rule generation method provided by an embodiment of the present application. The following describes a device for implementing the above rule generation method.

[0203] See also Figure 10 , Figure 10 This is a structural diagram of a data processing device provided in an embodiment of the present application. Figure 10 As shown, the rule generation device includes: an acquisition module 1001, which is used to acquire a sample set, and the sample set includes at least one sample of the target entity; a processing module 1002, which is used to input the sample set into a rule generation model to obtain a target data rule, wherein the rule generation model is used to generate a data rule that matches the positive samples in the sample set and does not match the negative samples in the sample set; the processing module 1002 is also used to generate a sample to be labeled based on the sample set when the target data rule does not meet the preset conditions, and the sample to be labeled is used to wait for labeling as a positive sample or a negative sample; the acquisition module 1001 is also used to obtain the labeling result for the sample to be labeled, and obtain an enhanced sample labeled as a positive sample or a negative sample; the processing module 1002 is also used to add the enhanced sample to the sample set to obtain an updated sample set, and the updated sample set is used to input the rule generation model so that the rule generation model generates a new data rule.

[0204] In a possible implementation, at least one sample is a character string, and the target data rule is a regular expression.

[0205] In one possible implementation, the processing module 1002 is further used to: determine a first subset based on the sample set, the first subset including one or more positive samples of the same length in the sample set; determine a classification result for each character of the positive samples in the first subset, the classification result including numbers, lowercase letters, uppercase letters or special symbols; and generate each character of the sample to be labeled based on the classification result of each character.

[0206] In one possible implementation, the processing module 1002 is further used to: determine the category selection probability of each character based on the classification result of each character, where the category selection probability is used to indicate the probability of a character selecting its category from multiple categories, where the multiple categories include the classification results of the character; determine the category to which each character belongs based on the category selection probability of each character, and select a character from the category to which each character belongs as the character of the sample to be labeled.

[0207] In one possible implementation, the processing module 1002 is further used to: when the category to which the target character belongs is the same as the classification result of the target character, determine the character selection probability of the target character based on the character hit by the positive sample in the first subset on the target character, the character selection probability is used to indicate the probability of selecting each character from multiple characters in the category to which the target character belongs, and the target character is any character in the sample to be labeled; based on the character selection probability, select a character in the category to which the target character belongs as the character of the sample to be labeled.

[0208] In a possible implementation, in the character selection probability, the selection probability of the positive sample in the first subset having hit the character at the target position character is less than the selection probability of the positive sample in the first subset not having hit the character at the target position character.

[0209] In one possible implementation, in the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, and the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position.

[0210] In a possible implementation, in the category selection probability, the selection probability of the first category is greater than the selection probability of the second category, the first category is the classification result of characters, and the second category is the classification result of non-characters.

[0211] In one possible implementation, when the rule generation model is a model based on a genetic programming algorithm, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. The leaf nodes in the algorithm tree are used to represent data rules for one character. The character ranges covered by data rules at multiple different levels are different, and the character coverage range of the data rules is negatively correlated with the probability of selecting the data rules.

[0212] In one possible implementation, the processing module 1002 is further used to: perform a preset number of editing operations on the positive samples in the sample set to generate negative samples, where the editing operations include deleting characters, exchanging characters, or inserting characters; and input the sample set and the generated negative samples into a rule generation model, where the rule generation model is used to generate data rules based on the sample set and the generated negative samples.

[0213] In a possible implementation, the preset condition is that the matching rate between the target data rule and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rule and the negative samples in the sample set is not less than a second threshold.

[0214] The acquisition module 1001 and the processing module 1002 can be implemented in software or hardware. For example, the implementation of the processing module 1002 will be described below using the processing module 1002 as an example. Similarly, the implementation of the acquisition module 1001 can refer to the implementation of the processing module 1002.

[0215] The processing module 1002 is taken as an example of a software functional unit. The processing module 1002 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the processing module 1002 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Generally, a region may include multiple AZs.

[0216] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.

[0217] As an example of a hardware functional unit, processing module 1002 may include at least one computing device, such as a server. Alternatively, processing module 1002 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0218] The multiple computing devices included in processing module 1002 can be distributed in the same region or in different regions. The multiple computing devices included in processing module 1002 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in processing module 1002 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.

[0219] It should be noted that the information interaction, implementation process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the embodiment of the present application, and no further details will be given here.

[0220] This embodiment of the application also provides a computing device 1100. Figure 11 , Figure 11 This is a schematic diagram of the structure of a computing device 1100 provided in an embodiment of the present application. Figure 11 As shown, computing device 1100 includes a bus 1102, a processor 1104, a memory 1106, and a communication interface 1108. Processor 1104, memory 1106, and communication interface 1108 communicate with each other via bus 1102. Computing device 1100 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 1100.

[0221] The bus 1102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 11 The bus 1102 may include a path for transmitting information between various components of the computing device 1100 (eg, memory 1106, processor 1104, communication interface 1108).

[0222] The processor 1104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0223] The memory 1106 may include volatile memory, such as random access memory (RAM). The processor 1104 may also include non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0224] The memory 1106 stores executable program codes, and the processor 1104 executes the executable program codes to respectively implement the functions of the aforementioned receiving module and processing module, thereby implementing the aforementioned rule generation method. That is, the memory 1106 stores instructions for executing the rule generation method.

[0225] The communication interface 1108 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1100 and other devices or a communication network.

[0226] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0227] See also Figure 12 , Figure 12 This is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. Figure 12 As shown, the computing device cluster includes at least one computing device 1100. The memory 1106 in one or more computing devices 1100 in the computing device cluster may store the same instructions for executing the rule generation method.

[0228] In some possible implementations, the memory 1106 of one or more computing devices 1100 in the computing device cluster may also store some instructions for executing the rule generation method. In other words, the combination of one or more computing devices 1100 can jointly execute the instructions for executing the rule generation method.

[0229] It should be noted that the memory 1106 in different computing devices 1100 in the computing device cluster can store different instructions, each for executing a portion of the functions of the data processing apparatus. In other words, the instructions stored in the memory 1106 in different computing devices 1100 can implement the functions of one or more of the aforementioned receiving module and processing module.

[0230] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network, which may be a wide area network or a local area network. Figure 13 A possible implementation is shown. Figure 13 This is a schematic diagram of the structure of another computing device cluster provided in an embodiment of the present application. Figure 13 As shown, in computing device cluster 1300, two computing devices 1100A and 1100B are connected via a network. Specifically, the connection to the network is achieved through a communication interface within each computing device. In this possible implementation, memory 1106 within computing device 1100A stores instructions for executing the functions of a receiving module. Simultaneously, memory 1106 within computing device 1100B stores instructions for executing the functions of a processing module.

[0231] It should be understood that Figure 13 The functionality of the computing device 1100A shown in FIG. 1 may also be implemented by multiple computing devices 1100. Similarly, the functionality of the computing device 1100B may also be implemented by multiple computing devices 1100.

[0232] See Figure 14 , Figure 14 This is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. This application also provides a computer-readable storage medium. In some embodiments, the workflow executed by the above-mentioned database system can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or products.

[0233] Figure 14 Schematically illustrates a conceptual partial view of an example computer-readable storage medium including a computer program for executing a computer process on a computing device, arranged in accordance with at least some embodiments presented herein.

[0234] In one embodiment, the computer-readable storage medium 1400 is provided using a signal-bearing medium 1401. The signal-bearing medium 1401 may include one or more program instructions 1402, which when executed by one or more processors may provide the functions or part of the functions described above for the database system.

[0235] In some examples, signal bearing medium 1401 may include computer readable medium 1403 such as, but not limited to, a hard drive, compact disk (CD), digital video disk (DVD), digital tape, memory, ROM or RAM, and the like.

[0236] In some embodiments, the signal-bearing medium 1401 may include a computer-recordable medium 1404, such as, but not limited to, a memory, a read / write (R / W) CD, a R / W DVD, or the like. In some embodiments, the signal-bearing medium 1401 may include a communication medium 1405, such as, but not limited to, a digital and / or analog communication medium (e.g., a fiber optic cable, a waveguide, a wired communication link, a wireless communication link, or the like). Thus, for example, the signal-bearing medium 1401 may be communicated via a wireless form of the communication medium 1405 (e.g., a wireless communication medium conforming to the IEEE 802.X standard or other transmission protocol).

[0237] The one or more program instructions 1402 may be, for example, computer-executable instructions or logic-implemented instructions. In some examples, the computing device may be configured to provide various operations, functions, or actions in response to the program instructions 1402 communicated to the computing device via one or more of computer-readable media 1403, computer-recordable media 1404, and / or communication media 1405.

[0238] The present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored on any available medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to execute the rule generation method described in the above embodiment.

[0239] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods of each embodiment of the present application.

[0240] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

Claims

1. A rule generation method, characterized in that: include: Acquire a sample set, where the sample set includes at least one sample of a target entity; Inputting the sample set into a rule generation model to obtain a target data rule, wherein the rule generation model is used to generate a data rule that matches positive samples in the sample set and does not match negative samples in the sample set; If the target data rule does not meet the preset conditions, generating samples to be labeled based on the sample set, the samples to be labeled are used to wait for being labeled as positive samples or negative samples; Obtaining a labeling result for the sample to be labeled, and obtaining an enhanced sample labeled as a positive sample or a negative sample; The enhanced sample is added to the sample set to obtain an updated sample set, and the updated sample set is used to input the rule generation model so that the rule generation model generates new data rules.

2. The method according to claim 1, characterized in that The at least one sample is a character string, and the target data rule is a regular expression.

3. The method according to claim 1 or 2, characterized in that Generating samples to be labeled based on the sample set includes: Determine a first subset based on the sample set, where the first subset includes one or more positive samples of the same length as in the sample set; Determine a classification result for each character in the positive sample of the first subset, wherein the classification result includes a number, a lowercase letter, an uppercase letter, or a special symbol; Based on the classification result of each character, each character of the sample to be labeled is generated.

4. The method according to claim 3, characterized in that Generating each character of the sample to be labeled based on the classification result of each character includes: Determining a category selection probability for each character based on the classification result for each character, wherein the category selection probability indicates a probability of a character selecting a category from a plurality of categories, wherein the plurality of categories include the classification results for the character; Based on the category selection probability of each character, the category to which each character belongs is determined, and a character is selected from the category to which each character belongs as the character of the sample to be labeled.

5. The method according to claim 4, characterized in that The step of selecting a character from the category to which each character belongs as the character of the sample to be labeled includes: In the case that the category to which the target character belongs is the same as the classification result of the target character, determining the character selection probability of the target character based on the character hit by the positive sample in the first subset on the target character, the character selection probability being used to indicate the probability of selecting each character from a plurality of characters under the category to which the target character belongs, and the target character is any character in the sample to be labeled; Based on the character selection probability, a character is selected from the category to which the target character belongs as the character of the sample to be labeled.

6. The method according to claim 5, characterized in that In the character selection probability, the selection probability of the positive sample in the first subset having hit the character at the target position character is less than the selection probability of the positive sample in the first subset not having hit the character at the target position character.

7. The method according to claim 5 or 6, characterized in that In the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, and the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position.

8. The method according to any one of claims 4 to 7, characterized in that: In the category selection probabilities, the selection probability of the first category is greater than the selection probability of the second category, the first category is the classification result of characters, and the second category is the classification result of non-characters.

9. The method according to any one of claims 1 to 8, characterized in that In the case where the rule generation model is a model based on a genetic programming algorithm, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. The leaf nodes in the algorithm tree are used to represent data rules for one character. The character ranges covered by the data rules at multiple different levels are different, and the character coverage range of the data rules is negatively correlated with the selection probability of the data rules.

10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: Performing a preset number of editing operations on positive samples in the sample set to generate negative samples, wherein the editing operations include deleting characters, swapping characters, or inserting characters; The step of inputting the sample set into a rule generation model comprises: The sample set and the generated negative samples are input into the rule generation model, and the rule generation model is used to generate data rules based on the sample set and the generated negative samples.

11. The method according to any one of claims 1 to 10, characterized in that: The preset condition is that the matching rate between the target data rule and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rule and the negative samples in the sample set is not less than a second threshold.

12. A rule generating device, characterized in that: include: an acquisition module, configured to acquire a sample set, wherein the sample set includes at least one sample of a target entity; a processing module, configured to input the sample set into a rule generation model to obtain a target data rule, wherein the rule generation model is configured to generate a data rule that matches positive samples in the sample set and does not match negative samples in the sample set; The processing module is further configured to generate a sample to be labeled based on the sample set when the target data rule does not meet a preset condition, and the sample to be labeled is used to wait for being labeled as a positive sample or a negative sample; The acquisition module is further configured to obtain a labeling result for the sample to be labeled, and obtain an enhanced sample labeled as a positive sample or a negative sample; The processing module is further configured to add the enhanced sample to the sample set to obtain an updated sample set, and the updated sample set is used to input the rule generation model so that the rule generation model generates new data rules.

13. The device according to claim 12, characterized in that The at least one sample is a character string, and the target data rule is a regular expression.

14. The device according to claim 12 or 13, characterized in that The processing module is further configured to: Determine a first subset based on the sample set, where the first subset includes one or more positive samples of the same length as in the sample set; Determine a classification result for each character in the positive sample of the first subset, wherein the classification result includes a number, a lowercase letter, an uppercase letter, or a special symbol; Based on the classification result of each character, each character of the sample to be labeled is generated.

15. The device according to claim 14, characterized in that The processing module is further configured to: Determining a category selection probability for each character based on the classification result for each character, wherein the category selection probability indicates a probability of a character selecting a category from a plurality of categories, wherein the plurality of categories include the classification results for the character; Based on the category selection probability of each character, the category to which each character belongs is determined, and a character is selected from the category to which each character belongs as the character of the sample to be labeled.

16. The device according to claim 15, characterized in that The processing module is further configured to: In the case that the category to which the target character belongs is the same as the classification result of the target character, determining the character selection probability of the target character based on the character hit by the positive sample in the first subset on the target character, the character selection probability being used to indicate the probability of selecting each character from a plurality of characters under the category to which the target character belongs, and the target character is any character in the sample to be labeled; Based on the character selection probability, a character is selected from the category to which the target character belongs as the character of the sample to be labeled.

17. The device according to claim 16, characterized in that In the character selection probability, the selection probability of the positive sample in the first subset having hit the character at the target position character is less than the selection probability of the positive sample in the first subset not having hit the character at the target position character.

18. The device according to claim 16 or 17, characterized in that In the character selection probability, the selection probability of the first character is greater than the selection probability of the second character, and the distance between the first character and the hit character on the target position is greater than the distance between the second character and the hit character on the target position.

19. The device according to any one of claims 15 to 18, characterized in that In the category selection probabilities, the selection probability of the first category is greater than the selection probability of the second category, the first category is the classification result of characters, and the second category is the classification result of non-characters.

20. The device according to any one of claims 12 to 19, characterized in that In the case where the rule generation model is a model based on a genetic programming algorithm, the leaf nodes of the algorithm tree initially generated by the rule generation model are selected from data rules at multiple different levels. The leaf nodes in the algorithm tree are used to represent data rules for one character. The character ranges covered by the data rules at multiple different levels are different, and the character coverage range of the data rules is negatively correlated with the selection probability of the data rules.

21. The device according to any one of claims 12 to 20, characterized in that The processing module is further configured to: Performing a preset number of editing operations on positive samples in the sample set to generate negative samples, wherein the editing operations include deleting characters, swapping characters, or inserting characters; The sample set and the generated negative samples are input into the rule generation model, and the rule generation model is used to generate data rules based on the sample set and the generated negative samples.

22. The device according to any one of claims 12 to 21, characterized in that The preset condition is that the matching rate between the target data rule and the positive samples in the sample set is not less than a first threshold, and the mismatch rate between the target data rule and the negative samples in the sample set is not less than a second threshold.

23. A computing device cluster, characterized in that: comprising at least one computing device, each computing device including a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in a memory of the at least one computing device, so that the computing device cluster performs the operating steps of the method according to any one of claims 1 to 11.

24. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster is caused to perform the operation steps of the method according to any one of claims 1 to 11.

25. A computer-readable storage medium, characterized in that The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the operation steps of the method according to any one of claims 1 to 11.