A method, system, device, and medium for detecting structured sensitive data

By processing structured data with token sequences and detecting anomalies in attention weights, the problem of model performance degradation caused by label conflicts is solved, achieving higher detection accuracy and robustness, and making it suitable for sensitive data identification in high-risk industries such as finance, healthcare, and government.

CN120805199BActive Publication Date: 2025-11-25JIANGXI POLICE COLLEGE +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511277839.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-09
Publication Date
2025-11-25
Estimated Expiration
2045-09-09

AI Technical Summary

Technical Problem

Existing sensitive data detection methods suffer from reduced model detection performance in structured data scenarios due to label conflicts. In particular, they are prone to misjudgment and attention drift in minority class detection tasks, and have difficulty identifying low-quality samples, affecting detection accuracy and robustness.

Method used

By acquiring structured data and preprocessing it into a token sequence, we can extract contextual features, calculate attention weights, generate anomaly-aware masks, perform adaptive masking and normalization, identify and quantify anomaly attention weights, and improve the robustness and accuracy of the model.

Benefits of technology

It achieves accurate identification and effective shielding of samples with conflicting labels, improves the model's detection accuracy and generalization ability in complex data scenarios, and enhances the model's robustness and adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120805199B_ABST
    Figure CN120805199B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of data security, and discloses a structured sensitive data detection method, system, device and medium, which comprises the following steps: obtaining structured data and preprocessing the structured data into a token sequence; extracting context features of the token sequence to obtain a context feature vector of each token; calculating attention weights of each token based on the context feature vector to form an initial attention weight distribution; performing abnormal perception on the initial attention weight distribution, identifying and quantifying abnormal attention weights, and generating a final attention weight mask; shielding and normalizing the initial attention weight distribution by applying the final attention weight mask to obtain adjusted attention weights; calculating a context representation vector of a sample based on the adjusted attention weights and the context feature vector; and predicting a sensitive category of the structured data according to the context representation vector. The method can solve the interference problem caused by label mixing and unstable semantics in structured data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data security technology, specifically to a feature anomaly perception and adaptive masking technology for structured sensitive data detection, which improves the accuracy of sensitive data identification and model robustness in the presence of labeled conflicting samples. Background Technology

[0002] With the acceleration of digitalization, data has become a national strategic resource and a key production factor. Data security, as a fundamental security issue in the digital age, is directly related to national security, corporate compliance, and the protection of personal privacy. Its protection capabilities are increasingly important, especially in high-risk industries such as finance, healthcare, and government. In recent years, frequent sensitive data breaches have repeatedly exposed weaknesses in the detection and protection capabilities of information systems, necessitating more effective detection and prevention measures.

[0003] Against this backdrop, sensitive information detection in structured data has become one of the core technologies for ensuring data compliance and security. Structured data is widely present in database systems, stored in tabular form, and covers a variety of highly sensitive attributes such as ID card numbers, phone numbers, addresses, and bank card numbers. Currently, mainstream detection methods can be roughly divided into two categories: one is rule-based traditional methods, such as regular expressions, keyword matching, and column name recognition, which have a certain degree of accuracy but lack generalization ability for unknown types and contextual changes; the other is automated detection methods based on deep learning, such as LSTM and BERT models, which have stronger semantic understanding and contextual modeling capabilities and have gradually become the mainstream research approach.

[0004] However, existing sensitive data detection methods still face key challenges in real-world structured data scenarios, the most typical being the "Label Conflict Problem" (LCP). When concatenating structured data into text sequences, a single sample often contains multiple sensitive types, blurring the semantic boundaries of the labels. This makes the model prone to misjudgments or attention drift during training. These "perceptual shifts" significantly interfere with the model's learning process, reducing detection accuracy and generalization ability.

[0005] Furthermore, current methods generally treat all training samples equally, making it difficult to identify "low-quality samples" in the training set that contain labeling errors, semantic noise, or contextual confusion. This is especially true in minority class detection tasks, where such samples can easily cause the training process to deviate and amplify erroneous learning signals, thus making the model unstable in actual deployment.

