Website classification model training, website classification method, device, equipment and medium
By generating and splicing URL feature vectors, the semantic learning and feature extraction capabilities of the malicious URL detection model are improved, the problem of low accuracy in the existing technology is solved, and higher recall and accuracy are achieved.
Patent Information
- Application Number
- CN202110820105.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-20
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-07-20
AI Technical Summary
Existing deep learning methods only rely on unilateral URL features in malicious URL detection, resulting in poor semantic learning and feature extraction capabilities of the model and low accuracy.
By obtaining the URL training data, a character vector matrix and a word vector matrix are generated, and their feature vectors are extracted and spliced to train the URL classification model to improve the model's semantic learning and feature extraction capabilities.
The recall rate and accuracy of the website classification model are improved, and the classification accuracy is improved.
Smart Images

Figure CN113449816B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to website classification model training, website classification methods, devices, equipment and media. Background Art
[0002] With the development of the Internet, network attacks have become an increasingly important security issue. Various types of attacks, such as phishing, Trojans, and malware, often use malicious URLs (Uniform Resource Locators) as a means. Therefore, identifying malicious URLs is of great significance in preventing various network attacks and maintaining network security.
[0003] With the development of artificial intelligence, deep learning methods have been widely used in malicious URL detection. However, existing deep learning methods are only trained based on unilateral URL features, such as character features, which leads to poor model semantic learning and feature extraction capabilities and low model accuracy. Summary of the invention
[0004] The embodiments of the present invention provide a website classification model training, website classification method, device, equipment and medium to improve the recall rate of the website classification model, thereby improving the accuracy and classification precision of the website classification model.
[0005] In a first aspect, an embodiment of the present invention provides a method for training a URL classification model, comprising:
[0006] Obtaining website training data; wherein the website training data includes URL addresses and address classification labels; generating a character vector matrix and a word vector matrix according to the website training data;
[0007] Extracting an eigenvector of the character vector matrix as a first eigenvector, and extracting an eigenvector of the word vector matrix as a second eigenvector;
[0008] Concatenating the first feature vector and the second feature vector to obtain a concatenated feature vector;
[0009] The URL classification model is trained according to the concatenated feature vector.
[0010] In a second aspect, an embodiment of the present invention further provides a method for classifying a website, including:
[0011] Get the URL data to be detected;
[0012] Input the to-be-detected URL data into a URL classification model to obtain a label prediction result of the to-be-detected URL data; wherein the label prediction result includes a predicted label and a label probability;
[0013] When it is determined that the label probability is greater than or equal to a preset label probability threshold, the predicted label is used as the URL label of the URL data to be detected.
[0014] In a third aspect, an embodiment of the present invention further provides a URL classification model training device, comprising:
[0015] A website training data acquisition module, used to acquire website training data; wherein the website training data includes URL addresses and address classification labels;
[0016] A vector matrix generation module, used to generate a character vector matrix and a word vector matrix according to the website training data;
[0017] A feature vector extraction module, used to extract the feature vector of the character vector matrix as a first feature vector, and extract the feature vector of the word vector matrix as a second feature vector;
[0018] A feature vector concatenation module, used for concatenating the first feature vector and the second feature vector to obtain a concatenated feature vector;
[0019] The website classification model training module is used to perform model training on the website classification model according to the concatenated feature vector.
[0020] In a fourth aspect, an embodiment of the present invention further provides a website classification device, including:
[0021] A module for acquiring data of a website to be detected, used for acquiring data of a website to be detected;
[0022] A label prediction result acquisition module is used to input the URL data to be detected into the URL classification model to obtain the label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability;
[0023] The website tag determination module is used to use the predicted tag as the website tag of the website data to be detected when it is determined that the tag probability is greater than or equal to a preset tag probability threshold.
[0024] In a fifth aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0025] one or more processors;
[0026] A storage device for storing one or more programs;
[0027] When the one or more programs are executed by the one or more processors, the one or more processors implement the URL classification model training method provided in the first aspect, or the URL classification method provided in the second aspect.
[0028] In a fourth aspect, an embodiment of the present invention further provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the URL classification model training method provided in the first aspect, or the URL classification method provided in the second aspect.
[0029] The embodiment of the present invention obtains URL training data, wherein the URL training data includes URL addresses and address classification labels, generates a character vector matrix and a word vector matrix according to the URL training data, extracts the eigenvector of the character vector matrix as the first eigenvector, extracts the eigenvector of the word vector matrix as the second eigenvector, and concatenates the first eigenvector and the second eigenvector to obtain a concatenated eigenvector, and then trains a URL classification model according to the concatenated eigenvector, so as to classify the URL data to be detected using the successfully trained URL classification model, solves the problem of low accuracy of the existing URL classification model, and can improve the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flow chart of a URL classification model training method provided by Embodiment 1 of the present invention;
[0031] Figure 2 is a flow chart of a URL classification model training method provided by Embodiment 2 of the present invention;
[0032] Figure 3 It is a structural diagram of a website classification model provided by the second embodiment of the present invention;
[0033] Figure 4 is a flow chart of a method for classifying website addresses provided in Embodiment 2 of the present invention;
[0034] Figure 5 is a specific example flow chart of a URL detection method provided by Embodiment 4 of the present invention;
[0035] Figure 6 is a schematic diagram of a URL classification model training device provided by Embodiment 5 of the present invention;
[0036] Figure 7 is a schematic diagram of a website classification device provided by Embodiment 6 of the present invention;
[0037] Figure 8 A schematic diagram of the structure of an electronic device provided in Embodiment 7 of the present invention. DETAILED DESCRIPTION
[0038] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention.
[0039] It should also be noted that, for ease of description, only the part relevant to the present invention but not all content is shown in the accompanying drawings. It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processing or methods depicted as flow charts. Although the flow chart describes each operation (or step) as sequential processing, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to methods, functions, procedures, subroutines, subprograms, etc.
[0040] The terms "first" and "second" and the like in the description, claims and drawings of the embodiments of the present invention are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0041] Embodiment 1
[0042] Figure 1 This is a flowchart of a URL classification model training method provided by the first embodiment of the present invention. This embodiment is applicable to the case where a URL classification model is trained using multi-dimensional URL features. This method can be performed by a URL classification model training device, which can be implemented by software and / or hardware and can generally be integrated in an electronic device that performs this method. Figure 1 As shown, the URL classification model training method may specifically include the following steps:
[0043] S110, obtaining website training data; wherein the website training data includes URL addresses and address classification labels.
[0044] The URL training data may be any type of URL data used for URL classification model training, and the embodiment of the present invention does not limit this.
[0045] In the embodiment of the present invention, the URL training data may be used as input to the URL classification model, so as to optimize and train the model using the URL training data.
[0046] Specifically, the URL training data may include but are not limited to URL addresses and address classification labels. The URL address may be a URL address in the URL training data, and the address classification label may be a classification label of the URL address in the URL training data. Exemplarily, the address classification label of the URL training data may be a malicious URL or a normal URL.
[0047] S120, generating a character vector matrix and a word vector matrix according to the website training data.
[0048] The character vector matrix may be a matrix of character feature vectors in the URL training data, and the word vector matrix may be a matrix of word feature vectors in the URL training data.
[0049] It is understandable that each URL training data may be composed of multiple characters and multiple words. Characters and words may respectively contain different types of features of the URL. Therefore, in an embodiment of the present invention, after obtaining the URL training data, the URL classification model may further generate a character vector matrix and a word vector matrix according to the URL training data, so as to extract the character features and word features of the URL training data according to the character vector matrix and the word vector matrix respectively.
[0050] S130, extracting the eigenvector of the character vector matrix as the first eigenvector, and extracting the eigenvector of the word vector matrix as the second eigenvector.
[0051] The first feature vector may be a character feature vector extracted from the character vector matrix, and the second feature vector may be a word feature vector extracted from the word vector matrix.
[0052] In an embodiment of the present invention, after the URL classification model generates a character vector matrix and a word vector matrix based on the URL training data, it can further extract the eigenvector of the character vector matrix as the first eigenvector, and extract the eigenvector of the word vector matrix as the second eigenvector, so as to realize the extraction of multi-dimensional features.
[0053] S140: Concatenate the first feature vector and the second feature vector to obtain a concatenated feature vector.
[0054] The concatenated feature vector may be a feature vector concatenated from the first feature vector and the second feature vector. Optionally, the concatenated feature vector may be a sequence feature vector.
[0055] In the embodiment of the present invention, after obtaining the first feature vector and the second feature vector, the URL classification model may further concatenate the first feature vector and the second feature vector to obtain a concatenated feature vector.
[0056] S150: Perform model training on a URL classification model according to the concatenated feature vector.
[0057] In an embodiment of the present invention, after the URL classification model obtains the concatenated feature vector, the URL classification model can be further trained according to the concatenated feature vector. Since the concatenated feature vector includes the multi-dimensional features of the URL training data, the concatenated feature vector is used to train the URL classification model, which can improve the semantic learning ability and feature extraction ability of the model, thereby improving the recall rate of the URL classification model, and further improving the accuracy and classification precision of the URL classification model.
[0058] The technical solution of this embodiment is to obtain URL training data, wherein the URL training data includes URL addresses and address classification labels, and generate a character vector matrix and a word vector matrix according to the URL training data, extract the eigenvector of the character vector matrix as the first eigenvector, and extract the eigenvector of the word vector matrix as the second eigenvector, and splice the first eigenvector and the second eigenvector to obtain a spliced eigenvector, and then train a URL classification model according to the spliced eigenvector, so as to solve the problem of low accuracy of the existing URL classification model, and improve the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model.
[0059] Embodiment 2
[0060] Figure 2 This is a flowchart of a URL classification model training method provided in the second embodiment of the present invention. This embodiment is a further refinement of the above-mentioned technical solutions, and provides a variety of specific optional implementation methods for generating character vector matrices and word vector matrices based on URL training data and training the URL classification model based on the concatenated feature vectors. The technical solution in this embodiment can be combined with each optional solution in one or more of the above-mentioned embodiments. Among them, Figure 3 is a structural diagram of a website classification model provided by the second embodiment of the present invention, such as Figure 3 As shown, the URL classification model may include a URL input layer 310, a character embedding layer 321, a word embedding layer 322, a character CNN feature extraction layer 331, a word CNN feature extraction layer 332, a vector concatenation layer 340, an RNN (Recurrent Neuron Network) feature extraction layer 350, a FC layer (fully connected layers) 360, and an output layer 370. It should be noted that the program of the URL classification model can be developed in other languages such as python, java, c++ or c, and the embodiment of the present invention does not limit this.
[0061] Optionally, during the training process of the URL classification mode, appropriate deep learning model structure hyperparameters and training hyperparameters may be selected, which may specifically include the following parameters:
[0062] The RNN hierarchy can adopt recurrent neural network structures such as Vanilla-RNN, LSTM and GRU; Maximum word sequence length: default 200; Maximum character sequence length: default 200; Minimum word frequency: default 1; Filter length list: default 3, 4, 5, 6; Number of epochs: default 5; Batch-size: default 1024; Learning rate: default 0.001; Optimizer: Adam.
[0063] Correspondingly, such as Figure 2 As shown, the method of this embodiment may include the following steps:
[0064] S210: Obtain original website training data.
[0065] The original URL training data may be the initial URL training data acquired by the URL classification model.
[0066] In an embodiment of the present invention, before inputting the URL training data into the URL classification model, the original URL training data may be first obtained, and data preprocessing may be performed on the original URL training data to generate the URL training data, so as to improve the accuracy of the URL training data.
[0067] In a specific implementation of the embodiment of the present invention, the original website training data may include URL addresses and address category labels.
[0068] S220: Preprocess the original website training data to obtain target website training data.
[0069] The target website training data may be data obtained by preprocessing the original website training data.
[0070] In an embodiment of the present invention, after obtaining the original URL training data, the original URL training data may be further preprocessed, for example, redundant data in the original URL training data may be deleted to obtain the target URL training data. Exemplarily, meaningless prefixes or suffixes such as "http", "www" and "html" in the original URL training data may be deleted. The embodiment of the present invention does not specifically limit the specific content of the preprocessing.
[0071] S230: Divide a set proportion of the target website training data into the website training data.
[0072] The set ratio may be pre-set, and a certain ratio of URL training data may be divided out from the target URL training data. For example, 80% of the target URL training data may be divided out as URL training data, or 70% of the target URL training data may be divided out as URL training data. The embodiment of the present invention does not limit the specific value of the set ratio.
[0073] In the embodiment of the present invention, after the target website training data is obtained, a set proportion of data can be further divided from the target website training data as website training data to train the website classification model.
[0074] S240: Obtain website training data.
[0075] S250: Determine a character encoding mapping table and a word encoding mapping table according to the website training data.
[0076] The character encoding mapping table may be a mapping table between characters and character encodings, for example, a mapping table between characters and corresponding ID sequences, and may also be referred to as a dictionary with characters as encoding units. The word encoding mapping table may be a mapping table between words and word encodings, for example, a mapping table between words and corresponding ID sequences, and may also be referred to as a dictionary with words as encoding units.
[0077] In an embodiment of the present invention, after obtaining the URL training data, a character encoding mapping table and a word encoding mapping table can be further determined based on the URL training data, so as to determine the ID sequence corresponding to the characters based on the characters in the URL training data, and determine the ID sequence corresponding to the words based on the words in the URL training data.
[0078] S260: Perform character segmentation processing and word segmentation processing on the website training data to obtain character segmentation results and word segmentation results.
[0079] Among them, the character segmentation processing may be to perform character segmentation processing on the characters in the URL training data according to the characters in the character encoding mapping table. The word segmentation processing may be to perform word segmentation processing on the URL training data according to the words in the word encoding mapping table. The character segmentation result may be the character segmentation result obtained after the character segmentation processing. The word segmentation result may be the word segmentation result obtained after the word segmentation processing. Exemplarily, if the character encoding mapping table includes character A, the character A in the URL training data may be extracted to achieve character segmentation processing. If the word encoding mapping table includes word AB, the word AB in the URL training data may be extracted to achieve word segmentation processing. The embodiment of the present invention does not limit this.
[0080] In the embodiment of the present invention, after acquiring the URL training data, the URL input layer 310 of the URL classification model can further perform character segmentation processing and word segmentation processing on the characters and words involved in the URL training data, thereby obtaining character segmentation results and word segmentation results.
[0081] S270. Generate the character vector matrix according to the character segmentation result and the character encoding mapping table.
[0082] In an embodiment of the present invention, after the URL input layer 310 of the URL classification model performs character segmentation processing on the URL training data to obtain character segmentation results, the character embedding layer 321 of the URL classification model can further generate a character vector matrix based on the character segmentation results and the character encoding mapping table.
[0083] In a specific example, after the URL input layer 310 of the URL classification model processes the URL training data by character, it can generate an ID sequence corresponding to the character according to the character encoding mapping table, and the mapping u of the character s can be expressed as:
[0084] s→u=(u 1 ,...,u n );
[0085] Among them, u i Represents the ID sequence of the corresponding character, and n represents the length of the character sequence.
[0086] In a specific example, the character embedding layer 321 of the URL classification model can further generate a character vector matrix according to the character mapping u and the number of characters:
[0087]
[0088] Among them, W char represents a character vector matrix, m1 represents the number of characters, and k1 represents the dimension of the character vector. The dimension of the character vector can be a custom number of digits used to represent the characters. For example, if k1 is 50, it means that there are 50 digits representing one character.
[0089] S280. Generate the word vector matrix according to the word segmentation result and the word encoding mapping table.
[0090] In an embodiment of the present invention, after the URL input layer 310 of the URL classification model performs word segmentation processing on the URL training data to obtain the word segmentation result, the word embedding layer 322 of the URL classification model can further generate a word vector matrix according to the word segmentation result and the word encoding mapping table.
[0091] In a specific example, after the URL input layer 310 of the URL classification model performs word segmentation processing on the URL training data, an ID sequence corresponding to the word can be generated according to the word encoding mapping table, and the mapping v of the word p can be expressed as:
[0092] p→v=(v 1 ,...,v n );
[0093] Among them, v i Represents the ID sequence of the corresponding word, and n represents the length of the word sequence.
[0094] In a specific example, the word embedding layer 322 of the URL classification model can further generate a word vector matrix according to the word mapping v and the number of words:
[0095]
[0096] Among them, W word represents the word vector matrix, m2 represents the number of words, and k2 represents the dimension of the word vector. The dimension of the word vector can be a custom number of numbers used to represent the word. For example, if k2 is 100, it means that there are 100 numbers representing one word.
[0097] S290, extracting the eigenvector of the character vector matrix as the first eigenvector, and extracting the eigenvector of the word vector matrix as the second eigenvector.
[0098] Optionally, the first eigenvector and the second eigenvector may be CNN eigenvectors.
[0099] In a specific example, after the word embedding layer 322 of the URL classification model generates a character vector matrix, the character vector matrix can be converted into a character feature vector through matrix operation, that is, u->x=(x 1 ,...,x n ), where x i Represents the i-th dimension vector. Correspondingly, after the word embedding layer 322 of the URL classification model generates the word vector matrix, the word vector matrix can be converted into a word feature vector through matrix operation, that is, v->y=(y 1 ,...,y n ), where y i Represents the i-th dimension vector.
[0100] Optionally, after the character embedding layer 321 of the URL classification model extracts the character feature vector and the word embedding layer 322 extracts the word feature vector, the character CNN feature extraction layer 331 can further pass the character feature vector through different convolution layers, and the word CNN feature extraction layer 332 can further pass the word feature vector through different convolution layers, and perform local feature extraction respectively. By setting filters of different sizes, the extracted feature vectors of different sizes are concatenated to finally obtain the first feature vector and the second feature vector respectively.
[0101] The above technical solution can identify the combination information of key characters in the URL training data according to the character features of a specific combination by performing character segmentation processing on the characters in the URL training data and performing the character CNN feature extraction process according to the result of the character segmentation processing. It can identify the combination information of keywords in the URL training data according to the word features of the feature word combination by performing word segmentation processing on the words in the URL training data and performing the word CNN feature extraction process according to the result of the word segmentation processing.
[0102] Exemplarily, the operation of each convolution filter can be expressed as follows:
[0103]
[0104] in, represents the extracted character feature vector, represents the extracted word feature vector, Denotes a filter w∈R of length t k×t Perform convolution operation on x or y, b i represents the bias, and f represents the nonlinear activation function. Finally, the new feature vectors output by all character CNN feature extraction layers 331 and word CNN feature extraction layers 332 can be expressed as:
[0105]
[0106]
[0107] in, and They are respectively represented as a new feature vector extracted by the character CNN feature extraction layer 331 and the word CNN feature extraction layer 332, W char represents the first eigenvector, W word represents the second eigenvector.
[0108] S2100: Concatenate the first feature vector and the second feature vector to obtain a concatenated feature vector.
[0109] Exemplarily, the vector concatenation layer 340 of the URL classification model may concatenate the first feature vector and the second feature vector to obtain a CNN feature extraction vector:
[0110]
[0111] in, represents the concatenation operation of vectors, and W represents the concatenated feature vector. Since both the first feature vector and the second feature vector are CNN feature vectors, the concatenated feature vector can also be a CNN feature vector.
[0112] S2110. Extract sequence features from the concatenated feature vector to obtain a sequence feature vector.
[0113] The sequence feature may be a sequence feature extracted from the concatenated feature vector by the RNN feature extraction layer 350. The sequence feature vector may be a feature vector generated by the sequence feature, for example, an output vector of a hidden layer at the last time step.
[0114] In the embodiment of the present invention, after the vector concatenation layer 340 obtains the concatenated feature vector, the concatenated feature vector may be further input into the RNN feature extraction layer 350 to perform sequence feature extraction, thereby obtaining a sequence feature vector.
[0115] Optionally, the RNN feature extraction layer 350 may adopt a recurrent neural network structure such as Vanilla-RNN, LSTM (Long Short-Term Memory) and GRU (Gated Recurrent Unit). Exemplarily, if the RNN feature extraction layer 350 adopts the LSTM structure, the data operation of the t-th time step of the recurrent neural network can be expressed as follows:
[0116] i (t) =σ(W (i) g (t) +U (i) h (t-1) +b i );
[0117] f (t) =σ(W (f) g (t) +U (f) h (t-1) +b f );
[0118] o (t) =σ(W (o) g (t) +U (o) h (t-1) +b o);
[0119]
[0120]
[0121] h (t) =o (t) tanh(c (t) );
[0122] Among them, g (t) represents the feature output of the character CNN feature extraction layer 331 and the word CNN feature extraction layer 332, i (t) 、f (t) , o (t) Respectively represent the outputs of the input gate, forget gate, and output gate in the LSTM structure at time t, represents the new candidate value vector, c (t) represents the new cell state, h (t) represents the hidden state, σ is the sigmoid activation function, W (i) , U (i) , W (f) , U (f) , W (o) , U (o) , W (c) , U (c) Both represent the weight coefficient of the linear relationship, b i 、b f 、b o 、b c is the offset.
[0123] S2120. Perform a nonlinear mapping transformation on the sequence feature vector to obtain a sequence transformation feature vector.
[0124] The sequence change feature vector may be obtained by performing a nonlinear mapping transformation on the sequence feature vector.
[0125] In an embodiment of the present invention, after the RNN feature extraction layer 350 of the URL classification model obtains the sequence feature vector, the FC layer 360 of the URL classification model can further perform a nonlinear mapping transformation on the sequence feature vector to obtain a sequence transformation feature vector to improve the fitting degree and abstractness of the URL classification model.
[0126] The above technical solution improves the feature extraction capability of the URL classification model by combining the CNN structure and the RNN structure.
[0127] S2130. Predicting a label prediction result of the URL training data according to the sequence transformation feature vector; wherein the label prediction result includes a predicted label and a label probability.
[0128] The label prediction result of the URL training data may be the URL label prediction result obtained by identifying the URL training data through the URL classification model. The predicted label of the URL training data may be a label that identifies the URL training data, for example, it may be a "malicious URL" prediction label that identifies the URL training data as a malicious URL, or it may be a "normal URL" prediction label that identifies the URL training data as a normal URL. The label probability of the URL training data may be the probability corresponding to the predicted label identified by the URL classification model. For example, if the probability that the URL training data identified by the URL classification model is a malicious URL is 80%, then the label probability of the predicted label "malicious URL" is "80%".
[0129] In an embodiment of the present invention, after the FC layer 360 of the URL classification model obtains the sequence transformation feature vector, the output layer 370 of the URL classification model can further predict the predicted label and label probability of the URL training data based on the sequence transformation feature vector to train the URL classification model.
[0130] Optionally, the output layer 370 of the URL classification model may include 2 neurons to perform a sigmoid transformation on the sequence change feature vector to obtain the final label probability. Exemplarily, the sigmoid function is as follows:
[0131]
[0132] Among them, x i Represents the output of the neuron.
[0133] S2140: Compare the website classification label and the label prediction result to determine the training effect of the website classification model.
[0134] In an embodiment of the present invention, after the output layer 370 of the URL classification model obtains the label prediction result, the URL classification label can be further compared with the label prediction result to determine the training effect of the URL classification model. Exemplarily, if the URL classification label of the URL training data is "malicious URL", and the predicted label of the URL training data identified by the URL classification model is "malicious URL", and the label probability is 95%, then it means that the URL training data is effective for the training effect of the URL classification model. If the URL classification label of the URL training data is "malicious URL", and the predicted label of the URL training data identified by the URL classification model is "malicious URL", and the label probability is 35%, then it means that the training effect of the URL training data on the URL classification model is invalid.
[0135] S2150. Obtain website test data.
[0136] The URL test data may be data used for URL classification model testing.
[0137] In the embodiment of the present invention, after the URL classification model is trained, URL test data may be further obtained from the target URL training data.
[0138] S2160: Perform model evaluation on the URL classification model according to the URL test data.
[0139] In the embodiment of the present invention, after obtaining the URL test data, the URL classification model can be further evaluated according to the URL test data to determine the availability of the URL classification model. It is understood that if the accuracy of the URL classification model is higher than the set online application standard, the URL classification model can be applied online.
[0140] The above technical solution trains the model by selecting appropriate deep learning model structure hyperparameters, training hyperparameters and URL training data. When the set number of training epochs is reached, the training is stopped and the model is saved. Early Stopping can also be used to control the model to stop training in advance.
[0141] The technical solution of this embodiment is to obtain the original URL training data and then pre-process the original URL training data to obtain the target URL training data, and divide a set proportion of data from the target URL training data as the URL training data, determine the character encoding mapping table and the word encoding mapping table according to the URL training data after obtaining the URL training data, perform character segmentation processing and word segmentation processing on the URL training data to obtain character segmentation results and word segmentation results, and then generate a character vector matrix according to the character segmentation results and the character encoding mapping table, generate a word vector matrix according to the word segmentation results and the word encoding mapping table, extract the eigenvector of the character vector matrix as the first eigenvector, and extract the eigenvector of the word vector matrix as the second eigenvector, The first feature vector and the second feature vector are concatenated to obtain a concatenated feature vector, sequence features are extracted from the concatenated feature vector to obtain a sequence feature vector, and then a nonlinear mapping transformation is performed on the sequence feature vector to obtain a sequence transformation feature vector, and the label prediction results of the URL training data are predicted according to the sequence transformation feature vector, and the URL classification labels and label prediction results are compared to determine the training effect of the URL classification model, and URL test data is obtained. The URL classification model is evaluated according to the URL test data, which solves the problem of low accuracy of the existing URL classification model, thereby improving the training effect of the URL classification model and improving the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model.
[0142] Embodiment 3
[0143] Figure 4 This is a flowchart of a method for classifying a website address provided in the second embodiment of the present invention. This embodiment is applicable to the case where the website address classification model in the above-mentioned technical solutions is used to classify the website addresses. This method can be executed by a website address classification device, which can be implemented by software and / or hardware, and can generally be integrated in an electronic device that executes this method. Figure 4 As shown, the URL classification method may specifically include the following steps:
[0144] S410: Obtain the website data to be detected.
[0145] The website data to be detected may be website data detected using a website classification model. In the embodiment of the present invention, the website classification model may obtain the website data to be detected to identify the website data to be detected.
[0146] S420: Input the URL data to be detected into a URL classification model to obtain a label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability.
[0147] The label prediction result of the URL data to be detected may be the URL label prediction result obtained by identifying the URL data to be detected through the URL classification model. The predicted label of the URL data to be detected may be a label that identifies the URL data to be detected. The label probability of the URL data to be detected may be the probability corresponding to the predicted label identified by the URL classification model.
[0148] In the embodiment of the present invention, after the URL data to be detected is input into the URL classification model, the URL classification model can be further used to identify the predicted label and label probability of the URL data to be detected, so as to identify the URL data to be detected.
[0149] S430, determine whether the label probability is greater than or equal to a preset label probability threshold; if so, execute S440, otherwise, execute S450.
[0150] Among them, the preset label probability threshold can be a preset label probability threshold. It can be understood that if the label probability is greater than or equal to the preset label probability threshold, it means that the probability value of the predicted label obtained by the URL classification model is large, and at this time, the predicted label can be used as the URL label of the URL data to be detected. If the label probability is less than the preset label probability threshold, it means that the probability value of the predicted label obtained by the URL classification model is small, and at this time, the predicted label cannot be used as the URL label of the URL data to be detected.
[0151] In the embodiment of the present invention, after obtaining the tag prediction result of the URL data to be detected, it can be further determined whether the tag probability is greater than or equal to a preset tag probability threshold.
[0152] S440: Use the predicted label as the URL label of the URL data to be detected.
[0153] In an embodiment of the present invention, when the label probability is greater than or equal to a preset label probability threshold, the predicted label can be used as the URL label of the URL data to be detected, thereby realizing the recognition of the URL to be detected. Exemplarily, if the preset label probability threshold is 85%, and the label probability corresponding to the predicted label is greater than or equal to 85%, the predicted label is used as the URL label of the URL data to be detected.
[0154] S450: Refuse to use the predicted label as the URL label of the URL data to be detected.
[0155] In the embodiment of the present invention, when the tag probability is less than a preset tag probability threshold, the predicted tag may be rejected as the URL tag of the URL data to be detected.
[0156] The technical solution of this embodiment obtains the URL data to be detected, inputs the URL data to be detected into the URL classification model, obtains the label prediction result of the URL data to be detected, and when the label probability is greater than or equal to the preset label probability threshold, uses the predicted label as the URL label of the URL data to be detected, thereby realizing automatic identification of URLs without maintaining a blacklist or specifying rules, and can improve the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model.
[0157] Embodiment 4
[0158] The embodiment of the present invention takes the URL detection application scenario as an example to specifically explain that with the development of the Internet, network attacks have become an increasingly important security issue. Various types of attacks, such as phishing, Trojans, and malware, often use malicious URLs as a means. Therefore, identifying malicious URLs is of great significance in preventing various network attacks and maintaining network security. Figure 5 is a specific example flow chart of a URL detection method provided by Embodiment 4 of the present invention, such as Figure 5 As shown, the following steps may be specifically included:
[0159] S1. Data collection: Collect a number of normal and malicious URLs to form URL training data. Each sample data includes: URL address and its corresponding classification label: normal or malicious. Preprocess the URL training data to remove unnecessary prefixes and suffixes such as "www.", "http: / / ", "https: / / " and ".html", and save the preprocessed URL training data. Finally, divide it according to a certain ratio to obtain URL training data and URL test data, where URL training data is used for model training and URL test data is used for URL classification model evaluation.
[0160] S2. Model development: The URL classification model structure can be a multi-Level-CRNN model structure, which can specifically include a URL input layer, a character embedding layer, a word embedding layer, a character CNN feature extraction layer, a word CNN feature extraction layer, a vector concatenation layer, a RNN feature extraction layer, a FC layer, and an output layer.
[0161] S3. Model training: Select appropriate deep learning model structure hyperparameters and training hyperparameters, and use the above hyperparameters and URL training data to train the URL classification model.
[0162] S4. Model evaluation: You can use different hyperparameter combinations to train the URL classification model, and use the URL test data to evaluate the saved URL classification model. The URL classification model with the highest accuracy is used as the optimal URL classification model. If its accuracy is higher than the online application standard, the URL classification model can be used online.
[0163] S5. Online application: Use the optimal URL classification model to perform online application on malicious URLs, which can be specifically: obtaining the URL address to be detected; performing preprocessing operations on the URL address, processing the URL sample data, first preprocessing to remove unnecessary prefixes and suffixes such as "www.", "http: / / ", "https: / / " and ".html"; inputting the preprocessed URL address into the URL classification model, and performing forward operations on the URL classification model; obtaining the final URL classification model output results, including: prediction labels: malicious or normal, and their corresponding probability values. If the probability value is greater than a preset threshold, the prediction label of the URL classification model is used, otherwise it is uncertain whether the URL address is malicious and further judgment is required.
[0164] The technical solution of this embodiment realizes automatic detection of malicious URLs by designing a multi-Level-CRNN deep learning model; by adopting the model hierarchy results of CRNN, the CNN structure and the RNN structure are combined to improve the feature extraction ability of the model; by adopting multi-level embedded identifiers, the semantic learning ability of the URL classification model can be optimized.
[0165] Embodiment 5
[0166] Figure 6 is a schematic diagram of a URL classification model training device provided by Embodiment 5 of the present invention, such as Figure 6 As shown, the device includes: a website training data acquisition module 610, a vector matrix generation module 620, a feature vector extraction module 630, a feature vector splicing module 640 and a website classification model training module 650, wherein:
[0167] The website training data acquisition module 610 is used to acquire website training data; wherein the website training data includes URL addresses and address classification labels;
[0168] A vector matrix generation module 620, used to generate a character vector matrix and a word vector matrix according to the website training data;
[0169] A feature vector extraction module 630, configured to extract a feature vector of the character vector matrix as a first feature vector, and to extract a feature vector of the word vector matrix as a second feature vector;
[0170] A feature vector concatenation module 640 is used to concatenate the first feature vector and the second feature vector to obtain a concatenated feature vector;
[0171] The website classification model training module 650 is used to perform model training on the website classification model according to the concatenated feature vector.
[0172] Optionally, the first eigenvector and the second eigenvector may be CNN eigenvectors.
[0173] Optionally, the URL classification model training module 650 can be further used to: extract sequence features from the concatenated feature vector to obtain a sequence feature vector; perform a nonlinear mapping transformation on the sequence feature vector to obtain a sequence transformation feature vector; predict the label prediction results of the URL training data based on the sequence transformation feature vector; wherein the label prediction results include predicted labels and label probabilities; and compare the address classification label with the label prediction results to determine the training effect of the URL classification model.
[0174] Optionally, the vector matrix generation module 620 can be further used to: determine a character encoding mapping table and a word encoding mapping table based on the URL training data; perform character segmentation processing and word segmentation processing on the URL training data to obtain character segmentation results and word segmentation results; generate the character vector matrix based on the character segmentation results and the character encoding mapping table; generate the word vector matrix based on the word segmentation results and the word encoding mapping table.
[0175] Optionally, the device may further include:
[0176] An original URL training data acquisition module is used to acquire original URL training data;
[0177] A target website training data generation module is used to pre-process the original website training to obtain target website training data;
[0178] The website training data division module is used to divide a set proportion of data from the target website training data as the website training data.
[0179] Optionally, the device may further include:
[0180] A website test data acquisition module is used to acquire website test data;
[0181] The website classification model evaluation module is used to perform model evaluation on the website classification model according to the website test data.
[0182] The technical solution of this embodiment is to obtain URL training data, wherein the URL training data includes URL addresses and address classification labels, and generate a character vector matrix and a word vector matrix according to the URL training data, extract the eigenvector of the character vector matrix as the first eigenvector, and extract the eigenvector of the word vector matrix as the second eigenvector, and splice the first eigenvector and the second eigenvector to obtain a spliced eigenvector, and then train a URL classification model according to the spliced eigenvector, so as to solve the problem of low accuracy of the existing URL classification model, and improve the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model.
[0183] The above-mentioned URL classification model training device can execute the URL classification model training method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, please refer to the URL classification model training method provided by any embodiment of the present invention.
[0184] Since the URL classification model training device introduced above is a device that can execute the URL classification model training method in the embodiment of the present invention, based on the URL classification model training method introduced in the embodiment of the present invention, the technical personnel in this field can understand the specific implementation method of the URL classification model training device of this embodiment and its various variations, so how the URL classification model training device implements the URL classification model training method in the embodiment of the present invention is not introduced in detail here. As long as the technical personnel in this field implement the device used by the URL classification model training method in the embodiment of the present invention, it belongs to the scope of protection of this application.
[0185] Embodiment 6
[0186] Figure 7 is a schematic diagram of a website classification device provided by Embodiment 6 of the present invention, such as Figure 7 As shown, the device includes: a to-be-detected website data acquisition module 710, a tag prediction result acquisition module 720 and a website tag determination module 730, wherein:
[0187] The to-be-detected website data acquisition module 710 is used to acquire the to-be-detected website data;
[0188] The label prediction result acquisition module 720 is used to input the URL data to be detected into the URL classification model to obtain the label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability;
[0189] The website tag determination module 730 is used to use the predicted tag as the website tag of the website data to be detected when it is determined that the tag probability is greater than or equal to a preset tag probability threshold.
[0190] The technical solution of this embodiment obtains the URL data to be detected, inputs the URL data to be detected into the URL classification model, obtains the label prediction result of the URL data to be detected, and when the label probability is greater than or equal to the preset label probability threshold, uses the predicted label as the URL label of the URL data to be detected, thereby solving the problem of low accuracy of the existing URL classification model and improving the recall rate of the URL classification model, thereby improving the accuracy and classification precision of the URL classification model.
[0191] The above-mentioned website classification device can execute the website classification method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, please refer to the website classification method provided by any embodiment of the present invention.
[0192] Since the URL classification device described above is a device that can execute the URL classification method in the embodiment of the present invention, based on the URL classification method described in the embodiment of the present invention, the technical personnel in the field can understand the specific implementation of the URL classification device of the present embodiment and its various variations, so how the URL classification device implements the URL classification method in the embodiment of the present invention is not described in detail here. As long as the technical personnel in the field implement the device used in the URL classification method in the embodiment of the present invention, it belongs to the scope of protection of this application.
[0193] Embodiment 7
[0194] Figure 8 This is a schematic diagram of the structure of an electronic device provided by Embodiment 7 of the present invention. Figure 8 As shown, the electronic device includes a processor 810, a memory 820, an input device 830 and an output device 840; the number of the processor 810 in the electronic device can be one or more. Figure 8 A processor 810 is taken as an example; the processor 810, the memory 820, the input device 830 and the output device 840 in the electronic device can be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0195] The memory 820, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the URL classification model training method in the embodiment of the present invention (for example, the URL training data acquisition module 610, the vector matrix generation module 620, the feature vector extraction module 630, the feature vector splicing module 640 and the URL classification model training module 650 in the URL classification model training device). The processor 810 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 820, that is, to implement the above-mentioned URL classification model training method: obtaining URL training data; wherein the URL training data includes URL addresses and address classification labels; generating a character vector matrix and a word vector matrix according to the URL training data; extracting the feature vector of the character vector matrix as the first feature vector, and extracting the feature vector of the word vector matrix as the second feature vector; splicing the first feature vector and the second feature vector to obtain a spliced feature vector; and training the URL classification model according to the spliced feature vector.
[0196] Alternatively, the memory 820, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the URL classification method in the embodiment of the present invention (for example, the URL data acquisition module 710 to be detected, the label prediction result acquisition module 720 and the URL label determination module 730 in the URL classification device). The processor 810 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 820, that is, to implement the above-mentioned URL classification method: obtain the URL data to be detected; input the URL data to be detected into the URL classification model to obtain the label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability; when it is determined that the label probability is greater than or equal to the preset label probability threshold, the predicted label is used as the URL label of the URL data to be detected.
[0197] The memory 820 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 820 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 820 may further include a memory remotely arranged relative to the processor 810, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0198] The input device 830 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 840 may include a display device such as a display screen.
[0199] Embodiment 8
[0200] Embodiment 8 of the present invention further provides a computer storage medium storing a computer program, wherein the computer program, when executed by a computer processor, is used to execute the URL classification model training method described in any of the above embodiments of the present invention: obtaining URL training data; wherein the URL training data includes URL addresses and address classification labels; generating a character vector matrix and a word vector matrix according to the URL training data; extracting the eigenvector of the character vector matrix as the first eigenvector, and extracting the eigenvector of the word vector matrix as the second eigenvector; concatenating the first eigenvector and the second eigenvector to obtain a concatenated eigenvector; and performing model training on the URL classification model according to the concatenated eigenvector.
[0201] Or the computer program, when executed by a computer processor, is used to perform the URL classification method described in any of the above embodiments of the present invention: obtaining URL data to be detected; inputting the URL data to be detected into a URL classification model to obtain a label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability; when it is determined that the label probability is greater than or equal to a preset label probability threshold, the predicted label is used as the URL label of the URL data to be detected.
[0202] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0203] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0204] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0205] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0206] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for training a URL classification model, characterized in that: include: Acquire website training data; wherein the website training data includes URL addresses and address classification labels; Generate a character vector matrix and a word vector matrix according to the website training data; Extracting the eigenvector of the character vector matrix as the first eigenvector, and extracting the eigenvector of the word vector matrix as the second eigenvector; wherein the first eigenvector and the second eigenvector are convolutional neural network (CNN) eigenvectors; Concatenating the first feature vector and the second feature vector to obtain a concatenated feature vector; Model training is performed on a URL classification model according to the concatenated feature vector, including: extracting sequence features from the concatenated feature vector to obtain a sequence feature vector; wherein the sequence features are extracted from the concatenated feature vector by an RNN feature extraction layer; performing a nonlinear mapping transformation on the sequence feature vector to obtain a sequence transformation feature vector; predicting a label prediction result of text training data according to the sequence transformation feature vector; wherein the label prediction result includes a predicted label and a label probability; comparing the URL classification label with the label prediction result to determine the training effect of the URL classification model; The step of generating a character vector matrix and a word vector matrix according to the URL training data includes: Determine a character encoding mapping table and a word encoding mapping table according to the website training data; Performing character segmentation processing and word segmentation processing on the URL training data to obtain character segmentation results and word segmentation results; Generate the character vector matrix according to the character segmentation result and the character encoding mapping table; Generate the word vector matrix according to the word segmentation result and the word encoding mapping table; Among them, the character encoding mapping table is a mapping relationship table between characters and their corresponding ID sequences; the word encoding mapping table is a mapping relationship table between words and their corresponding ID sequences; According to the character encoding mapping table, the ID sequence corresponding to the character is generated. The mapping u of character s can be expressed as: s→u=(u1,...,u n ), where u i Represents the ID sequence of the corresponding character, n represents the length of the character sequence; generate a character vector matrix based on the character mapping u and the number of characters: Among them, W char represents the character vector matrix, m1 represents the number of characters, and k1 represents the dimension of the character vector; According to the word encoding mapping table, the ID sequence corresponding to the word is generated. The mapping v of word p can be expressed as: p→v=(v1,...,v n ), where v i Represents the ID sequence of the corresponding word, n represents the length of the word sequence; the word vector matrix is generated according to the word mapping v and the number of words: Among them, W word Represents the word vector matrix, m2 represents the number of words, and k2 represents the dimension of the word vector.
2. The method according to claim 1, characterized in that Before obtaining the URL training data, it also includes: Get the original URL training data; Preprocessing the original website training data to obtain target website training data; A set proportion of data is divided from the target website training data as the website training data.
3. The method according to claim 1, characterized in that After the URL classification model is trained according to the concatenated feature vector, the method further includes: Get URL test data; The URL classification model is evaluated based on the URL test data.
4. A method for classifying web addresses, characterized in that: The method is applied to the case where the URL classification model according to any one of claims 1 to 3 is used to classify URLs, including: Get the URL data to be detected; Input the to-be-detected URL data into a URL classification model to obtain a label prediction result of the to-be-detected URL data; wherein the label prediction result includes a predicted label and a label probability; When it is determined that the label probability is greater than or equal to a preset label probability threshold, the predicted label is used as the URL label of the URL data to be detected.
5. A URL classification model training device, characterized in that: include: A website training data acquisition module, used to acquire website training data; wherein the website training data includes URL addresses and address classification labels; A vector matrix generation module, used to generate a character vector matrix and a word vector matrix according to the website training data; A feature vector extraction module, used to extract the feature vector of the character vector matrix as a first feature vector, and extract the feature vector of the word vector matrix as a second feature vector; wherein the first feature vector and the second feature vector are convolutional neural network (CNN) feature vectors; A feature vector concatenation module, used for concatenating the first feature vector and the second feature vector to obtain a concatenated feature vector; The URL classification model training module is used to perform model training on the URL classification model according to the concatenated feature vector, specifically used to: extract sequence features from the concatenated feature vector to obtain a sequence feature vector; perform nonlinear mapping transformation on the sequence feature vector to obtain a sequence transformation feature vector; wherein the sequence features are extracted from the concatenated feature vector by the RNN feature extraction layer; predict the label prediction result of the URL training data according to the sequence transformation feature vector; wherein the label prediction result includes a predicted label and a label probability; compare the address classification label with the label prediction result to determine the training effect of the URL classification model; The vector matrix generation module is used to: determine a character encoding mapping table and a word encoding mapping table according to the URL training data; perform character segmentation processing and word segmentation processing on the URL training data to obtain character segmentation results and word segmentation results; generate the character vector matrix according to the character segmentation results and the character encoding mapping table; generate the word vector matrix according to the word segmentation results and the word encoding mapping table; Among them, the character encoding mapping table is a mapping relationship table between characters and their corresponding ID sequences; the word encoding mapping table is a mapping relationship table between words and their corresponding ID sequences; According to the character encoding mapping table, the ID sequence corresponding to the character is generated. The mapping u of character s can be expressed as: s→u=(u1,...,u n ), where u i Represents the ID sequence of the corresponding character, n represents the length of the character sequence; generate a character vector matrix based on the character mapping u and the number of characters: Among them, W char represents the character vector matrix, m1 represents the number of characters, and k1 represents the dimension of the character vector; According to the word encoding mapping table, the ID sequence corresponding to the word is generated. The mapping v of word p can be expressed as: p→v=(v1,...,v n ), where v i Represents the ID sequence of the corresponding word, n represents the length of the word sequence; the word vector matrix is generated according to the word mapping v and the number of words: Among them, W word Represents the word vector matrix, m2 represents the number of words, and k2 represents the dimension of the word vector.
6. A website classification device, characterized in that: The method is applied to the case where the URL classification model according to any one of claims 1 to 3 is used to classify URLs, including: A module for acquiring data of a website to be detected, used for acquiring data of a website to be detected; A label prediction result acquisition module is used to input the URL data to be detected into the URL classification model to obtain the label prediction result of the URL data to be detected; wherein the label prediction result includes a predicted label and a label probability; The website tag determination module is used to use the predicted tag as the website tag of the website data to be detected when it is determined that the tag probability is greater than or equal to a preset tag probability threshold.
7. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the URL classification model training method as described in any one of claims 1-3, or implement the URL classification method as described in claim 4.
8. A computer storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the URL classification model training method as described in any one of claims 1-3, or implements the URL classification method as described in claim 4.
Citation Information
Patent Citations
Event trigger word extraction method based on document level attention mechanism
CN108829801A
Signal processing method and device, electronic equipment and storage medium
CN110650134A
Word classification model training method based on artificial intelligence and word processing method and device
CN111401066A
Training method of address text recognition model and prediction method and device of addresses
CN112052668A
Risk prediction method and device based on deep bidirectional language model and electronic equipment
CN112507628A
