Rule and deep learning-based multi-stage text irrigation recognition method and system, medium and product

By combining a multi-stage detection architecture with rules and deep learning, the accuracy and efficiency issues of text spam detection are solved, achieving efficient and accurate spam recognition, applicable to various scenarios such as social media, forums, and live streaming.

CN121859892APending Publication Date: 2026-04-14DATA SPACE RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-03
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing text spam detection technologies cannot simultaneously achieve detection accuracy, computational efficiency, and real-time performance, especially lacking effective means in handling Chinese word order disorder detection.

Method used

A multi-stage detection architecture is adopted, including preprocessing, fast screening based on preset rules, word order detection, and spam detection. By combining rules with deep learning, text spam recognition is carried out in a layered and progressive manner.

Benefits of technology

It achieves efficient and accurate text spam recognition, significantly improves detection efficiency, can identify multiple spam patterns, reduces false positives and false negatives, and meets real-time detection requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121859892A_ABST
    Figure CN121859892A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-stage text irrigation recognition method and system based on rules and deep learning, a medium and a product, and relates to the technical field of natural language processing, and the method comprises the steps: carrying out the preprocessing of a target recognition text, and obtaining an intermediate text; performing rapid screening on the intermediate text based on a preset rule, and judging whether the screening is passed or not; if not, it is judged that irrigation exists; if yes, performing disordered word order detection on the intermediate text to obtain a word order score; according to the word order score and a preset word order score threshold value, whether the word order disorder problem exists in the intermediate text or not is judged; if not, it is judged that irrigation does not exist; if yes, inputting the intermediate text into a preset irrigation detection model for irrigation detection to obtain an irrigation probability; judging whether the irrigation probability is greater than a preset probability threshold; if yes, judging that irrigation exists; if not, it is judged that irrigation does not exist. According to the method, the overall detection efficiency is remarkably improved, and efficient and accurate recognition of the text irrigation behavior is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a multi-stage text spam recognition method, system, medium, and product based on rules and deep learning. Background Technology

[0002] With the widespread adoption of the internet and mobile devices, communication methods such as social media, forums, short video bullet comments, and instant messaging have developed rapidly, leading to an explosive growth in user-generated content (UGC). However, a large amount of low-quality, meaningless, and even disruptive "spam" content has also emerged. This type of content is commonly found in comment sections, group chats, and posts, and takes the form of repetitive text, symbols, emoticons, randomly pieced-together meaningless characters, or sentences with disordered word order and lack of logic.

[0003] On social media platforms, spamming drowns out normal discussions, buries valuable information, and reduces user engagement. In real-time interactions such as live streaming and short videos, spamming disrupts the order of interaction and damages the community atmosphere. In e-commerce and customer service systems, spamming increases review costs and reduces processing efficiency. On search and Q&A platforms, it affects the quality of search results and damages the platform's credibility.

[0004] From an operational perspective, spam not only impacts the content ecosystem but also incurs additional costs in storage, bandwidth, and computing power. In high-concurrency environments, it increases server load and affects normal business response. For scenarios requiring manual review, an increase in spam will also increase the pressure and costs on the review team.

[0005] In industries such as finance, education, and healthcare, spamming not only affects user experience but can also lead to information delays, chaotic task allocation, and even business risks. In the field of public opinion monitoring, spamming can also be used to cover up sensitive events, dilute public attention, and affect information transparency and the accuracy of analysis.

[0006] Therefore, timely identification and filtering of spam content is of great value to both platforms and users. For users, effective spam detection ensures access to more valuable information and a cleaner communication environment; for platforms, it optimizes the community atmosphere, reduces operating costs, and mitigates the risk of malicious behavior disrupting order; and from a regulatory perspective, spam detection helps ensure the effectiveness and reliability of information dissemination, promoting a healthy online ecosystem.

[0007] As the online environment and user behavior evolve, spam tactics are shifting from simple repetition to more covert methods utilizing special characters, variant text, and cross-language mixing, making detection increasingly difficult. This trend demands that platforms possess more accurate, timely, and stable spam detection capabilities to cope with the ever-changing content environment. In the future, spam detection will not only be an operational tool for improving content quality but also a crucial capability for ensuring the long-term healthy development of the platform.

[0008] Currently, text spam detection technologies mainly include rule-based detection methods, traditional machine learning-based detection methods, and deep learning-based detection methods.

[0009] Rule-based detection methods identify spam behavior by using predefined rules such as matching repeated characters with regular expressions, counting word frequencies, and searching emoji dictionaries. While these methods are fast, completing detection in milliseconds, they heavily rely on manually defined rule sets. Their accuracy drops sharply when faced with circumvention strategies such as variant characters and mixed symbols, and they lack adaptability.

[0010] Traditional machine learning-based detection methods extract statistical features such as character frequency and word frequency distribution to train classifiers like SVM and random forests for judgment. However, this approach relies on manually designed shallow features, which cannot effectively capture deep semantic information in text. It also performs poorly when dealing with complex, spam content such as text with disordered word order, and the feature engineering process is cumbersome.

[0011] Deep learning-based detection methods, especially pre-trained language models like BERT, capture deep semantic features through the multi-head self-attention mechanism of the Transformer architecture. While these methods excel in identifying complex flooding patterns, they suffer from high computational complexity, with inference times typically ranging from hundreds of milliseconds to several seconds, making them unsuitable for real-time detection and prohibitively expensive to deploy.