[0006] Therefore, there is an urgent need for a new technical solution for the detection of structured sensitive data, which can automatically identify and perceive abnormal tokens or abnormal samples during model training, and perform targeted processing and shielding, thereby reducing semantic interference, improving the model's adaptability to complex samples, enhancing detection accuracy and robustness, and facilitating the reliable implementation of sensitive data identification technology in high-risk application scenarios. Summary of the Invention

[0007] Based on this, the present invention proposes a method, system, device and medium for detecting structured sensitive data, in order to solve the defect of the model detection performance degradation caused by label conflict in the prior art.

[0008] In a first aspect, the present invention provides a method for detecting structured sensitive data, comprising the following steps:

[0009] Obtain structured data and preprocess it into a token sequence;

[0010] Context features are extracted from the token sequence to obtain the context feature vector for each token;

[0011] The attention weight of each token is calculated based on the context feature vector to form an initial attention weight distribution;

[0012] Anomaly detection is performed on the initial attention weight distribution to identify and quantify abnormal attention weights, and a final attention weight mask is generated.

[0013] The initial attention weight distribution is masked and normalized by applying the final attention weight mask to obtain the adjusted attention weights.

[0014] The context representation vector of the sample is calculated based on the adjusted attention weights and the context feature vector;

[0015] Sensitive category classification prediction is performed on the structured data based on the context representation vector.

[0016] As an optional implementation of the first aspect of this application, the step of anomaly detection of the initial attention weight distribution specifically includes: within a batch of model training, for each token position, statistically analyzing the attention weights of all samples in the batch at that position, the statistical features including a first quartile and a third quartile, and calculating the interquartile range based on the first quartile and the third quartile; calculating the deviation of the attention weights of each sample at each token position according to the attention weights, the first quartile, the third quartile, and the interquartile range; and performing a nonlinear transformation on the deviation to obtain a final deviation that is insensitive to extreme values ​​and includes information on the deviation direction.

[0017] As an optional implementation of the first aspect of this application, the nonlinear transformation step is as follows: calculating the direction vector of the deviation; the final deviation is obtained by multiplying the direction vector by the logarithm of the absolute value of the deviation plus 1, and the specific calculation formula is as follows: ,in, Let D be the final deviation, sign() be the sign function, B be the number of training samples per batch, and L be the maximum length of the token.

[0018] As an optional implementation of the first aspect of this application, the step of generating the final attention weight mask includes generating a first layer mask and a second layer mask; the first layer mask is a global token-level mask, generated by: calculating the variance of the final deviation at each token position within a batch; comparing the variance with a preset variance threshold, and when the variance is greater than the variance threshold, marking the token position as pending processing in the first layer mask.

[0019] As an optional implementation of the first aspect of this application, the second layer mask is a sample-level mask, generated in the following manner: for the token positions marked as to be processed in the first layer mask, the mean and standard deviation of their final deviation within the batch are calculated; dynamic upper and lower boundary thresholds are set based on the mean and standard deviation, wherein the upper boundary threshold is the sum of the mean and a first coefficient multiplied by the standard deviation, and the lower boundary threshold is the difference between the mean and a second coefficient multiplied by the standard deviation; for each sample, if its final deviation at the token position to be processed is greater than the upper boundary threshold or less than the lower boundary threshold, it is marked at the corresponding position in the second layer mask; the final attention weight mask is obtained by performing a logical AND operation between the first layer mask and the second layer mask.

[0020] As an optional implementation of the first aspect of this application, the step of applying the final attention weight mask to mask and normalize the initial attention weight distribution specifically includes: setting the corresponding values ​​of the identified abnormal attention weights in the initial attention weight distribution to zero according to the final attention weight mask, forming masked attention weights; calculating the sum of the masked attention weights for each sample; if the sum of the weights for a sample is zero, replacing the masked attention weights of that sample with a uniform distribution to prevent division by zero errors in subsequent normalization operations; and normalizing the attention weights after masking and zero-sum processing to obtain the adjusted attention weights.

[0021] As an optional implementation of the first aspect of this application, the step of acquiring structured data and preprocessing it into a token sequence specifically includes: reading data from a structured table column by column; concatenating multiple cell data from the same column into a field set; connecting the data in the field set using a preset delimiter to form a string sample; if a column of data is missing, using a preset placeholder to fill it in; performing character-level word segmentation on the string sample to obtain an initial token sequence; and truncating or padding the initial token sequence to a preset maximum sequence length to obtain the token sequence.

