Training method and device for data generation model
By clustering malicious data and data pair training, adversarial text data is generated, which solves the problem of poor malicious data recognition and improves the recognition rate and model efficiency.
Patent Information
- Application Number
- CN202210247415.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-03-14
AI Technical Summary
When the existing technology performs semantic recognition of malicious data, it is easy to lose data features, resulting in poor recognition results. In particular, due to the many variants of malicious data and strong interference, the semantic information is destroyed by adversarial perturbations, affecting the recognition effect.
By clustering target adversarial text data, data pairs are constructed as training data samples, and the data generation model is used to generate adversarial text data to improve the recognition effect of the recognition model. Specific steps include obtaining multiple target adversarial text data, performing word segmentation processing and clustering, selecting data pairs as training samples, and training the data generation model to generate adversarial text data.
It improves the recognition rate of adversarial text data, ensures the retention of data features, enhances the generalization ability of the recognition model, avoids feature loss due to the mapping process, shortens the detection time of unrecognizable characters, and improves the training of data generation models. efficiency.
Smart Images

Figure CN114595775B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to Internet technology, and in particular to a training method and device for a data generation model. Background Art
[0002] Since malicious data has many variants, strong interference, and strong semantic adversarial characteristics, when performing semantic recognition on malicious data, the semantic information is easily destroyed by adversarial disturbances, and the data features of the malicious data are easily lost. Therefore, in the process of data enhancement of malicious data, since the data features of malicious data are easily lost, if the malicious data is directly enhanced by similar word replacement or text translation, it may affect the meaning of the original sentence, thereby affecting the recognition effect of malicious data. Summary of the invention
[0003] The embodiments of the present application provide a training method, device, electronic device, computer-readable storage medium and computer program product for a data generation model, which can generate rich adversarial text data, thereby improving the recognition effect of the corresponding data recognition model and effectively improving the recognition rate of adversarial text data.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a method for training a data generation model, including:
[0006] Acquire multiple pieces of target adversarial text data, and perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster;
[0007] For each of the data clusters, at least one data pair is selected from the data cluster, each of the data pairs includes two pieces of the target adversarial text data, and
[0008] Using the data pairs as training data samples for the data generation model;
[0009] The data generation model is trained using one piece of data in the training data sample as source data and another piece of data as standard data, so that the trained data generation model can generate adversarial text data based on the target adversarial text data to be processed.
[0010] An embodiment of the present application provides a training device for a data generation model, including:
[0011] An acquisition module, used to acquire multiple pieces of target adversarial text data, and perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster;
[0012] A selection module, for selecting at least one data pair from each of the data clusters, each of the data pairs comprising two pieces of the target adversarial text data, and using the data pair as a training data sample for the data generation model;
[0013] A training module is used to train the data generation model using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data to obtain a trained data generation model, wherein the trained data generation model is used to generate adversarial text data based on the target adversarial text data to be processed.
[0014] In the above scheme, the acquisition module is also used to perform word segmentation processing on each text data in the multiple target adversarial text data respectively to obtain the word segmentation results corresponding to each text data; based on the word segmentation results, determine the vocabulary intersection and vocabulary union between any two of the target adversarial text data; obtain the ratio of the vocabulary intersection and vocabulary union of any two of the target adversarial text data, and determine the ratio as the similarity between the corresponding two target adversarial text data; based on the determined similarity, cluster the multiple target adversarial text data to obtain at least one data cluster.
[0015] In the above scheme, the selection module is also used to randomly select two target adversarial text data from at least two target adversarial text data included in the data cluster, and form the two randomly selected target adversarial text data into a data pair; repeat the above operation until the target number of data pairs is selected or the data cluster is empty.
[0016] In the above scheme, the selection module is also used to obtain common text data of the text data included in the data cluster as a clustering seed of the data cluster; select at least one target adversarial text data from at least two target adversarial text data included in the data cluster; and respectively form the data pairs with the clustering seed and one of the selected target adversarial text data to obtain at least one data pair.
[0017] In the above scheme, the device also includes a recognition module, which is used to perform semantic recognition on the training data sample to obtain a semantic recognition result of the training data sample; when the semantic recognition result represents that the training data sample includes unrecognizable characters, based on a pre-set mapping relationship, the unrecognizable characters are mapped to recognizable characters to obtain a new training data sample; the training module is also used to train the data generation model using one target adversarial text data in the new training data sample as source data and another target adversarial text data as standard data.
[0018] In the above scheme, the recognition module is also used to detect the unrecognizable characters to determine the position and type of the unrecognizable characters; based on the type of the unrecognizable characters, obtain the unrecognizable character mapping relationship corresponding to the type, and based on the position of the unrecognizable characters, determine the position characteristics of the unrecognizable characters; based on the mapping relationship and the position characteristics, map the unrecognizable characters in the training data samples to recognizable characters to obtain new training data samples.
[0019] In the above scheme, the data generation model includes an encoding layer and a decoding layer, and the training module is also used to, through the encoding layer, encode the source data and the standard data in the training data sample respectively to obtain a first encoding feature corresponding to the source data and a second encoding feature corresponding to the standard data; through the decoding layer, based on the first encoding feature and the second encoding feature, decode the first encoding feature to obtain adversarial text data corresponding to the source data; obtain the difference between the adversarial text data and the standard data, and update the model parameters of the data generation model based on the difference.
[0020] In the above scheme, the training module is also used to, through the encoding layer, encode the source data and the standard data in the training data sample respectively to obtain the character features, position features and sentence features corresponding to the source data, and the character features, position features and sentence features corresponding to the standard data; wherein the sentence features are used to distinguish the source data from the standard data; the character features, position features and sentence features corresponding to the source data are merged to obtain the first encoding features corresponding to the source data; the character features, position features and sentence features corresponding to the standard data are merged to obtain the second encoding features corresponding to the standard data.
[0021] In the above scheme, the device also includes an encryption module, which is used to encrypt a target number of features in the second coding feature to obtain encrypted coding features corresponding to the second coding data; the training module is also used to decode the first coding feature through the decoding layer based on the first coding feature and the encrypted coding feature to obtain adversarial text data corresponding to the source data; obtain target sub-data in the adversarial text data corresponding to the encrypted features in the second coding feature, and obtain standard sub-data in the standard data corresponding to the encrypted features in the second coding feature; compare the target sub-data with the standard sub-data to obtain the difference between the target sub-data and the standard sub-data, and update the model parameters of the data generation model based on the difference.
[0022] In the above scheme, the device also includes a perturbation module, which is used to perform data perturbation on the training data sample to obtain a perturbed training sample corresponding to the training data sample; the training module is also used to train the data generation model using one target adversarial text data in the perturbed training sample as source data and another target adversarial text data as standard data.
[0023] In the above scheme, the device also includes an application module, which is used to obtain the trained data generation model and original target adversarial text data; through the data generation model, based on the original target adversarial text data, adversarial text data corresponding to the original target adversarial text data is generated.
[0024] In the above scheme, the application module is also used to perform data perturbation on the original target adversarial text data through the data generation model to obtain at least two perturbed text data; based on the at least two perturbed text data, generate at least two adversarial text data corresponding to the original target adversarial text data.
[0025] An embodiment of the present application provides an electronic device, including:
[0026] A memory for storing executable instructions;
[0027] The processor is used to implement the training method of the data generation model provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0028] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute and implement the training method of the data generation model provided in the embodiment of the present application.
[0029] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the training method of the data generation model provided in the embodiment of the present application.
[0030] The embodiments of the present application have the following beneficial effects:
[0031] By clustering the target adversarial text data, a data pair of the target adversarial text data is constructed as a training data sample, and a data generation model is trained by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data, so that the trained data generation model generates adversarial text data based on the target adversarial text data. In this way, the recognition effect of the corresponding data recognition model is improved through the generated adversarial text data, thereby effectively improving the recognition rate of the adversarial text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 1 is a schematic diagram of the architecture of a training system 100 for a data generation model provided in an embodiment of the present application;
[0033] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0034] Figure 3 It is a flowchart of a training method for a data generation model provided in an embodiment of the present application;
[0035] Figure 4 It is a schematic diagram of the vocabulary intersection and vocabulary union between two pieces of data provided in an embodiment of the present application;
[0036] Figure 5 It is a flowchart of performing semantic recognition on training data samples to obtain new training data samples provided by an embodiment of the present application;
[0037] Figure 6 is a schematic diagram of a process of mapping unrecognizable characters to recognizable characters provided by an embodiment of the present application;
[0038] Figure 7 It is a flowchart of the training process of the data generation model provided in the embodiment of the present application;
[0039] Figure 8 It is a structural diagram of a data generation model provided in an embodiment of the present application;
[0040] Fig. 9 It is a structural diagram of a data generation model provided in an embodiment of the present application;
[0041] Fig.10 It is a flowchart of the training process of the data generation model provided in the embodiment of the present application;
[0042] Fig.11 It is a structural diagram of a data generation model provided in an embodiment of the present application;
[0043] Fig.12 It is a flowchart of the training process of the data generation model provided in the embodiment of the present application;
[0044] Fig.13 It is a flowchart of the process of generating adversarial text data provided by an embodiment of the present application;
[0045] Fig.14 It is a flowchart of the process of generating adversarial text data provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0047] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0048] In the following description, the terms "first\second\third" are only used to distinguish similar objects, and do not represent a specific order for the objects. It is understandable that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In the following description, the term "plurality" refers to at least two.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0050] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0051] 1) Malicious data refers to illegal data that uses the Internet as a medium and network technology as the main means to bring potential threats (major security risks) to the security of computer information systems and the management order of cyberspace.
[0052] 2) Seq2Seq model (Sequence to Sequence), a sequence-to-sequence model, refers to a model that maps one sequence as input to obtain another sequence.
[0053] 3) BERT model (Bidirectional Encoder Representations from Transformer), a pre-training technology for natural language processing, is used to train with large-scale unlabeled corpus to obtain semantic representations of texts containing rich semantic information, and then fine-tune the semantic representations of texts in specific natural language processing tasks, and finally apply them to the natural language processing tasks.
[0054] 4) BertOnlyMLMHead model, a method for calling predicted values, used to return predicted values when training a language model in a mask-based manner.
[0055] 5) Adversarial text data, a type of illegal text data, which may exist on Internet pages. Adversarial text data is text data that is not allowed to be displayed on the current page, that is, the content of the adversarial text data does not meet the current scene conditions, that is, it is adversarial and disruptive to the current scene. Among them, the current scene conditions may include one or more relevant legal provisions, platform regulations, page regulations, etc., which are not limited here. Therefore, adversarial text data is also a type of malicious data. For example, when the page scene where the text data is located is a bullet screen scene (such as a bullet screen scene for a video), since it is stipulated in the page scene that only viewers are allowed to express their own opinions, conduct content comments or content exchanges, and no advertising content can appear in the bullet screen scene, therefore, when there is a bullet screen carrying advertisements in the bullet screen scene, the bullet screen is considered to be illegal text data, that is, target confrontation text data; for another example, when the page scene where the text data is located is a comment scene (such as a comment scene for news or articles), since it is stipulated in the page scene that comments are only used to express their own opinions, content comments or content exchanges, and no malicious comments such as insulting comments can appear, therefore, when comments including insulting comments appear in the comment scene, the comment is considered to be illegal text data, that is, confrontation text data. For another example, some platforms require that text data have semantic integrity. When the semantic information of text data is destroyed, the readability of text data without semantic integrity is poor, and even if it includes special characters, emoticons or other difficult-to-recognize texts, it will affect the user's visual experience. The aforementioned type of text data can also be determined as a type of confrontation text data.
[0056] 6) Target adversarial text data, a type of adversarial text data whose semantics are not continuous, that is, whose semantic integrity is destroyed. For example, some malicious advertisements currently destroy text semantic information by inserting various special characters, emoticons, or using homophones, similar characters and other text variations to resist the recognition of advertisement recognition models. They have strong adversarial properties, making such malicious data difficult to identify. In an embodiment of the present application, target adversarial text data includes text data whose text semantic information is destroyed. In some embodiments, target adversarial text data is a type of adversarial text data with strong adversarial properties.
[0057] During the implementation of the embodiments of the present application, the applicant discovered that the related technology has the following problems:
[0058] Since comments and bullet screens in various social platforms are the fastest and cheapest channels to reach users and expose malicious information, there are a large number of automatons and malicious accounts that send massive amounts of malicious text to comments and bullet screens on various platforms to harass users almost every moment. It is basically impossible to complete such a large amount of malicious data by using a comprehensive manual review method. However, if the review is based on the malicious data recognition model, the malicious data will destroy the text semantic information by inserting various special characters, emoticons, or using homophones, similar characters and other text variations, thereby affecting the recognition of the malicious data recognition model. In other words, due to the large number of variants and strong adversarial nature of malicious data, it is difficult to enhance the corresponding malicious data, which affects the recognition effect of malicious data, making the recognition of malicious data a difficult problem in the industry.
[0059] In the related art, malicious data is enhanced mainly through three methods: Method 1: Data enhancement method based on vocabulary replacement, mainly including replacement based on dictionary and word vector. This type of method usually randomly selects a part of vocabulary from the text, finds the synonyms corresponding to the vocabulary in the dictionary or pre-trained word vector for replacement; Method 2: Data enhancement method of reverse translation, first selects an intermediate language, translates the text into the intermediate language and then translates it back to the original language. For example, if the intermediate language is English, the text is translated into English, and then the English text is translated back to Chinese. Usually, the translated text is semantically similar to the original text but there are also differences, which can achieve the purpose of data enhancement. Alternatively, multiple intermediate languages can be selected to add more noise to achieve data enhancement; Method 3: Text error correction method, mainly divided into methods based on seq2seq model and BERT model. By correcting the interference part in the text and restoring it to the form of normal text, the purpose of data enhancement can also be achieved.
[0060] However, for Solution 1, when replacing text, the words to be replaced are usually randomly selected, and improper selection may affect the meaning of the original sentence; for Solution 2, when translating text, it relies more on the effect of the translation algorithm, and it is easy to have errors, which also affect the meaning of the original sentence; for Solution 3, since malicious data has the characteristics of many variants, strong interference, and strong semantic adversarial, and the corresponding error correction model usually relies on semantic context information, and each Chinese character has independent semantics, the semantic information is easily destroyed by adversarial disturbances, which makes it easy for malicious data to lose data features after passing through the error correction model, thereby affecting the recognition effect of the data.
[0061] Based on this, the present embodiment provides a training method, device, electronic device, computer-readable storage medium and computer program product for a data generation model. By automatically learning the features of the target adversarial text data and generating adversarial text data with similar features, the recognition effect of the corresponding data recognition model can be improved, thereby effectively improving the recognition rate of the adversarial text data.
[0062] See also Figure 1 , Figure 1 1 is a schematic diagram of the architecture of the training system 100 for the data generation model provided in an embodiment of the present application, wherein a terminal (terminal 400 is shown as an example) is connected to a server 200 via a network 300, and the network 300 may be a wide area network or a local area network, or a combination of the two. The terminal 400 and the server 200 are connected to each other via a wired or wireless network.
[0063] The terminal 400 is used to send multiple target confrontation text data to the server 200;
[0064] The server 200 is used to receive multiple target adversarial text data sent by the terminal 400; and cluster the multiple target adversarial text data to obtain at least one data cluster; for each data cluster, select at least one data pair from the data cluster, each data pair includes two target adversarial text data, and use the data pair as a training data sample for the data generation model; use one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data to train the data generation model to obtain a trained data generation model, and the trained data generation model is used to generate adversarial text data based on the target adversarial text data to be processed.
[0065] In some embodiments, the terminal 400 may also be configured with a data generation client 400-1, and the client 400-1 sends a request to obtain adversarial text data to the server 200, and then the server 200 obtains the target adversarial text data to be processed and generates adversarial text data based on the target adversarial text data to be processed through a data generation model; finally, the generated adversarial text data is sent to the client 400-1.
[0066] In some embodiments, the server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Deliver Network), and big data and artificial intelligence platforms and other basic cloud computing services. The terminal 400 can be a smart phone, a tablet computer, a laptop, a desktop computer, a set-top box, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device, an intelligent speaker and a smart watch), etc., but is not limited thereto. The terminal device and the server can be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiments of the present application.
[0067] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. In practical applications, the electronic device can be Figure 1 The server 200 or terminal 400 shown, see Figure 2 , Figure 2 The electronic device shown includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the terminal 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not shown in FIG. Figure 2 Various buses are labeled as bus system 440 .
[0068] Processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0069] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0070] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0071] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0072] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0073] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0074] A network communication module 452, for reaching other computing devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Compatibility Authentication (WiFi), and Universal Serial Bus (USB);
[0075] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., display screen, speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripherals and displaying content and information);
[0076] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.
[0077] In some embodiments, the training device for the data generation model provided in the embodiments of the present application can be implemented in software. Figure 2 A training device 455 of a data generation model stored in a memory 450 is shown, which may be software in the form of a program or plug-in, including the following software modules: an acquisition module 4551, a selection module 4552, and a training module 4553. These modules are logical and can therefore be arbitrarily combined or further split according to the functions implemented.
[0078] In other embodiments, the training device of the data generation model provided in the embodiments of the present application can be implemented in hardware. As an example, the training device of the data generation model provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the training method of the data generation model provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0079] In some embodiments, the terminal or server can implement the training method of the data generation model provided in the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a local (Native) application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as an instant messaging APP, a web browser APP; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0080] Based on the above description of the training system and electronic device for the data generation model provided by the embodiment of the present application, the following describes the training method for the data generation model provided by the embodiment of the present application. In actual implementation, the training method for the data generation model provided by the embodiment of the present application can be implemented by the terminal or the server alone, or by the terminal and the server in collaboration, so that Figure 1 The server 200 in the embodiment of the present application independently executes the training method of the data generation model provided in the embodiment of the present application as an example for explanation. Figure 3 , Figure 3 is a flow chart of the training method of the data generation model provided in the embodiment of the present application, which will be combined with Figure 3 The steps shown are explained.
[0081] Step 101: The server obtains multiple pieces of target adversarial text data, and performs clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster.
[0082] It should be noted that since the recognition rate of the data recognition model used to identify adversarial text data in the relevant technology is low, the adversarial text data may include adversarial text data that can be recognized by the data recognition model and adversarial text data that cannot be recognized by the data recognition model. The target adversarial text data here is the adversarial text data that cannot be recognized by the data recognition model.
[0083] In some embodiments, the server may obtain multiple pieces of target adversarial text data from a target adversarial text database, wherein the target adversarial text database is used to store the target adversarial text data.
[0084] In other embodiments, the server may also obtain multiple target adversarial text data through a data recognition model.
[0085] Next, the process of obtaining multiple target adversarial text data through the data recognition model is explained.
[0086] In one embodiment, the adversarial text data to be identified can be matched with the preset adversarial text data through the data recognition model. When the matching result indicates that the similarity between the adversarial text data to be identified and the preset adversarial text data reaches a preset similarity threshold, the adversarial text data to be identified is determined to be recognizable adversarial text data; when the matching result indicates that the similarity between the adversarial text data to be identified and the preset adversarial text data does not reach the preset similarity threshold, the adversarial text data to be identified is determined to be unrecognizable adversarial text data. It should be noted that the preset adversarial text data is adversarial text data with semantic continuity, that is, the semantic integrity is not destroyed. Here, when the similarity with the preset adversarial text data does not reach the preset similarity threshold, it is determined that the adversarial text data to be identified does not have semantic integrity, that is, the semantic integrity is destroyed. Therefore, the adversarial text data to be identified is determined to be the target adversarial text data.
[0087] In another embodiment, the data recognition model can also identify adversarial text data by recognizing the semantics of the data. For example, when the semantic recognition result of a text data to be processed meets the current scenario conditions, the text data to be processed can be determined as non-adversarial text data; when the semantic recognition result of a text data to be processed does not meet the current scenario conditions, the text data to be processed can be determined as adversarial text data. When the semantics of a text data to be processed cannot be recognized or a credible semantic recognition result cannot be obtained (for example, a semantic recognition result with a confidence level exceeding the confidence threshold cannot be obtained), the text data to be processed can be determined as target adversarial text data.
[0088] In this way, after obtaining the target adversarial text data, using the target adversarial text data to construct training samples to generate rich adversarial text data can further train the data recognition model in practical applications and improve the recognition rate of the data recognition model for adversarial text data.
[0089] In actual implementation, after obtaining multiple pieces of target adversarial text data, perform word segmentation processing on each of the multiple pieces of target adversarial text data to obtain the word segmentation results corresponding to each text data; based on each word segmentation result, determine the similarity between each target adversarial text data, and based on the determined similarity, perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster. Among them, the process of determining the similarity between each target adversarial text data based on each word segmentation result specifically includes determining the lexical intersection and lexical union between any two target adversarial text data based on the word segmentation result; obtaining the ratio of the lexical intersection and lexical union of any two target adversarial text data, and determining the ratio as the similarity between the corresponding two target adversarial text data.
[0090] As an example, the process of determining the similarity between each text data based on each word segmentation result is described. First, obtain two pieces of target adversarial text data such as "Those who need movies can find 9kk4" and "Those who want movies can find 4ss6", and then perform word segmentation processing on these two pieces of target adversarial text data to obtain the corresponding word segmentation results "‘need’, ‘want’, ‘movie’, ‘can’, ‘find’, ‘9’, ‘k’, ‘k’, ‘4’" and "‘want’, ‘movie’, ‘can’, ‘find’, ‘4’, ‘s’, ‘s’, ‘6’". Then, based on the word segmentation results, determine the lexical intersection and lexical union between these two pieces of target adversarial text data. Refer to Figure 4 , Figure 4 which is a schematic diagram of the lexical intersection and lexical union between two pieces of target adversarial text data provided by the embodiments of the present application. Based on Figure 4, obtain the ratio of the vocabulary intersection and the vocabulary union of the two target adversarial text data, 0.467, that is, 7 / (7+4+4), and determine the ratio as the similarity between the corresponding two target adversarial text data.
[0091] Step 102: for each data cluster, select at least one data pair from the data cluster, each data pair includes two target adversarial text data, and use the data pair as a training data sample for the data generation model.
[0092] In actual implementation, after obtaining at least one data cluster corresponding to multiple target adversarial text data, at least one data pair is selected from the data cluster. Here, selecting at least one data pair from the data cluster specifically includes two methods, and the specific selection process can adopt at least one of the two methods. Next, the two methods of selecting at least one data pair from the data cluster are explained.
[0093] In some embodiments, two target adversarial text data are randomly selected from at least two target adversarial text data included in the data cluster, and the two randomly selected target adversarial text data are combined into a data pair; the above operation is repeated until the target number of data pairs is selected or the data cluster is empty.
[0094] It should be noted that, since the target adversarial text data in the same data cluster have similar data distribution characteristics, data pairs are randomly selected in pairs to use the data pairs as training data samples for the data generation model.
[0095] In some embodiments, common text data of text data included in a data cluster is obtained as a clustering seed of the data cluster; at least one target adversarial text data is selected from at least two target adversarial text data included in the data cluster; and the clustering seed and one of the selected target adversarial text data are respectively formed into data pairs to obtain at least one data pair.
[0096] It should be noted that the method of obtaining the common text data of the text data included in the data cluster, that is, the clustering seed of the data cluster, can be to obtain the common text data of the text data included in the data cluster through the longest common subsequence or other common text data extraction methods.
[0097] In some embodiments, after the data pair is used as a training data sample of the data generation model, semantic recognition can also be performed on the training data sample to obtain a new training data sample, see Figure 5 , Figure 5 is a flow chart of obtaining new training data samples by semantically recognizing training data samples according to an embodiment of the present application, based on Figure 3 After step 102, you can also execute:
[0098] Step 201: The server performs semantic recognition on the training data sample to obtain the semantic recognition result of the training data sample.
[0099] Step 202: When the semantic recognition result indicates that the training data sample includes unrecognizable characters, the unrecognizable characters are mapped to recognizable characters based on a preset mapping relationship to obtain a new training data sample.
[0100] In actual implementation, when the semantic recognition result indicates that the training data sample includes unrecognizable characters, the unrecognizable characters are detected to obtain detection results. Based on the detection results and a pre-set mapping relationship, the unrecognizable characters are mapped to recognizable characters to obtain new training data samples, see Figure 6 , Figure 6 is a flowchart of mapping unrecognizable characters to recognizable characters provided by an embodiment of the present application, based on Figure 5 , step 202 can be implemented as follows:
[0101] Step 2021, detect the unrecognizable characters to determine the position and type of the unrecognizable characters.
[0102] In actual implementation, the unrecognizable characters are first detected to obtain the detection results, and then the position and type of the unrecognizable characters are determined based on the detection results. Here, the position of the unrecognizable characters refers to the specific position of the unrecognizable characters in the training data sample, and the types of unrecognizable characters include at least rare characters, special numeric symbols, and emoticons such as emoji expressions.
[0103] Step 2022: based on the type of the unrecognizable character, obtain an unrecognizable character mapping relationship corresponding to the type, and based on the position of the unrecognizable character, determine the position feature of the unrecognizable character.
[0104] In actual implementation, after the type of the unrecognizable character is determined, the unrecognizable character mapping relationship corresponding to the type of the unrecognizable character is obtained based on a pre-constructed corresponding unrecognizable character dictionary. For example, when the type of the unrecognizable character is a special numeric symbol, the corresponding unrecognizable character mapping relationship is obtained based on a pre-constructed special character dictionary; when the unrecognizable character is an emoticon, the corresponding unrecognizable character mapping relationship is obtained based on a pre-constructed emoticon dictionary.
[0105] In actual implementation, after the position of the unrecognizable character is determined, the position feature of the unrecognizable character is determined based on the position where the unrecognizable character appears.
[0106] Step 2023, based on the mapping relationship and the position feature, the unrecognizable characters in the training data sample are mapped to recognizable characters to obtain a new training data sample.
[0107] In actual implementation, after determining the mapping relationship and position features corresponding to the unrecognizable characters, based on the mapping relationship and the position features, the unrecognizable characters in the training data sample are mapped to recognizable characters. For example, when the unrecognizable character is ⑨ or ⑼, the type of the unrecognizable character is determined to be a special numeric symbol, and then based on a pre-constructed special character dictionary, the corresponding unrecognizable character mapping relationship is obtained, that is, the mapping relationship between ⑨ or ⑼ and the ordinary character 9; when the unrecognizable character is a thumbs-up emoticon, the type of the unrecognizable character is determined to be an emoticon, and then based on a pre-constructed emoticon dictionary, the corresponding unrecognizable character mapping relationship is obtained, that is, the mapping relationship between the thumbs-up emoticon and the code "u'\U0001F44D':':thumbs_up:"; then based on the position features of the unrecognizable characters, identification characters are added before and after the mapped unrecognizable characters, so as to map the unrecognizable characters in the training data sample to recognizable characters to obtain new training data samples.
[0108] In this way, based on the mapping relationship and position features, the unrecognizable characters in the training data samples are mapped to recognizable characters, which not only improves the recognition rate of the corresponding data recognition model, but also records the position of the unrecognizable characters, thereby avoiding the loss of some features of the target adversarial text data due to the mapping process, so that the corresponding data recognition model can not only recognize through semantic features, but also through the position and frequency of the occurrence of unrecognizable characters, thereby further improving the recognition rate of the corresponding data recognition model.
[0109] It should be noted that since the malicious data detection scenario requires tens of millions of calls every day and the amount of data is as high as billions, in order to reduce the detection time of unrecognizable characters, only when the semantic recognition result indicates that the training data sample includes unrecognizable characters, the unrecognizable characters will be detected accordingly, so as to map the unrecognizable characters to recognizable characters to obtain new training data samples, and use one target adversarial text data in the new training data sample as the source data and another target adversarial text data as the standard data to train the data generation model; and when the semantic recognition result indicates that the training data sample does not include unrecognizable characters, directly use one target adversarial text data in the training data sample as the source data and another target adversarial text data as the standard data to train the data generation model. In this way, the detection time of unrecognizable characters is reduced, and the training efficiency of the data generation model and the data generation efficiency are improved.
[0110] Step 103, using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data, a training data generation model is trained to obtain a trained data generation model, and the trained data generation model is used to generate adversarial text data based on the target adversarial text data to be processed.
[0111] See also Figure 7 , Figure 7 It is a flow chart of the training process of the data generation model provided in the embodiment of the present application. It should be noted that the data generation model includes an encoding layer and a decoding layer. Figure 8 , Figure 8 is a schematic diagram of the structure of the data generation model provided in the embodiment of the present application, based on Figure 7 and Figure 8 , with one target adversarial text data in the training data sample as the source data and another target adversarial text data as the standard data, the process of training data generation model can be performed as follows:
[0112] Step 1031, through the encoding layer, encode the source data and the standard data in the training data sample respectively to obtain a first encoding feature corresponding to the source data and a second encoding feature corresponding to the standard data.
[0113] In actual implementation, firstly, the source data and standard data in the training data sample are constructed as the input of [SOS] source data [EOS] standard data [SOS], and then refer to Fig. 9 , Fig. 9 is a schematic diagram of the structure of the data generation model provided in the embodiment of the present application, based on Fig. 9 , through the encoding layer, the source data in the training data sample and the standard data are respectively encoded to obtain the first encoding feature of the corresponding source data and the second encoding feature of the corresponding standard data. The process specifically includes: through the encoding layer, the source data in the training data sample and the standard data are respectively encoded to obtain the character features, position features and sentence features of the corresponding source data, and the character features, position features and sentence features of the corresponding standard data; wherein the sentence features are used to distinguish the source data from the standard data; the character features, position features and sentence features of the corresponding source data are fused to obtain the first encoding feature of the corresponding source data; the character features, position features and sentence features of the corresponding standard data are fused to obtain the second encoding feature of the corresponding standard data.
[0114] Step 1032, through the decoding layer, based on the first encoding feature and the second encoding feature, the first encoding feature is decoded to obtain adversarial text data corresponding to the source data.
[0115] Step 1033, obtaining the difference between the adversarial text data and the standard data, and updating the model parameters of the data generation model based on the difference.
[0116] In actual implementation, after obtaining the adversarial text data corresponding to the source data, the adversarial text data is compared with the standard data to obtain the difference between the adversarial text data and the standard data, and the model parameters of the data generation model are updated based on the difference.
[0117] In some embodiments, after obtaining the first coding feature and the second coding feature, see Fig.10 , Fig.10 is a flow chart of the training process of the data generation model provided in the embodiment of the present application, based on Figure 7 After step 1031, you can also execute:
[0118] Step 301: The server encrypts a target number of features in the second coding feature to obtain an encrypted coding feature corresponding to the second coding data.
[0119] In actual implementation, the server randomly encrypts the characteristics of the target quantity of standard data. Exemplarily, the encryption method here can be to randomly mask the characteristics of the target quantity. The embodiment of the present application does not limit the method of encrypting the characteristics of the target quantity.
[0120] Step 302, through a decoding layer, based on the first coding feature and the encrypted coding feature, the first coding feature is decoded to obtain adversarial text data corresponding to the source data.
[0121] See also Fig.11 , Fig.11 is a schematic diagram of the structure of the data generation model provided in the embodiment of the present application, based on Fig.11 , through the decoding layer, based on the first coding feature and the coding feature to the left of the encrypted feature in the encrypted coding feature, the first coding feature is decoded to obtain the adversarial text data corresponding to the source data.
[0122] Step 303, obtaining target sub-data in the adversarial text data corresponding to the encrypted features in the second coding feature, and obtaining standard sub-data in the standard data corresponding to the encrypted features in the second coding feature.
[0123] Step 304 : compare the target sub-data with the standard sub-data to obtain the difference between the target sub-data and the standard sub-data, and update the model parameters of the data generation model based on the difference.
[0124] It should be noted that in the process of training the data generation model, the end marker of the standard data segment can also be encrypted, in the hope that the model can learn to automatically end data generation.
[0125] In some embodiments, after the data pair is used as a training data sample for the data generation model, see Fig.12 , Fig.12 is a flow chart of the training process of the data generation model provided in the embodiment of the present application, based on Figure 3 After step 103, you can also execute:
[0126] Step 401: The server performs data perturbation on the training data samples to obtain perturbed training samples corresponding to the training data samples.
[0127] In actual implementation, there are two specific ways to perform data perturbation on training data samples to obtain perturbed training samples corresponding to the training data samples. Next, two ways to perform data perturbation on training data samples to obtain perturbed training samples corresponding to the training data samples are explained.
[0128] In some embodiments, a disturbance parameter is first obtained, and then the disturbance parameter is combined with the features in the training data sample to obtain a perturbed training sample corresponding to the training data sample. It should be noted that the combination method here can be addition, or the disturbance parameter can be used as a feature coefficient, etc., and this is not limited in the embodiments of the present application.
[0129] In some embodiments, the total features of the training data samples are first obtained, and then based on the total features, a target number of target features are randomly screened; based on the target features, target training samples corresponding to the target features are determined as perturbation training samples of the corresponding training data samples.
[0130] Step 402, using one target adversarial text data in the perturbed training sample as source data and another target adversarial text data as standard data, a training data generation model is generated.
[0131] In this way, the data generation model is trained by perturbing the training samples to avoid the model being overly dependent on certain local features, so that the model will neither overfit nor have too large differences, and will have stronger generalization, thereby obtaining more target adversarial text data.
[0132] In some embodiments, after the training of the data generation model is completed, target adversarial text data is generated based on the trained data generation model. Fig.13 , Fig.13 is a flow chart of the process of generating target adversarial text data provided by the embodiment of the present application, based on Figure 3 After step 103, you can also execute:
[0133] Step 501: The server obtains a trained data generation model and original target adversarial text data.
[0134] In actual implementation, the original target adversarial text data obtained by the server can be the original target adversarial text data in the barrage during video playback, or the original target adversarial text data in the comments of media information such as videos or articles, etc.
[0135] Step 502: Generate adversarial text data corresponding to the original target adversarial text data based on the original target adversarial text data through a data generation model.
[0136] In actual implementation, the process of generating adversarial text data corresponding to the original target adversarial text data based on the original target adversarial text data through a data generation model specifically includes: performing data perturbation on the original target adversarial text data through the data generation model to obtain at least two perturbed text data; and generating at least two adversarial text data corresponding to the original target adversarial text data based on the at least two perturbed text data.
[0137] As an example, see Fig.14 , Fig.14 is a flowchart of the generation process of adversarial text data provided by the embodiment of the present application, based on Fig.14 , through the data generation model, based on the original target adversarial text data, generating adversarial text data corresponding to the original target adversarial text data can be specifically implemented through steps 601 to 606. Specifically, through the data generation model, the original target adversarial text data is preprocessed to obtain intermediate target adversarial text data, and then the intermediate target adversarial text data is perturbed to obtain at least two perturbed data, and then based on the at least two perturbed data, at least two adversarial text data corresponding to the original target adversarial text data are generated.
[0138] In actual implementation, after obtaining adversarial text data based on the data generation model, the adversarial text data is added to a database storing adversarial text data, so that when the text data to be recognized is recognized, the similarity between the text data to be recognized and the adversarial text data in the database is determined. When the similarity reaches a preset similarity threshold, the text data to be recognized is determined to be adversarial text data.
[0139] It should be noted that in addition to generating rich adversarial text data based on the trained data generation model, it is also possible to generate richer black market advertising data resources through the confrontation between the generator and the discriminator based on the training method of the above-mentioned data generation model of this application.
[0140] By using the above-mentioned embodiment of the present application, by clustering the target adversarial text data, a data pair of the target adversarial text data is constructed as a training data sample, and a data generation model is trained by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data, so that the data generation model obtained by training generates adversarial text data based on the target adversarial text data. In this way, the recognition effect of the corresponding data recognition model is improved through the generated adversarial text data, thereby effectively improving the recognition rate of the adversarial text data.
[0141] The following is an explanation of an exemplary application of an embodiment of the present application in a practical application scenario.
[0142] Since the comments and bullet screens in various social platforms such as video playback software, news clients, and reading websites are the fastest and cheapest channels to reach users and expose malicious information, there are a large number of automatons and malicious accounts that send massive amounts of malicious text to the comments and bullet screens of various platforms to harass users almost every moment. It is basically impossible to complete such a large amount of malicious data by using a comprehensive manual review method. However, if the review is based on the adversarial malicious data recognition model, the malicious data will destroy the text semantic information by inserting various special characters, emoticons, or using homophones, similar characters, and other text variations, thereby affecting the recognition of the adversarial malicious data recognition model. That is, due to the large number of variants and strong adversarial nature of malicious data, it is difficult to enhance the corresponding malicious data, which affects the recognition effect of malicious data, making the recognition of malicious data a difficult problem in the industry.
[0143] In the related art, malicious data is enhanced mainly through three methods: Method 1: Data enhancement method based on vocabulary replacement, mainly including replacement based on dictionary and word vector. This type of method usually randomly selects a part of vocabulary from the text, finds the synonyms corresponding to the vocabulary in the dictionary or pre-trained word vector for replacement; Method 2: Data enhancement method of reverse translation, first selects an intermediate language, translates the text into the intermediate language and then translates it back to the original language. For example, if the intermediate language is English, the text is translated into English, and then the English text is translated back to Chinese. Usually, the translated text is semantically similar to the original text but there are also differences, which can achieve the purpose of data enhancement. Alternatively, multiple intermediate languages can be selected to add more noise to achieve data enhancement; Method 3: Text error correction method, mainly divided into methods based on seq2seq model and BERT model. By correcting the interference part in the text and restoring it to the form of normal text, the purpose of data enhancement can also be achieved.
[0144] However, for Solution 1, when replacing text, the words to be replaced are usually randomly selected, and improper selection may affect the meaning of the original sentence; for Solution 2, when translating text, it relies more on the effect of the translation algorithm, and it is easy to have errors, which also affect the meaning of the original sentence; for Solution 3, since malicious data has the characteristics of many variants, strong interference, and strong semantic adversarial, and the corresponding error correction model usually relies on semantic context information, and each Chinese character has independent semantics, the semantic information is easily destroyed by adversarial disturbances, which makes it easy for malicious data to lose data features after passing through the error correction model, thereby affecting the recognition effect of the data.
[0145] Based on this, we conducted an in-depth investigation of similar malicious data, systematically summarized the current evolution direction of malicious data, and proposed a semi-supervised method for simulating and generating malicious adversarial data. This method can automatically learn the features of existing malicious advertising data and generate text data with similar features to simulate the process of upgrading and confronting malicious advertisements. In terms of business, we can use the generated malicious advertising data to improve the generalization of the malicious advertising recognition model, improve the accuracy of malicious advertising recognition, accurately strike malicious behaviors existing in the corresponding platforms, maintain the community environment of each platform, and ensure user experience.
[0146] In the embodiments of the present application, data enhancement is performed by fully considering the characteristics of malicious data such as interference with special symbols and strong semantic confrontation. Specifically, first, the text is preprocessed to map the strongly confrontational special characters and emoticons therein into characters recognizable by the model; secondly, the text is segmented, and short texts are clustered based on the Jaccard similarity method of the segmentation results, and two types of training data are further constructed for the model through the clustering results. Specifically, the existing malicious data is clustered, and a data pair of <malicious advertisement data 1, malicious advertisement data 2> is constructed for the malicious data between each cluster cluster, and the clustering seeds of each category are obtained by the longest common subsequence method, and the data pairs of <clustering seeds, malicious advertisement data> are constructed as training data samples to train the deep natural language generation model (data generation model). It should be noted that the clustering seeds here are the most essential data features of this class; finally, a sample perturbation strategy is introduced in the data generation stage of the model, so as to automatically generate a large amount of malicious data with similar confrontation characteristics, and finally achieve the purpose of simulating the upgraded confrontation of malicious advertisements.
[0147] Regarding the above-mentioned process of preprocessing the text and mapping the strongly antagonistic special characters (unrecognizable characters), such as special numeric characters and emoticons, into characters recognizable by the model, it should be noted that, according to the text content of malicious advertisements, they are mainly divided into two types: alphanumeric symbol advertisements, i.e., advertisements with alphanumeric types clearly given in the text, and semantic advertisements, i.e., advertisements that mainly attract users through the semantic content of the text, thereby conducting malicious promotion. Among them, the alphanumeric advertisement type poses a greater challenge to data recognition. Here, in order to avoid recognition and attack by the adversarial recognition model, malicious data often uses various special characters to replace normal text. Such special characters include but are not limited to rare characters, special numeric symbols, emoticons, etc. Therefore, in an embodiment of the present application, the text will first be preprocessed with the aim of mapping these special characters into characters recognizable by the model and expressing similar meanings. The specific processing is as follows: for special numeric characters, by constructing a special character dictionary, special characters of a single word length, such as ⑨ or ⑼, are mapped to the character 9 that the model can recognize; for emoticons, by constructing the corresponding emoticon dictionary, emoticons are mapped to the corresponding encoding; finally, the positions where special numeric characters and emoticons appear are identified. Here, in order to retain the characteristics of malicious advertising data and distinguish the difference between the original malicious data and the normal text after mapping, we add "@#" characters before and after these special characters after mapping, so as to record the positions where special characters appear in the text for the model, thereby avoiding the loss of some features of the original malicious data due to the mapping process, so that the model can not only identify malicious advertising data through semantic features, but also identify malicious advertising data through the position and frequency of unrecognizable characters.
[0148] It should be noted that since the detection scenario of malicious advertising data requires tens of millions of calls every day and the amount of data is as high as billions, in order to reduce the detection time of special characters, emoticons and special numeric characters are only detected when characters that the model cannot recognize appear in the text.
[0149] In this way, in response to the strong antagonism of current malicious advertising data, that is, adding various confusing characters including special characters to the text to interfere with the recognition of the recognition model, the embodiments of the present application solve the impact of such problems on the recognition model with a high probability by preprocessing the text data.
[0150] In actual implementation, after preprocessing the text, the obtained data pair <malicious advertisement data 1, malicious advertisement data 2> and <clustering seed, malicious advertisement data> are constructed as the input of [SOS] source data [EOS] standard data [SOS], such as [SOS] malicious advertisement data 1 [EOS] malicious advertisement data 2 [SOS] and [SOS] clustering seed [EOS] malicious advertisement data [SOS] input, and then the corresponding character features, position features and sentence features are obtained, and the character features, position features and sentence features of the corresponding source data are fused to obtain the encoding features (first encoding features) of the corresponding source data; the character features, position features and sentence features of the corresponding standard data are fused to obtain the encoding features (second encoding features) of the corresponding standard data, so as to generate the corresponding data based on the two encoding features. Specifically, the seq2seq structure is adopted, firstly, 15% of the features in the standard data are randomly masked and the masked words are learned by using all the features in the source data plus the feature identifier on the left side of the word in the standard data. The masked data is replaced with a masked word 80% of the time, replaced with a randomly selected word 10% of the time, and retained as a real word 10% of the time. It should be noted that the end marker [SOS] at the end of the standard data can also be masked, in the hope that the model can learn to automatically end data generation.
[0151] It should be noted that after the corresponding data is generated based on the two coding features, the outputs of the masked positions are summarized, and the predicted data of the masked positions are obtained through the BertOnlyMLMHead model. The optimization goal of the final model is to maximize the likelihood of the masked standard data based on the context.
[0152] In actual implementation, since each platform currently uses real-time manual labeling online, the amount of malicious data missed by the online feedback model is usually relatively small. The original model can only generate a fixed output for one input data, and the number of generated is very limited. After iteration, the model may not be effectively improved. In response to this situation, the embodiment of the present application introduces a sample perturbation method, requiring that after the input is perturbed, the new output distribution is consistent with the distribution of the original output, so that the same source data can generate multiple target data with different content but similar features. It should be noted that there are many options for perturbation strategies, such as the random dropout method, which randomly sets a certain proportion of embeddings to 0 each time.
[0153] In actual implementation, in addition to the annotated data fed back online, we also focus on selecting text data with a recognition probability of less than 0.5 as source data. This solves the problem that due to the low recognition probability of such data, even if the model can successfully recognize this data, it can easily be upgraded to malicious data that can resist the ad recognition model through simple transformation.
[0154] The embodiments of the present application are aimed at the rapid upgrade of malicious data. Common malicious identification strategies usually use real-time sampling and real-time manual annotation to perceive the sudden mutation of malicious data and further use the feedback data to iterate the model. However, due to the limitation of manpower, the feedback data is usually small and time-consuming. By automatically learning the features of the upgraded malicious data and generating a large number of similar feature distributions, which can be called upgraded malicious data, the model can be quickly iterated, the R&D time can be shortened, and the total amount of black industry leakage during the period from the perception of black industry upgrade to the effectiveness of the crackdown can be reduced.
[0155] At the same time, in view of the diversity of malicious advertising attacks, due to the different data distribution characteristics and advertising identification standards of each business, malicious industry groups will consciously adopt different interference methods to generate adversarial texts for different scenarios. This community automatically generates enhanced data with corresponding business line characteristics by using the feedback data from different business lines, and further continuously iterates the malicious advertising recognition model for specific business lines, thereby coordinating the recall rate and recognition efficiency of the model to improve together.
[0156] In this way, the training samples of malicious data are supplemented through data enhancement, and the corresponding malicious data recognition model effect is improved. By combating malicious advertisements that divert malicious traffic, the exposure of high-quality comments is increased, attracting user attention, and thus improving the overall comments of the corresponding products and the interaction rate of the barrage area.
[0157] By using the above-mentioned embodiment of the present application, by clustering the target adversarial text data, a data pair of the target adversarial text data is constructed as a training data sample, and a data generation model is trained by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data, so that the data generation model obtained by training generates adversarial text data based on the target adversarial text data. In this way, the recognition effect of the corresponding data recognition model is improved through the generated adversarial text data, thereby effectively improving the recognition rate of the adversarial text data.
[0158] The following continues to describe the exemplary structure of the data generation model training device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, such as Figure 2 As shown, the software modules stored in the training device 455 of the data generation model in the memory 440 may include:
[0159] An acquisition module 4551 is used to acquire multiple pieces of target adversarial text data, and perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster;
[0160] A selection module 4552 is used to select at least one data pair from each of the data clusters, each of the data pairs including two pieces of the target adversarial text data, and use the data pair as a training data sample for the data generation model;
[0161] The training module 4553 is used to train the data generation model using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data to obtain a trained data generation model, and the trained data generation model is used to generate adversarial text data based on the target adversarial text data to be processed.
[0162] In some embodiments, the acquisition module 4551 is also used to perform word segmentation processing on each text data in the multiple target adversarial text data respectively to obtain the word segmentation results corresponding to each text data; based on the word segmentation results, determine the vocabulary intersection and vocabulary union between any two of the target adversarial text data; obtain the ratio of the vocabulary intersection and vocabulary union of any two of the target adversarial text data, and determine the ratio as the similarity between the corresponding two target adversarial text data; based on the determined similarity, cluster the multiple target adversarial text data to obtain at least one data cluster.
[0163] In some embodiments, the selection module 4552 randomly selects two target adversarial text data from at least two target adversarial text data included in the data cluster, and combines the two randomly selected target adversarial text data into a data pair; repeats the above operation until the target number of data pairs is selected or the data cluster is empty.
[0164] In some embodiments, the selection module 4552 is also used to obtain common text data of the text data included in the data cluster as a clustering seed of the data cluster; select at least one target adversarial text data from at least two target adversarial text data included in the data cluster; and respectively form the data pairs with the clustering seed and one of the selected target adversarial text data to obtain at least one data pair.
[0165] In some embodiments, the device also includes a recognition module, which is used to perform semantic recognition on the training data sample to obtain a semantic recognition result of the training data sample; when the semantic recognition result represents that the training data sample includes unrecognizable characters, based on a pre-set mapping relationship, the unrecognizable characters are mapped to recognizable characters to obtain a new training data sample; the training module 4553 is also used to train the data generation model using a target adversarial text data in the new training data sample as source data and another target adversarial text data as standard data.
[0166] In some embodiments, the recognition module is also used to detect the unrecognizable characters to determine the position and type of the unrecognizable characters; based on the type of the unrecognizable characters, obtain the unrecognizable character mapping relationship corresponding to the type, and based on the position of the unrecognizable characters, determine the position characteristics of the unrecognizable characters; based on the mapping relationship and the position characteristics, map the unrecognizable characters in the training data sample to recognizable characters to obtain new training data samples.
[0167] In some embodiments, the data generation model includes an encoding layer and a decoding layer, and the training module 4553 is also used to, through the encoding layer, encode the source data and the standard data in the training data sample, respectively, to obtain a first encoding feature corresponding to the source data and a second encoding feature corresponding to the standard data; through the decoding layer, decode the first encoding feature based on the first encoding feature and the second encoding feature to obtain adversarial text data corresponding to the source data; obtain the difference between the adversarial text data and the standard data, and update the model parameters of the data generation model based on the difference.
[0168] In some embodiments, the training module 4553 is also used to, through the encoding layer, encode the source data and the standard data in the training data sample, respectively, to obtain character features, position features and sentence features corresponding to the source data, and character features, position features and sentence features corresponding to the standard data; wherein the sentence features are used to distinguish the source data from the standard data; the character features, position features and sentence features corresponding to the source data are merged to obtain a first encoding feature corresponding to the source data; the character features, position features and sentence features corresponding to the standard data are merged to obtain a second encoding feature corresponding to the standard data.
[0169] In some embodiments, the device also includes an encryption module, which is used to encrypt a target number of features in the second coding feature to obtain an encrypted coding feature corresponding to the second coding data; the training module 4553 is also used to decode the first coding feature through the decoding layer based on the first coding feature and the encrypted coding feature to obtain adversarial text data corresponding to the source data; obtain target sub-data in the adversarial text data corresponding to the encrypted feature in the second coding feature, and obtain standard sub-data in the standard data corresponding to the encrypted feature in the second coding feature; compare the target sub-data with the standard sub-data to obtain the difference between the target sub-data and the standard sub-data, and update the model parameters of the data generation model based on the difference.
[0170] In some embodiments, the device also includes a perturbation module, which is used to perform data perturbation on the training data sample to obtain a perturbed training sample corresponding to the training data sample; the training module 4553 is also used to train the data generation model using one target adversarial text data in the perturbed training sample as source data and another target adversarial text data as standard data.
[0171] In some embodiments, the device also includes an application module, which is used to obtain the trained data generation model and original target adversarial text data; through the data generation model, based on the original target adversarial text data, generate adversarial text data corresponding to the original target adversarial text data.
[0172] In some embodiments, the application module is also used to perform data perturbation on the original target adversarial text data through the data generation model to obtain at least two perturbed text data; and generate at least two adversarial text data corresponding to the original target adversarial text data based on the at least two perturbed text data.
[0173] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the training method of the data generation model described in the embodiment of the present application.
[0174] The present application embodiment provides a computer-readable storage medium storing executable instructions, wherein executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the training method of the data generation model provided in the present application embodiment, for example, Figure 3The training method of the data generation model is shown.
[0175] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0176] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0177] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0178] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0179] In summary, the embodiments of the present application have the following beneficial effects:
[0180] (1) By automatically learning the features of the target adversarial text data and generating adversarial text data with similar features, the recognition effect of the corresponding data recognition model can be improved, thereby effectively improving the recognition rate of the adversarial text data.
[0181] (2) Based on the mapping relationship and position features, the unrecognizable characters in the training data samples are mapped to recognizable characters, which not only improves the recognition rate of the corresponding data recognition model, but also records the position of the unrecognizable characters, thereby avoiding the loss of some features of the target adversarial text data due to the mapping process. The corresponding data recognition model can not only recognize through semantic features, but also through the position and frequency of the unrecognizable characters, thereby further improving the recognition rate of the corresponding data recognition model.
[0182] (3) When the semantic recognition result indicates that the training data sample includes unrecognizable characters, the unrecognizable characters will be detected accordingly, so as to map the unrecognizable characters to recognizable characters, so as to obtain new training data samples to train the data generation model; and when the semantic recognition result indicates that the training data sample does not include unrecognizable characters, the data generation model is directly trained with the training data samples. In this way, the detection time of unrecognizable characters is reduced, and the training efficiency of the data generation model and the data generation efficiency are improved.
[0183] (4) The data generation model is trained by perturbing the training samples to avoid the model being overly dependent on certain local features, so that the model will neither overfit nor have too large a difference, and will have stronger generalization ability, thereby obtaining more adversarial text data.
[0184] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for training a data generation model, characterized in that: The method comprises: Acquire multiple pieces of target adversarial text data, and perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster; wherein the target adversarial text data includes text data whose text semantic information is destroyed; For each of the data clusters, at least one data pair is selected from the data cluster, each of the data pairs includes two pieces of the target adversarial text data, and Using the data pairs as training data samples for the data generation model; The data generation model is trained using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data to obtain a trained data generation model. The trained data generation model is used to perform data perturbation on the acquired original target adversarial text data to obtain at least two perturbed text data, and based on the at least two perturbed text data, at least two adversarial text data corresponding to the original target adversarial text data are generated.
2. The method according to claim 1, characterized in that The clustering process is performed on the plurality of target adversarial text data to obtain at least one data cluster, including: Performing word segmentation processing on each target adversarial text data in the plurality of target adversarial text data respectively to obtain a word segmentation result corresponding to each target adversarial text data; Based on the word segmentation results, determining the vocabulary intersection and vocabulary union between any two target adversarial text data; Obtaining a ratio of a vocabulary intersection to a vocabulary union of any two target adversarial text data, and determining the ratio as a similarity between the corresponding two target adversarial text data; Based on the determined similarity, clustering processing is performed on the plurality of target adversarial text data to obtain at least one data cluster.
3. The method according to claim 1, characterized in that The selecting at least one data pair from the data cluster comprises: Randomly selecting two target adversarial text data from at least two target adversarial text data included in the data cluster, and forming a data pair with the two randomly selected target adversarial text data; The above operation is repeated until the target number of data pairs is selected or the data cluster is empty.
4. The method according to claim 1, characterized in that The selecting at least one data pair from the data cluster comprises: Acquire common text data of the text data included in the data cluster as a clustering seed of the data cluster; Selecting at least one target adversarial text data from the at least two target adversarial text data included in the data cluster; The clustering seeds and one of the selected target adversarial text data are respectively combined into the data pairs to obtain at least one of the data pairs.
5. The method according to claim 1, characterized in that After using the data pair as a training data sample for the data generation model, the method further includes: Performing semantic recognition on the training data sample to obtain a semantic recognition result of the training data sample; When the semantic recognition result indicates that the training data sample includes unrecognizable characters, based on a preset mapping relationship, mapping the unrecognizable characters into recognizable characters to obtain a new training data sample; The step of training the data generation model by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data includes: The data generation model is trained using one target adversarial text data in the new training data sample as source data and another target adversarial text data as standard data.
6. The method according to claim 5, characterized in that The mapping of the unrecognizable characters to recognizable characters based on a preset mapping relationship to obtain new training data samples includes: Detecting the unrecognizable characters to determine the positions and types of the unrecognizable characters; Based on the type of the unrecognizable character, obtaining an unrecognizable character mapping relationship corresponding to the type, and Based on the position of the unrecognizable character, determining a position feature of the unrecognizable character; Based on the mapping relationship and the position feature, the unrecognizable characters in the training data sample are mapped to recognizable characters to obtain a new training data sample.
7. The method according to claim 1, characterized in that The data generation model includes an encoding layer and a decoding layer. The data generation model is trained by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data, including: By means of the encoding layer, the source data and the standard data in the training data sample are respectively encoded to obtain a first encoding feature corresponding to the source data and a second encoding feature corresponding to the standard data; By means of the decoding layer, based on the first coding feature and the second coding feature, the first coding feature is decoded to obtain adversarial text data corresponding to the source data; The difference between the adversarial text data and the standard data is obtained, and the model parameters of the data generation model are updated based on the difference.
8. The method according to claim 7, characterized in that The encoding layer is used to encode the source data and the standard data in the training data sample, respectively, to obtain a first encoding feature corresponding to the source data and a second encoding feature corresponding to the standard data, including: Through the encoding layer, the source data and the standard data in the training data sample are respectively encoded to obtain character features, position features and sentence features corresponding to the source data, and character features, position features and sentence features corresponding to the standard data; Wherein, the sentence feature is used to distinguish the source data from the standard data; The character feature, the position feature and the sentence feature corresponding to the source data are integrated to obtain a first coding feature corresponding to the source data; The character features, position features and sentence features corresponding to the standard data are integrated to obtain a second coding feature corresponding to the standard data.
9. The method according to claim 7, characterized in that The method further comprises: Encrypting a target number of features in the second coding feature to obtain an encrypted coding feature corresponding to the second coding data; The decoding layer decodes the first coding feature based on the first coding feature and the second coding feature to obtain adversarial text data corresponding to the source data, including: By means of the decoding layer, based on the first coding feature and the encrypted coding feature, the first coding feature is decoded to obtain adversarial text data corresponding to the source data; Obtaining a difference between the adversarial text data and the standard data, and updating a model parameter of the data generation model based on the difference, including: Acquire target sub-data in the adversarial text data corresponding to the encrypted feature in the second encoding feature, and acquire standard sub-data in the standard data corresponding to the encrypted feature in the second encoding feature; The target sub-data is compared with the standard sub-data to obtain a difference between the target sub-data and the standard sub-data, and a model parameter of the data generation model is updated based on the difference.
10. The method according to claim 1, characterized in that After using the data pair as a training data sample for the data generation model, the method further includes: Performing data perturbation on the training data samples to obtain perturbed training samples corresponding to the training data samples; The step of training the data generation model by using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data includes: The data generation model is trained using one target adversarial text data in the perturbation training sample as source data and another target adversarial text data as standard data.
11. A training device for a data generation model, characterized in that: The device comprises: An acquisition module, used to acquire multiple pieces of target adversarial text data, and perform clustering processing on the multiple pieces of target adversarial text data to obtain at least one data cluster; wherein the target adversarial text data includes text data whose text semantic information is destroyed; A selection module, for selecting at least one data pair from each of the data clusters, each of the data pairs comprising two pieces of the target adversarial text data, and using the data pair as a training data sample for the data generation model; A training module is used to train the data generation model using one target adversarial text data in the training data sample as source data and another target adversarial text data as standard data to obtain a trained data generation model. The trained data generation model is used to perform data perturbation on the acquired original target adversarial text data to obtain at least two perturbed text data, and based on the at least two perturbed text data, generate at least two adversarial text data corresponding to the original target adversarial text data.
12. An electronic device, characterized in that: include: A memory for storing computer executable instructions or computer programs; A processor, used to implement the training method of the data generation model described in any one of claims 1 to 10 when executing the computer executable instructions or computer program stored in the memory.
13. A computer-readable storage medium, characterized in that: Computer executable instructions or computer programs are stored, which are used to cause a processor to execute and implement the training method of the data generation model described in any one of claims 1 to 10.
14. A computer program product comprising computer executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the training method of the data generation model described in any one of claims 1 to 10 is implemented.
