A security entity detection method and device

Through the pre-constructed semantic related vocabulary query model and the secure entity detection model, the detection error problem caused by context changes in the existing technology is solved, and fast and accurate safe entity detection is achieved, which improves detection efficiency and accuracy.

CN114021571BActive Publication Date: 2024-11-26BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111423021.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-26
Publication Date
2024-11-26
Estimated Expiration
2041-11-26

AI Technical Summary

Technical Problem

The existing named entity detection methods cause detection errors due to context changes, which reduces detection efficiency and cannot quickly and accurately detect secure entities.

Method used

Through the pre-constructed semantic related vocabulary query model and safe entity detection model, the detection data is preprocessed and processed, vocabulary features are obtained and cooperative learning and training are carried out to improve detection accuracy and efficiency.

Benefits of technology

It realizes fast and accurate safe entity detection, reduces detection errors, improves detection efficiency, and improves the accuracy of entity detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114021571B_ABST
    Figure CN114021571B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a security entity detection method and device, which relate to the field of network security technology. The security entity detection method includes: first acquiring data to be detected; and preprocessing the data to be detected to obtain preprocessed data; then processing the preprocessed data through a pre-built semantically related vocabulary query model to obtain vocabulary features; further, processing the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result, which can quickly and accurately detect the security entity, with small detection error and high detection efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and in particular to a security entity detection method and device. Background Art

[0002] Named Entity Recognition (NER) is very important in the field of cybersecurity. It helps researchers extract cyber threat information from unstructured text sources. Existing entity detection methods usually perform named entity detection based on statistical dictionaries. Specifically, a reference dictionary is constructed for each named entity, and named entity detection is performed based on the reference dictionary. However, in practice, it is found that different words may be detected incorrectly due to context changes, thereby reducing detection efficiency. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a security entity detection method and device, which can quickly and accurately detect security entities with small detection errors and high detection efficiency.

[0004] A first aspect of an embodiment of the present application provides a security entity detection method, including:

[0005] Obtain the data to be tested;

[0006] Preprocessing the data to be detected to obtain preprocessed data;

[0007] Processing the preprocessed data by using a pre-built semantically related vocabulary query model to obtain vocabulary features;

[0008] The lexical features are processed by a pre-built security entity detection model to obtain a security entity detection result.

[0009] In the above implementation process, the data to be detected is first obtained; the data to be detected is preprocessed to obtain preprocessed data; then the preprocessed data is processed by a pre-built semantically related vocabulary query model to obtain vocabulary features; further, the vocabulary features are processed by a pre-built security entity detection model to obtain security entity detection results, which can quickly and accurately detect security entities with small detection errors and high detection efficiency.

[0010] Furthermore, the method further comprises:

[0011] Obtain training data for training the model, the original entity detection model, and the original semantic model;

[0012] According to the training data, the original semantic model is trained by an unsupervised learning method to obtain a semantically related vocabulary query model;

[0013] Inputting the training data into the semantically related vocabulary query model for processing to obtain external vocabulary features;

[0014] The original entity detection model is trained using the external vocabulary features to obtain a trained security entity detection model.

[0015] Furthermore, the inputting of the training data into the semantically related vocabulary query model for processing to obtain vocabulary feature samples includes:

[0016] Inputting the training data into the semantically related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors;

[0017] Determine, according to the word vector and the cosine similarity, an external semantically related vocabulary corresponding to the word vector;

[0018] The average word vector of the word vector is calculated according to the external semantically related words to obtain the external word feature.

[0019] Furthermore, the training of the original entity detection model by using the external vocabulary features to obtain a trained security entity detection model includes:

[0020] Input the training data into the encoding model for processing to obtain a word encoding vector; wherein the pre-built security entity detection model includes the encoding model and a classification layer, and the classification layer includes a first fully connected layer and a second fully connected layer with different inputs;

[0021] Inputting the word encoding vector into the first fully connected layer for processing to obtain a first processing result, and inputting the external vocabulary feature into the second fully connected layer for processing to obtain a second processing result;

[0022] Calculate the total loss according to the first processing result and the second processing result;

[0023] The model parameters of the original entity detection model are adjusted according to the total loss to obtain a trained security entity detection model.

[0024] In the above implementation process, the original entity detection model can be trained through cooperative learning, which is beneficial to improving the detection accuracy of the security entity detection model and making entity detection more accurate.