[0022] Secondly, embodiments of this application provide a system for detecting structured sensitive data, including:

[0023] The preprocessing module is used to acquire structured data and preprocess it into a token sequence;

[0024] The feature extraction module is used to extract context features from the token sequence to obtain the context feature vector of each token;

[0025] An adaptive feature masking and context representation construction module is used to calculate the attention weight of each token based on the context feature vector to form an initial attention weight distribution; to perform anomaly detection on the initial attention weight distribution, identify and quantify abnormal attention weights, and generate a final attention weight mask; to apply the final attention weight mask to mask and normalize the initial attention weight distribution to obtain adjusted attention weights; and to calculate the context representation vector of the sample based on the adjusted attention weights and the context feature vector.

[0026] The classification prediction module is used to perform sensitive category classification prediction on the structured data based on the context representation vector.

[0027] Thirdly, embodiments of this application provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the steps of the method described in the first aspect.

[0028] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0029] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0030] 1. Precise anomaly detection: By introducing deviation modeling based on interquartile range, the degree of anomaly in attention weights can be accurately quantified, effectively identifying attention drift caused by label conflicts.

[0031] 2. Layered adaptive masking: The innovative two-layer masking mechanism realizes adaptive masking from coarse-grained (identifying problem tokens) to fine-grained (locating abnormal samples), which is more flexible and robust than the single threshold method.

[0032] 3. Enhanced model robustness: By shielding abnormal attention and designing a robust normalization strategy, the interference of noisy samples on model training is effectively suppressed, significantly improving the detection accuracy and generalization ability of the model in complex and noisy data scenarios.

[0033] 4. Excellent integration and practicality: This technology is implemented entirely within the model through statistical analysis, without the need for additional manual annotation or complex network structure modification. It is easy to integrate into existing deep learning detection frameworks and has high practical application value. Attached Figure Description

[0034] Figure 1 This is a flowchart of a method for detecting structured sensitive data according to an embodiment of the present invention;

[0035] Figure 2 This is a technical roadmap of a method for detecting structured sensitive data according to an embodiment of the present invention;

[0036] Figure 3 This is a schematic diagram of a structured sensitive data detection system provided in an embodiment of the present invention.

[0037] The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation

[0038] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0039] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0040] Example 1

[0041] Please see Figure 1 and Figure 2 The following are flowcharts and technology roadmaps for a method for detecting structured sensitive data provided in embodiments of the present invention. The method may include the following steps:

[0042] S1: Obtain structured data and preprocess it into a token sequence;

[0043] The goal of this step is to convert the structured tabular data into a text sequence format suitable for model input, thus constructing training samples. Specifically, this includes the following operations:

[0044] Step 1.1 Constructing column samples:

[0045] Read the data from the original table and organize the samples by column. Each sample consists of multiple (e.g., 5) cells from the same column.

[0046] For example, a column contains the following five rows of data:

[0047] Beijing

[0048] ID 7458

[0049] Chaoyang District

[0050] No. 12

[0051] Postal code 100022.

[0052] Step 1.2 String sequence construction:

[0053] Concatenate the above fields using commas "," as the separator to construct a string sample (text_sample). ,in, This represents the content of a cell in a structured data table, specifically the data at position i, where n represents the number of cells involved in the concatenation, meaning the sample string is composed of n cells arranged in sequence.

[0054] For example: text_sample = "Beijing, ID7458, Chaoyang District, No.12, Postcode 100022".

[0055] If a column is missing, fill it with "0" to ensure that the number of columns is consistent.

[0056] Step 1.3 Character-level word segmentation:

[0057] Use a character-level word segmenter The concatenated string is segmented character by character to obtain a word segmentation vector. ,in This represents each word after processing by the word segmenter. The word segmentation process is shown below:

[0058]

[0059] in This refers to the number of tokens in the sequence, where the maximum token sequence length is set. Therefore, it exists:

[0060]

[0061] For example: tk=['Beijing', 'ID', '7458', 'Chaoyang', 'District', '1', '2', 'Number', 'Postal Code', '1', '0', '0', '2', '2'].