[0012] The fundamental flaw in existing technologies lies in their inability to simultaneously achieve detection accuracy, computational efficiency, and real-time performance. Rule-based methods are fast but lack accuracy, deep learning methods are accurate but inefficient, and traditional machine learning methods perform poorly in both dimensions. More importantly, existing methods lack a hierarchical processing mechanism, applying the same processing strategy to all texts, which wastes computational resources and fails to employ the most suitable detection strategy for spam content of varying complexity.

[0013] Furthermore, existing technologies are insufficient in detecting disordered word order in Chinese, and there is a lack of effective statistical linguistic evaluation methods to identify meaningless texts constructed by shuffling word order and randomly combining words.

[0014] Therefore, a technical solution is needed that can intelligently select detection strategies based on the complexity of the text, leverage the advantages of various technical means through reasonable architecture design, avoid their respective limitations, and achieve a balance between accuracy, efficiency, and real-time performance. Summary of the Invention

[0015] To address the technical problems existing in the background art, this invention proposes a multi-stage text spam recognition method, system, medium, and product based on rules and deep learning.

[0016] In a first aspect, the present invention proposes a multi-stage text flooding identification method and system based on rules and deep learning, comprising: Preprocess the target recognition text to obtain intermediate text; The intermediate text is quickly screened based on preset rules, and it is determined whether the screening passes. If the screening fails, it is determined that there is spam. If the screening passes, the intermediate text is checked for disordered word order, and a word order score is obtained. Based on the word order score and the preset word order score threshold, determine whether there is a word order disorder problem in the intermediate text; if not, it is determined that there is no spam; if so, input the intermediate text into the preset spam detection model for spam detection to obtain the spam probability; determine whether the spam probability is greater than the preset probability threshold; if so, it is determined that there is spam; if not, it is determined that there is no spam.

[0017] Preferably, the preprocessing includes character standardization, special symbol cleanup, text format normalization, and length pre-screening.

[0018] Preferably, the preset rules include a repeated character detection rule, a pure emoji detection rule, and a word repetition rate detection rule executed sequentially. If any one of the rules is met, it is determined that there is spam.

[0019] Preferably, the intermediate text is subjected to rapid screening based on preset rules, and a determination is made as to whether the screening passes. Specifically, this includes: The middle text is analyzed using regular expressions to detect consecutive repeating characters, and the result of the consecutive repeating character recognition is obtained. If the result of the consecutive repeating character recognition matches the repeating character detection rules, the screening is deemed to have failed. When the results of continuous repeated character recognition do not meet the repeated character detection rules, the intermediate text is subjected to pure emoji content detection based on the pre-established emoji dictionary to obtain the pure emoji detection result. If the pure emoji detection result meets the pure emoji detection rules, the screening is deemed to have failed. When the pure emoji detection result does not meet the pure emoji detection rules, the intermediate text is segmented to obtain multiple first word units, and the frequency of each first word unit is counted. If the frequency of each first word unit meets the word repetition rate detection rules, the screening is deemed to have failed; if the frequency of each first word unit does not meet the word repetition rate detection rules, the screening is deemed to have passed.

[0020] Preferably, disordered word order is detected in the intermediate text to obtain a word order score; The N-gram language model is used to detect disordered word order in the intermediate text and obtain word order scores.

[0021] Preferably, an N-gram language model is used to detect disordered word order in the intermediate text to obtain a word order score, specifically including: Lexical segmentation of the intermediate text yields multiple second lexical units; Stop word filtering is performed on multiple second vocabulary units, and the filtered second vocabulary units are used to form a valid vocabulary sequence. Traverse all n-gram combinations in the effective vocabulary sequence and use a pre-trained N-gram language model to obtain the conditional probability value of each n-gram combination; The conditional probability values ​​of all n-gram combinations are corrected using a one-plus smoothing technique to obtain the log probability values ​​of all n-gram segments. The average log probability is obtained by summing the log probabilities of all n-gram segments and then dividing by the length of the middle text. The average log probability is then used as the word order score.

[0022] Preferably, in the process of determining whether there is a word order disorder problem in the intermediate text, when the word order score is lower than a preset word order score threshold, it is determined that there is a word order disorder problem.

[0023] Preferably, when a word order disorder problem is determined, the method further includes: marking the intermediate text as having a word order disorder.

[0024] Preferably, the irrigation detection model is an irrigation detection model based on the BERT architecture.

[0025] Preferably, the watering detection model uses the Transformer Encoder architecture as the encoder and a fully connected layer and a softmax function as the output layer; wherein, the encoder is composed of multiple identical layers stacked together, and each layer contains a self-attention mechanism and a feedforward neural network.

[0026] Preferably, the flooding detection model is first pre-trained on a large-scale Chinese corpus, and then fine-tuned using an annotated flooding detection dataset. The optimization objective during the fine-tuning process is the binary classification cross-entropy loss function.

[0027] Preferably, the binary classification cross-entropy loss function is: ; In the formula, This represents the cross-entropy loss function for binary classification. For the sample size, For the first The true labels of the training samples The output of the irrigation detection model The predicted probability of watering in the training samples.