[0025] Further, calculating the total loss according to the first processing result and the second processing result includes:

[0026] Calculating a first cross entropy loss according to the first processing result, calculating a second cross entropy loss according to the second processing result, and calculating a loss of collaborative learning according to the first processing result and the second processing result;

[0027] A total loss is calculated according to the first cross entropy loss, the first cross entropy loss, and the loss of the collaborative learning.

[0028] A second aspect of an embodiment of the present application provides a security entity detection device, the security entity detection device comprising:

[0029] A first acquisition unit, used for acquiring data to be detected;

[0030] A preprocessing unit, used for preprocessing the data to be detected to obtain preprocessed data;

[0031] A first processing unit, configured to process the preprocessed data using a pre-built semantically related vocabulary query model to obtain vocabulary features;

[0032] The second processing unit is used to process the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result.

[0033] In the above implementation process, the first acquisition unit acquires the data to be detected; the preprocessing unit preprocesses the data to be detected to obtain preprocessed data; the first processing unit processes the preprocessed data through a pre-built semantically related vocabulary query model to obtain vocabulary features; the second processing unit processes the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result, which can quickly and accurately detect security entities with small detection errors and high detection efficiency.

[0034] Furthermore, the security entity detection device also includes:

[0035] A second acquisition unit, used to acquire training data for training a model, an original entity detection model, and an original semantic model;

[0036] A first training unit is used to train the original semantic model in an unsupervised learning manner according to the training data to obtain a semantically related vocabulary query model;

[0037] A third processing unit is used to input the training data into the semantically related vocabulary query model for processing to obtain external vocabulary features;

[0038] The second training unit is used to train the original entity detection model through the external vocabulary features to obtain a trained security entity detection model.

[0039] Furthermore, the third processing unit includes:

[0040] A first subunit is used to input the training data into the semantically related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors;

[0041] A second subunit is used to determine the external semantically related vocabulary corresponding to the word vector according to the word vector and the cosine similarity;

[0042] The third subunit is used to calculate the average word vector of the word vector according to the external semantically related vocabulary to obtain the external vocabulary feature.

[0043] A third aspect of an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the security entity detection method described in any one of the first aspect of the embodiment of the present application.

[0044] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the security entity detection method described in any one of the first aspect of the embodiment of the present application is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0046] Figure 1 A schematic diagram of a process flow of a security entity detection method provided in an embodiment of the present application;

[0047] Figure 2 A schematic diagram of the structure of a security entity detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0049] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0050] Example 1

[0051] Please see Figure 1 , Figure 1 A schematic flow chart of a security entity detection method is provided for an embodiment of the present application. The security entity detection method includes:

[0052] S101, obtaining training data for training a model, an original entity detection model, and an original semantic model.

[0053] In the embodiments of the present application, named entity recognition (NER) (also known as entity identification, entity chunking, and entity extraction) is a subtask of information extraction, which aims to locate and classify named entities in text into predefined categories, such as people, organizations, locations, time expressions, quantities, monetary values, percentages, etc. Named entity recognition (NER) is very important in the field of network security, and can help researchers extract network threat information from unstructured text sources. The extracted network entities or key expressions can be used to model network attacks described in open source texts.

[0054] In the embodiment of the present application, the original entity detection model is the original NER model.

[0055] As an optional implementation, obtaining training data for training a model may include the following steps:

[0056] Get the original sample data for training the model;

[0057] The original sample data is preprocessed to obtain training data.

[0058] In the above implementation, the original sample data includes security-related text information (such as security technology blog text data) crawled from various sources on the Internet, as well as security incident articles, APT incident reports, and WeChat public account tweets related to security incidents published by major network security companies, which is not limited to this embodiment of the present application.

[0059] In the above implementation, APT attack, namely advanced persistent threat attack, also known as targeted threat attack, refers to a continuous and effective attack activity launched by an organization against a specific target.

[0060] In the above implementation, the original sample data includes text data and PDF (Portable Document Format) data, so the original sample data needs to be preprocessed, wherein the preprocessing includes converting the PDF data into text data and sentence segmentation processing.

