Large classification model-based long text content security risk judgment method
By splitting long texts into short texts and analyzing them using risk identification models, combined with weighted statistical methods, the low accuracy of classification models in long text recognition is solved, and efficient and accurate assessment of the security risks of long text content is achieved, adapting to the risk judgment needs of different scenarios.
Patent Information
- Application Number
- CN202510661911.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-30
AI Technical Summary
The accuracy of existing classification models drops significantly when identifying long texts that are much longer than the training sample length. It is difficult for these models to capture the overall structure and contextual information of the long texts, resulting in low accuracy in identifying security risks in long text content.
Split long text into multiple short texts, analyze each short text using a pre-trained risk identification model, set risk weights for different types of risks and risk thresholds corresponding to scenarios, and determine the security risk of the long text by calculating the comprehensive risk value.
It improves the accuracy and flexibility of security risk identification for long text content, adapts to the risk tolerance of different application scenarios, optimizes the efficiency of long text processing, and enhances the flexibility and scenario adaptability of risk assessment.
Smart Images

Figure CN120723906A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text security identification, and in particular to a method for determining the security risk of long text content based on a large classification model. Background Art
[0002] With the continuous development and widespread application of AI (Artificial Intelligence) technology, especially in scenarios where large models generate text, accurately identifying text security risks in generated content has become an essential and increasingly important step. Traditional text security identification methods, such as sensitive word matching, while simple and efficient, have limitations in many complex and obscure scenarios and are prone to missed or false positives. In contrast, using classification models for text security risk identification, by learning the characteristics of a large number of samples, can achieve more accurate judgments in more scenarios.
[0003] However, when building and training these classification models, shorter sample data is often used. This is done to ensure the representativeness and adequacy of the training samples, thereby improving the model's generalization capabilities and effectively controlling the computing resources and costs required for training. Attempting to use long text samples covering all possible lengths for training would lead to a dramatic expansion of the training dataset and a significant increase in training costs, which is often unacceptable in practical applications.
[0004] Therefore, for cost and model efficiency reasons, the length of classification model training samples is typically limited to a certain range. Currently, existing classification models suffer from low accuracy when recognizing extremely long texts. When these existing classification models are used to recognize texts that are significantly longer than the training sample length, the model's recognition accuracy drops significantly. This is because the models fail to fully learn the overall structure and context of long texts during training, making it difficult to capture the complex risk patterns that may exist within them. Summary of the Invention
[0005] The embodiment of the present invention provides a long text content security risk determination method based on a large classification model, so as to effectively identify the security risks of long text content.
[0006] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions.
[0007] A method for determining security risks of long text content based on a large classification model, comprising:
[0008] Split a long text into multiple short texts according to certain rules;
[0009] Set risk weights for different types of risks and risk thresholds for different scenarios;
[0010] Use the pre-trained risk identification model to analyze each short text to determine whether it has potential risks;
[0011] The comprehensive risk value of the long text is calculated based on the number of short texts with risks and the risk weights corresponding to the short texts. Whether the long text has a security risk is determined based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text.
[0012] Preferably, the splitting of a long text into multiple short texts according to certain rules includes:
[0013] For different scenarios, the same splitting rules are set for the same type of long text. The splitting rules are as follows:
[0014] For text whose length is greater than the specified threshold N, we start counting from the start position of the text, find the Nth character, and then search backward from the Nth character position toward the start of the text. The search target is the line break or sentence end character. Once the nearest line break or sentence end character is found, the content from the start position of the text to the found position is treated as an independent short text segment.
[0015] Check the length of the remaining text. If the length of the remaining text is still greater than N, start a new search and split process from the starting position of the remaining text and repeat the above process until the length of the remaining text is less than or equal to N.
[0016] When the length of the remaining text is less than or equal to N, this part of the remaining text is taken as a final short text segment, and the entire long text splitting process is completed.
[0017] Preferably, the risk thresholds corresponding to different scenarios are set, including:
[0018] For different scenarios, risk thresholds for various types of risks are set separately, and the risk thresholds for the same type of risk in different scenarios can be set to be the same or different.
[0019] Preferably, the use of a pre-trained risk identification model to analyze each short text to determine whether each short text contains potential risks includes:
[0020] A deep learning-based text classification model is used as a risk identification model. Raw text data containing various potential risk types and security content is collected as samples. All samples constitute a sample set. The sample length is controlled within a specified threshold N, and the sample set is labeled with risk categories.
[0021] The risk identification model is trained using the sample set. During the training process, the top-level classifier of the risk identification model is adjusted according to the risk classification task, and the parameters of the risk identification model are updated. The performance of the adjusted risk identification model is evaluated using the validation set and the test set. Based on the evaluation results, the structure and hyperparameters of the risk identification model are further tuned until the performance of the risk identification model meets the expected requirements.
[0022] After converting the short text to be identified into a numerical representation acceptable to the risk identification model, it is input into the risk identification model. The risk identification model outputs a floating-point array. Each fixed position of the floating-point array corresponds to a predefined risk category, and the floating-point value at each position in the array represents the probability value of the input short text belonging to the corresponding risk category.
[0023] Preferably, the step of calculating the comprehensive risk value of the long text based on the number of risky short texts and the risk weights corresponding to the short texts, and determining whether the long text poses a security risk based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text, includes:
[0024] Assume that the total number of short texts after the long text is split is N, the number of short texts identified as risky among all the short texts is M, and the risk weight of each risk is set to A. The comprehensive risk value of the long text is calculated as: Comprehensive risk value = (M*A) / N;
[0025] Set the risk threshold corresponding to the scenario corresponding to the long text to K, and compare the calculated comprehensive risk value with the risk threshold K. If the comprehensive risk value is not less than K, it is considered that the long text is risky; if the comprehensive risk value is less than K, it is considered that the long text is not risky.
[0026] Preferably, the step of calculating the comprehensive risk value of the long text based on the number of risky short texts and the risk weights corresponding to the short texts, and determining whether the long text poses a security risk based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text, includes:
[0027] The risk weights for different types of risks are set as follows: A for political risk, B for pornographic risk, C for illegal risk, D for advertising risk, and so on. The total number of short texts after the long text is split is N. The number of short texts with different types of risks is counted: the number of short texts with political risk is M1, the number of short texts with pornographic risk is M2, the number of short texts with illegal risk is M3, the number of short texts with advertising risk is M4, and so on.
[0028] The calculation formula for the comprehensive risk value of the long text is: Comprehensive risk value = (M1*A+M2*B+M3*C+M4*D+...) / N;
[0029] Set the risk threshold corresponding to the scenario corresponding to the long text to K, and compare the calculated comprehensive risk value with the risk threshold K. If the comprehensive risk value is not less than K, it is considered that the long text is risky; if the comprehensive risk value is less than K, it is considered that the long text is not risky.
[0030] It can be seen from the technical solutions provided by the above embodiments of the present invention that the present invention can solve the problem of low accuracy of long text recognition by classification models and can output different results for different scenarios.
[0031] Additional aspects and advantages of the present invention will be set forth in part in the following description, will become apparent from the following description, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 A schematic diagram illustrating a method for determining security risks of long text content based on a large classification model provided by an embodiment of the present invention;
[0034] Figure 2 A processing flow chart of a method for determining the security risk of long text content based on a classification model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0035] The embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limiting the present invention.
[0036] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the description of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or couplings. The term "and / or" used herein includes any unit and all combinations of one or more associated listed items.
[0037] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art in the art to which the present invention pertains. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and, unless defined as such herein, will not be interpreted in an idealized or overly formal sense.
[0038] To facilitate understanding of the embodiments of the present invention, several specific embodiments will be further explained below with reference to the accompanying drawings, and each embodiment does not constitute a limitation on the embodiments of the present invention.
[0039] The implementation principle diagram of a long text content security risk determination method based on a classification model provided by an embodiment of the present invention is as follows: Figure 1 The specific processing flow is as shown in Figure 1 As shown, the processing steps include the following:
[0040] Step S10: Split the long text into multiple short texts according to certain rules.
[0041] The splitting rules for the same type of long text in different scenarios are the same, as follows:
[0042] For text longer than a specified threshold N, we start counting from the beginning of the text and find the Nth character. This threshold N is typically set to the maximum length of the model training sample data or a suitable fixed value. We then begin searching from this position back toward the beginning of the text. The search targets line breaks (such as \n) or sentence terminators (such as period, question mark, ?, exclamation mark, etc.). Once the nearest line break or sentence terminator is found, the content from the beginning of the text to the found position is treated as a separate short text segment.
[0043] After extracting a short text segment, check the length of the remaining text. If the length of the remaining text is still greater than N, start a new search and split process from the beginning of the remaining text. This process continues until the length of the remaining text is less than or equal to N.
[0044] When the length of the remaining text is less than or equal to N, this part of the remaining text is taken as a final short text segment, and the entire long text splitting process is completed.
[0045] The advantage of this splitting strategy is that it tries to ensure that each short text segment contains a complete sentence or at least is cut at the boundary of natural language, avoiding the situation where sentences are hard truncation, which helps the accuracy of the subsequent risk identification model.
[0046] Step S20: Set risk weights corresponding to different types of risks, and set risk thresholds for various types of risks in different scenarios.
[0047] Risks are divided into various categories, such as political, pornographic, illegal, and advertising. Set risk weights corresponding to different types of risks.
[0048] Risk thresholds for various types of risks are set for different scenarios. The same type of risk thresholds can be different for different scenarios.
[0049] Step S30: Analyze each short text using the pre-trained risk identification model to determine whether each short text has potential risks;
[0050] The risk identification model is the core component used in embodiments of the present invention to determine whether a short text contains potential risks. This model is typically a text classification model based on deep learning, and its structure can adopt a variety of mature neural network architectures, such as Transformer-based models (such as BERT and RoBERTa). The choice of model depends on the specific task requirements and available computing resources.
[0051] The main function of the risk identification model is to receive a short text as input and output the probability that the short text belongs to different predefined risk categories based on the pre-learned pattern.
[0052] The training process of the risk identification model is a typical supervised learning process. Its core lies in constructing a high-quality sample set, performing detailed manual annotation, and fine-tuning the pre-trained model. The specific steps include:
[0053] Sample set construction: Collect a large amount of raw text data containing various types of potentially risky content (such as political, pornographic, illegal, and advertising content), as well as safe content. This data should be diverse, covering different sources, styles, and expressions to ensure that the training samples are representative of the various situations likely to be encountered in real applications. The sample length is typically controlled within a specified threshold N to match the length of short text during model inference.
[0054] Manual Labeling: Professionally trained experts perform detailed risk classification on the constructed sample sets. This labeling process requires experts to accurately determine whether each sample text contains one or more risks based on predefined risk classification criteria and assign the corresponding labels. High-quality manual labeling is the foundation of model training and directly impacts the model's recognition accuracy and robustness.
[0055] Model selection and pre-trained model loading: Choose a deep learning model architecture suitable for text classification tasks, such as a Transformer-based model. Load a model pre-trained on large-scale general-purpose corpora (such as BERT and RoBERTa). Using a pre-trained model can leverage its rich language knowledge to accelerate training and improve model performance.
[0056] Model fine-tuning: Fine-tuning the pre-trained model using a manually labeled risk sample set. During fine-tuning, the model's top-level classifier is adjusted based on the risk classification task, while also making small updates to the pre-trained model's parameters. The goal of fine-tuning is to make the model more adaptable to the specific task of risk identification and learn to recognize the subtle characteristics of different risk categories.
[0057] Model evaluation and tuning: Evaluate the performance of the fine-tuned model on independent validation and test sets. Common evaluation metrics include accuracy, precision, recall, F1 score, and Area Under the Curve (AUC). Based on the evaluation results, further tune the model architecture and fine-tuning hyperparameters (such as learning rate, batch size, and number of fine-tuning epochs) until the model performance meets the expected requirements.
[0058] The input data for the risk identification model is a preprocessed test text string. This text string is a separate short text segment after the long text has been processed using the splitting strategy in step S10. Before being input into the model, the text string is typically converted into a numerical representation acceptable to the model, such as through word segmentation, vocabulary construction, word embedding generation, or conversion into a sequence of token IDs using a pretrained model's tokenizer.
[0059] The output data of the risk identification model is a float array. The length of this array is fixed, and each fixed position corresponds to a predefined risk category (for example, the first position of the array may correspond to "political" risk, the second position corresponds to "pornography" risk, and so on). The floating-point value at each position in the array represents the probability value that the input short text belongs to the corresponding risk category. These probability values are usually between 0 and 1, indicating the model's confidence that the short text belongs to a certain risk category. The system will determine whether the short text is identified as having one or more risks based on these probability values and preset thresholds.
[0060] Step S40: After splitting the long text into multiple short texts, perform independent risk identification on each short text. A pre-trained risk identification model can be used to analyze each short text to determine whether it contains potential risks.
[0061] Weighted statistical method:
[0062] Assume that each risk has a risk weight of A (a preset value reflecting the severity or level of concern of the risk), the total number of short texts after the long text is split is N, and the number of short texts identified as risky among all the short texts is M. The formula for calculating the comprehensive risk value of the long text is: Comprehensive Risk Value = (M*A) / N.
[0063] To determine whether a long text as a whole is risky, a risk threshold K is set. The calculated comprehensive risk value is compared with the risk threshold K. If the comprehensive risk value is not less than K, the long text is considered to be risky; if the comprehensive risk value is less than K, the long text is considered to be risk-free.
[0064] for example:
[0065] Suppose a long text is split into 10 short texts (N=10). After risk identification of these short texts, it is found that 2 of them are risky (M=2). If the risk weight of each risk is set to 1 (A=1), then the overall risk value of the long text is (2*1) / 10=0.2.
[0066] Now, based on the risk threshold K, we can determine:
[0067] If the risk threshold K is set to 0.3, then 0.2<0.3, and the long text is considered safe.
[0068] If the risk threshold K is set to 0.2, then 0.2>=0.2, and the long text is considered to be risky.
[0069] Taking into account that different types of risks (such as political, pornographic, illegal, advertising, etc.) may have different sensitivities and degrees of harm in actual applications, different risk values can be set for different types of risks, that is, different weights can be assigned.
[0070] Weighted statistical method:
[0071] The risk weights for different risk types are: A for political risk, B for pornographic content, C for illegal content, D for advertising risk, and so on. The total number of short texts after splitting a long text is N. The number of short texts with different risk types is counted: M1 for short texts with political risk, M2 for short texts with pornographic content, M3 for short texts with illegal content, M4 for short texts with advertising risk, and so on.
[0072] Then, the calculation formula for the comprehensive risk value of the long text is: Comprehensive risk value = (M1*A+M2*B+M3*C+M4*D+...) / N.
[0073] Similarly, the system calculates the comprehensive risk value of the long text and compares it with this fixed K value:
[0074] If the comprehensive risk value is not less than K, the long text is considered to be risky.
[0075] If the comprehensive risk value is less than K, it is considered that the long text has no risk.
[0076] To adapt to different risk tolerances or scenario requirements, the system doesn't change the K value, but rather adjusts the risk weights of the individual short-text risk categories that make up the overall risk value. This means that K provides a stable judgment boundary, while adjusting the weights provides adaptability. K itself can be any suitable value, such as 1 or 0.5, and once set, it serves as a baseline.
[0077] Set a risk threshold K. If the comprehensive risk value is not less than K, the long text is considered to be risky; if the comprehensive risk value is less than K, the long text is considered to be risk-free.
[0078] for example:
[0079] Assume that after splitting a long text, there are 10 short texts (N = 10). Assign risk weights to each risk type: political risk weight A = 1.5, pornography risk weight B = 0.8, illegal risk weight = 1, and advertising risk weight D = 0.4. The risk threshold K is set to 0.2.
[0080] If two short texts involving political risks are identified (M1=2), and the number of short texts with other types of risks is 0, then the comprehensive risk value is (2*1.5+0*0.8+0*1+0*0.4) / 10=3 / 10=0.3. If 0.3>0.2, it is considered that there is a risk.
[0081] If one short text with political risk (M1=1) and one short text with illegal risk (M3=1) is identified, and the number of short texts with other types of risks is 0, then the comprehensive risk value is (1*1.5+0*0.8+1*1+0*0.4) / 10=(1.5+1) / 10=2.5 / 10=0.25. If 0.25>0.2, it is considered that there is a risk.
[0082] If a short text with 1 advertising risk (M4=1) and 1 illegal risk (M3=1) is identified, and the number of other types of risk short texts is 0, then the comprehensive risk value is (0*1.5+0*0.8+1*1+1*0.4) / 10=(1+0.4) / 10=1.4 / 10=0.14. 0.14<0.2, it is considered that there is no risk.
[0083] Considering that the usage scenarios of long texts can affect the tolerance for different types of risks, for example, in legal education scenarios, descriptions of illegal behavior are normal, so the tolerance for "illegal" risks may be higher. To more flexibly adapt to the needs of different scenarios, the risk weights (weights) of different risk types can be dynamically adjusted based on the usage scenarios of long texts before risk identification.
[0084] The specific process is as follows: Before risk identification for long text, the usage scenario of the long text is first determined. Based on different scenarios, pre-configured risk values for various risks are obtained. These scenario-specific risk values are then used in weighted statistics.
[0085] Weighted statistical method:
[0086] Set the risk value of political involvement to A, the risk value of pornography involvement to B, the risk value of advertising to D..., the number of short texts after the long text is split is N, the number of short texts with political risks is M1, the number of short texts with pornography risks is M2, the number of short texts with illegal risks is M3, and the number of short texts with advertising risks is M4.
[0087] In Scenario 1, based on the scenario's configuration, the illegal risk value is C1. Therefore, the comprehensive risk value is (M1*A+M2*B+M3*C1+M4*D) / N. Set the risk threshold to K. If the comprehensive risk value is not less than K, risk is considered present; if the comprehensive risk value is less than K, risk is considered non-existent.
[0088] In Scenario 2, based on the scenario's configuration, the illegal risk value is C2 (C2 may be different from C1). Therefore, the comprehensive risk value is (M1*A+M2*B+M3*C2+M4*D) / N. Set the risk threshold to K. If the comprehensive risk value is not less than K, risk is considered present; if the comprehensive risk value is less than K, risk is considered non-existent.
[0089] for example:
[0090] After splitting the long text, there are 10 short texts (N = 10). One short text with illegal risks and one short text with political risks are identified (M3 = 1, M1 = 1). The number of short texts with other risk types is 0. The political risk value A is set to 1.5, the pornographic risk value B is set to 0.8, and the advertising risk value D is set to 0.4. The risk threshold K is set to 0.2.
[0091] In scenario 1, assume that the illegal risk value C1 = 1. Then the comprehensive risk value is (1*1.5+0*0.8+1*1+0*0.4) / 10=(1.5+1) / 10=2.5 / 10=0.25. 0.25>0.2, so it is considered that there is a risk.
[0092] In scenario 2, assuming that the illegal risk value C2 = 0.3, the comprehensive risk value is (1*1.5+0*0.8+1*0.3+0*0.4) / 10=(1.5+0.3) / 10=1.8 / 10=0.18. 0.18<0.2, so it is considered that there is no risk.
[0093] In summary, the embodiments of the present invention can solve the problem of low accuracy in long text recognition by classification models, output different results for different scenarios, and improve the accuracy of long text risk identification.
[0094] By breaking down long texts into short, moderately sized pieces based on natural language boundaries and independently identifying risks for each short piece, this method effectively avoids the problem of reduced recognition accuracy caused by long texts exceeding the model's processing capacity. Combined with weighted statistical methods, this method enables a more comprehensive and detailed assessment of the overall risk of long texts.
[0095] Enhanced flexibility and adaptability of risk assessment: This invention introduces weightings for different risk types and further supports dynamic adjustment of these weights for different application scenarios. This eliminates the need for a one-size-fits-all approach to risk assessment and enables more flexible and contextualized risk assessments tailored to specific business needs and risk tolerances.
[0096] Optimizing the efficiency of long text processing: Compared with trying to use a single model to process very long texts, the splitting and segmentation processing strategy of the present invention, combined with the possibility of parallel computing, can optimize the risk identification efficiency of long texts to a certain extent, especially in scenarios that require rapid response.
[0097] Promoting continuous optimization of risk identification models: The risk identification model relied upon by this invention can be iteratively optimized through continuous data collection, manual annotation, and model fine-tuning, continuously improving its ability to identify new risks and complex expressions.
[0098] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of an embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present invention.
[0099] From the above description of the embodiments, it can be seen that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus the necessary general-purpose hardware platform. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present invention or certain parts of the embodiments.
[0100] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device or system embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. A person of ordinary skill in the art can understand and implement it without making any creative efforts.
[0101] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A method for determining the security risk of long text content based on a large classification model, characterized in that: include: Split a long text into multiple short texts according to certain rules; Set risk weights for different types of risks and risk thresholds for different scenarios; Use the pre-trained risk identification model to analyze each short text to determine whether it has potential risks; The comprehensive risk value of the long text is calculated based on the number of short texts with risks and the risk weights corresponding to the short texts. Whether the long text has a security risk is determined based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text.
2. The method according to claim 1, characterized in that The method of splitting a long text into multiple short texts according to certain rules includes: For different scenarios, the same splitting rules are set for the same type of long text. The splitting rules are as follows: For text whose length is greater than the specified threshold N, we start counting from the start position of the text, find the Nth character, and then search backward from the Nth character position toward the start of the text. The search target is the line break or sentence end character. Once the nearest line break or sentence end character is found, the content from the start position of the text to the found position is treated as an independent short text segment. Check the length of the remaining text. If the length of the remaining text is still greater than N, start a new search and split process from the starting position of the remaining text and repeat the above process until the length of the remaining text is less than or equal to N. When the length of the remaining text is less than or equal to N, this part of the remaining text is taken as a final short text segment, and the entire long text splitting process is completed.
3. The method according to claim 1, characterized in that The risk thresholds corresponding to different scenarios are set as follows: For different scenarios, risk thresholds for various types of risks are set separately, and the risk thresholds for the same type of risk in different scenarios can be set to be the same or different.
4. The method according to claim 1, wherein The pre-trained risk identification model is used to analyze each short text to determine whether each short text contains potential risks, including: A deep learning-based text classification model is used as a risk identification model. Raw text data containing various potential risk types and security content is collected as samples. All samples constitute a sample set. The sample length is controlled within a specified threshold N, and the sample set is labeled with risk categories. The risk identification model is trained using the sample set. During the training process, the top-level classifier of the risk identification model is adjusted according to the risk classification task, and the parameters of the risk identification model are updated. The performance of the adjusted risk identification model is evaluated using the validation set and the test set. Based on the evaluation results, the structure and hyperparameters of the risk identification model are further tuned until the performance of the risk identification model meets the expected requirements. After converting the short text to be identified into a numerical representation acceptable to the risk identification model, it is input into the risk identification model. The risk identification model outputs a floating-point array. Each fixed position of the floating-point array corresponds to a predefined risk category, and the floating-point value at each position in the array represents the probability value of the input short text belonging to the corresponding risk category.
5. The method according to any one of claims 1 to 4, characterized in that The step of calculating the comprehensive risk value of the long text based on the number of risky short texts and the risk weights corresponding to the short texts, and determining whether the long text presents a security risk based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text, includes: Assume that the total number of short texts after the long text is split is N, the number of short texts identified as risky among all the short texts is M, and the risk weight of each risk is set to A. The comprehensive risk value of the long text is calculated as follows: Comprehensive risk value = (M*A) / N; Set the risk threshold corresponding to the scenario corresponding to the long text to K, and compare the calculated comprehensive risk value with the risk threshold K. If the comprehensive risk value is not less than K, it is considered that the long text is risky; if the comprehensive risk value is less than K, it is considered that the long text is not risky.
6. The method according to any one of claims 1 to 4, characterized in that The step of calculating the comprehensive risk value of the long text based on the number of risky short texts and the risk weights corresponding to the short texts, and determining whether the long text presents a security risk based on the comprehensive risk value of the long text and the risk threshold corresponding to the scenario corresponding to the long text, includes: The risk weights for different types of risks are set as follows: A for political risk, B for pornographic risk, C for illegal risk, D for advertising risk, and so on. The total number of short texts after the long text is split is N. The number of short texts with different types of risks is counted: the number of short texts with political risk is M1, the number of short texts with pornographic risk is M2, the number of short texts with illegal risk is M3, the number of short texts with advertising risk is M4, and so on. The calculation formula for the comprehensive risk value of the long text is: Comprehensive risk value = (M1*A+M2*B+M3*C+M4*D+...) / N; Set the risk threshold corresponding to the scenario corresponding to the long text to K, and compare the calculated comprehensive risk value with the risk threshold K. If the comprehensive risk value is not less than K, it is considered that the long text is risky; if the comprehensive risk value is less than K, it is considered that the long text is not risky.
Citation Information
Cited By
Risk text accurate semantic recognition method based on improved deep learning model
CN121212158A