[0028] Preferably, the intermediate text is input into a preset flooding detection model for flooding detection to obtain the flooding probability, specifically including: The intermediate text undergoes secondary preprocessing to obtain word vectors, position vectors, and segment vectors for each token. The secondary preprocessing includes word segmentation and the addition of special markers [CLS] and [SEP]. The word vector, position vector, and segment vector of each token are summed element by element to obtain the input vector of each token. The input vector of each token is fed into the BERT encoder for encoding to obtain the context representation vector of each token; Extract the context representation vector corresponding to the token with the special label [CLS] as the overall text representation, and obtain the flooding probability after passing through a fully connected layer and a softmax function.

[0029] Preferably, after determining whether or not spam exists, the method further includes: labeling the target text with spam tags; wherein the spam tags are divided into two types: non-spam and spam.

[0030] Preferably, after labeling the target recognition text with watermarks, the method further includes: Generate a watering inspection report.

[0031] Secondly, this invention also proposes a multi-stage text flooding recognition system based on rules and deep learning, comprising: The preprocessing module is used to preprocess the target recognition text to obtain intermediate text; The quick screening module is used to quickly screen intermediate text based on preset rules and determine whether the screening passes; if the screening fails, it is determined that there is spam. The disordered word order detection module is used to detect disordered word order in the intermediate text that has passed the screening and obtain a word order score; based on the word order score and the preset word order score threshold, it is determined whether there is a disordered word order problem in the intermediate text. The spam detection module is used to determine that there is no spam if there are no word order problems in the intermediate text; Alternatively, if there is a word order disorder problem in the intermediate text, the intermediate text is input into a preset spam detection model to detect spam and obtain the spam probability; it is then determined whether the spam probability is greater than a preset probability threshold; if so, spam is determined to exist; otherwise, spam is determined not to exist.

[0032] Thirdly, the present invention also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method described in any one of the first aspects.

[0033] Fourthly, a computer program product includes a computer program that, when executed by a processor, implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method as described in any one of the first aspects.

[0034] The proposed multi-stage text spam detection method, system, medium, and product based on rules and deep learning in this invention adopts a multi-stage detection architecture. Following an increasing order of detection complexity, the spam detection process is decomposed into four interrelated processes: preprocessing, rapid screening based on preset rules, word order detection, and spam detection. This employs a funnel-shaped, hierarchical, progressive detection approach. The rapid screening layer quickly filters out obvious spam content, the word order detection layer filters out text with abnormal word order, and the spam detection layer accurately verifies candidate samples. This approach ensures comprehensive detection while avoiding deep computation on all texts through an early screening mechanism, significantly improving overall detection efficiency and achieving efficient and accurate identification of text spam behavior. Attached Figure Description

[0035] Figure 1 This is a flowchart illustrating a rule-based and deep learning-based multi-stage text flooding identification method in one embodiment of the present invention. Detailed Implementation

[0036] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0037] Firstly, referring to Figure 1 This invention proposes a multi-stage text flooding identification method and system based on rules and deep learning, comprising: Preprocess the target recognition text to obtain intermediate text; The intermediate text is quickly screened based on preset rules, and it is determined whether the screening passes. If not, that is, the screening fails, it is determined that there is spam. If yes, that is, the screening passes, the intermediate text is checked for disordered word order, and a word order score is obtained. According to the word order score and the preset word order score threshold, determine whether there is a problem of chaotic word order in the intermediate text; if not, determine that the target recognition text is a normal text and determine that there is no watering; if so, input the intermediate text into the preset watering detection model for watering detection to obtain the watering probability; Judge whether the watering probability is greater than the preset probability threshold; if so, determine that there is watering; if so, determine that there is no watering and it is a normal text.

[0038] The present invention adopts a multi-stage detection architecture. According to the increasing order of detection complexity, the watering detection process is decomposed into four interrelated processes: preprocessing, rapid screening based on preset rules, word order detection, and watering detection, and a "funnel-type" hierarchical progressive detection is carried out. The rapid screening layer quickly filters out obvious watering content, the word order detection layer screens text with abnormal word order, and the watering detection layer accurately verifies candidate samples, which not only ensures the comprehensiveness of detection, but also avoids deep calculation of all texts through an early screening mechanism, significantly improving the overall detection efficiency and achieving efficient and accurate identification of text watering behavior.

[0039] In this embodiment, the preprocessing includes character standardization processing, special symbol cleaning, text format normalization, and length pre-screening.

[0040] Among them, in the process of character standardization processing, the OpenCC open-source library is used to implement the conversion from traditional Chinese to simplified Chinese. Based on Unicode standardization technology, through dictionary mapping and context analysis, it can accurately handle the many-to-one and one-to-many traditional and simplified conversion relationships, effectively solving the ambiguous conversion problems that cannot be handled by traditional character-level mapping tables (such as "后" and "後", "钟" and "锺", etc.). At the same time, the full-width and half-width characters are normalized and converted to ensure the consistency of character formats.

[0041] In the process of special symbol cleaning, through predefined symbol cleaning rules, punctuation marks, digital symbols, special Unicode characters, etc. that may interfere with detection are identified and processed. This process uses pattern matching technology and supports custom symbol filtering rules. Among them, the predefined symbol cleaning rules are character pattern matching rules based on regular expression technology.

[0042] In the process of text format normalization, the case format is unified, redundant blank characters are removed, line breaks and tab characters in the text are processed, and the unity of text format is ensured.

