Text keyword desensitization method, system and equipment based on large model and medium
Through the text keyword desensitization method based on the big model, the pre-trained large language model is used to identify and desensitize sensitive information, which solves the problem of automatic identification and desensitization in the existing technology, and realizes efficient and accurate sensitive information processing, improving information security.
Patent Information
- Application Number
- CN202411720763.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-14
AI Technical Summary
The prior art is difficult to automatically identify and effectively desensitize sensitive information in large model training data, resulting in the risk of privacy leakage. Traditional desensitization methods are easily bypassed by attackers, and there are problems with misidentification or misidentification.
Using a text keyword desensitization method based on large models, through data collection, preprocessing, labeling sensitive information, model fine-tuning and optimization, pre-training large language models such as BERT, GPT or RoBERTa, add an output layer for sequence annotation, identify and desensitize sensitive information.
It realizes rapid and accurate identification and intelligent desensitization of sensitive information in text, improves the accuracy of identification of sensitive information, reduces manual intervention, and improves text processing efficiency, and is suitable for protecting information security, especially when processing large-scale text data.
Smart Images

Figure CN119622809A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of large models and natural language processing, and in particular to a method, system, device and medium for desensitizing text keywords based on a large model. Background Art
[0002] During the training process of the Large Language Mode 1 (LLM) model, the training data may contain a large amount of sensitive data. An attacker can pose questions to the large model and extract sensitive data from the responses, thereby leaking privacy. There are two main existing solutions to address this privacy issue. One is to desensitize or directly delete the sensitive data in the training data and then retrain the large model. This method requires retraining the large model and is extremely costly. The other is to perform content filtering during the request and response phase of the large model, blocking or desensitizing malicious questions and responses containing sensitive information. However, this method is easily circumvented by attackers. Traditional desensitization methods can also lead to the misidentification or omission of sensitive information.
[0003] Therefore, how to automatically identify and desensitize sensitive information, improve the accuracy of sensitive information identification, and thus improve text processing efficiency is a technical problem that needs to be solved urgently. Summary of the Invention
[0004] The technical task of the present invention is to provide a text keyword desensitization method, system, device and medium based on a large model to solve the problem of how to automatically identify and desensitize sensitive information, improve the accuracy of sensitive information identification, and thus improve text processing efficiency.
[0005] The technical task of the present invention is achieved in the following way: a text keyword desensitization method based on a large model, the method is as follows:
[0006] Data collection: Determine the data source and, based on desensitization requirements, select data sets containing specific types of sensitive information and use crawler technology to extract the required data sets from the database;
[0007] Data preprocessing: clean the extracted data set to obtain a normalized data set;
[0008] Labeling sensitive information: Use BRAT or Doccano annotation tools to label the normalized dataset and obtain a dataset with sensitive information labeled.
[0009] Data segmentation: Split the labeled dataset into training, validation, and test sets for training and evaluating large models;
[0010] Base model selection: Use the pre-trained large language model BERT, GPT, or RoBERTa, and select the corresponding pre-trained large language model version based on computing power, computing time, and specific task requirements. Among them, the pre-trained large language model BERT uses BERT-base or BERT-large;
[0011] Model fine-tuning: Add a new output layer to the pre-trained large language model BERT, GPT, or RoBERTa to obtain a fine-tuned large language model. The output layer is used to perform the desensitization task of sequence labeling. For the desensitization task of sequence labeling, the output layer uses a softmax layer, which assigns a label to each word, including sensitive or non-sensitive.
[0012] Train the fine-tuned large language model, obtain and save the trained fine-tuned large language model;
[0013] Preprocess the text data to be processed;
[0014] Detect sensitive information, develop desensitization strategies and implement desensitization processing, verify the desensitization of desensitized text, and optimize and improve the fine-tuned large language model based on the verification results;
[0015] The optimized, improved, and fine-tuned large language model is encapsulated into an API service for application calls.
[0016] As an optimization, data cleaning is as follows:
[0017] Format unification: convert all texts into a unified format, including UTF-8 encoding.
[0018] Remove noise: Use regular expressions or other text processing tools to remove non-text elements such as HTML tags, script codes, and special characters;
[0019] Text normalization: Normalize the text to obtain normalized data. Normalization includes converting all characters to lowercase and removing extra spaces and punctuation.
[0020] The specific information to be marked as sensitive is as follows:
[0021] Data sampling: extract a portion of data from the collected data set for preliminary analysis to obtain the characteristics of the data and the distribution of sensitive information;
[0022] Preprocessing script writing: write preprocessing scripts to automate data cleaning tasks;
[0023] Labeled sample production: Create a labeled sample set for training and validating labeling rules;
[0024] Labeling rule iteration: Iteratively optimize the labeling rules based on the results of the labeled sample set;
[0025] Comprehensive labeling: Apply the finalized labeling rules to all data sets, perform comprehensive sensitive information labeling, and obtain data sets labeled with sensitive information.
[0026] Preferably, the fine-tuned large language model is trained, and the trained fine-tuned large language model is obtained and saved as follows:
[0027] Training data preparation: Convert the labeled dataset into the format required for model training, that is, the input text and the corresponding label sequence, and use the data loader to batch load the data for subsequent model training;
[0028] Model training: Initialize the output layer parameters of the fine-tuned large language model and define the loss function. Select the Adam or AdamW optimizer and set an appropriate learning rate. Start training the output layer of the fine-tuned large language model over multiple epochs, where the model traverses the entire training dataset in each epoch. For the desensitization task of sequence labeling, the cross-entropy loss function is used.
[0029] Monitor the training process: Use the validation dataset to monitor the performance of the fine-tuned large language model to avoid overfitting. Evaluate the performance of the fine-tuned large language model by observing the downward trend of the loss function and the accuracy metric. Apply an early stopping strategy, stopping training the fine-tuned large language model when performance on the validation dataset no longer improves.
[0030] Model evaluation: Evaluate the final performance of the model on the test dataset to ensure that the fine-tuned large language model has good generalization ability; and use various evaluation metrics such as precision, recall, F1 score, etc.
[0031] Model saving: After the fine-tuned large language model training is completed, the model parameters are saved for subsequent deployment and use.
[0032] Preferably, the text data to be processed is preprocessed as follows:
[0033] Word segmentation: Split the input text into words or subwords. For languages like Chinese that do not have clear space delimiters, word segmentation tools are used for word segmentation.
[0034] Encoding: Convert the segmented text into a digital code that can be understood by the trained and fine-tuned large language model, that is, use the vocabulary used in the pre-training of the fine-tuned large language model;
[0035] Padding and truncation: In order to meet the model's requirements for input length, the text is padded or truncated;
[0036] Adding special tags: Adding special tags (such as BERT’s [CLS] and [SEP]) at the beginning and end of the text to help the trained and fine-tuned large language model better understand the text structure.
[0037] As a preference, sensitive information detection is specifically as follows:
[0038] Model inference: The processed text is input into the fine-tuned large language model for forward propagation. The fine-tuned large language model outputs the probability distribution of sensitive information labels corresponding to each word.
[0039] Label decoding: Based on the probability distribution output by the fine-tuned large language model, a decoding strategy (such as Argmax decoding) is used to assign the most likely label to each word. The label indicates whether the word belongs to a specific sensitive information category (such as "name" or "phone number").
[0040] Sensitive information extraction: Extract sensitive information fragments from the text based on the decoded labels. For sequence labeling tasks, further post-processing is required to correctly combine adjacent tags to form a complete sensitive information entity. The post-processing is as follows:
[0041] Desensitization: Identified sensitive information is desensitized according to a desensitization strategy, replacing sensitive words with common markers (such as "*") or using fake data. Desensitization strategies are customized based on specific needs, for example, retaining some features of sensitive information (such as the last four digits of a phone number).
[0042] Result Verification: Verify the desensitized text to ensure that sensitive information has been correctly identified and desensitized, while leaving the rest of the text unchanged. Ensure the quality of desensitization through manual review or automated testing.
[0043] Feedback loop: If errors are found during the verification process, corresponding examples are collected and used for further training and optimization of the fine-tuned large language model.
[0044] As a preferred option, the formulation and selection of desensitization strategies are as follows:
[0045] Define desensitization rules: Define corresponding desensitization rules based on the type of sensitive information (such as personal name, phone number, address, etc.) and business needs. Desensitization rules include replacement, encryption, and masking.
[0046] Different desensitization strategies are customized for different types of sensitive information, specifically:
[0047] For Name, choose to replace it with "Mr. X" or "Ms. X";
[0048] For phone numbers, choose to mask the first or last digits;
[0049] For addresses, choose to retain only the city level and mask the specific street information;
[0050] Replacement desensitization: After identifying sensitive information, sensitive words are replaced with common words or symbols according to predefined replacement rules. For example, "Zhang San" is replaced with "Mr. So-and-so" and "Li Si" is replaced with "Ms. So-and-so".
[0051] Encryption and desensitization: When the original information needs to be retained but not directly read, an encryption algorithm (such as AES) is used to encrypt the sensitive information; the encrypted information can be restored using a decryption algorithm when needed;
[0052] Masking and desensitization: Use specific symbols (such as "*") to mask part of sensitive information; for example, the phone number "13800138000" can be masked as "138****8000";
[0053] Preferably, desensitization is performed as follows:
[0054] Sensitive information location: Determine the exact location of sensitive information in the text based on the labels output by the fine-tuned large language model;
[0055] Apply desensitization rules, specifically:
[0056] For each identified sensitive information fragment, apply the corresponding desensitization rules based on the sensitive information type;
[0057] The replacement operation is directly implemented through the string replacement function;
[0058] Encryption operations require calling encryption library functions and managing keys;
[0059] The masking operation intercepts a specific part of the string programmatically and replaces it with a masking symbol;
[0060] Output desensitized text: Output the desensitized text to replace the original text file or display it on the user interface;
[0061] Record desensitization logs: record detailed information about desensitization operations, including the time, operator, and desensitization rules, for easy auditing and tracking;
[0062] Redaction integrity check: Write scripts or use automated tools to check the redacted text to ensure that all identified sensitive information has been redacted accordingly;
[0063] Format preservation check: Verify whether the format of the desensitized text is consistent with the original text, for example, whether the format of telephone numbers and dates is correct;
[0064] Readability check: Ensure that the desensitized text remains readable and has not become difficult to understand due to the desensitization process;
[0065] Sample spot check: Randomly select samples from the anonymized text for manual inspection to verify the accuracy of automated verification.
[0066] A text keyword desensitization system based on a large model, the system comprising:
[0067] The data collection module is used to determine the data source and, based on the desensitization requirements, select data sets containing specific types of sensitive information and extract the required data sets from the database using crawler technology;
[0068] The data preprocessing module is used to clean the extracted data set and obtain a normalized data set;
[0069] The sensitive information annotation module is used to annotate the normalized dataset using the BRAT or Doccano annotation tools to obtain a dataset annotated with sensitive information;
[0070] The data segmentation module is used to split the labeled data set into training set, validation set and test set for training and evaluation of large models;
[0071] The basic model selection module is used to use the pre-trained large language model BERT, GPT, or RoBERTa, and select the corresponding pre-trained large language model version based on computing power, computing time, and specific task requirements. Among them, the pre-trained large language model BERT uses BERT-base or BERT-large;
[0072] The model fine-tuning module is used to add a new output layer based on the pre-trained large language model BERT, GPT, or RoBERTa to obtain a fine-tuned large language model. The output layer is used to perform the desensitization task of sequence labeling. For the desensitization task of sequence labeling, the output layer uses a softmax layer, which assigns a label to each word, including sensitive or non-sensitive labels.
[0073] The model training module is used to train the fine-tuned large language model and obtain and save the trained and fine-tuned large language model;
[0074] A text preprocessing module, used for preprocessing text data to be processed;
[0075] The text desensitization module is used to detect sensitive information, formulate desensitization strategies, and implement desensitization processing. It also verifies the desensitization of desensitized text and optimizes and improves the fine-tuned large language model based on the verification results.
[0076] The model optimization module is used to encapsulate the optimized, improved, and fine-tuned large language model into an API service for application calls.
[0077] An electronic device comprising: a memory and at least one processor;
[0078] wherein the memory stores computer-executable instructions;
[0079] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the above-mentioned large model-based text keyword desensitization method.
[0080] A computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the above-mentioned large model-based text keyword desensitization method is implemented.
[0081] The large model-based text keyword desensitization method, system, device, and medium of the present invention have the following advantages:
[0082] (1) The present invention achieves rapid and accurate identification and intelligent desensitization of sensitive information in texts through data collection and preprocessing, keyword identification, formulation of desensitization strategies, and execution and optimization of the desensitization process. It also utilizes the deep learning capabilities of large models, combined with contextual analysis, to dynamically generate desensitization strategies and customize them according to different needs. Through automated execution and continuous learning optimization, the present invention significantly improves the efficiency and accuracy of desensitization operations, is suitable for protecting information security, and exhibits significant advantages in processing large-scale text data.
[0083] (2) The present invention uses pre-trained large-scale language models (such as BERT, GPT, etc.), which have the ability to understand complex language structures and contexts;
[0084] (3) The present invention utilizes the natural language processing capabilities of large models to accurately identify sensitive keywords in texts, which may include but are not limited to personally identifiable information (PII), trade secrets, medical information, etc.;
[0085] (4) The present invention can understand the context of keywords in the text to ensure that the desensitization process does not change the intent and semantics of the original information;
[0086] (5) The present invention adopts a variety of desensitization strategies, such as replacement, masking, encryption, etc., to adapt to different security and privacy requirements, and allows users to customize the granularity of desensitization, which can be the entire word, part of the word, or specific characters;
[0087] (6) The present invention uses a large model to automatically annotate sensitive information in text, reducing the workload of manual annotation;
[0088] (7) The present invention dynamically adjusts the desensitization strategy according to different application scenarios and user permissions to achieve flexible data protection. During the desensitization process, it ensures that the semantics of the text remain consistent to avoid introducing ambiguity. At the same time, the desensitization strategy is optimized through user feedback, enabling the model to learn from its mistakes and continuously improve.
[0089] (8) The present invention ensures that the desensitization method complies with relevant data protection laws and standards, such as GDPR, HIPAA, etc. through compliance checks;
[0090] (9) The present invention optimizes the performance of large models, reduces computing resources and time consumption, and improves desensitization efficiency; at the same time, it takes into account scalability, enabling it to process large-scale data sets and multilingual texts, and provides a user-friendly interface that allows non-technical users to easily configure and perform desensitization tasks;
[0091] (10) The present invention records detailed logs of desensitization operations for auditing and monitoring purposes, and ensures that the desensitization method can be easily integrated into existing data processes and systems and is compatible with other tools and services;
[0092] (11) The present invention's large-scale model-based text keyword desensitization technology deeply integrates multiple fields such as natural language processing, machine learning, and information security. It uses advanced algorithms to conduct in-depth analysis of text content, accurately identify sensitive keywords containing personal identity information, trade secrets, etc., and uses efficient desensitization strategies to anonymize them. This ensures that during data sharing and transmission, it can protect user privacy and security while maintaining data availability and business continuity. It is an important component of modern information security systems;
[0093] (12) The present invention improves the accuracy and efficiency of desensitization technology: Traditional desensitization methods may have the problem of misidentifying or missing sensitive information. The present invention utilizes the powerful language understanding capabilities of large models to more accurately identify sensitive keywords in texts, while reducing human intervention. It automatically identifies and desensitizes sensitive information through algorithms, thereby improving the efficiency of processing large-scale text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] The present invention will be further described below with reference to the accompanying drawings.
[0095] Attachment Figure 1This is a flowchart of the text keyword desensitization method based on a large model. DETAILED DESCRIPTION
[0096] The text keyword desensitization method, system, device and medium based on a large model of the present invention are described in detail below with reference to the accompanying drawings and specific embodiments.
[0097] Example 1:
[0098] As attached Figure 1 As shown, this embodiment provides a text keyword desensitization method based on a large model, and the method is specifically as follows:
[0099] S1. Data collection: Determine the data source and, based on the desensitization requirements, select data sets containing specific types of sensitive information and use crawler technology to extract the required data sets from the database;
[0100] S2. Data preprocessing: clean the extracted data set to obtain a normalized data set;
[0101] S3. Labeling sensitive information: Use BRAT or Doccano annotation tools to label the normalized dataset and obtain a dataset labeled with sensitive information.
[0102] S4. Data segmentation: Split the labeled dataset into training, validation, and test sets for training and evaluating large models.
[0103] S5. Base model selection: Use the pre-trained large language model BERT, GPT, or RoBERTa, and select the corresponding pre-trained large language model version based on computing power, computing time, and specific task requirements. Among them, the pre-trained large language model BERT uses BERT-base or BERT-large;
[0104] S6. Model fine-tuning: Add a new output layer to the pre-trained large language model BERT, GPT, or RoBERTa to obtain a fine-tuned large language model; the output layer is used to perform the desensitization task of sequence labeling; for the desensitization task of sequence labeling, the output layer uses a softmax layer, which assigns a label to each word, including sensitive or non-sensitive labels;
[0105] S7, training the fine-tuned large language model, obtaining and saving the trained fine-tuned large language model;
[0106] S8, preprocessing the text data to be processed;
[0107] S9. Detect sensitive information, develop desensitization strategies and implement desensitization processing, verify the desensitization of the desensitized text, and optimize and improve the fine-tuned large language model based on the verification results;
[0108] S10. Encapsulate the optimized, improved, and fine-tuned large language model into an API service for application calls.
[0109] The data cleaning in step S2 of this embodiment is specifically as follows:
[0110] S201, format unification: convert all texts into a unified format; wherein the text format includes UTF-8 encoding;
[0111] S202. Noise removal: Use regular expressions or other text processing tools to remove non-text elements such as HTML tags, script codes, and special characters;
[0112] S203, text normalization: normalizing the text to obtain normalized data; wherein the normalization includes converting all characters to lowercase and removing redundant spaces and punctuation marks.
[0113] The specific details of the sensitive information marked in step S3 of this embodiment are as follows:
[0114] S301. Data sampling: Extract a portion of data from the collected data set for preliminary analysis to obtain data characteristics and distribution data of sensitive information;
[0115] S302. Preprocessing script writing: Writing preprocessing scripts to automatically perform data cleaning tasks;
[0116] S303, labeling sample production: creating a labeling sample set for training and verifying labeling rules;
[0117] S304, labeling rule iteration: iteratively optimize the labeling rules based on the results of labeling the sample set;
[0118] S305. Comprehensive labeling: Apply the finalized labeling rules to all data sets, perform comprehensive sensitive information labeling, and obtain data sets with labeled sensitive information.
[0119] Manual annotation: Professional annotators will annotate sensitive information in the text according to guidelines. The annotation process may require multiple rounds of iteration to ensure consistency and accuracy.
[0120] Semi-automatic annotation: Use existing NLP tools, such as named entity recognition (NER) models, to perform preliminary annotation. Manual review and correction of automatic annotation results to improve annotation quality.
[0121] In step S7 of this embodiment, the training and fine-tuning of the large language model is performed, and the obtained and saved training and fine-tuning of the large language model is performed as follows:
[0122] S701. Training data preparation: Convert the labeled dataset into the format required for model training, i.e., input text and corresponding label sequence, and use the data loader to batch load the data for subsequent model training;
[0123] S702, model training: Initialize the output layer parameters of the fine-tuned large language model, define the loss function, select the Adam or AdamW optimizer, and set an appropriate learning rate. Start training the output layer of the fine-tuned large language model, including multiple epochs, in each epoch the model traverses the entire training dataset; for the desensitization task of sequence labeling, the loss function uses the cross-entropy loss function;
[0124] S703. Monitoring the training process: Use the validation dataset to monitor the performance of the fine-tuned large language model to avoid overfitting. Evaluate the performance of the fine-tuned large language model by observing the downward trend of the loss function and the accuracy metric. Apply an early stopping strategy, that is, stop training the fine-tuned large language model when the performance on the validation dataset no longer improves.
[0125] S704, Model Evaluation: Evaluate the final performance of the model on the test dataset to ensure that the fine-tuned large language model has good generalization ability; and use various evaluation metrics such as precision, recall, F1 score, etc.
[0126] S705, model saving: After the fine-tuned large language model training is completed, the model parameters are saved for subsequent deployment and use.
[0127] The pre-processing of the text data to be processed in step S8 of this embodiment is specifically as follows:
[0128] S801, word segmentation: Segment the input text into words or subwords. For languages like Chinese that do not have clear space delimiters, use a word segmentation tool to segment words.
[0129] S802, encoding: converting the segmented text into a digital code that can be understood by the trained and fine-tuned large language model, i.e., using the vocabulary used in pre-training of the fine-tuned large language model;
[0130] S803, padding and truncation: To meet the model's input length requirements, perform padding or truncation on the text.
[0131] S804. Add special tags: Add special tags (such as BERT's [CLS] and [SEP]) at the beginning and end of the text to help the trained and fine-tuned large language model better understand the text structure.
[0132] The sensitive information detection in step S9 of this embodiment is specifically as follows:
[0133] S901, Model Inference: The processed text is input into the fine-tuned large language model for forward propagation. The fine-tuned large language model outputs the probability distribution of sensitive information labels corresponding to each word.
[0134] S902, label decoding: Based on the probability distribution output by the fine-tuned large language model, a decoding strategy (such as Argmax decoding) is used to assign a most likely label to each word. The label indicates whether the word belongs to a specific sensitive information category (such as "name" or "phone number").
[0135] S903, Sensitive Information Extraction: Extract sensitive information fragments from the text based on the decoded labels. For sequence labeling tasks, further post-processing is required to correctly combine adjacent tags to form a complete sensitive information entity. The post-processing is as follows:
[0136] S904, desensitization operation: Desensitize the identified sensitive information according to the desensitization strategy, replacing sensitive words with common marks (such as "*") or replacing them with false data. The desensitization strategy is customized according to specific needs, for example, retaining some features of sensitive information (such as the last four digits of a phone number);
[0137] S905. Result Verification: Verify the desensitized text to ensure that sensitive information has been correctly identified and desensitized, while leaving the rest of the text unchanged. Ensure the quality of desensitization through manual review or automated testing.
[0138] S906, Feedback loop: If errors are found during the verification process, the corresponding cases are collected and used for further training and optimization of the fine-tuned large language model.
[0139] The formulation and selection of the desensitization strategy in this embodiment are as follows:
[0140] Define desensitization rules: Define corresponding desensitization rules based on the type of sensitive information (such as personal name, phone number, address, etc.) and business needs. Desensitization rules include replacement, encryption, and masking.
[0141] Different desensitization strategies are customized for different types of sensitive information, specifically:
[0142] For Name, choose to replace it with "Mr. X" or "Ms. X";
[0143] For phone numbers, choose to mask the first or last digits;
[0144] For addresses, choose to retain only the city level and mask the specific street information;
[0145] Replacement desensitization: After identifying sensitive information, sensitive words are replaced with common words or symbols according to predefined replacement rules. For example, "Zhang San" is replaced with "Mr. So-and-so" and "Li Si" is replaced with "Ms. So-and-so".
[0146] Encryption and desensitization: When the original information needs to be retained but not directly read, an encryption algorithm (such as AES) is used to encrypt the sensitive information; the encrypted information can be restored using a decryption algorithm when needed;
[0147] Masking and desensitization: Use specific symbols (such as "*") to mask part of sensitive information; for example, the phone number "13800138000" can be masked as "138****8000";
[0148] In this embodiment, desensitization is implemented as follows:
[0149] (1) Sensitive information location: Determine the exact location of sensitive information in the text based on the labels output by the fine-tuned large language model;
[0150] (2) Apply desensitization rules, specifically:
[0151] For each identified sensitive information fragment, apply the corresponding desensitization rules based on the sensitive information type;
[0152] The replacement operation is directly implemented through the string replacement function;
[0153] Encryption operations require calling encryption library functions and managing keys;
[0154] The masking operation intercepts a specific part of the string programmatically and replaces it with a masking symbol;
[0155] (3) Outputting the desensitized text: Outputting the desensitized text to replace the original text file or displaying it on the user interface;
[0156] (4) Record desensitization logs: record detailed information about desensitization operations, including the time, operator, and desensitization rules, for easy auditing and tracking;
[0157] (5) Desensitization integrity check: Write a script or use an automated tool to check the desensitized text to ensure that all identified sensitive information has been desensitized accordingly;
[0158] (6) Format preservation check: Verify whether the format of the desensitized text is consistent with the original text, for example, whether the format of telephone numbers, dates, etc. is correct;
[0159] (7) Readability check: Ensure that the desensitized text still maintains good readability and does not become difficult to understand due to the desensitization process;
[0160] (8) Sample spot check: Randomly select samples from the desensitized text and conduct manual inspection to verify the accuracy of automated verification.
[0161] Establish audit standards: clarify the standards and processes for manual review, including which situations require manual intervention, how to record and provide feedback on issues, etc.
[0162] Implement manual review: For text that may have problems with automated verification or areas of model uncertainty, manual review is conducted. Reviewers check whether the desensitization is appropriate and whether sensitive information is correctly identified and processed.
[0163] Problem recording and feedback: Problems found during the review process need to be recorded, including the error type, location, and handling suggestions. Feedback the problems to the model maintenance team to improve the desensitization model and rules.
[0164] Adjustment and correction: Based on the results of manual review, necessary adjustments are made to the desensitization model, such as modifying desensitization rules, retraining the model, etc. Individual errors can be corrected directly in the text.
[0165] Automated Verification Script: Write a script to automatically execute the above steps for verifying the effectiveness of the desensitization. The script can include functions such as regular expression matching and keyword search to check the consistency and format of the desensitization.
[0166] Establish a review workflow: Use workflow management tools such as JIRA and Trello to manage the task allocation and progress tracking of manual reviews, and provide reviewers with user-friendly tools to facilitate them in marking issues and making suggestions.
[0167] Continuous Improvement: Regularly review audit results and feedback to iteratively optimize the desensitization model. Use machine learning techniques, such as reinforcement learning, to make the model more accurate when processing specific types of text.
[0168] Integrate into applications: Encapsulate the desensitizing model into an API service so that it can be called by other applications, ensuring the stability and security of the API interface, such as using HTTPS to encrypt data transmission.
[0169] System Integration: Integrate masking APIs into data processing workflows, such as invoking masking services before data export, report generation, or data sharing. Design flexible masking strategies based on specific data processing needs, such as real-time or batch masking.
[0170] Configuration management: Provides a configuration interface or file to allow users to customize desensitization rules and parameters, such as sensitive word lists and desensitization replacement methods, to ensure that configuration changes can take effect immediately or be updated according to a predetermined schedule.
[0171] Monitoring mechanism: Implement a monitoring system to track the performance indicators of the desensitized API in real time, such as response time, processing volume, error rate, etc.
[0172] Set up alert systems to automatically notify administrators when unusual behavior or performance degradation is detected.
[0173] Logging: Record detailed log information, including request content, desensitization results, processing time, etc., to facilitate problem tracking and auditing.
[0174] Feedback loop: Establish a feedback mechanism to allow users to report errors or deficiencies in desensitization. Regularly analyze user feedback and log data to identify potential problems with the model.
[0175] Model Update: Regularly retrain and optimize the desensitization model based on monitoring and feedback. Implement rolling updates or blue-green deployment strategies to minimize service interruptions.
[0176] Continuous learning: Leverage online learning or incremental learning techniques to enable the model to learn and adapt from new data. Regularly evaluate the desensitization effectiveness of the model to ensure it continues to meet business needs and compliance requirements.
[0177] API development: Use frameworks such as Flask and FastAPI to develop API interfaces for desensitizing models and implement key functions such as input validation, error handling, and load balancing.
[0178] Deployment environment preparation: Deploy the model on a server or cloud platform, configure the necessary computing resources and storage space, and ensure the security and stability of the deployment environment, such as using firewalls and regularly backing up data.
[0179] System Integration Testing: Before integration into the production environment, comprehensive system integration testing is performed to ensure compatibility between the desensitization service and other system components. Different workload scenarios are tested to ensure stable operation of the system even under high traffic.
[0180] Monitoring and maintenance: Use tools such as Prometheus and Grafana to set up monitoring dashboards.
[0181] Regularly review monitoring data and perform necessary maintenance operations, such as cleaning logs and updating system dependencies.
[0182] Example 2:
[0183] This embodiment provides a text keyword desensitization system based on a large model, which includes:
[0184] The data collection module is used to determine the data source and, based on the desensitization requirements, select data sets containing specific types of sensitive information and extract the required data sets from the database using crawler technology;
[0185] The data preprocessing module is used to clean the extracted data set and obtain a normalized data set;
[0186] The sensitive information annotation module is used to annotate the normalized dataset using the BRAT or Doccano annotation tools to obtain a dataset annotated with sensitive information;
[0187] The data segmentation module is used to split the labeled data set into training set, validation set and test set for training and evaluation of large models;
[0188] The basic model selection module is used to use the pre-trained large language model BERT, GPT, or RoBERTa, and select the corresponding pre-trained large language model version based on computing power, computing time, and specific task requirements. Among them, the pre-trained large language model BERT uses BERT-base or BERT-large;
[0189] The model fine-tuning module is used to add a new output layer based on the pre-trained large language model BERT, GPT, or RoBERTa to obtain a fine-tuned large language model. The output layer is used to perform the desensitization task of sequence labeling. For the desensitization task of sequence labeling, the output layer uses a softmax layer, which assigns a label to each word, including sensitive or non-sensitive labels.
[0190] The model training module is used to train the fine-tuned large language model and obtain and save the trained and fine-tuned large language model;
[0191] A text preprocessing module, used for preprocessing text data to be processed;
[0192] The text desensitization module is used to detect sensitive information, formulate desensitization strategies, and implement desensitization processing. It also verifies the desensitization of desensitized text and optimizes and improves the fine-tuned large language model based on the verification results.
[0193] The model optimization module is used to encapsulate the optimized, improved, and fine-tuned large language model into an API service for application calls.
[0194] Example 3:
[0195] This embodiment also provides an electronic device, including: a memory and at least one processor;
[0196] wherein the memory stores computer-executable instructions;
[0197] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the large model-based text keyword desensitization method described in any one of the present inventions.
[0198] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or any conventional processor, etc.
[0199] The memory can be used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, the memory can also include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage period, a flash memory device, or other volatile solid-state memory devices.
[0200] Example 4:
[0201] This embodiment also provides a computer-readable storage medium storing a plurality of instructions, which are loaded by a processor to cause the processor to execute the large model-based text keyword desensitization method in any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided, on which software program code implementing the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.
[0202] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute part of the present invention.
[0203] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0204] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.
[0205] In addition, it can be understood that the program code read from the storage medium is written into the memory provided in the expansion board inserted into the computer or into the memory provided in the expansion unit connected to the computer, and then based on the instructions of the program code, the CPU installed on the expansion board or expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above embodiments.
[0206] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A text keyword desensitization method based on a large model, characterized in that: The method is as follows: Data collection: Determine the data source and select data sets containing specific types of sensitive information based on desensitization requirements, and use crawler technology to extract the required data sets from the database; Data preprocessing: clean the extracted data set to obtain a normalized data set; Labeling sensitive information: Use BRAT or Doccano labeling tools to label the normalized data set and obtain a data set with labeled sensitive information. Data segmentation: Split the labeled data set into training set, validation set, and test set for training and evaluation of large models; Basic model selection: Use the pre-trained large language model BERT, GPT or RoBERTa, and select the corresponding version of the pre-trained large language model based on computing power, computing time and specific task requirements; among them, the pre-trained large language model BERT uses BERT-base or BERT-large; Model fine-tuning: Add a new output layer based on the pre-trained large language model BERT, GPT or RoBERTa to obtain a fine-tuned large language model; the output layer is used to perform the desensitization task of sequence labeling; among them, for the desensitization task of sequence labeling, the output layer uses a softmax layer, and the softmax layer assigns a label to each word, including sensitive or non-sensitive labels; Train the fine-tuned large language model, obtain and save the trained fine-tuned large language model; Preprocess the text data to be processed; Detect sensitive information, formulate desensitization strategies and implement desensitization processing, verify the desensitization of the desensitized text, and optimize and improve the fine-tuned large language model based on the verification results; The optimized, improved, and fine-tuned large language model is encapsulated into an API service for application calls.
2. The method for desensitizing text keywords based on a large model according to claim 1, characterized in that: The data cleaning is as follows: Format unification: convert all texts into a unified format, including UTF-8 encoding; Remove noise: Use regular expressions or other text processing tools to remove non-text elements such as HTML tags, script codes, and special characters; Text normalization: normalize the text to obtain normalized data; the normalization process includes converting all characters to lowercase and removing extra spaces and punctuation marks; The specific information to be marked as sensitive is as follows: Data sampling: extract a portion of data from the collected data set for preliminary analysis to obtain the characteristics of the data and the distribution data of sensitive information; Preprocessing script writing: write preprocessing scripts to automate data cleaning tasks; Annotated sample production: Create an annotated sample set for training and validating annotation rules; Labeling rule iteration: Iteratively optimize the labeling rules based on the results of the labeling sample set; Comprehensive labeling: Apply the finalized labeling rules to all data sets, perform comprehensive sensitive information labeling, and obtain data sets with labeled sensitive information.
3. The method for desensitizing text keywords based on a large model according to claim 1, characterized in that: Train the fine-tuned large language model, and obtain and save the trained fine-tuned large language model as follows: Training data preparation: Convert the labeled data set into the format required for model training, that is, input text and corresponding label sequence, and use the data loader to load the data in batches for subsequent model training; Model training: Initialize the output layer parameters of the fine-tuned large language model, define the loss function, select the Adam or AdamW optimizer, and set an appropriate learning rate to start the output layer training of the fine-tuned large language model, including multiple epochs, in each epoch the model traverses the entire training data set; for the desensitization task of sequence labeling, the loss function uses the cross entropy loss function; Monitor the training process: Use the validation data set to monitor the performance of the fine-tuned large language model to avoid overfitting, and evaluate the performance of the fine-tuned large language model by observing the downward trend of the loss function and the accuracy index. Then apply the early stopping strategy, that is, stop the training of the fine-tuned large language model when the performance on the validation data set no longer improves; Model evaluation: Evaluate the final performance of the model on the test dataset to ensure that the fine-tuned large language model has good generalization ability; and use various evaluation indicators; Model saving: After the fine-tuned large language model training is completed, the model parameters are saved for subsequent deployment and use.
4. The method for desensitizing text keywords based on a large model according to claim 1, characterized in that: The text data to be processed is preprocessed as follows: Word segmentation: Split the input text into words or subwords. For Chinese, a language without clear space separation, word segmentation tools are used for word segmentation. Encoding: Convert the segmented text into digital encoding that can be understood by the trained and fine-tuned large language model, that is, use the vocabulary used in pre-training of the fine-tuned large language model; Filling and truncation: fill or truncate the text; Add special tags: Add special tags at the beginning and end of the text to help the trained and fine-tuned large language model better understand the text structure.
5. The method for desensitizing text keywords based on a large model according to claim 1, characterized in that: The specific sensitive information detection is as follows: Model reasoning: The processed text is input into the fine-tuned large language model for forward propagation; the fine-tuned large language model will output the probability distribution of sensitive information labels corresponding to each word; Label decoding: Based on the probability distribution output by the fine-tuned large language model, a decoding strategy is used to assign the most likely label to each word. The label indicates whether the word belongs to a specific sensitive information category. Sensitive information extraction: Extract sensitive information fragments from the text based on the decoded labels. For sequence labeling tasks, further post-processing is required to correctly combine adjacent tags to form a complete sensitive information entity. The post-processing is as follows: Desensitization operation: Desensitize the identified sensitive information according to the desensitization strategy, and replace sensitive words with common tags or replace them with false data; Result verification: Verify the desensitized text to ensure that sensitive information has been correctly identified and desensitized, while keeping the rest of the text unchanged, and ensure the quality of desensitization through manual review or automated testing; Feedback loop: If errors are found during the verification process, the corresponding examples are collected and used for further training and optimization of the fine-tuned large language model.
6. The method for desensitizing text keywords based on a large model according to claim 1, characterized in that: The formulation and selection of desensitization strategies are as follows: Define desensitization rules: Define corresponding desensitization rules according to the type of sensitive information and business requirements; among them, desensitization rules include multiple desensitization methods such as replacement, encryption and masking; Different desensitization strategies are customized for different types of sensitive information, specifically: For the name, choose to replace it with "Mr. So-and-so" or "Ms. So-and-so"; For phone numbers, choose to mask the first or last few digits; For addresses, choose to keep only the city level and mask the specific street information; Replacement desensitization: After identifying sensitive information, sensitive words are replaced with common words or symbols according to predefined replacement rules; Encryption desensitization: In cases where the original information needs to be retained but not directly read, the sensitive information is encrypted using an encryption algorithm; the encrypted information is restored using a decryption algorithm when needed; Masking and desensitization: using specific symbols to mask part of sensitive information.
7. The method for desensitizing text keywords based on a large model according to any one of claims 1 to 6, characterized in that: The implementation of desensitization is as follows: Sensitive information location: Determine the exact location of sensitive information in the text based on the labels output by the fine-tuned large language model; Apply desensitization rules, specifically: For each identified sensitive information fragment, apply the corresponding desensitization rules according to the sensitive information type; The replacement operation is implemented directly through the string replacement function; Encryption operations require calling encryption library functions and managing keys; The masking operation intercepts a specific part of the string programmatically and replaces it with a masking symbol; Output desensitized text: Output the desensitized text to replace the original text file or display it in the user interface; Record desensitization logs: record detailed information of desensitization operations, including desensitization time, operator, desensitization rules, etc., for easy auditing and tracking; Masking integrity check: Write a script or use an automated tool to check the masked text to ensure that all identified sensitive information has been masked accordingly; Format preservation check: Verify whether the format of the desensitized text is consistent with the original text; Readability check: Ensure that the desensitized text still maintains good readability and does not become difficult to understand due to the desensitization process; Sample spot check: Randomly select samples from the anonymized text for manual inspection to verify the accuracy of automated verification.
8. A text keyword desensitization system based on a large model, characterized in that: The system includes: The data collection module is used to determine the source of data and select data sets containing specific types of sensitive information based on desensitization requirements, and use crawler technology to extract the required data sets from the database; The data preprocessing module is used to clean the extracted data set and obtain a normalized data set; The sensitive information labeling module is used to label the normalized data set using BRAT or Doccano labeling tools to obtain a data set with labeled sensitive information; The data segmentation module is used to segment the labeled data set into training set, validation set and test set for training and evaluation of large models; The basic model selection module is used to use the pre-trained large language model BERT, GPT or RoBERTa, and select the corresponding version of the pre-trained large language model according to the computing power, computing time and specific task requirements; among them, the pre-trained large language model BERT uses BERT-base or BERT-large; The model fine-tuning module is used to add a new output layer based on the pre-trained large language model BERT, GPT or RoBERTa to obtain a fine-tuned large language model; the output layer is used to perform the desensitization task of sequence labeling; among them, for the desensitization task of sequence labeling, the output layer adopts a softmax layer, and the softmax layer assigns a label to each word, and the label includes sensitive or non-sensitive; A model training module is used to train the fine-tuned large language model, obtain and save the trained fine-tuned large language model; A text preprocessing module, used for preprocessing text data to be processed; The text desensitization module is used to detect sensitive information, formulate desensitization strategies and implement desensitization processing, verify the desensitization of the desensitized text, and optimize and improve the fine-tuned large language model based on the verification results; The model optimization module is used to encapsulate the optimized and improved fine-tuned large language model into an API service for application calls.
9. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the large model-based text keyword desensitization method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the large model-based text keyword desensitization method as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Data security management method and device based on natural language transformation technology
CN120067138A
Software development application data processing method based on AI large model
CN120086878A
A data processing method for software development application based on large AI models
CN120086878B
Clinical test sensitive data automatic shielding method and system based on mobile terminal
CN120279560A
System and method for realizing data grading and classification based on metadata
CN120654064A