Sensitive word online detection method and device, electronic equipment and storage medium
By dynamically generating stateless computing nodes and loading the latest online detection model of sensitive word, the problem of unavailability under the delay in the detection of sensitive word updates and high concurrent requests in the prior art is solved, and real-time, accurate and scalable detection effects are achieved.
Patent Information
- Application Number
- CN202411512367.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-28
AI Technical Summary
The existing sensitive word detection system has delays and unavailability problems under updates and high concurrency requests, making it difficult to deal with new vocabulary and large amounts of data processing in real time.
Real-time, accurate and scalable detection is achieved by dynamically generating stateless computing nodes and loading the latest sensitive word online detection model from a shared online database.
It solves the problem of unavailability under sensitive word detection delay and high concurrent requests, improves the real-time, accuracy and scalability of detection, and reduces the risk of false positives and underreports.
Smart Images

Figure CN119443092A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of data processing technology and financial technology, and in particular to a sensitive word online detection method, device, electronic device and storage medium. Background Art
[0002] In the financial sector, with the rapid development of Internet finance, mobile payments and social media marketing, the amount of user-generated content has increased dramatically, bringing unprecedented challenges to content management and supervision. In particular, the monitoring of sensitive words is particularly important in the financial industry, because these contents may involve illegal activities such as fraud and illegal fundraising, and may also leak customer privacy information, affecting market order and the reputation of financial institutions.
[0003] In order to meet the growing demand for data processing, the existing sensitive word detection systems of financial enterprises mainly use static rule matching or machine learning-based methods. Although static rule matching is simple to implement, it is difficult to cope with the ever-changing new vocabulary and is prone to false positives. Although machine learning-based methods can improve accuracy, they often use offline versions of detection models to detect sensitive words because model training requires a lot of data and time. This cannot reflect the latest language usage in a timely manner, causing the detection results to lag behind actual needs.
[0004] In addition, as the amount of text to be processed increases, traditional single-node or multi-node fixed-configuration sensitive word detection systems face performance bottlenecks. These systems experience increased latency or even service unavailability under high concurrent requests. At the same time, since computing nodes are usually stateful, when the system needs to be expanded, the newly added nodes must synchronize the status information of the original nodes, which increases the complexity and maintenance cost of the system.
[0005] Therefore, solving the delay in sensitive word detection updates and the unavailability issues under high concurrent requests is a technical problem that needs to be solved urgently. Summary of the invention
[0006] In view of the above, it is necessary to provide an online sensitive word detection method, which aims to provide real-time, accurate and scalable detection of sensitive words by dynamically generating stateless computing nodes and loading the latest online sensitive word detection model from a shared online database, so as to solve the delay in sensitive word detection updates and the unavailability problems under high concurrent requests.
[0007] In a first aspect, a sensitive word online detection method is provided, comprising:
[0008] Receiving a request for sensitive word detection on a text to be detected, obtaining the text to be detected according to the request, and dividing the text to be detected into a first preset number of subtexts;
[0009] Storing each subtext in a detection queue, dynamically generating a second preset number of computing nodes according to a first preset number of subtexts, wherein the computing nodes are stateless computing nodes that do not store any persistent information, and the second preset number is equal to or less than the first preset number;
[0010] Establishing connections between the second preset number of computing nodes and a preset shared online database, and loading the sensitive word online detection model in the preset shared online database into each computing node;
[0011] The sensitive word online detection model of each computing node is called, and sub-texts are read from the detection queue in turn for detection, so as to obtain the detection result of each computing node for at least one sub-text, and the detection results corresponding to each sub-text are integrated to obtain the detection report of the text to be detected.
[0012] In a second aspect, a sensitive word online detection device is provided, comprising:
[0013] A segmentation module, configured to receive a request for sensitive word detection on a text to be detected, obtain the text to be detected according to the request, and segment the text to be detected to obtain a first preset number of sub-texts;
[0014] A generation module, used to store each subtext into a detection queue, dynamically generate a second preset number of computing nodes according to a first preset number of subtexts, the computing nodes being stateless computing nodes that do not store any persistent information, the second preset number being equal to or less than the first preset number;
[0015] A loading module, used to establish a connection between the second preset number of computing nodes and a preset shared online database, and load the sensitive word online detection model in the preset shared online database to each computing node;
[0016] The merging module is used to call the online sensitive word detection model of each computing node, read the sub-texts from the detection queue in turn for detection, obtain the detection result of each computing node for at least one sub-text, and fuse the detection results corresponding to each sub-text to obtain the detection report of the text to be detected.
[0017] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned sensitive word online detection method when executing the computer program.
[0018] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned sensitive word online detection method are implemented.
[0019] Compared with the prior art, the present invention helps to reduce the burden of a single computing node by dividing the text to be detected into multiple sub-texts, so that the system can process larger data sets. The segmented sub-texts are placed in the detection queue, and the number of stateless computing nodes is dynamically adjusted according to the number of sub-texts. The computing resources are dynamically adjusted to match the actual task volume to ensure efficient use of computing power. The design of stateless computing nodes simplifies the expansion and maintenance of the system.
[0020] Connect all computing nodes to a shared online database and load the latest sensitive word detection model from it to ensure that all computing nodes use the same latest version of the model for detection, which improves the consistency and accuracy of detection. In addition, models trained based on real-time data can better cope with newly emerging sensitive words and reduce the risk of false positives and false negatives. Each computing node calls the sensitive word online detection model to detect the sub-texts in the detection queue and combines the detection results to form a final report. The parallel processing mechanism speeds up the overall detection speed while ensuring that the entire text to be detected is thoroughly checked. This effectively solves the problems of delays in sensitive word detection updates and unavailability under high concurrent requests in existing technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a schematic diagram of an application environment of a sensitive word online detection method according to an embodiment of the present invention;
[0022] Figure 2 A schematic diagram of a process flow of an online sensitive word detection method provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of a module of an online sensitive word detection device provided by an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of the structure of an electronic device for implementing an online sensitive word detection method provided by an embodiment of the present invention;
[0025] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0027] It should be noted that the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0028] The sensitive word online detection method provided by the embodiment of the present invention can be applied in the following aspects: Figure 1 In an application environment, the client communicates with the server through a network. The server can receive a request for sensitive word detection for the text to be detected sent by the client, obtain the text to be detected according to the request, and divide the text to be detected to obtain a first preset number of sub-texts; store each sub-text in a detection queue, dynamically generate a second preset number of computing nodes according to the first preset number of sub-texts, and the computing nodes are stateless computing nodes that do not store any persistent information; establish a connection between the second preset number of computing nodes and a preset shared online database, and load the sensitive word online detection model in the preset shared online database to each computing node; call the sensitive word online detection model of each computing node, read the sub-text from the detection queue in turn for detection, obtain the detection result of each computing node for at least one sub-text, and fuse the detection results corresponding to each sub-text to obtain a detection report of the text to be detected. The present invention is aimed at financial service enterprises, social media and network platforms, e-commerce, government and public sectors, etc., by dynamically generating stateless computing nodes and loading the latest sensitive word online detection model from a shared online database, to provide real-time, accurate and scalable detection of sensitive words, so as to solve the delay in sensitive word detection update and the problem of unavailability under high concurrent requests. The client may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server may be implemented by an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific embodiments.
[0029] Reference Figure 2 FIG. 1 is a flow chart of a method for online sensitive word detection provided by an embodiment of the present invention. The method is executed by an electronic device.
[0030] In this embodiment, the sensitive word online detection method includes:
[0031] S1. Receive a request for sensitive word detection on a text to be detected, obtain the text to be detected according to the request, and divide the text to be detected into a first preset number of sub-texts.
[0032] In this embodiment, the server or system receives a request for sensitive word detection, which includes text to be detected, or obtains the text to be detected from a preset database based on the identifier of the text to be detected in the request. The text to be detected can be text data or various media types such as images and videos.
[0033] The text to be detected can be segmented into multiple sub-texts based on segmentation strategies such as paragraphs, sentences, and fixed lengths. The first preset number of sub-texts is determined according to the paragraphs, sentences, and fixed lengths of the text to be detected.
[0034] For example: A financial institution needs to perform sensitive word detection on the loan application document submitted by customer A to ensure that the document does not contain any illegal or sensitive information.
[0035] The loan application documents are as follows:
[0036] Applicant: Customer A, ID number: 123456789012345678, Loan amount: 100,000 yuan, Loan purpose: Purchase of real estate, Remarks: I plan to use the money to invest in the stock market and participate in some high-risk speculative activities.
[0037] The loan application document is split into three sub-files according to the split points (the split points can be blank lines or specific formatting marks).
[0038] Segmentation results:
[0039] Applicant: Zhang San ID number: 123456789012345678
[0040] Loan amount: 100,000 yuan Loan purpose: Purchase of real estate
[0041] Note: I plan to use this money to invest in the stock market and participate in some high-risk speculative activities.
[0042] In one embodiment, segmenting the to-be-detected text to obtain a first preset number of sub-texts includes:
[0043] Segment the text to be detected according to punctuation marks in the text to be detected to obtain at least one initial clause;
[0044] Each initial clause is segmented according to a preset dependency syntax to obtain a first preset number of subtexts.
[0045] Identify punctuation marks in the text to be detected, and divide the text to be detected into multiple initial clauses according to the identified punctuation marks (such as period, question mark, exclamation mark, etc.). By identifying punctuation marks, ensure that each initial clause is part of a complete sentence or paragraph.
[0046] Perform dependency syntactic analysis on each initial clause to identify the subject, predicate, object and other components in the initial clause. According to the preset dependency relationship rules, the initial clause is further subdivided into smaller subtexts to ensure that each subdivided subtext has a certain semantic integrity.
[0047] The preset dependency rules refer to further subdividing sentences according to the dependency relationships between the various components in the sentence (such as subject, predicate, object, etc.) when performing dependency syntactic analysis. These rules can be customized according to specific application requirements and the purpose of sensitive word detection.
[0048] In one embodiment, segmenting the to-be-detected text to obtain a first preset number of sub-texts includes:
[0049] Segmenting the text to be detected to obtain multiple phrases, and marking the part of speech for each phrase;
[0050] The preset segmentation point prediction model is used to analyze the position and contextual relationship of each phrase after the part of speech is marked in the text to be detected, and the probability of each phrase being a segmentation point is obtained, and the end position of the phrase with a probability greater than a threshold is selected as the segmentation point;
[0051] The text to be detected is segmented based on the segmentation points to obtain a first preset number of sub-texts.
[0052] Use the preset word segmentation tool (such as Jieba, HanLP, etc.) to perform word segmentation on the text to be detected, and divide the continuous text to be detected into multiple separate phrases.
[0053] Use a part-of-speech tagging tool (such as Stanford NLP, spaCy, or the part-of-speech tagger in NLTK) to tag each phrase in the text to be tested with a part-of-speech tag, such as noun (NN), verb (VB), adjective (JJ), etc.
[0054] The preset segmentation point prediction model is used to analyze the position and contextual relationship of each phrase after part-of-speech tagging in the text to be detected. The preset segmentation point prediction model predicts whether the phrase should be regarded as a segmentation point based on the position and contextual relationship of the phrase, and obtains the probability of each phrase being a segmentation point. The probability of the segmentation point reflects the possibility of ending a sub-text at the current position and starting the next sub-text.
[0055] The sentence end positions of all phrases whose probabilities are greater than a threshold are selected as segmentation points, and the text to be detected is segmented based on the segmentation points to obtain a first preset number of sub-texts.
[0056] The preset segmentation point prediction models include but are not limited to sequence-to-sequence (Seq2Seq) models, recurrent neural networks (RNNs), and long short-term memory networks (LSTM). The model structure of the preset text segmentation model includes: word encoding layer, attention layer, fusion layer, sentence encoding layer and output layer.
[0057] The word encoding layer is used to convert each word group after the input part-of-speech tagging into a vector representation. When processing the current word, the attention layer is used to pay more attention to the key parts of the input sequence, which is very useful for capturing long-distance dependencies and important information.
[0058] The fusion layer is used to fuse the outputs of the word encoding layer and the attention layer to generate a richer feature representation. The sentence encoding layer is used to further encode the fused features to capture the semantic information of the entire sentence or clause. The output layer is responsible for generating the final segmentation point prediction.
[0059] In step S1, the text to be detected is divided into a first preset number of sub-texts, which can be processed in parallel using multi-threading or multi-processing. Each computing node can independently process one or more sub-texts, thereby significantly improving the overall processing speed. Evenly distributing tasks to multiple computing nodes avoids overloading of a single node, making resource utilization more balanced.
[0060] S2. Store each subtext into a detection queue, and dynamically generate a second preset number of computing nodes according to the first preset number of subtexts, wherein the computing nodes are stateless computing nodes that do not store any persistent information, and the second preset number is equal to or less than the first preset number.
[0061] In this embodiment, a detection queue of a data structure is pre-constructed, and each segmented sub-text is sequentially placed into the detection queue. Multi-threading or multi-computing nodes can be used to process these sub-texts in parallel, which can significantly improve the processing speed, especially when processing large amounts of data.
[0062] The number of computing nodes can be adjusted dynamically based on the number of tasks in the subtext detection queue. If there are more tasks, more computing nodes can be added; if there are fewer tasks, fewer computing nodes can be reduced to save resources. The queue mechanism ensures that each computing node can get tasks evenly, avoiding the situation where some nodes are overloaded while others are idle.
[0063] A computing node refers to a computing resource that performs actual processing tasks, which can be a physical server, virtual machine, container, or other computing unit. Each computing node does not save any persistent information when processing a task. In other words, each time a subtext is processed, the computing node starts from scratch and does not rely on the previous state. This makes it easier to scale stateless nodes horizontally without considering state synchronization issues. For example, if a node fails, it can be easily replaced with another node without losing any important information.
[0064] If the number of compute nodes is less than or equal to the number of subtexts, it can ensure that each node has enough work to process, and the load can be better balanced to avoid situations where some nodes are overloaded while others are idle.
[0065] S3. Establish connections between the second preset number of computing nodes and a preset shared online database, and load the sensitive word online detection model in the preset shared online database to each computing node.
[0066] In this embodiment, the preset shared online database is a centralized data storage system for storing sensitive word detection models and their related data. All computing nodes can access and connect to the preset shared online database through the network. Each computing node loads the latest sensitive word detection model from the shared online database at startup or regularly, which can ensure that each computing node uses the latest version of the model, thereby improving the accuracy and consistency of detection.
[0067] The online sensitive word detection model is trained based on the latest real-time data and updated regularly, so that all computing nodes use the latest version of the model. Real-time data refers to the latest, constantly updated data sources, such as new text submitted by users, new information on the Internet, new laws and regulations, etc. Use this latest real-time data to train the sensitive word detection model to ensure that the model can recognize the latest sensitive words and patterns.
[0068] By loading the latest model from a shared online database in each computing node of the present invention, all computing nodes can use the same, latest model version for processing, ensuring that the model versions of all computing nodes are consistent, avoiding inconsistent detection or omissions caused by using old models.
[0069] In one embodiment, before establishing the connection between the second preset number of computing nodes and the preset shared online database, the method further includes:
[0070] Constructing an initial database of a network attached storage type, and setting a directory structure and file naming rules for the initial database;
[0071] According to the directory structure and the file naming rule, the relevant data of the sensitive word online detection model is stored in the initial database to obtain the preset shared online database, wherein the relevant data includes a sensitive word list, a training data set and a model file.
[0072] Build an initial database of network attached storage type, such as NAS storage database, to centrally manage and store various data required for sensitive word detection.
[0073] Set up the directory structure and file naming rules for the initial database. For example, define a clear folder hierarchy through the directory structure to facilitate the organization and management of different types of data. For example, there can be separate folders for sensitive word lists, training data sets, and model files. Develop a unified set of file naming rules to ensure file naming consistency and readability. This helps to quickly locate and manage files.
[0074] The relevant data of the sensitive word online detection model is stored in the initial database, which becomes a preset shared online database. All computing nodes can access the shared online database through the network and obtain the latest sensitive word detection model and its related data from it.
[0075] The relevant data includes the sensitive word list, training data set and model file. The sensitive word list contains all the sensitive words that need to be detected. The training data set refers to the data set used to train the sensitive word detection model, which usually includes a large number of text samples and their labels. The model file refers to the trained sensitive word detection model file, which can be loaded into the computing node for actual detection.
[0076] In one embodiment, the step of loading the sensitive word online detection model in the preset shared online database to each computing node includes:
[0077] Querying the timestamps of each sensitive word online detection model in the preset shared online database;
[0078] The sensitive word online detection model with the latest version of the timestamp is loaded into each computing node, and the sensitive word online detection model is a detection model that is trained based on real-time sensitive word data and updated in real time.
[0079] Configure network settings for each computing node so that it can access the preset shared online database. Network settings include setting IP addresses, port numbers, authentication information, etc.
[0080] Use network libraries in the preset programming language (such as Python, Java, etc.) on the computing node to establish a connection with the shared online database. These network libraries can be standard libraries or third-party libraries to handle network communication.
[0081] A stable network connection can be established between the computing node and the shared online database through TCP / IP protocol or other network protocols. The timestamps of all sensitive word online detection models are queried from the shared online database. The timestamp records the last update time of each model file.
[0082] By comparing the timestamps of different versions of model files, we can determine which model is the latest version. Based on the timestamp, we can select the latest online sensitive word detection model, download the latest version of the model from the shared online database and load it into the memory of each computing node to perform the sensitive word detection task.
[0083] In one embodiment, the sensitive word online detection model is obtained according to the following method, including:
[0084] Collecting text data sets from a preset data source in real time, annotating and recording sensitive words in the text data sets to obtain a training data set, wherein the records include data sequence numbers of sensitive words, the included sensitive words, and the number of included sensitive words;
[0085] Dividing the training data set into a training set and a test set, and using the training set to train the initial detection model;
[0086] The test set is used to adjust the hyperparameters of the trained initial detection model. When the preset indicators of the trained initial detection model meet the preset requirements, the training is terminated to obtain the sensitive word online detection model.
[0087] A large amount of text data is collected from a preset data source (such as the Internet, social media, news articles, user-submitted documents, etc.) to obtain a text dataset, and the text dataset is annotated (such as manually or automatically) and recorded to obtain a training dataset. For example, for each text sample containing sensitive words, the sensitive words contained therein are marked.
[0088] Record the following information for each text sample containing sensitive words: Data serial number: unique identifier of each text sample. Sensitive words included: all sensitive words that appear in the text. Number of sensitive words included: number of sensitive words in the text.
[0089] The annotated and recorded text dataset is divided into two parts: training set: a dataset used to train the initial detection model. Test set: a dataset used to evaluate and adjust the model performance.
[0090] Select a suitable machine learning algorithm (such as logistic regression, support vector machine, neural network, etc.) as the initial detection model, use the training set to train the initial detection model and optimize the model parameters. Through training, the model can recognize and classify sensitive words in the text.
[0091] Use the test set to evaluate the performance of the initial detection model after training, including adjusting hyperparameters and evaluation indicators. Adjust hyperparameters: According to the evaluation results on the test set, adjust the model's hyperparameters (such as learning rate, regularization parameters, number of network layers, etc.) to further optimize the model performance. Evaluation indicators: Commonly used evaluation indicators include accuracy, precision, recall, F1 score, etc.
[0092] When the preset indicators of the trained initial detection model on the test set meet the preset requirements, it is considered that the trained initial detection model has reached the expected performance level, and the training is ended, that is, the final sensitive word online detection model is obtained, which can be stored in the shared online database for practical application by computing nodes.
[0093] In one embodiment, the method further comprises:
[0094] When it is detected that the training of the online sensitive word detection model has been completed, a version number and a timestamp of the online sensitive word detection model are generated according to the time when the training has been completed;
[0095] The sensitive word online detection model, the version number and the timestamp of the sensitive word online detection model are packaged and stored in the preset shared online database.
[0096] Generate a unique version number for the online sensitive word detection model based on the time or identification information of the online sensitive word detection model. The version number can help track and manage different versions of the model. Record the specific time when the online sensitive word detection model is generated to generate a timestamp for the online sensitive word detection model. The timestamp is used to indicate the time point when the model is created or updated.
[0097] Package the sensitive word online detection model, version number and timestamp together, and store the packaged files in the preset shared online database. According to the previously set directory structure and file naming rules, store the files in the corresponding folders and use the file names containing the version number and timestamp for storage.
[0098] The trained sensitive word online detection model, version number and timestamp are packaged and stored in the preset shared online database, so that all computing nodes can obtain the latest model file from the same shared online database, ensuring that all nodes use the same version of the model, thereby ensuring the consistency of processing results.
[0099] By centrally storing and managing model files, data inconsistency problems caused by using different versions of models can be avoided. There is no need to update each computing node one by one. The computing nodes can regularly check the latest version in the shared online database and automatically download and load new model files, thereby achieving seamless updates.
[0100] In step S3, by loading the latest sensitive word online detection model from the shared online database, it can be ensured that all computing nodes use the latest version of the model, which helps to improve the accuracy and consistency of detection. Because the sensitive word online detection model is regularly updated to include the latest sensitive words and variants, all computing nodes use the same model version, avoiding the problem of inconsistent detection results caused by using different versions of the model.
[0101] S4. Call the online sensitive word detection model of each computing node, read sub-texts from the detection queue in turn for detection, obtain the detection result of each computing node for at least one sub-text, and fuse the detection results corresponding to each sub-text to obtain the detection report of the text to be detected.
[0102] In this embodiment, according to the first-in-first-out processing rule, each computing node reads sub-texts from the detection queue in turn, uses the loaded sensitive word online detection model to detect sensitive words for each sub-text, summarizes the detection results of all sub-texts, and obtains a detection report for the text to be detected.
[0103] The detection report includes the overall situation of the text to be tested, such as the total number of words, the number of sub-texts, the detection results of each sub-text, lists specific sensitive words and their locations, the number of sensitive words, type distribution, and suggestions or treatment measures based on the detection results.
[0104] For example: A financial institution needs to perform sensitive word detection on the loan application document submitted by customer A to ensure that the document does not contain any illegal or sensitive information.
[0105] The loan application documents are as follows:
[0106] Applicant: Customer A, ID number: 123456789012345678, Loan amount: 100,000 yuan, Loan purpose: Purchase of real estate, Remarks: I plan to use the money to invest in the stock market and participate in some high-risk speculative activities.
[0107] The loan application document is split into three sub-files according to paragraph boundaries (paragraph boundaries can be blank lines or specific formatting marks).
[0108] Segmentation results:
[0109] Applicant: Zhang San ID number: 123456789012345678
[0110] Loan amount: 100,000 yuan Loan purpose: Purchase of real estate
[0111] Note: I plan to use this money to invest in the stock market and participate in some high-risk speculative activities.
[0112] Put these three subtexts into the detection queue. Assuming that each subtext requires a computing node to process, the system will dynamically create three stateless computing nodes, which will not store any persistent information.
[0113] Each computing node establishes a connection with the shared online database and loads the latest online sensitive word detection model. This online sensitive word detection model is trained based on real-time collected data and is regularly updated to identify the latest sensitive words.
[0114] Each computing node takes out a sub-text from the detection queue in turn and uses the loaded sensitive word online detection model for detection.
[0115] Computing node 1 processes subtext 1 and may detect the ID card number as sensitive information.
[0116] Computing node 2 processes subtext 2 and finds no sensitive information.
[0117] Computing node 3 processes subtext 3 and detects that "investing in the stock market" and "high-risk speculative activities" are sensitive content.
[0118] The detection results of all subtexts are combined to form a final report.
[0119] In one embodiment, calling the sensitive word online detection model of each computing node, sequentially reading subtexts from the detection queue for detection, and obtaining the detection result of each computing node for at least one subtext includes:
[0120] Performing sensitive word matching on each subtext according to a first sensitive word library of the online sensitive word detection model, and determining sensitive word sentences in each subtext according to the sensitive word matching results, wherein the sensitive word library includes at least one sensitive word list group;
[0121] Performing sensitive word variant detection on each subtext according to a second sensitive word library of the online sensitive word detection model, and determining sensitive word variant sentences in each subtext according to the sensitive word variant detection result, wherein the sensitive word library includes at least one sensitive word variant list group;
[0122] According to the sensitive word sentences and sensitive word variant sentences in each sub-text, the detection result of each computing node for at least one sub-text is obtained.
[0123] The first sensitive word library contains a library of standard sensitive word lists, including directly listed sensitive words. The computing node uses the first sensitive word library to match each subtext word by word to find out whether the subtext contains these standard sensitive words. If the subtext contains a standard sensitive word, the sensitive word and the sentence or fragment in which it is located are marked as sensitive word sentences.
[0124] The second sensitive word library contains a library of sensitive word variant lists, including various deformations, synonyms, near-synonyms, etc. of sensitive words. The computing node uses the second sensitive word library to detect each sub-text to find out whether the sub-text contains variant forms of these sensitive words. If the sub-text contains a variant form of a sensitive word, the variant and the sentence or fragment in which it is located are marked as sensitive word variant sentences.
[0125] The results of sensitive word sentences and sensitive word variant sentences are combined to generate the final detection results for each sub-text.
[0126] In step S4, all computing nodes use the same, latest online sensitive word detection model to ensure the consistency and accuracy of detection, and avoid the problem of inconsistent detection results caused by using different versions of models. By detecting sub-texts one by one, it is ensured that all parts of the entire text to be detected are checked and no sensitive content is missed.
[0127] The present invention is aimed at financial service enterprises, social media and network platforms, e-commerce, government and public sectors, etc., by dynamically generating stateless computing nodes and loading the latest online detection model of sensitive words from a shared online database, to provide real-time, accurate and scalable detection of sensitive words. For example, banks and financial institutions can use the present invention to monitor documents, application forms, etc. submitted by customers to ensure that they do not contain fraudulent or illegal information. Social media and network platforms can use the present invention to monitor the content posted by users in real time to prevent the occurrence of illegal and other bad information. E-commerce can use the present invention to check product descriptions and user comments to avoid false advertising, infringing content or illegal product information, etc.
[0128] In steps S1-S4, by segmenting the text to be detected into multiple sub-texts, it helps to reduce the burden on a single computing node, allowing the system to process larger data sets. The segmented sub-texts are placed in the detection queue, and the number of stateless computing nodes is dynamically adjusted according to the number of sub-texts. The computing resources are dynamically adjusted to match the actual task volume to ensure efficient use of computing power. The design of stateless computing nodes simplifies the expansion and maintenance of the system.
[0129] Connect all computing nodes to a shared online database and load the latest sensitive word detection model from it to ensure that all computing nodes use the same latest version of the model for detection, which improves the consistency and accuracy of detection. In addition, models trained based on real-time data can better cope with newly emerging sensitive words and reduce the risk of false positives and false negatives. Each computing node calls the sensitive word online detection model to detect the sub-texts in the detection queue and combines the detection results to form a final report. The parallel processing mechanism speeds up the overall detection speed while ensuring that the entire text to be detected is thoroughly checked. This effectively solves the problems of delays in sensitive word detection updates and unavailability under high concurrent requests in existing technologies.
[0130] like Figure 3 , which is a module schematic diagram of an online sensitive word detection device provided by an embodiment of the present invention.
[0131] The sensitive word online detection device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the sensitive word online detection device 100 may include a segmentation module 110, a generation module 120, a loading module 130 and a merging module 140. The module of the present invention may also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, and is stored in the memory of the electronic device.
[0132] In this embodiment, the functions of each module / unit are as follows:
[0133] The segmentation module 110 is used to receive a request for sensitive word detection on a text to be detected, obtain the text to be detected according to the request, and segment the text to be detected to obtain a first preset number of sub-texts;
[0134] A generating module 120, configured to store each subtext into a detection queue, dynamically generate a second preset number of computing nodes according to a first preset number of subtexts, wherein the computing nodes are stateless computing nodes that do not store any persistent information, and the second preset number is equal to or less than the first preset number;
[0135] A loading module 130 is used to establish a connection between the second preset number of computing nodes and a preset shared online database, and load the sensitive word online detection model in the preset shared online database to each computing node;
[0136] The merging module 140 is used to call the online sensitive word detection model of each computing node, read sub-texts from the detection queue in turn for detection, obtain the detection result of each computing node for at least one sub-text, and fuse the detection results corresponding to each sub-text to obtain the detection report of the text to be detected.
[0137] In one embodiment, the segmentation module 110 is specifically configured to:
[0138] Segment the text to be detected according to punctuation marks in the text to be detected to obtain at least one initial clause;
[0139] Each initial clause is segmented according to a preset dependency syntax to obtain a first preset number of subtexts.
[0140] In one embodiment, the segmentation module 110 is specifically configured to:
[0141] Segmenting the text to be detected to obtain multiple phrases, and marking the part of speech for each phrase;
[0142] The preset segmentation point prediction model is used to analyze the position and contextual relationship of each phrase after the part of speech is marked in the text to be detected, and the probability of each phrase being a segmentation point is obtained, and the end position of the phrase with a probability greater than a threshold is selected as the segmentation point;
[0143] The text to be detected is segmented based on the segmentation points to obtain a first preset number of sub-texts.
[0144] In one embodiment, the loading module 130 is specifically used to:
[0145] Constructing an initial database of a network attached storage type, and setting a directory structure and file naming rules for the initial database;
[0146] According to the directory structure and the file naming rule, the relevant data of the sensitive word online detection model is stored in the initial database to obtain the preset shared online database, wherein the relevant data includes a sensitive word list, a training data set and a model file.
[0147] In one embodiment, the loading module 130 is specifically used to:
[0148] Querying the timestamps of each sensitive word online detection model in the preset shared online database;
[0149] The sensitive word online detection model with the latest version of the timestamp is loaded into each computing node, and the sensitive word online detection model is a detection model that is trained based on real-time sensitive word data and updated in real time.
[0150] In one embodiment, the loading module 130 is specifically used to:
[0151] Collecting text data sets from a preset data source in real time, annotating and recording sensitive words in the text data sets to obtain a training data set, wherein the records include data sequence numbers of sensitive words, the included sensitive words, and the number of included sensitive words;
[0152] Dividing the training data set into a training set and a test set, and using the training set to train the initial detection model;
[0153] The test set is used to adjust the hyperparameters of the trained initial detection model. When the preset indicators of the trained initial detection model meet the preset requirements, the training is terminated to obtain the sensitive word online detection model.
[0154] In one embodiment, the loading module 130 is specifically used to:
[0155] When it is detected that the training of the online sensitive word detection model has been completed, a version number and a timestamp of the online sensitive word detection model are generated according to the time when the training has been completed;
[0156] The sensitive word online detection model, the version number and the timestamp of the sensitive word online detection model are packaged and stored in the preset shared online database.
[0157] like Figure 4 , which is a schematic diagram of the structure of an electronic device for implementing an online sensitive word detection method provided by an embodiment of the present invention.
[0158] In this embodiment, the electronic device 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13, which can be interconnected and communicated via a system bus. The memory 11 stores a sensitive word online detection program 10, and the sensitive word online detection program 10 can be executed by the processor 12. Figure 4 Only the electronic device 1 having components 11-13 and the sensitive word online detection program 10 is shown. It can be understood by those skilled in the art that Figure 4 The structure shown does not constitute a limitation on the electronic device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0159] Among them, the memory 11 includes a memory and at least one type of readable storage medium. The memory provides a cache for the operation of the electronic device 1; the readable storage medium may be a non-volatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 1; in other embodiments, the non-volatile storage medium may also be an external storage device of the electronic device 1, such as a plug-in hard disk equipped on the electronic device 1, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. In this embodiment, the readable storage medium of the memory 11 is generally used to store an operating system and various application software installed on the electronic device 1, such as storing the code of the sensitive word online detection program 10 in an embodiment of the present invention. In addition, the memory 11 may also be used to temporarily store various types of data that have been output or are to be output.
[0160] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices. In this embodiment, the processor 12 is used to run the program code stored in the memory 11 or process data, such as running the sensitive word online detection program 10.
[0161] The network interface 13 may include a wireless network interface or a wired network interface, and the network interface 13 is used to establish a communication connection between the electronic device 1 and a terminal (not shown in the figure).
[0162] Optionally, the electronic device 1 may further include a user interface, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0163] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0164] The sensitive word online detection program 10 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 12, it can achieve:
[0165] Receiving a request for sensitive word detection on a text to be detected, obtaining the text to be detected according to the request, and dividing the text to be detected into a first preset number of subtexts;
[0166] Storing each subtext in a detection queue, dynamically generating a second preset number of computing nodes according to a first preset number of subtexts, wherein the computing nodes are stateless computing nodes that do not store any persistent information, and the second preset number is equal to or less than the first preset number;
[0167] Establishing connections between the second preset number of computing nodes and a preset shared online database, and loading the sensitive word online detection model in the preset shared online database into each computing node;
[0168] The sensitive word online detection model of each computing node is called, and sub-texts are read from the detection queue in turn for detection, so as to obtain the detection result of each computing node for at least one sub-text, and the detection results corresponding to each sub-text are integrated to obtain the detection report of the text to be detected.
[0169] Specifically, the specific implementation method of the processor 12 for the above-mentioned sensitive word online detection program 10 can refer to Figure 2 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0170] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or non-volatile. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0171] The computer-readable storage medium stores a sensitive word online detection program 10, which can be executed by one or more processors. The specific implementation of the computer-readable storage medium of the present invention is basically the same as the above-mentioned sensitive word online detection method embodiments, and will not be described in detail here.
[0172] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0173] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0174] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0175] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0176] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0177] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0178] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention. If software tools or components other than those of the Company appear in the embodiments of the present application, they are only used for example and do not represent actual use.
Claims
1. A sensitive word online detection method, characterized in that: The method comprises: Receiving a request for sensitive word detection on a text to be detected, obtaining the text to be detected according to the request, and dividing the text to be detected into a first preset number of subtexts; Storing each subtext in a detection queue, dynamically generating a second preset number of computing nodes according to a first preset number of subtexts, wherein the computing nodes are stateless computing nodes that do not store any persistent information, and the second preset number is equal to or less than the first preset number; Establishing connections between the second preset number of computing nodes and a preset shared online database, and loading the sensitive word online detection model in the preset shared online database into each computing node; The sensitive word online detection model of each computing node is called, and sub-texts are read from the detection queue in turn for detection, so as to obtain the detection result of each computing node for at least one sub-text, and the detection results corresponding to each sub-text are integrated to obtain the detection report of the text to be detected.
2. The method for online sensitive word detection according to claim 1, characterized in that: The step of segmenting the to-be-detected text to obtain a first preset number of sub-texts includes: Segment the text to be detected according to punctuation marks in the text to be detected to obtain at least one initial clause; Each initial clause is segmented according to a preset dependency syntax to obtain a first preset number of subtexts.
3. The sensitive word online detection method according to claim 1, characterized in that: The step of segmenting the to-be-detected text to obtain a first preset number of sub-texts includes: Segmenting the text to be detected to obtain multiple phrases, and marking the part of speech for each phrase; The preset segmentation point prediction model is used to analyze the position and contextual relationship of each phrase after the part of speech is marked in the text to be detected, and the probability of each phrase being a segmentation point is obtained, and the end position of the phrase with a probability greater than a threshold is selected as the segmentation point; The text to be detected is segmented based on the segmentation points to obtain a first preset number of sub-texts.
4. The sensitive word online detection method according to claim 1, characterized in that: Before establishing the connection between the second preset number of computing nodes and the preset shared online database, the method further includes: Constructing an initial database of a network attached storage type, and setting a directory structure and file naming rules for the initial database; According to the directory structure and the file naming rules, the relevant data of the sensitive word online detection model is stored in the initial database to obtain the preset shared online database, wherein the relevant data includes a sensitive word list, a training data set and a model file.
5. The method for online sensitive word detection according to claim 1, characterized in that: The step of loading the sensitive word online detection model in the preset shared online database to each computing node includes: Querying the timestamps of each sensitive word online detection model in the preset shared online database; The online sensitive word detection model with the latest version of the timestamp is loaded into each computing node, and the online sensitive word detection model is a detection model that is trained based on real-time sensitive word data and updated in real time.
6. The method for online sensitive word detection according to claim 1, characterized in that: The sensitive word online detection model is obtained according to the following method, including: Collecting text data sets from a preset data source in real time, annotating and recording sensitive words in the text data sets to obtain a training data set, wherein the records include data sequence numbers of sensitive words, the included sensitive words, and the number of included sensitive words; Dividing the training data set into a training set and a test set, and using the training set to train the initial detection model; The test set is used to adjust the hyperparameters of the trained initial detection model. When the preset indicators of the trained initial detection model meet the preset requirements, the training is terminated to obtain the sensitive word online detection model.
7. The method for online sensitive word detection according to claim 6, characterized in that: The method further comprises: When it is detected that the training of the online sensitive word detection model has been completed, a version number and a timestamp of the online sensitive word detection model are generated according to the time when the training has been completed; The sensitive word online detection model, the version number and the timestamp of the sensitive word online detection model are packaged and stored in the preset shared online database.
8. A sensitive word online detection device, characterized in that: The device comprises: A segmentation module, configured to receive a request for sensitive word detection on a text to be detected, obtain the text to be detected according to the request, and segment the text to be detected to obtain a first preset number of sub-texts; A generation module, used to store each subtext into a detection queue, dynamically generate a second preset number of computing nodes according to a first preset number of subtexts, the computing nodes being stateless computing nodes that do not store any persistent information, the second preset number being equal to or less than the first preset number; A loading module, used to establish a connection between the second preset number of computing nodes and a preset shared online database, and load the sensitive word online detection model in the preset shared online database to each computing node; The merging module is used to call the online sensitive word detection model of each computing node, read the sub-texts from the detection queue in turn for detection, obtain the detection result of each computing node for at least one sub-text, and fuse the detection results corresponding to each sub-text to obtain the detection report of the text to be detected.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a sensitive word online detection program that can be executed by the at least one processor, and the sensitive word online detection program is executed by the at least one processor so that the at least one processor can execute the sensitive word online detection 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 a sensitive word online detection program, and the sensitive word online detection program can be executed by one or more processors to implement the sensitive word online detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Authenticating method of sensitive information in texts, electronic device and readable storage medium
CN108519970A
Data processing method, device and equipment and storage medium
CN112100379A
Text processing method and device, equipment and storage medium
CN113361260A
Sensitive word auditing method based on large language model, storage medium and electronic equipment
CN116720515A
Text segmentation method and device based on deep learning, equipment and medium
CN117011854A
Cited By
AI security fence implementation method, device and system
CN121279322A