[0043] Specifically, the case of characters is unified using the built-in string processing method in Python to convert English characters into lowercase forms uniformly, eliminating the problem of matching failure caused by case differences and improving the matching accuracy of subsequent processing links.

[0044] During the length pre-screening process, the length of the input text is checked, and text that is too short (e.g., less than 3 characters) or too long is specially marked to provide reference information for subsequent modules.

[0045] This embodiment can detect and process inconsistencies such as traditional Chinese characters, special symbols, and inconsistent capitalization in the target text, including converting traditional Chinese to simplified Chinese, removing irrelevant special symbols, and unifying capitalization in English, to ensure that subsequent detection algorithms run on a consistent text format.

[0046] The preset rules in this embodiment include: duplicate character detection rules, word repetition rate detection rules, and pure emoji detection rules.

[0047] Among them, the duplicate character detection rule can effectively identify obvious character repetition patterns such as "hahahaha" and "...", solving the problem that traditional methods struggle to quickly identify spam containing duplicate characters. The word repetition rate detection rule, by analyzing the proportion of high-frequency words, can accurately identify meaningless content constructed through repeated words, filling the technical gap in semantic-level duplicate detection. The pure emoji detection rule is specifically designed for emoji spamming behavior, achieving accurate recognition by establishing a complete emoji dictionary, effectively solving the problem of detecting pure emoji content.

[0048] In this embodiment, the execution priority order of the preset rules is as follows: duplicate character detection rule, pure emoji detection rule, and word repetition rate detection rule. If any rule is hit, satisfied, or conforms to, it is directly determined that there is spam.

[0049] This embodiment employs a priority execution strategy to achieve millisecond-level rapid identification.

[0050] In this embodiment, the intermediate text is quickly screened based on preset rules, and it is determined whether the screening passes. Specifically, this includes: The middle text is analyzed using regular expressions to detect consecutive repeating characters, and the result of the consecutive repeating character recognition is obtained. If the result of the consecutive repeating character recognition matches the repeating character detection rules, the screening is deemed to have failed. When the results of continuous repeated character recognition do not meet the repeated character detection rules, the intermediate text is subjected to pure emoji content detection based on the pre-established emoji dictionary to obtain the pure emoji detection result. If the pure emoji detection result meets the pure emoji detection rules, the screening is deemed to have failed. When the pure emoji detection result does not meet the pure emoji detection rules, the intermediate text is segmented to obtain multiple first word units, and the frequency of each first word unit is counted. If the frequency of each first word unit meets the word repetition rate detection rules, the screening is deemed to have failed; if the frequency of each first word unit does not meet the word repetition rate detection rules, the screening is deemed to have passed.

[0051] When the number of consecutive repeated characters in the consecutive repeated character recognition result is greater than the consecutive repeated character threshold in the repeated character detection rule, it means that the consecutive repeated character recognition result conforms to the repeated character detection rule.

[0052] In this embodiment, the pure emoji detection result includes either pure emoji content or non-pure emoji content. When the pure emoji detection result is pure emoji content, it indicates that the continuous repeating character recognition result conforms to the repeating character detection rule.

[0053] In each vocabulary unit, when the proportion of vocabulary units that appear more frequently than a preset frequency to the total number of vocabulary types is greater than a preset threshold, it indicates that the frequency of each vocabulary unit meets the vocabulary repetition rate detection rules.

[0054] In this embodiment, disordered word order is detected in the intermediate text to obtain a word order score; The N-gram language model is used to detect disordered word order in the intermediate text and obtain word order scores.

[0055] The word order disorder detection method based on the N-gram language model proposed in this embodiment is based on the principles of statistical linguistics. It evaluates the rationality of word order by calculating the average log probability of the text, which can eliminate the interference of irrelevant words and focus on the collocation rationality of core semantic words, effectively identifying hidden spamming methods such as word order disorder.

[0056] Specifically, the N-gram language model is used to detect disordered word order in the intermediate text and obtain a word order score, which includes: Lexical segmentation of the intermediate text yields multiple second lexical units; Stop word filtering is performed on multiple second vocabulary units, and the filtered second vocabulary units are used to form a valid vocabulary sequence. Traverse all n-gram combinations in the effective vocabulary sequence and use a pre-trained N-gram language model to obtain the conditional probability value of each n-gram combination; The conditional probability values ​​of all n-gram combinations are corrected using a one-plus smoothing technique to obtain the log probability values ​​of all n-gram segments. The average log probability is obtained by summing the log probabilities of all n-gram segments and then dividing by the length of the middle text. The average log probability is then used as the word order score.

[0057] In the process of lexical segmentation, first call the jieba Chinese word segmentation component to segment the input intermediate text, and decompose the continuous string into independent lexical units.

[0058] In the process of stop word filtering, load the predefined stop word list, filter out functional words such as "de", "le", "shi" etc. that contribute less to semantics, and retain the core semantic words to form a valid word sequence.

[0059] Among them, the N-gram language model is based on the Markov assumption, believing that the occurrence probability of the current word only depends on the previous n - 1 words. For the word sequence , its joint probability is expressed as: ; In the formula, represents the word sequence, represents the joint probability of the word sequence, represents the th word in the word sequence, i = 1, 2,..., m, where m represents the total number of words in the word sequence; The N-gram language model can capture the grammar rules and lexical collocation habits of normal Chinese language, so as to identify abnormal texts that do not conform to language norms.