[0062] S2: Extract context features from the token sequence to obtain the context feature vector of each token;

[0063] The goal of this step is to convert the concatenated token sequence into a vector representation that reflects its contextual semantics. The specific steps are as follows:

[0064] Step 2.1 Index Mapping and Filling Process:

[0065] The obtained word segmentation vector Each word follows a fixed vocabulary list ( ), perform index mapping operations For characters that exist in the vocabulary, provide the mapped index position; for characters that do not exist... <unk>The index position is set to 1, and an index mapping vector is generated. The index mapping process is represented as follows:

[0066]

[0067]

[0068] in This represents the i-th token after word segmentation. This indicates the index position of the token in the vocabulary. This represents the index position value of the i-th token.

[0069] Obtain the vector of index mapping Then, for those that do not meet the maximum length requirement... The index vector needs to be padded. Operation, filling with 0 represents the fill character. <pad>The index filling process is as follows:

[0070]

[0071] For example, the sample token sequence is:

[0072] "North" → 12, "Beijing" → 15, "ID" → 28, "7458" → 3, "North Korea" → 46, ..., "2" → 9

[0073] The mapped index sequence is obtained as follows:

[0074] [12, 15, 28, 3, 46, 52, 36, 3, 19, 31, 44, 3, 7, 9, 60, 3, 23, 45, 7, 8, 8, 8, 9, 9]

[0075] Since the model sets the maximum token sequence length to 128, and the current input length is 24, padding is needed at the end:

[0076] The padded index sequence is [12, 15, 28, 3, ..., 9, 9, 0, 0, ..., 0] (128 bits in total).

[0077] Where 0 represents <pad>Position

[0078] Step 2.2 Word Embedding Mapping:

[0079] For the padded vector , we perform the embedding operation , and the main process is to look up the parameter matrix through the padded vector to obtain the embedding vector , and finally obtain the embedding matrix . The embedding process is shown as follows:

[0080]

[0081]

[0082] For example:

[0083] "North" → [0.12, -0.03,..., 0.98]

[0084] "Beijing" → [0.22, 0.01,..., 0.91]

[0085] "," → [0.07, -0.02,..., 0.61]

[0086] "1" → [0.09, -0.08,..., 0.83]

[0087] "0" → [0.15, -0.05,..., 0.76] ...

[0088] After embedding, an embedding matrix of size (128 × 128) is obtained, indicating that there are 128 characters (including padding), and each character is represented as a 128-dimensional vector.

[0089] Step 2.3 Context Feature Extraction (LSTM layer):

[0090] In this step, the entire token sequence is fed into the LSTM layer for processing. That is, after obtaining the embedding matrix , the hidden layer (hidden_output) matrix [[ID=XX]]is calculated through the LSTM layer , and the generated hidden layer matrix is shown as follows: <X

[0091]

[0092] Note: There seems to be an error in the original text where "XX" is added in the translation of line 55. It should be "is calculated through the LSTM layer" instead.Through the above steps, the original character sequence is efficiently transformed into a context-aware semantic representation, providing rich input features with strong expressive power for subsequent attention modeling, anomaly detection, and classification.

[0093] For example, if the output dimension of the LSTM is set to 256, the output shape is: (128 × 256), indicating that each token is encoded as a 256-dimensional context vector.

[0094] ("North") → [0.18, 0.35, ..., 0.44]

[0095] ("Beijing") → [0.21, 0.39, ..., 0.53]

[0096] ("ID") → [0.27, 0.41, ..., 0.67] ...

