A knowledge graph-based multi-source data annotation rule optimization method
Patent Information
- Application Number
- CN202611177819.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-05
- Publication Date
- 2026-10-09
AI Technical Summary
反馈数据到达后,部分系统还需要重新检查全部规则,更新范围较大,难以及时适应数据来源和标注需求的变化
[0061]首先,本发明通过序列模式挖掘和条件互信息分析,从多源标注数据中筛定与标注结果具有稳定关联的规则片段,并构建标注规则知识图谱,能够清晰表示规则之间的执行关系和传递强度。
Smart Images

Figure CN122886764A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data annotation technology, and in particular to a method for optimizing multi-source data annotation rules based on knowledge graphs. Background Technology
[0002] As data volume continues to expand, data annotation has been widely applied in scenarios such as model training, data governance, content moderation, and business analysis. In practical applications, the data to be annotated typically comes from multiple systems, and different data sources differ in field structure, data format, label definitions, and processing procedures. To ensure the continuous execution of annotation work, existing systems usually pre-configure several annotation rules and execute corresponding annotation processes based on data sources and business conditions.
[0003] Most existing annotation rules rely on manual compilation and regular maintenance. When annotation results deviate, they are usually addressed by checking rule hit records, adjusting judgment conditions, or modifying the rule order. Some systems also track rule usage frequency and annotation accuracy to help identify rules that have not been used for a long time or have a high error rate. This approach is suitable for scenarios with a small number of rules and relatively stable data sources, but as data sources increase and rule relationships become more complex, the efficiency of manual review and rule-by-rule adjustment decreases significantly.
[0004] In multi-source data annotation, the same annotation object may be expressed using different fields and rule combinations under different data sources. Even if the final label is the same, the actual execution process may differ significantly. Existing methods typically only focus on whether a single rule is hit, making it difficult to discover stable patterns formed by the continuous execution of multiple rules, and also difficult to determine whether there is a real correlation between a certain rule and the final annotation result. Therefore, when inconsistent annotations occur from different data sources, corrections can often only be made at the result end, making it impossible to accurately pinpoint where the deviation occurred during rule execution.
[0005] Furthermore, existing rule adjustment methods primarily focus on adding, deleting, or replacing individual rules, with little consideration for the sequential relationships between rules. Local modifications can easily lead to issues such as rule chain breaks, execution order conflicts, or subsequent rule failures. For situations with multiple candidate rule paths, there is also a lack of a path selection method that can simultaneously consider rule reliability, execution consistency, and annotation bias. After feedback data arrives, some systems still need to re-examine all rules, resulting in a large update scope and difficulty in adapting promptly to changes in data sources and annotation requirements.
[0006] Therefore, how to provide a method for optimizing multi-source data annotation rules based on knowledge graphs is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0007] One objective of this invention is to propose a multi-source data annotation rule optimization method based on knowledge graphs. This invention fully utilizes sequence pattern mining, knowledge graphs, path alignment, and minimum cost flow techniques, and describes in detail the implementation process of multi-source annotation rule association modeling, deviation attribution, path reorganization, and feedback update. It has the advantages of high rule consistency, accurate deviation location, and strong rule adaptability.
[0008] A method for optimizing multi-source data annotation rules based on knowledge graphs according to an embodiment of the present invention includes the following steps:
[0009] S1. Acquire multi-source labeled data and preprocess it to form a standard labeled sequence;
[0010] S2. Perform sequence pattern mining on the standard labeled sequence to identify recurring rule execution segments, and use conditional mutual information to calculate the dependency strength between the segment and the labeling results to screen out target rule segments.
[0011] S3. Map the target rule fragments to graph nodes, establish directed connection edges according to the direction of rule execution, calculate the transmission strength between adjacent graph nodes using transfer entropy, and configure directed edge weights according to the transmission strength to construct a labeled rule knowledge graph.
[0012] S4. Use edit distance to align the rule execution paths corresponding to different data sources, calculate the difference in annotation results of the alignment rule execution paths, and recursively calculate the difference in annotation results along the alignment rule execution paths according to the directed edge weights to obtain the node deviation contribution value.
[0013] S5. Calculate the travel cost of directed connection edges based on the node deviation contribution value. Under the constraint of maintaining the connectivity of the rule execution path, use the minimum cost flow method to filter low-cost connections and reorganize the rule execution path along the retained connections to generate optimized annotation rules.
[0014] S6. Obtain feedback data for optimizing annotation rules, and update the annotation rule knowledge graph using the Bayesian confidence update method.
[0015] Optionally, the preprocessing specifically includes:
[0016] Parse the data source identifier, annotation object identifier, rule code, execution time, and annotation result in multi-source labeled data, and perform field mapping;
[0017] Cross-source merging is performed based on the correspondence between labeled object identifiers, and rule coding, time format and label coding are unified;
[0018] Remove duplicate records and records with missing labels, and arrange the processed multi-source labeled data according to the labeled object label and execution time;
[0019] Based on the arrangement results, organize the rule execution process corresponding to each labeled object to form a standard label sequence.
[0020] Optionally, S2 specifically includes:
[0021] S21. Arrange the rule codes in the standard annotation sequence in order according to the rule execution time, and extract the rule codes that are executed consecutively to form candidate rule execution segments;
[0022] S22. The PrefixSpan algorithm is used to recursively project the candidate rule execution segments, calculate the support of each candidate rule execution segment in the standard labeled sequence, and screen out the recurring rule execution segments based on the minimum support.
[0023] S23. Under different data sources, statistically analyze the occurrence status and corresponding annotation results of each rule execution segment, calculate the joint probability and marginal probability between the rule execution segment and the annotation results, calculate the conditional mutual information with the data source as the conditional variable, and obtain the dependency strength.
[0024] S24. Sort the recurring rule execution fragments according to their dependency strength, and filter out the rule execution fragments with a dependency strength lower than the set threshold to obtain the target rule fragments.
[0025] Optionally, S22 specifically includes:
[0026] S221. Count the number of rule execution sequences containing each rule code, calculate the support of each rule code, take the rule code with the support reaching the minimum support threshold as the frequent prefix, and establish a projection database based on the occurrence position of the frequent prefix in the rule execution sequence.
[0027] S222. In the projection database, search for the successor rule code from the next execution position after the last position of the frequent prefix, count the number of rule execution sequences containing the corresponding rule code combination, and calculate the support of the rule code combination.
[0028] S223. Encode the successor rules whose support reaches the minimum support threshold, append them to the frequent prefix, update the projection database according to the occurrence position of the appended rules, and perform a recursive search on the updated projection database.
[0029] S224. During the recursive search process, record frequent prefixes whose support reaches the minimum support threshold and whose length reaches the set fragment length. When there is no subsequent rule encoding that satisfies the minimum support threshold, terminate the recursive search of the corresponding branch and obtain the recurring rule execution fragment.
[0030] Optionally, S3 specifically includes:
[0031] S31. Merge target rule fragments with consistent rule encoding and arrangement order into the same graph node, and form a binary occurrence sequence of graph nodes according to the execution position of the target rule fragments in the standard annotation sequence;
[0032] S32. Count the number of times different graph nodes appear together according to the execution order and the execution interval, connect the graph nodes whose number of common occurrences reaches the set threshold in sequence, establish candidate directed connection edges, and determine the candidate transmission delay according to the execution interval.
[0033] S33. According to the candidate transmission delay, the binary occurrence sequence of the preceding and following graph nodes is misaligned, the transmission intensity between adjacent graph nodes is calculated using the transfer entropy, and the candidate transmission delay corresponding to the maximum transmission intensity is selected as the target transmission delay.
[0034] S34. Filter out candidate directed edges with transmission strength below a set threshold, configure the weights of the directed edges according to the transmission strength of the retained directed edges, and construct a knowledge graph of annotation rules.
[0035] Optionally, S33 specifically includes:
[0036] S331. For each candidate transmission delay, combine the current binary state and the historical binary state of the subsequent graph node into a subsequent state index, and encode the binary state of the corresponding delay position of the preceding graph node into a preceding state index.
[0037] S332. Establish a subsequent state transition matrix based on the subsequent state index, and establish a joint state transition matrix based on the subsequent state index and the preceding state index. Use Laplace smoothing to calculate the conditional transition probabilities in each state transition matrix.
[0038] S333. Calculate the conditional entropy of the subsequent graph node based on the subsequent state transition matrix, calculate the conditional entropy after introducing the preceding graph node based on the joint state transition matrix, and take the difference between the two conditional entropies as the transmission intensity under the corresponding candidate transmission delay.
[0039] S334. Compare the transmission strengths corresponding to each candidate transmission delay, and determine the candidate transmission delay corresponding to the maximum transmission strength as the target transmission delay.
[0040] Optionally, S4 specifically includes:
[0041] S41. Extract the graph nodes that the same labeled object passes through in sequence under different data sources, and form the corresponding rule execution path according to the execution order of the graph nodes;
[0042] S42. In the two rule execution paths, construct the edit distance matrix based on the rule encoding consistency and execution position deviation of the graph nodes, use dynamic programming to calculate the cumulative edit cost, and backtrack the matrix path corresponding to the minimum cumulative edit cost to obtain the alignment rule execution path;
[0043] S43. Classify the annotation results corresponding to the alignment rule execution path, calculate the distance between different class codes, and obtain the difference in annotation results;
[0044] S44. In the alignment rule execution path, the directed edge weight is used as the reverse propagation coefficient between adjacent graph nodes. The graph node at the end of the path is initialized with the difference in the annotation results, and the node deviation contribution value of each graph node is obtained by recursively probing layer by layer along the alignment rule execution path.
[0045] Optionally, S42 specifically includes:
[0046] S421. Use the graph node numbers in the two rule execution paths as row and column indices respectively to build an edit distance matrix, and configure the boundary cost of the edit distance matrix according to the row and column indices;
[0047] S422. Traverse the graph node combinations in the two rule execution paths, calculate the code matching cost based on whether the rule codes are consistent, and calculate the position deviation cost based on the execution position difference between the graph nodes to obtain the node alignment cost.
[0048] S423. Based on the node alignment cost, the cumulative editing costs of the left, top, and top-left matrix units of the current matrix unit are recursively calculated, and the minimum recursive result is selected as the cumulative editing cost of the current matrix unit until the editing distance matrix calculation is completed.
[0049] S424. Starting from the last matrix cell of the edit distance matrix, trace back to the matrix cell corresponding to the minimum cumulative edit cost, record the correspondence between the graph nodes in the two rule execution paths, and obtain the alignment rule execution path.
[0050] Optionally, S5 specifically includes:
[0051] S51. Obtain the node deviation contribution value corresponding to each graph node, and combine it with the directed edge weights between adjacent graph nodes to calculate the passage cost corresponding to each directed connection edge, forming a connection edge cost set.
[0052] S52. Take the graph nodes corresponding to the rule execution start point and the annotation result as path endpoints, construct a directed flow network based on the set of connection edge costs, take the graph nodes in the rule execution path as flow constraint nodes, and restrict the inflow and outflow of each graph node to be consistent.
[0053] S53. In a directed flow network, based on the set of connection edge costs, solve for the minimum cost flow between the starting point of rule execution and the corresponding graph node of the annotation result, filter out the valid connection edges that satisfy the flow constraints, and form a low-cost rule execution path.
[0054] S54. Traverse the corresponding graph nodes along the effective connection edges in the low-cost rule execution path, extract the target rule fragments corresponding to the graph nodes, and reorganize the rule execution relationship according to the connection order to generate optimized annotation rules.
[0055] Optionally, S6 specifically includes:
[0056] S61. Obtain the feedback data after the optimization annotation rule is executed, match the feedback data with the corresponding annotation results, and locate the directed connection edges involved in the feedback data along the graph nodes traversed by the optimization annotation rule.
[0057] S62. Count the number of times the labeling results are consistent and the number of times the labeling results are inconsistent for each directed connection edge. Take the confidence state corresponding to the original directed edge weight as the prior distribution and use the statistical results to correct the prior distribution to obtain the posterior confidence of each directed connection edge.
[0058] S63. The directed edge weights involved in the feedback data are corrected using the posterior confidence level. Taking the graph node where the directed edge weights have changed as the center, the system expands along the preceding and following directed connection edges to screen out the affected rule execution paths.
[0059] S64. Recalculate the travel cost of each directed edge in the affected rule execution path, and use the minimum cost flow method to locally solve the affected rule execution path to complete the local update of the labeled rule knowledge graph.
[0060] The beneficial effects of this invention are:
[0061] First, this invention uses sequence pattern mining and conditional mutual information analysis to screen out rule fragments that have a stable correlation with the annotation results from multi-source labeled data, and constructs a knowledge graph of annotation rules, which can clearly represent the execution relationship and transmission strength between rules.
[0062] Secondly, this invention aligns the rule execution paths under different data sources and recursively calculates the differences in annotation results along the directed edge weights, which can locate the key rule nodes that cause annotation deviations; combined with the minimum cost flow method, it reorganizes low-cost rule execution paths to avoid local modifications causing rule chain interruptions.
[0063] Finally, this invention uses feedback data to correct directed edge weights and performs local recalculation on affected rule execution paths, reducing the overall update scope and improving the consistency, accuracy, and adaptability of annotation rules. Attached Figure Description
[0064] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0065] Figure 1 This is an overall flowchart of a knowledge graph-based multi-source data annotation rule optimization method proposed in this invention;
[0066] Figure 2 This is a flowchart illustrating the knowledge graph construction process for a knowledge graph-based multi-source data annotation rule optimization method proposed in this invention.
[0067] Figure 3 This is a flowchart illustrating the low-cost rule execution path solution and rule reorganization process of a knowledge graph-based multi-source data annotation rule optimization method proposed in this invention. Detailed Implementation
[0068] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0069] refer to Figures 1-3 A method for optimizing multi-source data annotation rules based on knowledge graphs includes the following steps:
[0070] S1. Acquire multi-source labeled data and preprocess it to form a standard labeled sequence;
[0071] S2. Perform sequence pattern mining on the standard labeled sequence to identify recurring rule execution segments, and use conditional mutual information to calculate the dependency strength between the segment and the labeling results to screen out target rule segments.
[0072] S3. Map the target rule fragments to graph nodes, establish directed connection edges according to the direction of rule execution, calculate the transmission strength between adjacent graph nodes using transfer entropy, and configure directed edge weights according to the transmission strength to construct a labeled rule knowledge graph.
[0073] S4. Use edit distance to align the rule execution paths corresponding to different data sources, calculate the difference in annotation results of the alignment rule execution paths, and recursively calculate the difference in annotation results along the alignment rule execution paths according to the directed edge weights to obtain the node deviation contribution value.
[0074] S5. Calculate the travel cost of directed connection edges based on the node deviation contribution value. Under the constraint of maintaining the connectivity of the rule execution path, use the minimum cost flow method to filter low-cost connections and reorganize the rule execution path along the retained connections to generate optimized annotation rules.
[0075] S6. Obtain feedback data for optimizing annotation rules, and update the annotation rule knowledge graph using the Bayesian confidence update method.
[0076] In this embodiment, the preprocessing specifically includes:
[0077] Parse the data source identifier, annotation object identifier, rule code, execution time, and annotation result in multi-source labeled data, and perform field mapping;
[0078] Cross-source merging is performed based on the correspondence between labeled object identifiers, and rule coding, time format and label coding are unified;
[0079] Remove duplicate records and records with missing labels, and arrange the processed multi-source labeled data according to the labeled object label and execution time;
[0080] Based on the arrangement results, organize the rule execution process corresponding to each labeled object to form a standard labeling sequence;
[0081] In this embodiment, field names from four types of data sources are mapped to a unified field table. Each type of data source contains at least five fields: data source identifier, labeled object identifier, rule code, execution time, and labeling result. The execution time is uniformly converted into a millisecond-level time format.
[0082] For records with the same annotation object, rule code, and annotation result, and whose execution times differ by no more than 2 seconds, only the record with the earliest execution time will be retained;
[0083] Records with missing data source identifiers, labeled object identifiers, or rule codes are directly removed; records with missing values of more than 20% for other fields are not included in subsequent processing.
[0084] After cross-source merging is completed, the objects labeled are sorted in ascending order using the first-level index and the execution time as the second-level index.
[0085] When the execution time interval between two adjacent records exceeds 30 minutes, the corresponding rule execution process will be divided into different rule execution sequences;
[0086] When the same labeled object appears with the same rule code more than 3 times in a single rule execution sequence, only the first and last occurrence positions are retained.
[0087] Rule execution sequences containing fewer than 3 or more than 50 rule codes are removed. For rule execution sequences with more than 30 rule codes, they are segmented according to a window length of 20 rule codes and a sliding step of 5 rule codes to form standard annotation sequences.
[0088] In this embodiment, S2 specifically includes:
[0089] S21. Arrange the rule codes in the standard annotation sequence in order according to the rule execution time, and extract the rule codes that are executed consecutively to form candidate rule execution segments;
[0090] S22. The PrefixSpan algorithm is used to recursively project the candidate rule execution segments, calculate the support of each candidate rule execution segment in the standard labeled sequence, and screen out the recurring rule execution segments based on the minimum support.
[0091] S23. Under different data sources, statistically analyze the occurrence status and corresponding annotation results of each rule execution segment, calculate the joint probability and marginal probability between the rule execution segment and the annotation results, calculate the conditional mutual information with the data source as the conditional variable, and obtain the dependency strength.
[0092] S24. Sort the recurring rule execution fragments according to their dependency strength, and filter out the rule execution fragments with a dependency strength lower than the set threshold to obtain the target rule fragments.
[0093] In this embodiment, S22 specifically includes:
[0094] S221. Count the number of rule execution sequences containing each rule code, calculate the support of each rule code, take the rule code with the support reaching the minimum support threshold as the frequent prefix, and establish a projection database based on the occurrence position of the frequent prefix in the rule execution sequence.
[0095] S222. In the projection database, search for the successor rule code from the next execution position after the last position of the frequent prefix, count the number of rule execution sequences containing the corresponding rule code combination, and calculate the support of the rule code combination.
[0096] S223. Encode the successor rules whose support reaches the minimum support threshold, append them to the frequent prefix, update the projection database according to the occurrence position of the appended rules, and perform a recursive search on the updated projection database.
[0097] S224. During the recursive search process, record the frequent prefixes whose support reaches the minimum support threshold and whose length reaches the set fragment length. When there is no subsequent rule encoding that satisfies the minimum support threshold, terminate the recursive search of the corresponding branch and obtain the repeated rule execution fragment.
[0098] In this embodiment, the minimum support threshold is set to 10% of the total number of rule execution sequences, and the segment length is set to 2-8 rule codes;
[0099] The occurrence of each rule code in the entire rule execution sequence is counted. When the same rule code appears repeatedly in the same rule execution sequence, it is only counted once. The rule code with a support of 10% is regarded as a frequent prefix.
[0100] When building the projection database, retain the sequence portion that is no more than 5 execution positions after the last frequent prefix;
[0101] When searching for successor rule codes, an interval of 0-2 execution positions is allowed between adjacent rule codes, and the support corresponding to the expanded rule code combination is calculated.
[0102] For subsequent rule codes with a support rate of 10%, append the subsequent rule codes to the frequent prefixes and update the projection database;
[0103] When the length of the frequent prefix reaches 8 rule codes, the number of rule execution sequences in the projection database is less than 5% of the total number of rule execution sequences, or there is no successor rule code with support of 10%, the recursive search of the corresponding branch is terminated.
[0104] Frequent prefixes with a length of 2-8 rule codes and a support rate of 10% are retained to obtain recurring rule execution fragments.
[0105] In this embodiment, S3 specifically includes:
[0106] S31. Merge target rule fragments with consistent rule encoding and arrangement order into the same graph node, and form a binary occurrence sequence of graph nodes according to the execution position of the target rule fragments in the standard annotation sequence;
[0107] S32. Count the number of times different graph nodes appear together according to the execution order and the execution interval, connect the graph nodes whose number of common occurrences reaches the set threshold in sequence, establish candidate directed connection edges, and determine the candidate transmission delay according to the execution interval.
[0108] S33. According to the candidate transmission delay, the binary occurrence sequence of the preceding and following graph nodes is misaligned, the transmission intensity between adjacent graph nodes is calculated using the transfer entropy, and the candidate transmission delay corresponding to the maximum transmission intensity is selected as the target transmission delay.
[0109] S34. Filter out candidate directed edges with transmission strength below a set threshold, configure the weights of the directed edges according to the transmission strength of the retained directed edges, and construct a knowledge graph of annotation rules.
[0110] In this embodiment, S33 specifically includes:
[0111] S331. For each candidate transmission delay, combine the current binary state and the historical binary state of the subsequent graph node into a subsequent state index, and encode the binary state of the corresponding delay position of the preceding graph node into a preceding state index.
[0112] S332. Establish a subsequent state transition matrix based on the subsequent state index, and establish a joint state transition matrix based on the subsequent state index and the preceding state index. Use Laplace smoothing to calculate the conditional transition probabilities in each state transition matrix.
[0113] S333. Calculate the conditional entropy of the subsequent graph node based on the subsequent state transition matrix, calculate the conditional entropy after introducing the preceding graph node based on the joint state transition matrix, and take the difference between the two conditional entropies as the transmission intensity under the corresponding candidate transmission delay.
[0114] S334. Compare the transmission strengths corresponding to each candidate transmission delay, and determine the candidate transmission delay corresponding to the maximum transmission strength as the target transmission delay.
[0115] In this embodiment, the candidate propagation delay is set to 1-6 rule execution positions, and the binary state of the three consecutive execution positions before the current execution position of the subsequent graph node is used to represent the historical binary state.
[0116] For each candidate propagation delay, the current binary state of the subsequent graph node is combined with the 3-bit historical binary state to form the subsequent state index, and the binary state of the corresponding delay position of the preceding graph node is encoded as the preceding state index.
[0117] The subsequent state index forms 16 state combinations, the preceding state index forms 2 states, and the subsequent state index and the preceding state index together form 32 joint state combinations.
[0118] The number of transitions for each state combination is counted, and the conditional transition probability is calculated using Laplace smoothing with a smoothing coefficient of 1.
[0119] When a single state combination occurs less than 5 times, the corresponding state combination is not used alone for transmission strength calculation, but is incorporated into the statistical results corresponding to the same subsequent historical state.
[0120] Calculate the conditional entropy of the subsequent graph node and the conditional entropy after introducing the preceding graph node, and use the difference between the two as the transmission intensity under the corresponding candidate transmission delay.
[0121] Compare the transmission strength of 1-6 candidate transmission delays. When the maximum transmission strength is higher than 0.05 and at least 10% higher than the second largest transmission strength, the candidate transmission delay corresponding to the maximum transmission strength is determined as the target transmission delay.
[0122] If the above conditions are not met, the two candidate transmission delays with the highest transmission intensity are retained, and the delays are recalculated in the subsequent three consecutive sets of standard annotation sequences. The candidate transmission delay that appears more often is selected as the target transmission delay.
[0123] In this embodiment, S4 specifically includes:
[0124] S41. Extract the graph nodes that the same labeled object passes through in sequence under different data sources, and form the corresponding rule execution path according to the execution order of the graph nodes;
[0125] S42. In the two rule execution paths, construct the edit distance matrix based on the rule encoding consistency and execution position deviation of the graph nodes, use dynamic programming to calculate the cumulative edit cost, and backtrack the matrix path corresponding to the minimum cumulative edit cost to obtain the alignment rule execution path;
[0126] S43. Classify the annotation results corresponding to the alignment rule execution path, calculate the distance between different class codes, and obtain the difference in annotation results;
[0127] S44. In the alignment rule execution path, the directed edge weight is used as the reverse propagation coefficient between adjacent graph nodes. The graph node at the end of the path is initialized with the difference in the annotation results, and the node deviation contribution value of each graph node is obtained by recursively probing layer by layer along the alignment rule execution path.
[0128] In this embodiment, S42 specifically includes:
[0129] S421. Use the graph node numbers in the two rule execution paths as row and column indices respectively to build an edit distance matrix, and configure the boundary cost of the edit distance matrix according to the row and column indices;
[0130] S422. Traverse the graph node combinations in the two rule execution paths, calculate the code matching cost based on whether the rule codes are consistent, and calculate the position deviation cost based on the execution position difference between the graph nodes to obtain the node alignment cost.
[0131] S423. Based on the node alignment cost, the cumulative editing costs of the left, top, and top-left matrix units of the current matrix unit are recursively calculated, and the minimum recursive result is selected as the cumulative editing cost of the current matrix unit until the editing distance matrix calculation is completed.
[0132] S424. Starting from the last matrix cell of the edit distance matrix, trace back to the matrix cell corresponding to the minimum cumulative edit cost, record the correspondence between the graph nodes in the two rule execution paths, and obtain the alignment rule execution path.
[0133] In this embodiment, S5 specifically includes:
[0134] S51. Obtain the node deviation contribution value corresponding to each graph node, and combine it with the directed edge weights between adjacent graph nodes to calculate the passage cost corresponding to each directed connection edge, forming a connection edge cost set.
[0135] S52. Take the graph nodes corresponding to the rule execution start point and the annotation result as path endpoints, construct a directed flow network based on the set of connection edge costs, take the graph nodes in the rule execution path as flow constraint nodes, and restrict the inflow and outflow of each graph node to be consistent.
[0136] S53. In directed flow networks, based on the set of edge costs, calculate the minimum cost flow between the starting point of rule execution and the corresponding graph node of the labeled result, filter out valid edge connections that satisfy the flow constraints, and form a low-cost rule execution path, specifically including:
[0137] Starting from the rule execution point, the reachable graph nodes are expanded layer by layer along the directed connection edges. The cumulative passage cost to each graph node and the corresponding preceding graph node are recorded to form candidate traffic paths.
[0138] Check the inflow and outflow relationships of intermediate graph nodes in the candidate flow paths, delete directed connection edges that cannot continue to reach the graph nodes corresponding to the labeled results, and retain candidate flow paths that satisfy path connectivity and flow conservation.
[0139] Compare candidate traffic paths reaching the same graph node, retain the candidate traffic path with the lower cumulative passage cost, and continue to push towards the graph node corresponding to the annotation result until the path search between the rule execution start point and the graph node corresponding to the annotation result is completed;
[0140] Tracing backward from the previous graph node corresponding to the annotation result to the starting point of rule execution, the directed connection edges traversed during the tracing process are extracted to form a low-cost rule execution path;
[0141] S54. Traverse the corresponding graph nodes along the effective connection edges in the low-cost rule execution path, extract the target rule fragments corresponding to the graph nodes, and reorganize the rule execution relationship according to the connection order to generate optimized annotation rules.
[0142] In this embodiment, S6 specifically includes:
[0143] S61. Obtain the feedback data after the optimization annotation rule is executed, match the feedback data with the corresponding annotation results, and locate the directed connection edges involved in the feedback data along the graph nodes traversed by the optimization annotation rule.
[0144] S62. Count the number of times the labeling results are consistent and the number of times the labeling results are inconsistent for each directed connection edge. Take the confidence state corresponding to the original directed edge weight as the prior distribution and use the statistical results to correct the prior distribution to obtain the posterior confidence of each directed connection edge.
[0145] S63. The directed edge weights involved in the feedback data are corrected using the posterior confidence level. Taking the graph node where the directed edge weights have changed as the center, the system expands along the preceding and following directed connection edges to screen out the affected rule execution paths.
[0146] S64. Recalculate the travel cost of each directed connection edge in the affected rule execution path, and use the minimum cost flow method to locally solve the affected rule execution path to complete the local update of the labeled rule knowledge graph.
[0147] Example 1: To verify the feasibility of this invention in practice, it was applied to a multi-source text data annotation scenario. This scenario simultaneously receives data to be annotated from business systems, manual input terminals, data exchange interfaces, and historical databases, primarily completing the automatic annotation of object categories, status types, and risk levels. Different data sources use different field names, rule codes, and label definitions, and the same annotation object may undergo different rule execution orders under different data sources. The original annotation method uses a fixed rule chain; when a preceding rule deviates, subsequent rules will continuously reference incorrect results, resulting in multiple labels for the same object. Manual investigation requires reviewing each rule record individually, making it difficult to quickly locate the rule link causing the annotation inconsistency.
[0148] During implementation, a total of 126,400 annotation records were collected from four types of data sources, involving 8,600 annotation objects and 73 rule codes. First, the data source identifier, annotation object identifier, rule code, execution time, and annotation result were parsed. Field names from different data sources were mapped to a unified field table, and the execution time was converted to millisecond format. For records with the same annotation object, rule code, and annotation result, and whose execution times differed by no more than 2 seconds, only the first record was retained. After deleting records with missing identifiers, 119,760 valid records were obtained. These records were arranged according to the annotation object identifier and execution time, with a 30-minute interval used to separate the rule execution process, forming 14,820 standard annotation sequences.
[0149] Subsequently, the PrefixSpan algorithm was used to mine recurring rule execution fragments, with the minimum support set to 10% and the fragment length set to 2-8 rule codes. This resulted in 186 frequent rule execution fragments. The conditional mutual information between the rule execution fragments and the annotation results was then calculated using the data source as a conditional variable. Fragments with weak correlation to the annotation results were filtered out, retaining 64 target rule fragments. These target rule fragments were mapped to graph nodes, directed edges were established according to the rule execution order, and the transmission strength between adjacent nodes was calculated. This resulted in an annotation rule knowledge graph containing 64 graph nodes and 157 directed edges.
[0150] To address inconsistencies in annotation results from different data sources, edit distance alignment was performed on the rule execution paths corresponding to the same annotated object. A total of 1376 cross-source corresponding paths were identified, of which 428 showed discrepancies in annotation results. By recursively extrapolating the discrepancies along the alignment paths, the bias contribution value of each graph node was obtained. Analysis showed that the bias was mainly concentrated in 11 graph nodes and their adjacent connections. Specifically, 3 nodes used inconsistent state judgment conditions under different data sources, and 4 connection edges had low propagation strength, causing subsequent rules to continue execution.
[0151] After obtaining the node deviation contribution value, the passage cost of each directed connection edge is calculated, and path connectivity and flow conservation are maintained between the rule execution start point and the annotation result. The minimum cost flow method is used to re-search for low total cost rule execution paths, and the target rule fragments carrying effective flow are reorganized. After reorganization, the original rule execution path containing an average of 12.6 rule nodes is reduced to 9.8 rule nodes, and the number of repeatedly executed rules is reduced from an average of 2.1 to 0.6, while preserving the complete connection relationship between the rule execution start point and the annotation result.
[0152] To verify the optimization effect, 24,000 labeled data points not involved in the aforementioned processing were selected for validation and compared with the original fixed rule chain method. Before optimization, the labeling consistency rate between different data sources was 89.4%, the labeling accuracy rate was 91.2%, and the average time for a single anomaly check was 46 minutes. After adopting this invention, the labeling consistency rate increased to 96.8%, the labeling accuracy rate increased to 97.1%, and the time for a single anomaly check was shortened to 17 minutes. For newly added feedback data, every 50 feedback records were used as an update batch. The Bayesian confidence update method was used to correct the directed edge weights involved, and only the rule execution paths where the edge weights changed were locally recalculated. The local recalculation involved an average of 8.7% of the directed connection edges in the knowledge graph, and the update time per batch was shortened from 38 seconds for overall recalculation to 7.4 seconds.
[0153] Table 1 Comparison of runtime effects before and after optimization of multi-source annotation rules
[0154] Comparison content Before optimization After optimization Label consistency rate 89.40% 96.80% Labeling accuracy 91.20% 97.10% Average number of rule nodes 12.6 9.8 Average number of repeated rules 2.1 0.6 Single anomaly detection time 46 minutes 17 minutes Single batch update time 38 seconds 7.4 seconds Local recalculation edge ratio 100% 8.70%
[0155] As can be seen from the data in Table 1, the present invention can locate the source of labeling deviation while maintaining the integrity of the rule execution path, reduce invalid rule execution, and continuously correct rule relationships based on feedback data.
[0156] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for optimizing multi-source data annotation rules based on knowledge graphs, characterized in that, Includes the following steps: S1. Acquire multi-source labeled data and preprocess it to form a standard labeled sequence; S2. Perform sequence pattern mining on the standard labeled sequence to identify recurring rule execution segments, and use conditional mutual information to calculate the dependency strength between the segment and the labeling results to screen out target rule segments. S3. Map the target rule fragments to graph nodes, establish directed connection edges according to the direction of rule execution, calculate the transmission strength between adjacent graph nodes using transfer entropy, and configure directed edge weights according to the transmission strength to construct a labeled rule knowledge graph. S4. Use edit distance to align the rule execution paths corresponding to different data sources, calculate the difference in annotation results of the alignment rule execution paths, and recursively calculate the difference in annotation results along the alignment rule execution paths according to the directed edge weights to obtain the node deviation contribution value. S5. Calculate the travel cost of directed connection edges based on the node deviation contribution value. Under the constraint of maintaining the connectivity of the rule execution path, use the minimum cost flow method to filter low-cost connections and reorganize the rule execution path along the retained connections to generate optimized annotation rules. S6. Obtain feedback data for optimizing annotation rules, and update the annotation rule knowledge graph using the Bayesian confidence update method.
2. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, The preprocessing specifically includes: Parse the data source identifier, annotation object identifier, rule code, execution time, and annotation result in multi-source labeled data, and perform field mapping; Cross-source merging is performed based on the correspondence between labeled object identifiers, and rule coding, time format and label coding are unified; Remove duplicate records and records with missing labels, and arrange the processed multi-source labeled data according to the labeled object label and execution time; Based on the arrangement results, organize the rule execution process corresponding to each labeled object to form a standard label sequence.
3. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, S2 specifically includes: S21. Arrange the rule codes in the standard annotation sequence in order according to the rule execution time, and extract the rule codes that are executed consecutively to form candidate rule execution segments; S22. The PrefixSpan algorithm is used to recursively project the candidate rule execution segments, calculate the support of each candidate rule execution segment in the standard labeled sequence, and screen out the recurring rule execution segments based on the minimum support. S23. Under different data sources, statistically analyze the occurrence status and corresponding annotation results of each rule execution segment, calculate the joint probability and marginal probability between the rule execution segment and the annotation results, calculate the conditional mutual information with the data source as the conditional variable, and obtain the dependency strength. S24. Sort the recurring rule execution fragments according to their dependency strength, and filter out the rule execution fragments with a dependency strength lower than the set threshold to obtain the target rule fragments.
4. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 3, characterized in that, S22 specifically includes: S221. Count the number of rule execution sequences containing each rule code, calculate the support of each rule code, take the rule code with the support reaching the minimum support threshold as the frequent prefix, and establish a projection database based on the occurrence position of the frequent prefix in the rule execution sequence. S222. In the projection database, search for the successor rule code from the next execution position after the last position of the frequent prefix, count the number of rule execution sequences containing the corresponding rule code combination, and calculate the support of the rule code combination. S223. Encode the successor rules whose support reaches the minimum support threshold, append them to the frequent prefix, update the projection database according to the occurrence position of the appended rules, and perform a recursive search on the updated projection database. S224. During the recursive search process, record frequent prefixes whose support reaches the minimum support threshold and whose length reaches the set fragment length. When there is no subsequent rule encoding that satisfies the minimum support threshold, terminate the recursive search of the corresponding branch and obtain the recurring rule execution fragment.
5. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, S3 specifically includes: S31. Merge target rule fragments with consistent rule encoding and arrangement order into the same graph node, and form a binary occurrence sequence of graph nodes according to the execution position of the target rule fragments in the standard annotation sequence; S32. Count the number of times different graph nodes appear together according to the execution order and the execution interval, connect the graph nodes whose number of common occurrences reaches the set threshold in sequence, establish candidate directed connection edges, and determine the candidate transmission delay according to the execution interval. S33. According to the candidate transmission delay, the binary occurrence sequence of the preceding and following graph nodes is misaligned, the transmission intensity between adjacent graph nodes is calculated using the transfer entropy, and the candidate transmission delay corresponding to the maximum transmission intensity is selected as the target transmission delay. S34. Filter out candidate directed edges with transmission strength below a set threshold, configure the weights of the directed edges according to the transmission strength of the retained directed edges, and construct a knowledge graph of annotation rules.
6. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 5, characterized in that, Specifically, S33 includes: S331. For each candidate transmission delay, combine the current binary state and the historical binary state of the subsequent graph node into a subsequent state index, and encode the binary state of the corresponding delay position of the preceding graph node into a preceding state index. S332. Establish a subsequent state transition matrix based on the subsequent state index, and establish a joint state transition matrix based on the subsequent state index and the preceding state index. Use Laplace smoothing to calculate the conditional transition probabilities in each state transition matrix. S333. Calculate the conditional entropy of the subsequent graph node based on the subsequent state transition matrix, calculate the conditional entropy after introducing the preceding graph node based on the joint state transition matrix, and take the difference between the two conditional entropies as the transmission intensity under the corresponding candidate transmission delay. S334. Compare the transmission strengths corresponding to each candidate transmission delay, and determine the candidate transmission delay corresponding to the maximum transmission strength as the target transmission delay.
7. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, S4 specifically includes: S41. Extract the graph nodes that the same labeled object passes through in sequence under different data sources, and form the corresponding rule execution path according to the execution order of the graph nodes; S42. In the two rule execution paths, construct the edit distance matrix based on the rule encoding consistency and execution position deviation of the graph nodes, use dynamic programming to calculate the cumulative edit cost, and backtrack the matrix path corresponding to the minimum cumulative edit cost to obtain the alignment rule execution path; S43. Classify the annotation results corresponding to the alignment rule execution path, calculate the distance between different class codes, and obtain the difference in annotation results; S44. In the alignment rule execution path, the directed edge weight is used as the reverse propagation coefficient between adjacent graph nodes. The graph node at the end of the path is initialized with the difference in the annotation results, and the node deviation contribution value of each graph node is obtained by recursively probing layer by layer along the alignment rule execution path.
8. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 7, characterized in that, S42 specifically includes: S421. Use the graph node numbers in the two rule execution paths as row and column indices respectively to build an edit distance matrix, and configure the boundary cost of the edit distance matrix according to the row and column indices; S422. Traverse the graph node combinations in the two rule execution paths, calculate the code matching cost based on whether the rule codes are consistent, and calculate the position deviation cost based on the execution position difference between the graph nodes to obtain the node alignment cost. S423. Based on the node alignment cost, the cumulative editing costs of the left, top, and top-left matrix units of the current matrix unit are recursively calculated, and the minimum recursive result is selected as the cumulative editing cost of the current matrix unit until the editing distance matrix calculation is completed. S424. Starting from the last matrix cell of the edit distance matrix, trace back to the matrix cell corresponding to the minimum cumulative edit cost, record the correspondence between the graph nodes in the two rule execution paths, and obtain the alignment rule execution path.
9. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, S5 specifically includes: S51. Obtain the node deviation contribution value corresponding to each graph node, and combine it with the directed edge weights between adjacent graph nodes to calculate the passage cost corresponding to each directed connection edge, forming a connection edge cost set. S52. Take the graph nodes corresponding to the rule execution start point and the annotation result as path endpoints, construct a directed flow network based on the set of connection edge costs, take the graph nodes in the rule execution path as flow constraint nodes, and restrict the inflow and outflow of each graph node to be consistent. S53. In a directed flow network, based on the set of connection edge costs, solve for the minimum cost flow between the starting point of rule execution and the corresponding graph node of the annotation result, filter out the valid connection edges that satisfy the flow constraints, and form a low-cost rule execution path. S54. Traverse the corresponding graph nodes along the effective connection edges in the low-cost rule execution path, extract the target rule fragments corresponding to the graph nodes, and reorganize the rule execution relationship according to the connection order to generate optimized annotation rules.
10. The method for optimizing multi-source data annotation rules based on knowledge graphs according to claim 1, characterized in that, S6 specifically includes: S61. Obtain the feedback data after the optimization annotation rule is executed, match the feedback data with the corresponding annotation results, and locate the directed connection edges involved in the feedback data along the graph nodes traversed by the optimization annotation rule. S62. Count the number of times the labeling results are consistent and the number of times the labeling results are inconsistent for each directed connection edge. Take the confidence state corresponding to the original directed edge weight as the prior distribution and use the statistical results to correct the prior distribution to obtain the posterior confidence of each directed connection edge. S63. The directed edge weights involved in the feedback data are corrected using the posterior confidence level. Taking the graph node where the directed edge weights have changed as the center, the system expands along the preceding and following directed connection edges to screen out the affected rule execution paths. S64. Recalculate the travel cost of each directed connection edge in the affected rule execution path, and use the minimum cost flow method to locally solve the affected rule execution path to complete the local update of the labeled rule knowledge graph.