[0060] Among them, for a word sequence , the conditional probability is: ; In the formula, represents the joint probability of the entire word sequence, represents the number of occurrences of the corresponding word sequence in the training corpus, n represents the n words before the i-th word, and n < m.

[0061] This embodiment uses the maximum likelihood estimation method to calculate the conditional probability, and estimates the probability distribution by counting the occurrence frequencies of n-grams in the training corpus. This method based on large-scale corpus statistics can learn rich language patterns and effectively distinguish normal expressions and randomly pieced text fragments.

[0062] To avoid the zero probability problem caused by data sparsity, add-one smoothing is adopted. Among them, the log probability value after add-one smoothing is: ; In the formula, represents the log probability value after add-one smoothing, represents the size of the vocabulary, [[ID=5,1]] represents the number of occurrences of the corresponding word sequence in the training corpus.

[0063] This embodiment uses the average logarithmic probability of the input text as the word order score, which reflects the degree to which the text conforms to normal language patterns. The word order score is as follows: ; In the formula, For text length, Indicates word order score.

[0064] In one specific embodiment, the word order scoring threshold When the word order score is lower than the word order score threshold, it is judged as word order disorder.

[0065] In this embodiment, the disordered word order detection based on the N-gram language model adopts vectorized computation optimization, and the time for a single detection is controlled within the range of 10-50 milliseconds. It supports the parallel processing of batch texts and effectively improves the detection efficiency.

[0066] In a further embodiment, in the process of determining whether there is a word order disorder problem in the intermediate text, when the word order score is lower than a preset word order score threshold, it is determined that there is a word order disorder problem; when the word order score is equal to or higher than the preset word order score threshold, it is determined that there is no word order disorder problem, that is, it is normal text and it is determined that there is no spam.

[0067] In a further embodiment, when a word order disorder problem is determined to exist, the method further includes: marking the intermediate text as word order disordered.

[0068] After marking the intermediate text as having disordered word order, the method also includes: outputting detection labels for disordered word order to facilitate the generation of subsequent detection reports and the analysis of the reasons for spam.

[0069] Among them, when the word order score is higher than the preset word order score threshold, it indicates that the text conforms to the grammatical rules and vocabulary collocation habits of normal Chinese language, and it is determined that there is no word order disorder problem. If it is determined that there is no word order disorder, the target text is directly output as normal text, indicating that there is no padding, and the detection process ends.

[0070] The threshold in this embodiment is determined through validation set optimization and is typically set between -8.5 and -10.0.

[0071] The irrigation detection model in this embodiment is an irrigation detection model based on the BERT architecture.

[0072] The water-filling detection model based on the BERT architecture in this embodiment uses the BERT encoder as the encoder and fully connected layers and a softmax function as the output layer. The encoder consists of multiple identical layers stacked together, each layer containing a self-attention mechanism and a feedforward neural network. Specifically, BERT is composed of multiple Transformer Encoders stacked layer by layer.

[0073] Among them, the BERT encoder models the semantic associations between words through a multi-head self-attention mechanism: the multi-head attention mechanism captures semantic relationships at different levels by computing multiple attention heads in parallel.

[0074] This embodiment uses the BERT architecture as the base model for the flooding detection model, leveraging its powerful bidirectional contextual understanding capabilities to capture the deep semantic features of the text.

[0075] In this embodiment, the BERT-based flooding detection model is first pre-trained on a large-scale Chinese corpus, and then fine-tuned using a flooding detection dataset labeled with flooding tags. During fine-tuning, the optimization objective is the binary cross-entropy loss function. The Adam optimizer and a linear learning rate scheduler are used to optimize the flooding detection model, and grid search is used to find the optimal model parameters. The optimal parameters for this embodiment are set as follows: Train_Batch_Size=128; Learning_rate=7e-5; max_seq_length=256; num_train_epochs=3; warmup_ratio=0.01; seed=42; data_seed=42.

[0076] The binary classification cross-entropy loss function is: ; In the formula, This represents the cross-entropy loss function for binary classification. For the sample size, For the first The true labels of the training samples The output of the irrigation detection model The predicted probability of watering in the training samples.

[0077] In one specific embodiment, during the fine-tuning process, the flooding detection dataset is randomly divided into a training set, a validation set, and a test set. The BERT-based flooding detection model is then trained, validated, and tested sequentially using these sets. The training set : validation set : test set ratio is: .

[0078] The specific statistical information of the irrigation detection dataset is shown in Table 1.

[0079] Table 1 The flooding detection model based on the BERT architecture was tested using a test set, and the test results are shown in Table 2.

[0080] Table 2

[0081] The waterlogging detection model based on the BERT architecture proposed in this embodiment has high detection accuracy.

[0082] In this embodiment, the intermediate text is input into a preset flooding detection model for flooding detection to obtain the flooding probability, specifically including: The intermediate text undergoes secondary preprocessing to obtain word vectors, position vectors, and segment vectors for each token. The secondary preprocessing includes word segmentation and the addition of special markers [CLS] and [SEP]. The word vector, position vector, and segment vector of each token are summed element by element to obtain the input vector of each token. The input vector of each token is fed into the BERT encoder for encoding to obtain the context representation vector of each token; Extract the context representation vector corresponding to the token with the special label [CLS] as the overall text representation, and obtain the flooding probability after passing through a fully connected layer and a softmax function.