[0097] ( <pad>→ [0.00, 0.00, ..., 0.00]

[0098] Finally, the context feature tensor of the sample is obtained:

[0099] hidden_output= ∈R 128×256 .

[0100] S3: Calculate the attention weight of each token based on the context feature vector to form an initial attention weight distribution; perform anomaly detection on the initial attention weight distribution, identify and quantify abnormal attention weights, and generate a final attention weight mask; apply the final attention weight mask to mask and normalize the initial attention weight distribution to obtain the adjusted attention weight; calculate the context representation vector of the sample based on the adjusted attention weight and the context feature vector;

[0101] The core of this step lies in identifying outliers in the attention distribution and automatically constructing a mask to block interfering tokens. Specifically, it includes the following steps:

[0102] Step 3.1 Calculate the token attention weight:

[0103] Each token's context vector is mapped to a scalar score through a linear layer.

[0104] Normalization is performed using the Softmax operation to obtain the attention weight (soft_attn) for each token.

[0105] For example, for a sample with a token sequence length of 128, its partial attention weights are as follows: soft_attn = [0.00149, 0.00221, 0.00175, ..., 0.00092, 0.00325, 0.00118]

[0106] The attention weight for the 10th token is:

[0107] soft_attn

[10] = 0.00325

[0108] Step 3.2 Anomaly Detection in Token Attention Weight Distribution

[0109] During training, each token of all samples in each batch constitutes a sample space, and we need to statistically analyze each token. , and Features; The quantile function, quantile(A, p, dim=0), calculates the p-th quantile of matrix A along the specified dimension. This indicates the dimension used to calculate quantiles. dim=0 means that the calculation is performed on the 0th dimension, which means that the attention weights for the same token position in different samples are statistically analyzed. The statistical method is as follows:

[0110]

[0111]

[0112] For each token across all samples in a batch, we calculate the deviation based on statistical characteristics. The formula for calculating the deviation is defined as follows:

[0113]

[0114] in This represents the deviation of the j-th feature of the i-th sample. This represents the value of the i-th sample in the j-th feature dimension. This represents the interquartile range of the j-th feature dimension.

[0115] Based on the LCP Optimization Analysis, for LCP samples, the outlier weights exhibit an upward and downward distribution, resulting in a larger variance. Conversely, the outlier weights for normal samples are almost entirely distributed at the top. Therefore, we introduced a direction vector to measure the deviation of outlier samples. The definition is as follows:

[0116]

[0117] Taking into account the calculated deviation , direction vector To prevent extreme deviation values ​​from dominating subsequent statistical calculations, we defined the following nonlinear substitution to calculate a more representative deviation. The nonlinear substitution is represented as follows:

[0118]

[0119] in, Let D be the final deviation, sign() be the sign function, B be the number of training samples per batch (set to a fixed value of 80), and L be the maximum token length (set to a fixed value of 128).

[0120] For example, the relevant statistics calculated for the 10th token are as follows:

[0121] Deviation D

[10] = 1.208964

[0122] E (mean deviation of the sample) = 0.1545735

[0123] std (standard deviation of the sample) = 0.349563

[0124] Step 3.3 First-layer mask generation

[0125] First, we analyze the deviation samples. variance characteristics and average characteristics The statistical method is expressed as follows:

[0126]

[0127] The mean() function represents the operation of calculating the average value along a specified dimension.

[0128] Based on the weighting analysis results, we found that the variance of the deviation between the normal sample and the LCP sample... The difference is significant; the variance of LCP samples is generally higher than that of normal samples. Therefore, we set a hyperparameter variance threshold. To automatically generate a global mask for each token in each batch. The first-layer mask generation representation is as follows:

[0129]

[0130] For example: the first layer mask is = [1,1,0,1,0, ...,1]

[0131] Step 3.4 Second-layer mask generation

[0132] In the second layer of the mask, we perform finer-grained sample-level processing on the deviation weights of the tokens filtered out by the first layer of the mask. We assign a weight deviation higher than [value missing] to each token in each sample. and below The selected samples are set to 1 to generate the second layer mask. The second-layer mask generation representation is as follows:

[0133]

[0134] Where boundary values and The definition is as follows:

[0135]

[0136] Finally, the generated first-layer mask will be... Second layer mask conduct The final mask is obtained through an operation (the "AND" operation in logical operations). The final mask representation is as follows:

[0137]

[0138] For example, taking the current sample as an example, tokens with a deviation exceeding E + 0.5 × std ≈ 0.329 will be marked as abnormal. If the deviation of the 10th bit is 1.208964, the condition is met:

[0139]

[10] = 1

[0140] The masks for other locations are as follows (partial):

[0141] = [[0, 0, ..., 1, ..., 0],

[0142] [0, 1, ..., 0, ..., 1],

[0143] ...

[0144] [1, 1, ..., 0, ..., 0]] ∈ R B×L

[0145] The final mask is:

[0146] = &

[0147] = [[0, 0, ..., 1, ..., 0],

[0148] [0, 1, ..., 0, ..., 1],

[0149] ...

[0150] [1, 1, ..., 0, ..., 0]] ∈R B×L .

[0151] Step 3.5 Attention masking and normalization:

[0152] Get the final mask Then, we... (The sentence is incomplete and requires more context to translate accurately.) Perform the following mask discard operation:

[0153] 1. When When the current bit is 1, we discard the current weight;

[0154] 2. When When the current bit is 0, we retain the current weight.

[0155] The overall mask discard operation is represented as follows:

[0156]

[0157] For example, the original attention vector is:

[0158] [0.01, 0.02, 0.05, 0.08, 0.01, ..., 0.00]

[0159] The mask is:

[0160] [0, 0, 1, 0, 1, ..., 0]

[0161] The result after masking is:

[0162] [0.01, 0.02, 0.00, 0.08, 0.00, ..., 0.00]

[0163] For the generated mask discard matrix We first calculate the token weight for each sample. The calculation process is as follows:

[0164]

[0165] For the zero-sum case (i.e., the sum of all token values ​​is 0), we set the overall distribution to a uniform distribution to prevent the division by zero anomaly. For the normal case, we retain the original weight values, and the processing is as follows:

[0166]

[0167] This yields a corrected mask discard matrix. The sum of the token weights for each sample is then recalculated on this matrix, ensuring that no weight sum is zero. For example, if the weights of all tokens for a sample are zero after passing through the mask, then...

[0168] [0.0, 0.0, ..., 0.0] (128 dimensions in total)

[0169] At this point, replace it with a uniform distribution:

[0170] [1 / 128, 1 / 128, ..., 1 / 128].

[0171] Then, a normalization operation is performed to ensure that the sum of the overall weights is 1 and the overall expectation remains unchanged, generating the final weight matrix. The normalization operation is represented as follows:

[0172]

[0173] For example, the weights retained after discarding outliers are:

[0174] [0.01, 0.02, 0.00, 0.08, 0.00, ..., 0.04]

[0175] The weighted sum is 0.15, and after normalization, it becomes:

[0176] [0.0667, 0.1333, 0.00, 0.5333, 0.00, ..., 0.2667] (rounded to four decimal places).

[0177] Use the obtained new weight matrix and the output matrix of the LSTM layer Perform matrix multiplication to calculate the context vector. The process is as follows:

[0178]

[0179] For example: context = [0.2532, 0.7649, 0.9984, ..., 1.4335] (256 dimensions in total)

[0180] For example, the token weight of a sample before it was blocked was:

[0181] [0.05, 0.1, 0.2, 0.15, 0.05, ..., 0.0]

[0182] After masking and normalization, it becomes:

[0183] [0.0, 0.15, 0.3, 0.25, 0.0, ..., 0.0].

[0184] The corresponding context vector is updated to focus more on the direction of the key token, resulting in a more discriminative classification result.

[0185] S4: Perform sensitive category classification prediction on the structured data based on the context representation vector.

[0186] Get the context vector Then, through a fully connected layer, the number of categories to be classified is recorded as follows: As the final output of the entire model , and These are parameters, and the process is represented as follows:

[0187]

[0188] Through all the above processes, the text sequence vector was successfully transformed into a vector with the number of categories as its dimension. The output vector For predicting the category, the vector is directly passed through a... The layer with the maximum value is the predicted category. The base is the natural number. The prediction process for any category is represented as follows:

[0189]

[0190] in This represents the predicted class label of the i-th sample. This indicates taking the category index that maximizes the value within the parentheses. Let represent the k-th element of the vector, which is the predicted score of the i-th sample in the k-th class. This indicates that the predicted score is exponentially calculated in the softmax function.

[0191] In other words, the context vector is fed into a fully connected layer and Softmax for classification, and the sensitive category (such as Phone number, Email, Address, etc.) is output.

[0192] For example: =[0.76, 1.23, 1.77, …, 2.11]

[0193] =[0.09, 0.17, 0.20, …, 0.26]

[0194] The largest value is selected as the output, which is mapped to the corresponding label. For example, if 0.26 is selected, the output category will be Address.

[0195] The above is the complete implementation process of the method of the present invention. By introducing an anomaly perception mechanism of attention distribution and an adaptive masking strategy, the interference of label conflict samples in structured data can be effectively suppressed, thereby improving the accuracy and robustness of sensitive data detection.

[0196] Example 2

[0197] Please see Figure 3 The diagram shown is a structural schematic of a structured sensitive data detection system according to the second embodiment of this application. The system includes the following key modules:

[0198] Preprocessing module 100 is used to acquire structured data and preprocess it into a token sequence;

[0199] The feature extraction module 200 is used to extract context features from the token sequence to obtain the context feature vector of each token;

[0200] The adaptive feature masking and context representation construction module 300 is used to calculate the attention weight of each token based on the context feature vector to form an initial attention weight distribution; to perform anomaly detection on the initial attention weight distribution, identify and quantify abnormal attention weights, and generate a final attention weight mask; to apply the final attention weight mask to mask and normalize the initial attention weight distribution to obtain adjusted attention weights; and to calculate the context representation vector of the sample based on the adjusted attention weights and the context feature vector.

[0201] The classification prediction module 400 is used to perform sensitive category classification prediction on the structured data based on the context representation vector.

[0202] The structured sensitive data detection system in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), etc. This application embodiment does not impose specific limitations.