[0061] In the above implementation, when converting PDF data into text data, firstly, the image contained in the PDF file is extracted, and then the text content appearing in the image is recognized using text recognition technology. Then, a conversion algorithm (such as a pdf2text conversion tool) is used to convert the PDF file into text data, and finally, the text content of the text recognition and the converted text data are summarized to obtain the converted data.

[0062] In the above implementation, after the conversion data is obtained, since NER recognition is performed in units of sentences, it is also necessary to segment the conversion data in units of sentences to obtain pre-processed data.

[0063] S102: According to the training data, the original semantic model is trained by an unsupervised learning method to obtain a semantically related vocabulary query model.

[0064] In the embodiment of the present application, two models are pre-built: the original entity detection model and the original semantic model. The original semantic model can be trained first to obtain a semantically related vocabulary query model, and then the query of word knowledge in reality is simulated in the semantically related vocabulary query model. According to the input sentence, the semantically related vocabulary of each word in the sentence is retrieved respectively, sorted according to the semantic similarity, and several vocabulary features are selected to be merged with the vocabulary features in the original sentence. The fused features are input into the NER classification layer for security entity detection.

[0065] S103: Input the training data into a semantically related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors.

[0066] After step S103, the following steps are also included:

[0067] S104: Determine the external semantically related vocabulary corresponding to the word vector according to the word vector and the cosine similarity.

[0068] S105. Calculate the average word vector of the word vectors according to the external semantically related words to obtain the external word features.

[0069] In the embodiment of the present application, by implementing the above steps S103 to S105, the training data can be input into the semantically related vocabulary query model for processing to obtain external vocabulary features.

[0070] In the embodiment of the present application, the semantically related vocabulary query model can capture the correlation between words in the security field through unsupervised learning. Specifically, the unlabeled corpus collected and related to the security field is used as training data and trained through unsupervised learning.

[0071] In the embodiment of the present application, the semantically related vocabulary query model may specifically be a Word2Vec model.

[0072] In an embodiment of the present application, the input sentence is represented as X={x1,x2,x3,…,xn}, and each word xi (i∈[1,n]) is used as the input of the semantically related vocabulary query model to obtain the vector representation corresponding to the word and calculate the cosine similarity with other word vectors. The larger the cosine similarity, the stronger the semantic correlation between the words. Then, the words are sorted according to the cosine similarity, and a preset number (for example, 5) of words with the largest similarity are selected as the external semantically related words of the word. Furthermore, the average word vector value of these external semantically related words is calculated as the external vocabulary feature, and then steps S106 to S109 are executed. After encoding by the encoder of the original NER model, the word vector corresponding to the word is input into the classification layer of the original NER model for security entity recognition.

[0073] After step S105, the following steps are also included:

[0074] S106. Input the training data into the encoding model for processing to obtain a word encoding vector; wherein the pre-built security entity detection model includes an encoding model and a classification layer, and the classification layer includes a first fully connected layer and a second fully connected layer with different inputs.

[0075] In an embodiment of the present application, the encoder of the original NER model may specifically be a Bert model. Specifically, the Bert model is a pre-trained context-embedded Bert model based on a transformer.

[0076] S107, input the word encoding vector into the first fully connected layer for processing to obtain a first processing result, and input the external vocabulary feature into the second fully connected layer for processing to obtain a second processing result.

[0077] In the embodiment of the present application, the input sentence X is input into the encoder to obtain a word encoding vector, which is represented as {v1,…,vn}, where vi=embedi(X). The fused external vocabulary feature x is processed by the second classification layer to obtain a second processing result, which can be represented as: qθ(yi|x, _ x _), for the first processing result of the original vocabulary feature (ie, word encoding vector) x output by the first classification layer, the first processing result can be expressed as: qθ(yi|x), i=1,2,…,n.

[0078] After step S107, the following steps are also included:

[0079] S108. Calculate the total loss according to the first processing result and the second processing result.

[0080] As an optional implementation, calculating the total loss according to the first processing result and the second processing result includes:

[0081] Calculating a first cross entropy loss according to the first processing result, calculating a second cross entropy loss according to the second processing result, and calculating a loss of collaborative learning according to the first processing result and the second processing result;

[0082] The total loss is calculated based on the first cross entropy loss, the first cross entropy loss, and the loss of collaborative learning.

[0083] In the above implementation, the loss of cooperative learning can be calculated according to the first processing result and the second processing result, so as to calculate the cross entropy loss between two different inputs as the loss of cooperative learning. The specific calculation formula is as follows:

[0084]

[0085] Among them, t is the number of categories.

[0086] In the above formula, for example, a sentence has n words and each word has t categories.

[0087] In the above formula, The summation variables are yi=1, yi=2,..., yi=t, The summation variables are i=1, i=2, ... i=n. For example, when i=1, then The summed variables are y1=1, y1=2,…, y1=t.

[0088] In the above embodiment, the total loss of the model is L=L1+L2+L3.

[0089] S109. Adjust the model parameters of the original entity detection model according to the total loss to obtain a trained security entity detection model.

[0090] In the embodiment of the present application, the original entity detection model can be trained according to the pre-set training parameters, and the parameters can be adjusted to the optimal state. The training parameters include the number of training rounds (epoch), batch size (batch size), learning rate (lr), maximum input length (max_len), etc., which are not limited in the embodiment of the present application.

[0091] In the embodiment of the present application, by implementing the above steps S106 to S109, the original entity detection model can be trained through external vocabulary features to obtain a trained security entity detection model.

[0092] In the embodiments of the present application, different application scenarios are taken into consideration, such as high requirements for prediction speed or high requirements for model accuracy, and then cooperative learning is used to jointly improve the model performance of the two inputs.

[0093] In the embodiments of the present application, the accuracy of security entity detection can be improved by utilizing external semantically related vocabulary and collaborative learning.

[0094] In the embodiment of the present application, if it is an offline prediction, the prediction accuracy requirement is high and the prediction speed requirement is low; if it is an online prediction, the opposite is true. After fusing the external vocabulary features, although the accuracy is improved, the speed will be reduced during prediction, and it is necessary to perform cooperative learning training through S108 to step S109, by adding constraints between the distributions of the outputs corresponding to the two input features to force the predictions of the two inputs to be close, so the model accuracy of the two inputs can be jointly improved through cooperative learning.

[0095] S110, obtaining data to be detected.

[0096] In the embodiment of the present application, the data to be detected includes security-related text information (such as security technology blog text data) crawled from various sources on the Internet, as well as security incident articles, APT incident reports, and WeChat public account tweets related to security incidents published by major network security companies, which are not limited to the embodiment of the present application.

[0097] S111, preprocessing the data to be detected to obtain preprocessed data.

[0098] In an embodiment of the present application, if the data to be detected includes text data and PDF (Portable Document Format) data, the original sample data needs to be preprocessed, wherein the preprocessing includes converting the PDF data into text data and sentence segmentation processing. Wherein, when converting the PDF data into text data, first extract the picture contained in the PDF file, and then use the text recognition technology to identify the text content appearing in the picture. Then use a conversion algorithm (such as the pdf2text conversion tool) to convert the PDF file into text data, and finally summarize the text content of the text recognition and the converted text data to obtain the converted data. Secondly, after obtaining the converted data, since NER recognition is based on sentence recognition, it is also necessary to segment the converted data in units of sentences to obtain preprocessed data.

[0099] S112, processing the preprocessed data through a pre-built semantically related vocabulary query model to obtain vocabulary features.

[0100] After step S112, the following steps are also included:

[0101] S113. Process the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result.

[0102] In the embodiment of the present application, the query of word knowledge in reality is simulated in the semantically related vocabulary query model, and the semantically related vocabulary of each word in the sentence is retrieved according to the sentence in the input preprocessed data, sorted according to the semantic similarity, and several vocabulary features are selected to be merged with the vocabulary features in the original sentence. The merged vocabulary features are input into the classification layer of the security entity detection model for security entity detection to obtain the security entity detection result.

[0103] In an embodiment of the present application, the method is based on the way of understanding knowledge and proposes a method of improving the contextual representation of the input sentence by searching for semantically related words. At the same time, cooperative learning is used to jointly improve the accuracy of two different inputs for different application scenarios.

[0104] In the embodiment of the present application, the execution subject of the method can be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0105] In the embodiment of the present application, the execution subject of the method can also be a smart device such as a smart phone, a tablet computer, etc., and there is no limitation on this in the present embodiment.

[0106] It can be seen that the implementation of the security entity detection method described in this embodiment can detect the security entity quickly and accurately, with small detection error and high detection efficiency.

[0107] Example 2

