Text processing method and device, equipment and readable medium
By mining variant rules from text databases and generating variant texts, the text content review model is updated, which solves the misclassification problem of neural network models when processing variant adversarial texts and improves the accuracy and defense capabilities of the review.
Patent Information
- Application Number
- CN202410282902.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2025-09-16
AI Technical Summary
Existing neural network models tend to output incorrect classification results when processing variant adversarial text, resulting in reduced accuracy in text content review.
By obtaining recently generated real texts from the text database, mining variant rules, and generating variant texts based on these rules, the parameters of the text content review model are updated to enhance the model's ability to classify variant texts.
It improves the accuracy of text content review, strengthens the defense against variant attacks, and can timely learn and adapt to the latest variant methods on the Internet.
Smart Images

Figure CN120654687A_ABST
Abstract
Claims
1. A text processing method, characterized in that: The method comprises: Acquire multiple real texts generated within a preset time period from the current time from a text database; Performing text clustering on the multiple real texts to obtain multiple text clusters; Perform word segmentation on the text in each text cluster to obtain multiple fields; generating a variant rule based on two fields among the plurality of fields whose semantic similarity is greater than or equal to a similarity threshold; Adjusting the fields in the training text based on the fields contained in the variant rule to obtain a variant text; According to the training text and the text category label of the training text, and the variant text and the text category label of the variant text, the model parameters of the text content audit model are updated to obtain an updated text content audit model; If a text to be reviewed is detected, the updated text content review model is called to perform content review on the text to be reviewed to obtain a review result of the text to be reviewed; the review result is used to indicate whether the text to be reviewed has passed the content review.
2. The method according to claim 1, characterized in that The updating of the model parameters of the text content audit model according to the training text and the text category label of the training text, and the variant text and the text category label of the variant text includes: Using the training text and the variant text as training samples; Performing feature encoding on the training sample to obtain a text feature vector of the training sample; and performing perturbation encoding on the training sample to obtain a perturbation feature vector of the training sample; Performing classification prediction processing on the text feature vector to obtain a first category prediction result of the training sample for the text feature vector; Performing classification prediction processing on the disturbance feature vector to obtain a second category prediction result of the training sample for the disturbance feature vector; Adversarial training is performed based on the text feature vector, perturbation feature vector, first category prediction result, second category prediction result and text category label of the training sample to update the model parameters of the text content review model.
3. The method according to claim 2, characterized in that The adversarial training is performed based on the text feature vector, the perturbation feature vector, the first category prediction result, the second category prediction result, and the text category label of the training sample to update the model parameters of the text content audit model, including: Calculating a vector difference between the text feature vector of the training sample and the perturbation feature vector; and calculating a prediction loss value between the first category prediction result of the training sample and the text category label; Obtaining a probability distribution difference between a first category prediction result and a second category prediction result of the training sample; Under the condition that the probability distribution difference is controlled to be less than or equal to the preset distribution difference, the model parameters of the text content review model are updated in the direction of increasing the vector difference and reducing the predicted loss value.
4. The method according to claim 1, wherein The step of adjusting the fields in the training text based on the fields contained in the variant rule to obtain the variant text includes: If the training text contains a field that matches a field in the variant rule, the field in the training text that matches the field in the variant rule is replaced with another field in the variant rule to obtain the variant text; If the training text does not contain a field that matches the field in the variant rule, calling a preset data enhancement strategy to process the training text to obtain the variant text; Among them, the preset data enhancement strategy includes at least one of a pinyin replacement strategy, a similar-looking character replacement strategy, a similar-sounding character replacement strategy, a synonym replacement strategy, an antonym replacement strategy, an English replacement strategy, an emoticon replacement strategy, a character splitting strategy, a character merging strategy, a random order strategy, and a character insertion strategy.
5. The method according to claim 1, wherein The method further comprises: Performing text recovery processing on the training text to obtain a processed training text; wherein the semantics of the processed training text are the same as the semantics of the training text, and the text information entropy of the processed training text is less than the text information entropy of the training text; The step of adjusting the fields in the training text based on the fields contained in the variant rule to obtain the variant text includes: The fields in the processed training text are adjusted based on the fields contained in the variant rule to obtain a variant text.
6. The method according to claim 5, characterized in that The performing text recovery processing on the training text to obtain the processed training text includes: Determine the field with the smallest field information entropy among the two fields included in the variant rule as the source field, and determine the field with the largest field information entropy among the two fields as the variant field; If any field in the training text matches the variant field, any field in the training text is replaced with the source field to obtain the processed training text.
7. The method according to claim 1, characterized in that The generating of a variant rule based on two fields whose semantic similarity among the multiple fields is greater than or equal to a similarity threshold comprises: Obtaining frequent item sets corresponding to the multiple fields according to the number of texts containing each field in each text cluster; For each frequent item set, obtaining the semantic similarity between every two fields in the frequent item set; Combining two fields in the frequent item set whose semantic similarity is greater than or equal to the similarity threshold obtains a variant rule.
8. The method according to any one of claims 1 to 7, characterized in that The calling of the updated text content audit model to perform content audit on the text to be audited, and obtaining the audit result of the text to be audited, includes: Calling the updated text content review model to perform category prediction processing on the text to be reviewed to obtain a category prediction result of the text to be reviewed; Obtaining a security level for each preset text category based on the probability corresponding to each preset text category in the category prediction result of the text to be reviewed and the preset security weight corresponding to each preset text category; The review result of the text to be reviewed is generated based on the security level of each preset text category.
9. The method according to any one of claims 1 to 7, characterized in that Before calling the updated text content review model to perform content review on the text to be reviewed, the method further includes: Perform word segmentation on the text to be reviewed to obtain multiple fields; If there is a field among the obtained multiple fields that matches a specified word included in the preset word library, then generating an audit result indicating that the text to be audited has failed the content audit; If there is no field in the obtained multiple fields that matches the specified word contained in the preset vocabulary, the step of calling the updated text content review model to perform content review on the text to be reviewed is triggered.
10. A text processing device, characterized in that: The device includes an acquisition unit, a rule generation unit, a variant confrontation unit, a model training unit, and a text review unit, wherein: The acquisition unit is configured to acquire, from a text database, a plurality of real texts generated within a preset time period from a current time; The acquisition unit is further configured to perform text clustering on the plurality of real texts to obtain a plurality of text clusters; The rule generating unit is used to perform word segmentation processing on the text in each text cluster to obtain multiple fields; The rule generating unit is further configured to generate a variant rule based on two fields in the plurality of fields whose semantic similarity is greater than or equal to a similarity threshold; The variant countermeasure unit is used to adjust the fields in the training text based on the fields contained in the variant rule to obtain the variant text; The model training unit is used to update the model parameters of the text content audit model according to the training text and the text category label of the training text, and the variant text and the text category label of the variant text, to obtain an updated text content audit model; The text review unit is used to call the updated text content review model to perform content review on the text to be reviewed if a text to be reviewed is detected, and obtain a review result of the text to be reviewed; the review result is used to indicate whether the text to be reviewed has passed the content review.
11. A computer-readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the text processing method according to any one of claims 1 to 9 is implemented.
12. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the text processing method according to any one of claims 1 to 9.