[0203] The structured sensitive data detection system in this application embodiment can be a device with an operating system. The operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system.

[0204] The structured sensitive data detection system provided in this application embodiment can achieve... Figure 1 The various processes implemented in the method embodiment of the structured sensitive data detection method are not described in detail here to avoid repetition.

[0205] Optionally, embodiments of this application also provide an electronic device, including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the various processes of the above-described embodiment of the method for detecting structured sensitive data and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0206] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described embodiment of the method for detecting structured sensitive data and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0207] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0208] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one…" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0209] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0210] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.< / pad> < / pad> < / pad> < / unk>

Claims

1. A method for detecting structured sensitive data, characterized in that, Includes the following steps: Obtain structured data and preprocess it into a token sequence; Context features are extracted from the token sequence to obtain the context feature vector for each token; The attention weight of each token is calculated based on the context feature vector to form an initial attention weight distribution; Anomaly detection is performed on the initial attention weight distribution to identify and quantify abnormal attention weights, and a final attention weight mask is generated. Anomaly detection of the initial attention weight distribution specifically includes: within a batch of model training, for each token position, statistical features of the attention weights of all samples in that batch at that position are calculated, including the first quartile and the third quartile, and the interquartile range is calculated based on the first quartile and the third quartile; the deviation of the attention weights of each sample at each token position is calculated based on the attention weights, the first quartile, the third quartile, and the interquartile range; and a nonlinear transformation is performed on the deviation to obtain a final deviation that is insensitive to extreme values ​​and includes information on the direction of deviation. The step of generating the final attention weight mask includes generating a first layer mask and a second layer mask; the first layer mask is a global token-level mask, which is generated in the following way: calculating the variance of the final deviation at each token position within a batch; comparing the variance with a preset variance threshold, and when the variance is greater than the variance threshold, marking the token position as pending processing in the first layer mask; The second layer mask is a sample-level mask, generated as follows: For the token positions marked as to be processed in the first layer mask, calculate the mean and standard deviation of their final deviation within the batch; set dynamic upper and lower boundary thresholds based on the mean and standard deviation, wherein the upper boundary threshold is the sum of the mean and a first coefficient multiplied by the standard deviation, and the lower boundary threshold is the difference between the mean and a second coefficient multiplied by the standard deviation; for each sample, if its final deviation at the token position to be processed is greater than the upper boundary threshold or less than the lower boundary threshold, then mark it at the corresponding position in the second layer mask; the final attention weight mask is obtained by performing a logical AND operation between the first layer mask and the second layer mask; The initial attention weight distribution is masked and normalized by applying the final attention weight mask to obtain the adjusted attention weights. The context representation vector of the sample is calculated based on the adjusted attention weights and the context feature vector; Sensitive category classification prediction is performed on the structured data based on the context representation vector.