[0108] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a security entity detection device provided in an embodiment of the present application. Figure 2 As shown, the security entity detection device includes:

[0109] A first acquisition unit 210, used to acquire data to be detected;

[0110] A preprocessing unit 220, used for preprocessing the data to be detected to obtain preprocessed data;

[0111] A first processing unit 230 is used to process the preprocessed data through a pre-built semantically related vocabulary query model to obtain vocabulary features;

[0112] The second processing unit 240 is used to process the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result.

[0113] As an optional implementation manner, the security entity detection device further includes:

[0114] A second acquisition unit 250 is used to acquire training data for training the model, the original entity detection model and the original semantic model;

[0115] A first training unit 260 is used to train the original semantic model in an unsupervised learning manner according to the training data to obtain a semantically related vocabulary query model;

[0116] The third processing unit 270 is used to input the training data into the semantic related vocabulary query model for processing to obtain external vocabulary features;

[0117] The second training unit 280 is used to train the original entity detection model through external vocabulary features to obtain a trained security entity detection model.

[0118] As an optional implementation, the third processing unit 270 includes:

[0119] The first subunit 271 is used to input the training data into the semantic related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors;

[0120] The second subunit 272 is used to determine the external semantically related vocabulary corresponding to the word vector according to the word vector and the cosine similarity;

[0121] The third subunit 273 is used to calculate the average word vector of the word vector according to the external semantically related words to obtain the external word feature.

[0122] As an optional implementation, the second training unit 280 includes:

[0123] The fourth subunit 281 is used to input the training data into the encoding model for processing to obtain a word encoding vector; wherein the pre-built security entity detection model includes an encoding model and a classification layer, and the classification layer includes a first fully connected layer and a second fully connected layer with different inputs; and input the word encoding vector into the first fully connected layer for processing to obtain a first processing result, and input the external vocabulary feature into the second fully connected layer for processing to obtain a second processing result;

[0124] A fifth subunit 282, configured to calculate a total loss according to the first processing result and the second processing result;

[0125] The sixth subunit 283 is used to adjust the model parameters of the original entity detection model according to the total loss to obtain a trained security entity detection model.

[0126] As an optional implementation, the fifth subunit 282 includes:

[0127] A first module is used to calculate a first cross entropy loss according to the first processing result, calculate a second cross entropy loss according to the second processing result, and calculate a loss of collaborative learning according to the first processing result and the second processing result;

[0128] The second module is used to calculate the total loss based on the first cross entropy loss, the first cross entropy loss and the loss of collaborative learning.

[0129] In the embodiments of the present application, the explanation of the security entity detection device can refer to the description in Embodiment 1, and no further elaboration will be given in this embodiment.

[0130] It can be seen that the security entity detection device described in this embodiment can detect the security entity quickly and accurately, with small detection error and high detection efficiency.

[0131] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute any one of the security entity detection methods in Embodiment 1 or Embodiment 2 of the present application.

[0132] An embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, any security entity detection method in Embodiment 1 or Embodiment 2 of the present application is executed.

[0133] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0134] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0135] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0136] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0137] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0138] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A security entity detection method, characterized in that: include: Obtain the data to be tested; Preprocessing the data to be detected to obtain preprocessed data; Processing the preprocessed data by using a pre-built semantically related vocabulary query model to obtain vocabulary features; Processing the vocabulary features through a pre-built security entity detection model to obtain a security entity detection result; Wherein, the method further comprises: Obtain training data for training the model, the original entity detection model, and the original semantic model; According to the training data, the original semantic model is trained by an unsupervised learning method to obtain a semantically related vocabulary query model; Inputting the training data into the semantically related vocabulary query model for processing to obtain external vocabulary features; Input the training data into the encoding model for processing to obtain a word encoding vector; wherein the pre-built security entity detection model includes the encoding model and a classification layer, and the classification layer includes a first fully connected layer and a second fully connected layer with different inputs; Inputting the word encoding vector into the first fully connected layer for processing to obtain a first processing result, and inputting the external vocabulary feature into the second fully connected layer for processing to obtain a second processing result; Calculate the total loss according to the first processing result and the second processing result; Adjusting the model parameters of the original entity detection model according to the total loss to obtain a trained security entity detection model; The total loss is calculated according to the first processing result and the second processing result, including: Calculating a first cross entropy loss according to the first processing result, calculating a second cross entropy loss according to the second processing result, and calculating a loss of collaborative learning according to the first processing result and the second processing result; Calculating a total loss according to the first cross entropy loss, the second cross entropy loss, and the loss of the collaborative learning; Among them, the specific calculation formula for the loss of cooperative learning is as follows: ; Where t is the number of categories; n is the number of words in the input sentence, and each word has t categories; The summation variables are yi=1, yi=2,…, yi=t, The summation variables are i=1, i=2,...i=n; represents the second processing result, represents the first processing result, i=1,2,…,n; The calculation formula for calculating the total loss according to the first cross entropy loss, the second cross entropy loss and the loss of the collaborative learning is: L=L1+L2+L3; Among them, L represents the total loss, L1 is the first cross entropy loss, L2 is the second cross entropy loss, and L3 is the loss of collaborative learning.

