A method, apparatus, and electronic device for detecting abnormal content
By converting feature data into preset numbers and using coding network processing, the detection speed reduction caused by the increase in the embedding matrix dimension is solved, and faster acquisition of abnormal content detection results is achieved, improving the user experience.
Patent Information
- Application Number
- CN202411898732.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2044-12-20
AI Technical Summary
When using neural network detection models to detect abnormal content, the improvement of the embedded matrix dimension in the pre-processing step leads to a decrease in the acquisition speed of detection results, affecting the user experience.
By converting the characteristic data of the numerical type into data of the preset number system, and determining the representation matrix corresponding to the converted characteristic data based on the data of the preset number system, encoding the representation matrix using the pretrained encoding network, obtaining the representation vector, and inputting the detection model for abnormal content detection.
This method improves the speed of obtaining detection results and improves user experience by reducing the representation matrix dimension of feature data.
Smart Images

Figure CN119357641B_ABST
Abstract
Description
Technical Field
[0001] This document belongs to the technical field of data processing, and particularly relates to a method, device and electronic device for detecting abnormal content. Background Art
[0002] In fields such as industrial production, network security, and financial risk control, using a detection model composed of a neural network is a conventional solution for detecting abnormal content. Before building the detection model, preprocessing is often performed on feature data of numerical type that does not violate user privacy, and this preprocessing often includes bucketing (or binning) the feature data.
[0003] Generally, several numerical intervals are divided according to methods such as equal frequency or equal width. Each numerical interval is used as a bucket. Assuming there are a total of m buckets and the feature data falls into the nth bucket, then the nth row can be selected from the initialized m*d embedding matrix (i.e., the embeeding matrix) as the representation of the feature data. Furthermore, the representation of the feature data can be input into the detection model to detect abnormal content.
[0004] However, the speed of preprocessing often drops rapidly as the dimension of the embeeding matrix increases, which will greatly reduce the speed at which users obtain the detection results output by the detection model. Therefore, it is necessary to provide a better abnormal content detection solution to improve the speed at which users obtain the detection results for abnormal content, thereby improving the user experience. Summary of the Invention
[0005] Embodiments of this specification provide a method, device and electronic device for detecting abnormal content to provide a detection solution for abnormal content.
[0006] In a first aspect, embodiments of this specification provide a method for detecting abnormal content. The method includes: obtaining feature data of numerical type of a target user and converting the feature data into data in a preset number system; determining a representation matrix corresponding to the converted feature data based on preset representation vectors corresponding to the digits of each data bit in the data in the preset number system in a preset representation matrix; encoding the representation matrix corresponding to the feature data using a pre-trained encoding network to obtain a representation vector corresponding to the feature data; and inputting the representation vector corresponding to the feature data into a detection model for detecting abnormal content to obtain a detection result for the abnormal content of the target user.
[0007] In a second aspect, an embodiment of this specification provides a device for detecting abnormal content, including: a number system conversion module, configured to obtain feature data of a numerical type of a target user and convert the feature data into data in a preset number system; a representation matrix module, configured to determine a representation matrix corresponding to the converted feature data based on preset representation vectors corresponding to the digits of each data bit in the data in the preset number system in a preset representation matrix; a representation vector module, configured to perform encoding processing on the representation matrix corresponding to the feature data by using a pre-trained encoding network to obtain a representation vector corresponding to the feature data; a detection result module, configured to input the representation vector corresponding to the feature data into a detection model for detecting abnormal content to obtain a detection result of the abnormal content for the target user.
[0008] In a third aspect, an embodiment of this specification provides an electronic device, which includes: a processor, and a memory arranged to store computer-executable instructions, and when the executable instructions are executed, it can enable the processor to: obtain feature data of a numerical type of a target user, convert the feature data into data in a preset number system; determine a representation matrix corresponding to the converted feature data based on preset representation vectors corresponding to the digits of each data bit in the data in the preset number system in a preset representation matrix; perform encoding processing on the representation matrix corresponding to the feature data by using a pre-trained encoding network to obtain a representation vector corresponding to the feature data; input the representation vector corresponding to the feature data into a detection model for detecting abnormal content to obtain a detection result of the abnormal content for the target user.
[0009] In a fourth aspect, an embodiment of this specification provides a storage medium for storing a computer program, and the computer program can be executed by a processor to implement the following process: obtain feature data of a numerical type of a target user, convert the feature data into data in a preset number system; determine a representation matrix corresponding to the converted feature data based on preset representation vectors corresponding to the digits of each data bit in the data in the preset number system in a preset representation matrix; perform encoding processing on the representation matrix corresponding to the feature data by using a pre-trained encoding network to obtain a representation vector corresponding to the feature data; input the representation vector corresponding to the feature data into a detection model for detecting abnormal content to obtain a detection result of the abnormal content for the target user.
[0010] Fifth aspect, an embodiment of this specification provides a computer program product, including a computer program which, when executed by a processor, implements the following processes: obtaining characteristic data of a numerical type of a target user, and converting the characteristic data into data in a preset number system; determining a representation matrix corresponding to the converted characteristic data based on preset representation vectors corresponding to the numerical digits of each data bit in the data in the preset number system in a preset representation matrix; using a pre-trained encoding network to perform encoding processing on the representation matrix corresponding to the characteristic data to obtain a representation vector corresponding to the characteristic data; and inputting the representation vector corresponding to the characteristic data into a detection model for detecting abnormal content to obtain a detection result of abnormal content for the target user. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] To more clearly illustrate the technical solutions in one or more embodiments of this specification or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0012] Figure 1 is a schematic flowchart of a method for detecting abnormal content provided by an embodiment of this specification;
[0013] Figure 2 is a schematic diagram of an application scenario of a method for detecting abnormal content provided by an embodiment of this specification;
[0014] Figure 3 is a schematic structural diagram of a device for detecting abnormal content provided by an embodiment of this specification;
[0015] Figure 4 is a schematic structural diagram of an electronic device provided by an embodiment of this specification. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0016] The following will clearly and completely describe the technical solutions in the embodiments of this specification with reference to the drawings in the embodiments of this specification. Obviously, the described embodiments are some, but not all, of the embodiments of this specification. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this document.
[0017] In the description and claims of this document, terms such as "first", "second", etc. are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of this specification can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and do not limit the number of objects. For example, the first object can be one or multiple. In addition, "and / or" in the description and claims means at least one of the connected objects, and the character " / ", generally represents an "or" relationship between the associated objects before and after.
[0018] The following will, in conjunction with the accompanying drawings, through specific embodiments and their application scenarios, elaborate in detail on the method, apparatus, and electronic device for detecting abnormal content provided by the embodiments of this specification.
[0019] Figure 1 There is shown a method for detecting abnormal content provided by an embodiment of the present invention. This method can be executed by an electronic device, which can include: a server and / or a terminal device, where the terminal device can be, for example, an in-vehicle terminal or a mobile phone terminal, etc. In other words, this method can be executed by software or hardware installed in the aforementioned electronic device. The method for detecting abnormal content includes the following steps:
[0020] Step S102: Obtain the numerical type of feature data of the target user, and convert the feature data into data in a preset number system.
[0021] Among them, the target user is the user to be detected for abnormal content, and the corresponding feature data is the data collected according to the detection target. For example, when the detection target is an abnormal transaction, the feature data can be the historical transaction data and / or the current transaction data of the target user (such as the transaction user, etc.); when the detection target is an abnormal score, the feature data can be the data related to the score of the target user (such as a student, etc.). In this specification, the detection target is not specifically limited and can be determined according to the actual situation.
[0022] A preset number system is a preset method for representing numerical values, which may include data bit information (which can be 32 bits, 64 bits, etc.), data storage methods (which can be integer type, floating-point type), and number system information (which can be binary, octal, decimal, etc.). In this specification, the preset number system is not specifically limited and can be determined according to the actual situation. Binary is the basis for data processing inside a computer. In one example, float32 (32-bit floating-point binary) or float64 (64-bit floating-point binary) can be selected as the preset number system. After obtaining the feature data, the feature data can be uniformly converted into data in the preset number system to realize the mining of information in the feature data. To better illustrate the embodiments in this specification and highlight the main idea of this specification, the specific embodiments of this specification take float32 as the description object. Those skilled in the art should understand that this specification can also be implemented for other number systems.
[0023] Specifically, after obtaining the preset numerical values, the data storage methods of each preset numerical value can be unified according to the data storage method in the preset number system (usually converted from integer type to floating-point type); then, according to the number system information and data bit information in the preset number system, the number systems and data bits of each preset numerical value can be unified.
[0024] Step S104: Determine the representation matrix corresponding to the converted feature data based on the preset representation vectors corresponding to the digital codes of each data bit in the data of the preset number system in the preset representation matrix.
[0025] Among them, the preset representation vector is an embedding vector that constitutes the preset representation matrix (embedding matrix) determined according to the preset number system. This embedding matrix can be initialized with a standard normal distribution (that is, the mean is 0 and the standard deviation is 1). The number of preset representation vectors that make up the preset representation matrix is the same as the sum of the number of digital codes included in each data bit in the preset number system.
[0026] Digital code is a different digital symbol used to represent the basic numerical size in a number system. For example, the decimal system has 10 digital codes: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; the binary system has 2 digital codes: 0, 1. In the case where the preset number system is in the form of float32, the number of data bits is 32. Each digital code 0 or digital code 1 of each data bit corresponds to an embedding vector (i.e., the preset representation vector) in the initialized embedding matrix. Assuming the dimension of the embedding vector is d1, the dimension of the embedding matrix corresponding to the preset number system float32 is 64 * d1.
[0027] The bucketing scheme can bucket various types of feature data separately. Since the numerical distributions of each feature are different and each feature needs to be bucketed individually, for example, each type of feature can be divided into 100 buckets, and each bucket corresponds to a representation vector. If there are 100 types of features, there will be 10,000 representation vectors in the end. That is to say, when the dimension of each representation vector is d1, the dimension of the embedding matrix is 100 * 100 * d1 (i.e., n * m * d1, where n is the number of feature categories and m is the number of buckets for each type of feature). In this way, the dimension of the embedding matrix in this bucketing scheme will increase rapidly with the increase in the number of feature categories (usually in thousands or tens of thousands) and / or the number of buckets for each type of feature.
[0028] For the above bucketing scheme, this specification provides a different bucketing scheme. In this bucketing scheme, the dimension of the preset representation matrix corresponds to a preset number system and does not change with the change in the number of feature types. Moreover, since the dimension of the preset representation matrix 64 * d1 is much smaller than the dimension of the embedding matrix n * m * d1 in the previous bucketing scheme, therefore, compared with the dimension of the embedding matrix in the previous bucketing scheme, the dimension of the preset representation matrix in this bucketing scheme is significantly reduced and can represent rich feature data.
[0029] After initializing the embedding matrix, the preset representation vectors corresponding to the values of each data bit in the converted feature data can be determined from the embedding matrix. Furthermore, the preset representation vectors corresponding to each data bit in the feature data can be concatenated to determine the representation matrix. For float32 feature data, there are 32 data bits. After finding the corresponding preset representation vectors f1, f2, ..., f32 in the embedding matrix for the value of each data bit in the feature data, a representation matrix R of 32 * d1 can be finally obtained.
[0030] Step S106: Use the pre-trained encoding network to perform encoding processing on the representation matrix corresponding to the feature data to obtain the representation vector corresponding to the feature data.
[0031] Among them, the encoding (encoder) network is a network that converts the representation matrix into a representation vector. The encoding network can be composed of a neural network, and this neural network can be a Recurrent Neural Network (RNN), a Convolutional Neural Network (CNN), and / or a neural network based on the self-attention mechanism (transformer), etc. To achieve the transformation of the feature data from a matrix to a vector, the encoding network can include a normalization layer with L2 norm at the end of the network structure.
[0032] After initializing the encoding network, a dataset composed of representation matrices can be used for pre-training. Then, after inputting the representation matrix corresponding to the feature data into the pre-trained encoding network (with parameters frozen at this time), the representation vector corresponding to the feature data can be obtained. For feature data in float32, the dimension of the representation matrix R is 32 * d1, and the pre-trained encoding network can output a representation vector r with a dimension of d2.
[0033] Step S108: Input the representation vector corresponding to the feature data into a detection model for detecting abnormal content to obtain a detection result of the abnormal content for the target user.
[0034] Among them, the detection model is a model for detecting abnormal content in input data, and this detection model can be trained using training data collected according to the detection target. Inputting the representation vector corresponding to the aforementioned determined feature data into the trained detection model can obtain the detection result of the abnormal content for the target user.
[0035] In the embodiments of this specification, the digital codes of each data bit in the preset representation matrix are used to determine the representation matrix corresponding to the feature data converted to the preset number system. After using the encoding network to perform encoding processing on the representation matrix corresponding to the feature data, the representation vector for determining the detection result of abnormal content can be obtained. This process determines the representation matrices corresponding to each feature data by sharing the same preset representation matrix, realizing a new data bucketing scheme. Since this preset representation matrix corresponds to the preset number system, the dimension of the preset representation matrix is fixed and relatively small, which can improve the speed of using the preset representation matrix to determine the detection result for abnormal content, and thus can improve the user experience.
[0036] Figure 2 A schematic diagram of an application scenario of a method for detecting abnormal content is provided, as Figure 2 shown, the user sends a service request to the server through a terminal such as a mobile phone. The service request includes: performing a target task of detecting abnormal content for the target user on the feature data of the target user provided by the user. After receiving the service request, the server uses the method for detecting abnormal content in this specification to obtain the detection result of the abnormal content for the target user, and sends the detection result of the abnormal content to the terminal for the user's reference.
[0037] In one implementation, step S104 can be performed as steps A1 - A3 as follows:
[0038] Step A1: Determine the target digital codes corresponding to the values of each data bit in the converted feature data from the digital codes of each data bit in the data of the preset number system;
[0039] Step A2: Determine the preset representation vector corresponding to the target digital code from the preset representation matrix;
[0040] Step A3: Concatenate the preset representation vectors of the target digital codes corresponding to each data bit in the feature data to obtain the representation matrix of the feature data.
[0041] Among them, the target digital code is the digital code corresponding to the value on the data bit in the feature data. Specifically, the process of determining the representation matrix corresponding to the feature data according to the preset representation matrix can be: first determine the data bits corresponding to each data bit in the converted feature data in the preset number system; from the digital codes of the corresponding data bits, determine the target digital code corresponding to the value in the data bit of the feature data; determine the preset representation vector corresponding to the target digital code from the preset representation matrix; concatenate the preset representation vectors corresponding to each data bit in the feature data to obtain the representation matrix corresponding to the feature data.
[0042] Binary is the basis for data processing inside a computer. In one example, the preset number system is binary, and Step A1 can be executed as the following Steps B1 - B2:
[0043] Step B1: When the value corresponding to the target data bit in the converted feature data is 0, use the digital code 0 corresponding to the target data bit in the preset number system as the target digital code of the target data bit;
[0044] Step B2: When the value corresponding to the target data bit in the converted feature data is 1, use the digital code 1 corresponding to the target data bit in the preset number system as the target digital code of the target data bit.
[0045] Among them, the target data bit is one of the data bits in the converted feature data. For the case where the preset number system is binary, the digital codes include 0 and 1. Therefore, for the same data bit (i.e., the target data bit) of the converted feature data and the preset value, when the values of the converted feature data and the preset value are the same (both 0 or both 1), the digital code of the preset value can be used as the target digital code of the converted data. For example, for the target data bit of the converted feature data and the preset value, when the value of the target data is 0, the digital code 0 of the preset value can be used as the target digital code of the target data bit; when the value of the target data is 1, the digital code 1 of the preset value can be used as the target digital code of the target data bit.
[0046] Similar to the construction process of the representation matrix corresponding to the converted feature data, the process of determining the preset representation matrix corresponding to the preset number system can be executed as the following Steps C1 - C2:
[0047] Step C1: Obtain the digits of each data bit in the data in the preset number system, and determine the preset representation vectors corresponding to the digits according to the digits and the data bits corresponding to the digits.
[0048] Step C2: Perform a concatenation operation on the preset representation vectors corresponding to each digit in the preset number system to obtain a preset representation matrix corresponding to the preset value.
[0049] Specifically, for the digits of each data bit in the data of the preset number system, the preset representation vectors of each digit in this data bit can be determined according to the digits and the data bits corresponding to the digits. Furthermore, the preset representation vectors corresponding to different digits in each data bit of the preset value can be concatenated to obtain the preset representation matrix. As mentioned above, the dimension of the preset representation matrix corresponding to the preset number system float32 is 64*d1. Among them, the preset representation vectors can be initialized through a standard normal distribution (mean is 0, standard deviation is 1).
[0050] In the above process, since the dimension of the preset representation matrix is fixed and small, the process of determining the representation matrix corresponding to the transformed feature data based on the preset representation vectors corresponding in the preset representation matrix can greatly reduce the determination time of the representation matrix of the feature data, and thus can improve the speed of using the preset representation matrix to determine the detection result for abnormal content.
[0051] In one implementation, the pre-training process of the encoding network can be performed as the following steps D1 - D5:
[0052] Step D1: Obtain the randomly generated sample data included in the dataset, and convert the sample data into the data of the preset number system.
[0053] Step D2: Based on the preset representation vectors corresponding to the digits of each data bit in the data of the preset number system in the preset representation matrix, determine the representation matrix corresponding to the transformed sample data.
[0054] Step D3: Use the encoding network to perform encoding processing on the representation matrix corresponding to the sample data to obtain the representation vector corresponding to the sample data.
[0055] Step D4: Randomly select two sample data from the dataset in sequence and each time to construct multiple binary groups, and construct a first loss according to the similarity between the representation vectors corresponding to the two sample data in the binary group.
[0056] Step D5: Pre-train the encoding network according to the first loss to obtain the pre-trained encoding network.
[0057] Among them, the dataset is used to pre-train the encoding network. Each data included in it is sample data, and the sample data in the dataset can be randomly generated data. After obtaining the dataset, each sample data in the dataset can be first converted into data in a preset number system (such as float32).
[0058] Similar to the above process of determining the representation matrix, from the embedding matrix, the preset representation vectors corresponding to the values of each data bit in the converted sample feature data can be determined. Furthermore, the preset representation vectors corresponding to each data bit in the sample feature data can be concatenated to determine the sample representation matrix. For the float32 sample feature data, a representation matrix R of 32 * d1 can be obtained.
[0059] After initializing the encoding network, the encoding network can be used to determine the representation vector corresponding to the sample data. For the float32 sample feature data, the dimension of the sample representation matrix R is 32 * d1, and the dimension of the representation vector r corresponding to the sample data output by the encoding network is d2.
[0060] After determining the representation vector corresponding to the sample data, the first loss can be determined based on the similarity between the dimensions of the representation vectors corresponding to each sample data in the dataset. Then, the encoding network can be pre-trained according to the first loss. In one example, the first loss can be constructed using the contrastive learning method. Specifically, for the target sample data that is any sample data in the dataset, based on the absolute value of the difference between other sample data and the target sample data, the positive example and negative example of the target sample data can be determined. The positive example is the sample data with a smaller absolute value of the difference from the target sample data, and the negative example is the sample data with a larger absolute value of the difference from the target sample data. Based on the representation vectors of the positive example and negative example, the first loss can be constructed, and then the encoding network can be trained according to the first loss.
[0061] In addition to the above contrastive learning method, step D5 can be performed as the following steps E1 - E2:
[0062] Step E1, construct the second loss according to the difference degree between the two sample data in the binary group;
[0063] Step E2, pre-train the encoding network according to the first loss and the second loss to obtain the pre-trained encoding network.
[0064] In addition to constructing the first loss based on the similarity between the representation vectors corresponding to the two sample data in the binary tuple, the similarity and the difference degree can be combined to pre-train the encoding network. Specifically, two sample data num1 and num2 in the dataset can be randomly selected to construct a binary tuple (num1, num2), and the second loss can be constructed based on the difference degree between the two sample data in the binary tuple. Furthermore, the encoding network can be trained according to the first loss and the second loss.
[0065] Specifically, after encoding the binary tuple (num1, num2), two representation matrices R1 and R2 can be obtained. Then, these two representation matrices are input into the encoding network, and two representation vectors r1 and r2 can be obtained. Furthermore, according to the similarity between the representation vectors r1 and r2, the first loss can be constructed, and according to the difference degree between num1 and num2, the second loss can be constructed.
[0066] In this way, the loss for training the encoding network includes, in addition to the first loss, the second loss that expresses the difference degree between the sample data, so that the representation vectors corresponding to the feature data output by the encoding network trained according to the first loss and the second loss can express the gap between the original feature data to a certain extent. Furthermore, the detection model can more easily learn the information in the representation vectors corresponding to the feature data, increasing the probability of detecting the abnormal content of the target user and improving the accuracy of abnormal content detection.
[0067] Since the value ranges of both the similarity and the difference degree are (-1, 1), the first loss can be determined by taking the absolute value of the similarity, and the second loss can be determined by taking the absolute value of the difference degree. In addition, step E2 can be executed as the following steps F1 - F3:
[0068] Step F1, map the first loss to the target value range to obtain the mapped first loss, and map the second loss to the target value range to obtain the mapped second loss;
[0069] Step F2, determine the distance loss representing the distance between the two sample data in the binary tuple according to the extreme points of the target value range and the mapped first loss;
[0070] Step F3, pre-train the encoding network according to the distance loss and the mapped second loss to obtain the pre-trained encoding network.
[0071] Since the values of the similarity and the difference can be positive or negative, the first loss and the second loss can also be positive or negative. For the convenience of calculation, the target value range can be (0, 1). Specifically, the first loss and the second loss can be mapped to this target value range by taking the absolute value or squaring, etc., retaining the values of the similarity and the difference and discarding the directions.
[0072] When the target value range can be (0, 1), the preset extreme point can be taken as 1. At this time, according to the difference between the preset extreme point of the target value range and the mapped first loss, the distance loss representing the distance between the representation vectors corresponding to the two sample data in the binary group can be obtained.
[0073] Since the difference between the two sample data in the binary group represents the distance between the two sample data in the binary group, the difference between the two sample data in the binary group can be used to determine the difference degree between the two sample data, and the difference degree can be mapped to the target value range to obtain the mapped second loss. Furthermore, the gap between the mapped second loss and the distance loss is used as the total loss of the encoding network to train the encoding network according to the total loss. Specifically, the training objective of this training process can be to make the gap between the mapped second loss and the distance loss close to 0.
[0074] In one implementation, step E1 can be executed as the following steps G1 - G2:
[0075] Step G1, use a preset activation function to perform an activation operation on the difference between the two sample data in the binary group to obtain the activation difference between the two sample data in the binary group;
[0076] Step G2, construct the second loss according to the activation difference between the two sample data in the binary group.
[0077] The distance loss represents the loss of the distance between the two sample data in the binary group, while the second loss represents the difference degree between the two sample data in the binary group. Therefore, the association between the distance loss and the second loss can be established, and the total loss of the encoding network can be constructed through the difference between the two. In the process of constructing the second loss based on the difference between the two sample data in the binary group, since the value range of the distance loss constructed based on the similarity between the representation vectors corresponding to the two sample data in the binary group is (0, 1), in order to establish the association between the distance loss and the second loss, an activation function (such as tanh) can be used to perform an activation operation on the difference between the two sample data in the binary group to obtain the activation difference.
[0078] When the activation function is tanh, the value range of the activation difference determined by the activation function tanh is (-1, 1). The activation difference is used as the second loss and mapped to the target value range by means such as squaring or taking the absolute value to obtain the mapped second loss. The value range of the mapped second loss is the same as that of the distance loss, both being (0, 1). At this time, the association between the target loss and the second loss is established. According to the distance loss and the mapped second loss, the total loss of the encoding network can be constructed, and then the encoding network can be trained according to the total loss.
[0079] Formula 1 shows the determination process of the total loss of the encoding network:
[0080] loss = ((1 - dot(r1, r2) 2 ) - tanh(num1 - num2) 2 ) 2 (Formula 1)
[0081] Where loss is the total loss of the encoding network, num1 and num2 are the values of two sample data in each binary group, r1 and r2 are the representation vectors corresponding to the two sample data in the binary group, dot(r1, r2) 2 is the first loss, (1 - dot(r1, r2) 2 ) is the distance loss, and tanh(num1 - num2) 2 is the second loss.
[0082] It can be understood that the above-mentioned method embodiments mentioned in this specification can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, they are not elaborated in this specification. Those skilled in the art can understand that in the above methods of the specific implementation manner, the specific execution order of each step should be determined according to its function and possible internal logic.
[0083] It should be noted that for the method for detecting abnormal content provided in the embodiments of this specification, the execution subject can be a device for detecting abnormal content, or a control module in the device for detecting abnormal content that executes the method for detecting abnormal content. In the embodiments of this specification, the method for detecting abnormal content executed by the device for detecting abnormal content is taken as an example to illustrate the device for detecting abnormal content provided in the embodiments of this specification.
[0084] Figure 3 is a schematic structural diagram of a device for detecting abnormal content according to an embodiment of the present invention. As Figure 3 shown, the device 300 for detecting abnormal content includes:
[0085] The number system conversion module 310 is used to obtain the feature data of the numerical type of the target user and convert the feature data into data in a preset number system;
[0086] The characterization matrix module 320 is used to determine the characterization matrix corresponding to the converted feature data based on the preset characterization vectors corresponding to the digital codes of each data bit in the data of the preset number system in a preset characterization matrix;
[0087] The characterization vector module 330 is used to perform encoding processing on the characterization matrix corresponding to the feature data using a pre-trained encoding network to obtain the characterization vector corresponding to the feature data;
[0088] The detection result module 340 is used to input the characterization vector corresponding to the feature data into a detection model for detecting abnormal content to obtain the detection result of the abnormal content for the target user.
[0089] In one embodiment, the characterization matrix module 320 includes:
[0090] The target digital unit is used to determine the target digital code corresponding to the value of each data bit in the converted feature data from the digital codes of each data bit in the data of the preset number system;
[0091] The characterization vector unit is used to determine the preset characterization vector corresponding to the target digital code from the preset characterization matrix;
[0092] The characterization matrix unit is used to perform a splicing operation on the preset characterization vectors of the target digital codes corresponding to each data bit in the feature data to obtain the characterization matrix of the feature data.
[0093] In one embodiment, the preset number system is binary, and the target digital unit is used for:
[0094] When the value corresponding to the target data bit in the converted feature data is 0, the digital code 0 corresponding to the target data bit in the preset number system is used as the target digital code of the target data bit;
[0095] When the value corresponding to the target data bit in the converted feature data is 1, the digital code 1 corresponding to the target data bit in the preset number system is used as the target digital code of the target data bit.
[0096] In one embodiment, the process of determining the preset characterization matrix corresponding to the preset number system includes:
[0097] Obtain the digital codes of each data bit in the data of the preset number system, and determine the preset characterization vector corresponding to the digital code according to the digital code and the data bit corresponding to the digital code;
[0098] Perform a splicing operation on the preset characterization vectors corresponding to each digital code in the preset number system to obtain the preset characterization matrix corresponding to the preset number system.
[0099] In one embodiment, the pre-training process of the encoding network includes:
[0100] Obtain randomly generated sample data included in the dataset, and convert the sample data into data in a preset number system;
[0101] Based on the preset representation vectors corresponding to the digital codes of each data bit in the data of the preset number system in the preset representation matrix, determine the representation matrix corresponding to the converted sample data;
[0102] Use the encoding network to perform encoding processing on the representation matrix corresponding to the sample data to obtain the representation vector corresponding to the sample data;
[0103] Randomly extract two sample data from the dataset in sequence and each time to construct multiple pairs, and construct a first loss according to the similarity between the representation vectors corresponding to the two sample data in the pair;
[0104] Pre-train the encoding network according to the first loss to obtain the pre-trained encoding network.
[0105] In one embodiment, pre-training the encoding network according to the first loss to obtain the pre-trained encoding network includes:
[0106] Construct a second loss according to the difference degree between the two sample data in the pair;
[0107] Pre-train the encoding network according to the first loss and the second loss to obtain the pre-trained encoding network.
[0108] In one embodiment, pre-training the encoding network according to the first loss and the second loss to obtain the pre-trained encoding network includes:
[0109] Map the first loss to the target value range to obtain the mapped first loss, and map the second loss to the target value range to obtain the mapped second loss;
[0110] Determine the distance loss representing the distance between the representation vectors corresponding to the two sample data in the pair according to the extreme points of the target value range and the mapped first loss;
[0111] Pre-train the encoding network according to the distance loss and the mapped second loss to obtain the pre-trained encoding network.
[0112] In one embodiment, constructing the second loss according to the difference degree between the two sample data in the pair includes:
[0113] Perform an activation operation on the difference between the two sample data in the binary tuple using a preset activation function to obtain the activation difference between the two sample data in the binary tuple;
[0114] Construct a second loss according to the activation difference between the two sample data in the binary tuple.
[0115] It should be noted that the embodiments of the apparatus for abnormal content detection in this specification and the embodiments of the method for abnormal content detection in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method for abnormal content detection described above, and the repeated parts will not be elaborated.
[0116] Each module in the above-mentioned apparatus for abnormal content detection can be implemented in whole or in part by software, hardware, and their combination. The above-mentioned modules can be embedded in the processor in the terminal device or the processor in the server in the form of hardware, or can be stored in the memory in the terminal device or the memory in the server in the form of software, so as to facilitate the processor to call and execute the operations corresponding to the above-mentioned modules.
[0117] Furthermore, corresponding to the above-described method for abnormal content detection, based on the same technical concept, one or more embodiments of this specification also provide an electronic device, which is used to execute the above-mentioned method for abnormal content detection. Figure 4 FIG. is a schematic structural diagram of an electronic device provided by one or more embodiments of this specification.
[0118] Based on the same idea, one or more embodiments of this specification also provide an electronic device, as Figure 4 shown. The electronic device may vary greatly due to configuration or performance differences, and may include one or more processors 401 and a memory 402. One or more application programs or data may be stored in the memory 402. Among them, the memory 402 may be a transient storage or a persistent storage. The application programs stored in the memory 402 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions in the electronic device. Further, the processor 401 may be set to communicate with the memory 402 and execute a series of computer-executable instructions in the memory 402 on the electronic device. The electronic device may also include one or more power supplies 403, one or more wired or wireless network interfaces 404, one or more input / output interfaces 405, and one or more keyboards 406.
[0119] In a specific embodiment, an electronic device includes a memory and one or more programs. One or more of the programs are stored in the memory, and one or more of the programs may include one or more modules. Each module may include a series of computer-executable instructions in the electronic device and is configured to be executed by one or more processors. The one or more programs include the following computer-executable instructions for:
[0120] Obtain the feature data of the numerical type of the target user and convert the feature data into data in a preset number system;
[0121] Based on the preset representation vectors corresponding to the digits of each data bit in the data of the preset number system in the preset representation matrix, determine the representation matrix corresponding to the converted feature data;
[0122] Use the pre-trained encoding network to perform encoding processing on the representation matrix corresponding to the feature data to obtain the representation vector corresponding to the feature data;
[0123] Input the representation vector corresponding to the feature data into the detection model for detecting abnormal content to obtain the detection result of the abnormal content for the target user.
[0124] It should be noted that the embodiment of the electronic device in this specification and the embodiment of the method for detecting abnormal content in this specification are based on the same inventive concept. Therefore, for the specific implementation of this embodiment, reference may be made to the corresponding implementation of the method for detecting abnormal content described above, and the repeated parts will not be elaborated.
[0125] Furthermore, corresponding to the method for detecting abnormal content described above and based on the same technical concept, one or more embodiments of this specification also provide a storage medium for storing computer-executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disc, a hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by a processor, the following process can be realized:
[0126] Obtain the feature data of the numerical type of the target user and convert the feature data into data in a preset number system;
[0127] Based on the preset representation vectors corresponding to the digits of each data bit in the data of the preset number system in the preset representation matrix, determine the representation matrix corresponding to the converted feature data;
[0128] Use the pre-trained encoding network to perform encoding processing on the representation matrix corresponding to the feature data to obtain the representation vector corresponding to the feature data;
[0129] Input the representation vector corresponding to the feature data into the detection model for detecting abnormal content to obtain the detection result of the abnormal content for the target user.
[0130] It should be noted that the embodiments of the storage medium in this specification and the method for detecting abnormal content in this specification are based on the same inventive concept. Therefore, for the specific implementation of this embodiment, reference may be made to the implementation of the corresponding method for detecting abnormal content described above, and repeated parts will not be elaborated.
[0131] Furthermore, corresponding to the method for detecting abnormal content described above and based on the same technical concept, one or more embodiments of this specification also provide a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, it can implement the following processes:
[0132] Obtain the feature data of the numerical type of the target user, and convert the feature data into data in a preset number system;
[0133] Based on the preset representation vectors corresponding to the digits of each data bit in the data in the preset number system in the preset representation matrix, determine the representation matrix corresponding to the converted feature data;
[0134] Use the pre-trained encoding network to perform encoding processing on the representation matrix corresponding to the feature data to obtain the representation vector corresponding to the feature data;
[0135] Input the representation vector corresponding to the feature data into the detection model for detecting abnormal content to obtain the detection result of the abnormal content for the target user.
[0136] It should be noted that the embodiments of the computer program product in this specification and the embodiments of the method for detecting abnormal content in this specification are based on the same inventive concept. Therefore, for the specific implementation of this embodiment, reference may be made to the implementation of the corresponding method for detecting abnormal content described above, and repeated parts will not be elaborated.
[0137] The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0138] In the 1990s, it was obvious to distinguish whether an improvement in a technology was an improvement in hardware (e.g., improvement in circuit structures such as diodes, transistors, switches, etc.) or an improvement in software (improvement in method flows). However, with the development of technology, many improvements in method flows today can be regarded as direct improvements in hardware circuit structures. Almost all designers obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented with a hardware entity module. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can program by themselves to "integrate" a digital system on a piece of PLD without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL). And there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. Currently, the most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be clear that as long as the method flow is slightly logically programmed with the above-mentioned several hardware description languages and programmed into the integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0139] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or structures within the hardware component.
[0140] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0141] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0142] Those skilled in the art should understand that one or more embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, one or more embodiments of this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0143] This specification is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the specification. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks for implementing the specified functions.
[0144] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks for implementing the specified functions.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 one or more of the blocks for implementing the specified functions.
[0146] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0147] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0148] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transitory medium that can store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0149] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0150] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
[0151] Each embodiment in this specification is described in a progressive manner, and the same or similar parts among the embodiments may be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts may refer to the description of the method embodiments.
[0152] The above are only examples of this document and are not intended to limit this document. For those skilled in the art, various changes and modifications can be made to this document. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document shall be included within the scope of the claims of this document.
Claims
1. A method for detecting abnormal content, comprising: Acquire characteristic data of a target user in a numerical type, and convert the characteristic data into data in a preset numerical system; Performing a concatenation operation on the preset characterization vectors corresponding to the digital numbers of each data bit in the data of the preset number system in the preset characterization matrix to obtain a characterization matrix corresponding to the converted feature data; Using a pre-trained encoding network to encode the representation matrix corresponding to the feature data, to obtain a representation vector corresponding to the feature data; The representation vector corresponding to the feature data is input into a detection model for abnormal content detection to obtain a detection result of abnormal content for the target user.
2. According to the method of claim 1, the step of concatenating the preset characterization vectors corresponding to the digital numbers of each data bit in the data of the preset number system in the preset characterization matrix to obtain the characterization matrix corresponding to the converted feature data comprises: Determine the target digital number corresponding to the value of each data bit in the converted characteristic data from the digital number of each data bit in the data of the preset digital system; Determining a preset characterization vector corresponding to the target digital number from the preset characterization matrix; The preset characterization vectors of the target digital number corresponding to each data bit in the characteristic data are concatenated to obtain a characterization matrix of the characteristic data.
3. The method according to claim 2, wherein the preset number system is binary, and the step of determining the target number corresponding to the value of each data bit in the converted feature data from the number of each data bit in the data of the preset number system comprises: When the value corresponding to the target data bit in the converted characteristic data is 0, the digital number 0 corresponding to the target data bit in the preset number system is used as the target digital number of the target data bit; When the value corresponding to the target data bit in the converted characteristic data is 1, the digital number 1 corresponding to the target data bit in the preset number system is used as the target digital number of the target data bit.
4. The method according to claim 3, wherein the process of determining the preset representation matrix corresponding to the preset number system comprises: Obtaining the digital number of each data bit in the data of the preset number system, and determining the preset representation vector corresponding to the digital number according to the digital number and the data bit corresponding to the digital number; The preset representation vectors corresponding to the respective digits in the preset number system are concatenated to obtain a preset representation matrix corresponding to the preset number system.
5. According to the method of claim 1, the pre-training process of the encoding network comprises: Obtain randomly generated sample data contained in the data set, and convert the sample data into data in a preset number system; Determine the representation matrix corresponding to the converted sample data based on the preset representation vector corresponding to the digital number of each data bit in the data of the preset number system in the preset representation matrix; Using the encoding network to encode the representation matrix corresponding to the sample data, to obtain the representation vector corresponding to the sample data; Sequentially and randomly extracting two sample data from the data set each time to construct a plurality of bigrams, and constructing a first loss according to the similarity between the representation vectors corresponding to the two sample data in the bigram; The encoding network is pre-trained according to the first loss to obtain the pre-trained encoding network.
6. The method according to claim 5, wherein the pre-training the encoding network according to the first loss to obtain the pre-trained encoding network comprises: Constructing a second loss according to the difference between two sample data in the binary group; The encoding network is pre-trained according to the first loss and the second loss to obtain the pre-trained encoding network.
7. The method according to claim 6, wherein the pre-training the encoding network according to the first loss and the second loss to obtain the pre-trained encoding network comprises: Mapping the first loss into a target value range to obtain a mapped first loss, and mapping the second loss into the target value range to obtain a mapped second loss; Determine, according to the extreme value point of the target value range and the mapped first loss, a distance loss representing the distance between the characterization vectors corresponding to the two sample data in the binary group; The encoding network is pre-trained according to the distance loss and the mapped second loss to obtain the pre-trained encoding network.
8. The method according to claim 6, wherein constructing the second loss according to the difference between the two sample data in the binary group comprises: Using a preset activation function to perform an activation operation on the difference between the two sample data in the binary group to obtain an activation difference between the two sample data in the binary group; The second loss is constructed according to the activation difference between two sample data in the bigram.
9. A device for detecting abnormal content, comprising: A number system conversion module, used to obtain characteristic data of a target user in a numerical type and convert the characteristic data into data of a preset number system; A characterization matrix module, used for performing a splicing operation on the preset characterization vectors corresponding to the digital numbers of each data bit in the data of the preset number system in the preset characterization matrix to obtain a characterization matrix corresponding to the converted feature data; A representation vector module, used to encode the representation matrix corresponding to the feature data using a pre-trained encoding network to obtain a representation vector corresponding to the feature data; The detection result module is used to input the representation vector corresponding to the feature data into a detection model for abnormal content detection to obtain a detection result of abnormal content for the target user.
10. An electronic device comprising: processor, and a memory arranged to store computer executable instructions which, when executed, cause the processor to: Acquire characteristic data of a target user in a numerical type, and convert the characteristic data into data in a preset numerical system; Performing a concatenation operation on the preset characterization vectors corresponding to the digital numbers of each data bit in the data of the preset number system in the preset characterization matrix to obtain a characterization matrix corresponding to the converted feature data; Using a pre-trained encoding network to encode the representation matrix corresponding to the feature data, to obtain a representation vector corresponding to the feature data; The representation vector corresponding to the feature data is input into a detection model for abnormal content detection to obtain a detection result of abnormal content for the target user.
Citation Information
Patent Citations
Network traffic classification method based on self-attention mechanism, medium and terminal equipment
CN111355671A
Feature perception pre-training method and system for time sequence anomaly detection
CN118708932A