2. The method for detecting structured sensitive data according to claim 1, characterized in that, The steps of the nonlinear transformation are as follows: Calculate the direction vector of the deviation; The final deviation is obtained by multiplying the direction vector by the logarithm of the absolute value of the deviation plus 1, and the specific calculation formula is as follows: in, Let D be the final deviation, sign() be the sign function, B be the number of training samples per batch, and L be the maximum length of the token.

3. The method for detecting structured sensitive data according to claim 1, characterized in that, The step of applying the final attention weight mask to mask and normalize the initial attention weight distribution specifically includes: Based on the final attention weight mask, the corresponding values ​​of the identified abnormal attention weights in the initial attention weight distribution are set to zero, forming the masked attention weights; Calculate the sum of attention weights after masking each sample; If the sum of the weights of a sample is zero, the masked attention weights of that sample are replaced with a uniform distribution to prevent division by zero errors in subsequent normalization operations. The attention weights after masking and zero-sum processing are normalized to obtain the adjusted attention weights.

4. The method for detecting structured sensitive data according to claim 1, characterized in that, The step of acquiring structured data and preprocessing it into a token sequence specifically includes: Read data from a structured table by column and concatenate multiple cells in the same column into a field set; The data in the field set are connected using a preset delimiter to form a string sample. If a column of data is missing, a preset placeholder is used to fill it in. The string sample is segmented into characters to obtain an initial token sequence; The initial token sequence is truncated or padded to a preset maximum sequence length to obtain the token sequence.