2. The security entity detection method according to claim 1, characterized in that: The step of inputting the training data into the semantically related vocabulary query model for processing to obtain vocabulary feature samples includes: Input the training data into the semantically related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors; Determine, according to the word vector and the cosine similarity, an external semantically related vocabulary corresponding to the word vector; The average word vector of the word vector is calculated according to the external semantically related words to obtain the external word feature.

3. A security entity detection device, characterized in that: The security entity detection device comprises: A first acquisition unit, used for acquiring data to be detected; A preprocessing unit, used for preprocessing the data to be detected to obtain preprocessed data; A first processing unit, configured to process the preprocessed data using a pre-built semantically related vocabulary query model to obtain vocabulary features; A second processing unit, configured to process the lexical features through a pre-built security entity detection model to obtain a security entity detection result; Wherein, the security entity detection device also includes: A second acquisition unit, used to acquire training data for training a model, an original entity detection model, and an original semantic model; A first training unit is used to train the original semantic model in an unsupervised learning manner according to the training data to obtain a semantically related vocabulary query model; A third processing unit, used for inputting the training data into the semantically related vocabulary query model for processing to obtain external vocabulary features; A second training unit is used to train the original entity detection model through the external vocabulary features to obtain a trained security entity detection model; Wherein, the second training unit comprises: The fourth subunit is used to input the training data into the encoding model for processing to obtain a word encoding vector; wherein the pre-built security entity detection model includes an encoding model and a classification layer, and the classification layer includes a first fully connected layer and a second fully connected layer with different inputs; and input the word encoding vector into the first fully connected layer for processing to obtain a first processing result, and input the external vocabulary feature into the second fully connected layer for processing to obtain a second processing result; A fifth subunit, configured to calculate a total loss according to the first processing result and the second processing result; A sixth subunit is used to adjust the model parameters of the original entity detection model according to the total loss to obtain a trained security entity detection model; The fifth subunit includes: A first module is used to calculate a first cross entropy loss according to the first processing result, calculate a second cross entropy loss according to the second processing result, and calculate a loss of collaborative learning according to the first processing result and the second processing result; The second module is used to calculate the total loss according to the first cross entropy loss, the second cross entropy loss and the loss of collaborative learning; Among them, the specific calculation formula for the loss of cooperative learning is as follows: ; Where t is the number of categories; n is the number of words in the input sentence, and each word has t categories; The summation variables are yi=1, yi=2,…, yi=t, The summation variables are i=1, i=2,...i=n; represents the second processing result, represents the first processing result, i=1,2,…,n; The calculation formula for calculating the total loss according to the first cross entropy loss, the second cross entropy loss and the loss of the collaborative learning is: L=L1+L2+L3; Among them, L represents the total loss, L1 is the first cross entropy loss, L2 is the second cross entropy loss, and L3 is the loss of collaborative learning.

4. The security entity detection device according to claim 3, characterized in that: The third processing unit comprises: A first subunit is used to input the training data into the semantically related vocabulary query model for processing to obtain a word vector and a cosine similarity between the word vector and other word vectors; A second subunit is used to determine the external semantically related vocabulary corresponding to the word vector according to the word vector and the cosine similarity; The third subunit is used to calculate the average word vector of the word vector according to the external semantically related vocabulary to obtain the external vocabulary feature.

5. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the security entity detection method according to any one of claims 1 to 2.

6. A readable storage medium, characterized in that: The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the security entity detection method according to any one of claims 1 to 2 is executed.