[0083] The probability of watering is: ; In the formula, Indicates the probability of flooding. The text is represented as a vector. , , , These are the parameters for the classification layer.

[0084] When the probability output by the BERT-based spam detection model exceeds a set probability threshold (usually 0.5-0.7), the intermediate text is determined to be spam content.

[0085] This embodiment uses deep semantic analysis to understand the true semantic intent of the text, effectively distinguishing between text with disordered word order but still having practical meaning and purely meaningless spam content.

[0086] Among them, the irrigation detection dataset includes irrigation samples and normal samples. The irrigation samples are constructed by an artificial construction method. The construction method of the irrigation samples is a random combination of common Chinese characters, rare Chinese characters, common Chinese words, English letters and numbers. The normal samples are classification data from CBS-News and Toutiao and some non-compliant data. If the sample is an irrigation sample, the label value of the sample is set to 1, otherwise the label value of the sample is set to 0.

[0087] In one specific embodiment, the irrigation sample data is as follows: {"query": "Net 6a wheat string fishing pull b Shangtang Road Intersection Hall惦街跋搂侵息何曼骑袁羔s building face bead twist gravel ridge # Lvchuan <托恳蕴算3 roll general anise) craftsman sitting oath hook hectare", "label": 1}; {"query": "Regulations on the Use of Civil Aviation Airport Runyu 2 bowl friends <1 class刁般酷", "label": 1}; The normal sample data is as follows: {"query": "If you were the village head, how would you lead everyone to get rich?", "label": 0}; {"query": "Is the Evergrande and Shanghai SIPG without a picturesque frontcourt attack the Chinese Super League football we want?", "label": 0}.

[0088] In a further embodiment, after determining the existence or non-existence of irrigation, it further includes: marking an irrigation label for the target recognition text; among them, the irrigation label is divided into two types: non-irrigation and irrigation, and the detection process is ended.

[0089] After marking the irrigation label for the target recognition text, it further includes: Generating an irrigation detection report.

[0090] This embodiment can integrate and process the multi-stage detection results.

[0091] In one specific embodiment, the irrigation detection report includes the original target recognition text, irrigation label and specific triggering reasons.

[0092] In a further specific embodiment, the irrigation detection report includes the original target recognition text, irrigation label, specific triggering reasons and related feature words.

[0093] For example, when the continuous repeated character recognition result conforms to the repeated character detection rule, the specific triggering reason is a high text repetition ratio; when the pure emoji detection result conforms to the pure emoji detection rule, the specific triggering reason is that the emoji is meaningless; when the frequency of each lexical unit appears conforms to the lexical repetition rate detection rule, the specific triggering reason is lexical repetition type irrigation.

[0094] Secondly, this invention also proposes a multi-stage text flooding recognition system based on rules and deep learning, comprising: The preprocessing module is used to preprocess the target recognition text to obtain intermediate text; The quick screening module is used to quickly screen intermediate text based on preset rules and determine whether the screening passes; if the screening fails, it is determined that there is spam. The disordered word order detection module is used to detect disordered word order in the intermediate text that has passed the screening and obtain a word order score; based on the word order score and the preset word order score threshold, it is determined whether there is a disordered word order problem in the intermediate text. The spam detection module is used to determine that there is no spam when there is no word order disorder in the intermediate text; or, when there is word order disorder in the intermediate text, the intermediate text is input into a preset spam detection model to perform spam detection and obtain the spam probability; it is then determined whether the spam probability is greater than a preset probability threshold; if so, spam is determined to exist.

[0095] The preprocessing in this embodiment includes character standardization, special symbol cleanup, text format normalization, and length pre-screening.

[0096] The preset rules include repeating character detection rules, pure emoji detection rules, and word repetition rate detection rules, which are executed sequentially. If any of these rules are met, it is determined that there is spam.

[0097] In this embodiment, the process of quickly screening the intermediate text based on preset rules and determining whether the screening passes includes: The middle text is analyzed using regular expressions to detect consecutive repeating characters, and the result of the consecutive repeating character recognition is obtained. If the result of the consecutive repeating character recognition matches the repeating character detection rules, the screening is deemed to have failed. When the results of continuous repeated character recognition do not meet the repeated character detection rules, the intermediate text is subjected to pure emoji content detection based on the pre-established emoji dictionary to obtain the pure emoji detection result. If the pure emoji detection result meets the pure emoji detection rules, the screening is deemed to have failed. When the pure emoji detection result does not meet the pure emoji detection rules, the intermediate text is segmented to obtain multiple first word units, and the frequency of each first word unit is counted. If the frequency of each first word unit meets the word repetition rate detection rules, the screening is deemed to have failed; if the frequency of each first word unit does not meet the word repetition rate detection rules, the screening is deemed to have passed.