5. A system for detecting structured sensitive data, characterized in that, include: The preprocessing module is used to acquire structured data and preprocess it into a token sequence; The feature extraction module is used to extract context features from the token sequence to obtain the context feature vector of each token; An adaptive feature masking and context representation construction module is used to calculate the attention weight of each token based on the context feature vector to form an initial attention weight distribution; to perform anomaly detection on the initial attention weight distribution, identify and quantify abnormal attention weights, and generate a final attention weight mask; Anomaly detection of the initial attention weight distribution specifically includes: within a batch of model training, for each token position, statistically analyzing the attention weights of all samples in that batch at that position, including the first quartile and the third quartile, and calculating the interquartile range based on the first quartile and the third quartile; calculating the deviation of the attention weights of each sample at each token position based on the attention weights, the first quartile, the third quartile, and the interquartile range; performing a nonlinear transformation on the deviation to obtain a final deviation that is insensitive to extreme values ​​and contains information about the deviation direction; generating the final attention weight mask includes generating a first-layer mask and a second-layer mask; the first-layer mask is a global token-level mask, generated by: calculating the variance of the final deviation at each token position within the batch; comparing the variance with a preset variance threshold, and when the variance is greater than the variance threshold, deselecting the token. The location is marked as pending processing in the first layer mask; the second layer mask is a sample-level mask, generated as follows: for the token location marked as pending processing in the first layer mask, the mean and standard deviation of its final deviation within the batch are calculated; dynamic upper and lower boundary thresholds are set based on the mean and standard deviation, wherein the upper boundary threshold is the sum of the mean and a first coefficient multiplied by the standard deviation, and the lower boundary threshold is the difference between the mean and a second coefficient multiplied by the standard deviation; for each sample, if its final deviation at the pending token location is greater than the upper boundary threshold or less than the lower boundary threshold, it is marked at the corresponding position in the second layer mask; the final attention weight mask is obtained by performing a logical AND operation on the first layer mask and the second layer mask; the initial attention weight distribution is masked and normalized using the final attention weight mask to obtain the adjusted attention weight; the context representation vector of the sample is calculated based on the adjusted attention weight and the context feature vector; The classification prediction module is used to perform sensitive category classification prediction on the structured data based on the context representation vector.

6. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein when the program or instructions are executed by the processor, they implement the steps of the method for detecting structured sensitive data as described in any one of claims 1-4.

7. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions, which, when executed by a processor, implement the steps of the method for detecting structured sensitive data as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Chinese named entity recognition system, method and equipment based on multi-scale features and medium

    CN120409476A

  • Automatically labeling data using natural language processing

    EP4040330A1