[0098] The process of disordered word order detection in this embodiment includes: using an N-gram language model to detect disordered word order in the intermediate text and obtaining a word order score; Specifically, the N-gram language model is used to detect disordered word order in the intermediate text and obtain a word order score, which includes: Lexical segmentation of the intermediate text yields multiple second lexical units; Stop word filtering is performed on multiple second vocabulary units, and the filtered second vocabulary units are used to form a valid vocabulary sequence. Traverse all n-gram combinations in the effective vocabulary sequence and use a pre-trained N-gram language model to obtain the conditional probability value of each n-gram combination; The conditional probability values ​​of all n-gram combinations are corrected using a one-plus smoothing technique to obtain the log probability values ​​of all n-gram segments. The average log probability is obtained by summing the log probabilities of all n-gram segments and then dividing by the length of the middle text. The average log probability is then used as the word order score.

[0099] In determining whether there is a word order disorder problem in the intermediate text, if the word order score is lower than the preset word order score threshold, it is determined that there is a word order disorder problem; if the word order score is equal to or higher than the preset word order score threshold, it is determined that there is no word order disorder problem, that is, it is normal text and there is no spam.

[0100] When a word order disorder is detected, the method also includes marking the intermediate text as having a word order disorder.

[0101] The irrigation detection model in this embodiment is an irrigation detection model based on the BERT architecture.

[0102] The water flooding detection model uses the Transformer Encoder architecture as the encoder and a fully connected layer and a softmax function as the output layer. The encoder consists of multiple identical layers stacked together, each containing a self-attention mechanism and a feedforward neural network.

[0103] In this embodiment, the spam detection model is first pre-trained on a large-scale Chinese corpus, and then fine-tuned using a spam detection dataset labeled with spam tags. The optimization objective during the fine-tuning process is a binary classification cross-entropy loss function. Specifically, spam tags use 0 to represent non-spam and 1 to represent spam.

[0104] The intermediate text is input into a preset flooding detection model for flooding detection to obtain the flooding probability, specifically including: The intermediate text undergoes secondary preprocessing to obtain word vectors, position vectors, and segment vectors for each token. The secondary preprocessing includes word segmentation and the addition of special markers [CLS] and [SEP]. The word vector, position vector, and segment vector of each token are summed element by element to obtain the input vector of each token. The input vector of each token is fed into the BERT encoder for encoding to obtain the context representation vector of each token; Extract the context representation vector corresponding to the token with the special label [CLS] as the overall text representation, and obtain the flooding probability after passing through a fully connected layer and a softmax function.

[0105] In this embodiment, it also includes a generation module, which is used to generate a spam tag according to the rules or conditions triggered when it is determined that spam exists.

[0106] In this embodiment, after the generation module marks the target identified text with a spam tag, it is also used to generate a spam detection report.

[0107] In summary, this invention employs an innovative multi-stage progressive detection architecture. Preprocessing is performed through a preprocessing module, followed by the collaborative work of three modules: a fast screening module based on preset rules, a disordered word order detection module based on N-gram language, and a flooding detection module based on the BERT architecture. This effectively solves the problem of traditional single-method detection methods being unable to balance accuracy and efficiency. The core advantage of this architecture design lies in its layered processing according to increasing detection complexity, fully leveraging the advantages of various technologies while avoiding their limitations. The fast screening module based on preset rules serves as the first line of defense, capable of identifying obvious spam content within milliseconds and directly filtering out approximately 60-70% of typical spam texts. The disordered word order detection module based on the N-gram language module serves as an intermediate filtering layer, evaluating the rationality of word order through statistical linguistics methods to further filter out candidate texts with abnormal word order. The spam detection module based on the BERT architecture serves as the final verification layer, performing deep semantic analysis only on a small number of texts that have passed the first two stages of filtering. This "funnel-shaped" architecture design ensures that computing resources are mainly concentrated on texts that truly require in-depth analysis, avoiding unnecessary deep calculations on a large amount of obviously spam content. While maintaining high accuracy, it improves the overall detection efficiency by 3-5 times.

[0108] Regarding detection accuracy, as shown in Table 2, the overall accuracy of this invention reaches 99.71%, recall reaches 98.31%, and F1 score reaches 99.01%, significantly outperforming existing single detection methods. The multi-stage architecture in this invention, through the complementary advantages of different technical means, can identify various flooding patterns ranging from simple repetition to complex semantic confusion, effectively reducing false positives and false negatives.

[0109] In terms of real-time performance, the average response time of this invention is controlled within 449 milliseconds, with the fastest response time being only 63 milliseconds, which can meet the real-time detection requirements of high-concurrency, large-scale platforms. The hierarchical processing strategy improves computational efficiency several times compared to solutions that directly use deep learning models, while the memory usage is only 4GB, achieving efficient resource utilization.

[0110] Moreover, this embodiment uses the ONNX format for deployment, supports CPU and GPU inference, greatly improves the overall detection efficiency, and can effectively identify various complex spam patterns, providing reliable technical support for content moderation.

[0111] Thirdly, the present invention also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method described in any one of the first aspects.

[0112] Fourthly, a computer program product includes a computer program that, when executed by a processor, implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method as described in any one of the first aspects.

[0113] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A multi-stage text flooding identification method based on rules and deep learning, characterized in that, include: Preprocess the target recognition text to obtain intermediate text; The intermediate text is quickly screened based on preset rules, and it is determined whether the screening passes. If not, it is determined that there is spam. If so, the intermediate text is checked for disordered word order and a word order score is obtained. Based on the word order score and the preset word order score threshold, determine whether there is a word order disorder problem in the intermediate text; if not, it is determined that there is no spam; if so, the intermediate text is input into the preset spam detection model for spam detection to obtain the spam probability. Determine if the probability of spamming is greater than a preset probability threshold; if yes, determine that spamming exists; otherwise, determine that spamming does not exist.

2. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, Preprocessing includes character normalization, special character cleanup, text format normalization, and length pre-screening.

3. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, The preset rules include repeating character detection rules, pure emoji detection rules, and word repetition rate detection rules, which are executed sequentially. If any of these rules are met, it is determined that there is spam. Preferably, the intermediate text is subjected to rapid screening based on preset rules, and a determination is made as to whether the screening passes. Specifically, this includes: The middle text is analyzed using regular expressions to detect consecutive repeating characters, and the result of the consecutive repeating character recognition is obtained. If the result of the consecutive repeating character recognition matches the repeating character detection rules, the screening is deemed to have failed. When the results of continuous repeated character recognition do not meet the repeated character detection rules, the intermediate text is subjected to pure emoji content detection based on the pre-established emoji dictionary to obtain pure emoji detection results. If the pure emoji detection result meets the pure emoji detection rules, the screening is deemed to have failed. When the pure emoji detection result does not meet the pure emoji detection rules, the intermediate text is segmented to obtain multiple first word units, and the frequency of each first word unit is counted. If the frequency of each first word unit meets the word repetition rate detection rules, the screening is deemed to have failed; if the frequency of each first word unit does not meet the word repetition rate detection rules, the screening is deemed to have passed.

4. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, The intermediate text is subjected to disordered word order detection to obtain a word order score; An N-gram language model is used to detect disordered word order in the intermediate text and obtain word order scores. Preferably, an N-gram language model is used to detect disordered word order in the intermediate text to obtain a word order score, specifically including: Lexical segmentation of the intermediate text yields multiple second lexical units; Stop word filtering is performed on multiple second vocabulary units, and the filtered second vocabulary units are used to form a valid vocabulary sequence. Traverse all n-gram combinations in the effective vocabulary sequence and use a pre-trained N-gram language model to obtain the conditional probability value of each n-gram combination; The conditional probability values ​​of all n-gram combinations are corrected using a one-plus smoothing technique to obtain the log probability values ​​of all n-gram segments. The average log probability is obtained by summing the log probabilities of all n-gram segments and then dividing by the length of the middle text. The average log probability is then used as the word order score.

5. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, In determining whether there is a word order disorder problem in the intermediate text, if the word order score is lower than the preset word order score threshold, it is determined that there is a word order disorder problem; if the word order score is equal to or higher than the preset word order score threshold, it is determined that there is no word order disorder problem. Preferably, when a word order disorder problem is determined, the method further includes: marking the intermediate text as having a word order disorder.

6. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, The irrigation detection model is based on the BERT architecture. Preferably, the watering detection model uses a BERT encoder as the encoder and a fully connected layer and a softmax function as the output layer; wherein, the encoder is composed of multiple identical layers stacked together, and each layer contains a self-attention mechanism and a feedforward neural network; Preferably, the irrigation detection model is fine-tuned using a labeled irrigation detection dataset, and the optimization objective during the fine-tuning process is a binary classification cross-entropy loss function; Preferably, the binary classification cross-entropy loss function is: ; In the formula, This represents the cross-entropy loss function for binary classification. For the sample size, For the first The true labels of the training samples The output of the irrigation detection model The predicted probability of flooding in the training samples; Preferably, the intermediate text is input into a preset flooding detection model for flooding detection to obtain the flooding probability, specifically including: The intermediate text undergoes secondary preprocessing to obtain word vectors, position vectors, and segment vectors for each token. The secondary preprocessing includes word segmentation and the addition of special markers [CLS] and [SEP]. The word vector, position vector, and segment vector of each token are summed element by element to obtain the input vector of each token. The input vector of each token is fed into the BERT encoder for encoding to obtain the context representation vector of each token; Extract the context representation vector corresponding to the token with the special label [CLS] as the overall text representation, and obtain the flooding probability after passing through a fully connected layer and a softmax function.

7. The multi-stage text flooding identification method based on rules and deep learning according to claim 1, characterized in that, After determining whether or not spam exists, the process also includes: labeling the target text with spam tags; whereby spam tags are divided into two types: non-spam and spam. Preferably, after labeling the target recognition text with watermarks, the method further includes: Generate a watering inspection report.

8. A multi-stage text spam recognition system based on rules and deep learning, characterized in that, include: The preprocessing module is used to preprocess the target recognition text to obtain intermediate text; The quick screening module is used to quickly screen intermediate text based on preset rules and determine whether the screening passes. If the screening fails, it is determined that there is spam. The disordered word order detection module is used to detect disordered word order in the intermediate text that has passed the screening and obtain a word order score; based on the word order score and the preset word order score threshold, it is determined whether there is a disordered word order problem in the intermediate text. The spam detection module is used to determine that there is no spam when there is no word order disorder in the intermediate text; or, when there is word order disorder in the intermediate text, the intermediate text is input into a preset spam detection model to detect spam and obtain the spam probability; it is then determined whether the spam probability is greater than a preset probability threshold; if so, spam is determined to exist; otherwise, spam is determined not to exist.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method as described in any one of claims 1-8.

10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the rule-based and deep learning-based multi-stage text flooding identification method as described in any one of claims 1-8.