An entity recognition method, apparatus and electronic device

By combining absolute and relative positional encoding in the BERT model, the start and end positions of entities in cybersecurity text are identified, solving the accuracy problem of nested or overlapping entity recognition and improving the accuracy of entity recognition and the efficiency of cybersecurity processing.

CN119623468BActive Publication Date: 2025-11-14CHINA TELECOM NETWORK SECURITY TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411648517.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-11-14
Estimated Expiration
2044-11-18

AI Technical Summary

Technical Problem

Traditional entity recognition methods struggle to accurately identify nested or overlapping entities when processing unstructured or semi-structured text in the cybersecurity field, and the BERT model has limitations in handling long-distance dependencies.

Method used

By acquiring multiple word segments of the text to be identified, the positional encoding of each word is determined. Using the BERT model that combines relative and absolute positional encoding, the beginning and end words are identified, thereby determining the start and end positions of the entity.

Benefits of technology

It improved the accuracy of entity recognition, reduced false alarms and irrelevant alerts, and enhanced threat awareness and processing efficiency in the field of cybersecurity technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119623468B_ABST
    Figure CN119623468B_ABST
Patent Text Reader

Abstract

This application provides an entity recognition method, apparatus, and electronic device, relating to the field of network security technology, to address the problem that related technologies cannot accurately identify all entities when there is nesting or overlap between entities belonging to different entity types in text. The method first obtains multiple word segments from the text to be recognized; based on the position of each word segment in the text, a positional code for each word is determined; based on the positional code of each word segment, the head words and tail words included in the multiple word segments, and the target entity types corresponding to the head words and tail words are determined; based on the positions of the head words and tail words corresponding to the same target entity type in the text, at least one target entity included in the text to be recognized is determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cybersecurity technology, and in particular to an entity recognition method, device, and electronic device. Background Technology

[0002] In the field of cybersecurity, entity recognition technology is a fundamental natural language processing technique that can automatically extract key information from text, such as IP addresses, usernames, and device identifiers. This information is crucial for various security operations in cybersecurity. However, with the increasing complexity of the network environment and the growing number of security threats, traditional security entity recognition technologies are facing increasing challenges.

[0003] Traditional entity recognition methods are typically based on rule-based or statistical learning models. These methods perform well when dealing with simple, well-formatted text, but their efficiency and accuracy often fall short when faced with unstructured or semi-structured text specific to the cybersecurity field.

[0004] In recent years, with the development of deep learning technology, entity recognition methods based on neural networks have gradually emerged. For example, the Bidirectional Encoder Representations from Transformers (BERT) model can capture contextual relationships in text through a pre-trained bidirectional Transformer network, thereby improving the performance of entity recognition. However, BERT mainly relies on absolute positional encoding to process positional information in text, which still has limitations when processing text containing long-distance dependencies. Furthermore, when there is nesting or overlap between entities belonging to different entity types in the text, BERT cannot accurately identify all entities included in the text. Summary of the Invention

[0005] This application provides an entity recognition method, apparatus, and electronic device to address the problem that related technologies cannot accurately identify all entities when there is nesting or overlap between entities belonging to different entity types in a text.

[0006] In a first aspect, embodiments of this application provide an entity recognition method, comprising: acquiring a plurality of word segments included in a text to be recognized; determining a position code for each word segment based on its respective position in the text to be recognized; determining, based on the position code of each word segment, a head word and a tail word included in the plurality of word segments, and a target entity type corresponding to the head word and the tail word; wherein the head word represents a word segment located at the beginning position of any entity, and the tail word represents a word segment located at the end position of any entity; and determining at least one target entity included in the text to be recognized based on the respective positions of the head word and the tail word corresponding to the same target entity type in the text to be recognized.

[0007] In one possible implementation, determining the positional encoding of each word based on its position in the text to be identified includes: determining the embedding vector corresponding to each of the multiple words based on their respective arrangement positions in the text to be identified; and determining the positional encoding of each of the multiple words based on their respective embedding vectors and the relative positional relationships between the multiple words.

[0008] In one possible implementation, determining the positional encoding of each of the multiple word segments based on their respective embedding vectors and the relative positional relationships between the multiple word segments includes: obtaining a relative positional difference mapping of the text to be identified; the relative positional difference mapping includes the relative positional difference between every two word segments; for any one of the multiple word segments, performing the following operations: in the relative positional difference mapping, obtaining a reference relative positional difference between the arbitrary word segment and the other word segments based on the arrangement position of the arbitrary word segment; determining relative positional scores between the arbitrary word segment and the other word segments based on the obtained reference relative positional differences; the relative positional scores correspond one-to-one with the reference relative positional differences, and the relative positional scores are positively correlated with the reference relative positional differences; determining attention scores between the arbitrary word segment and the other word segments based on the embedding vectors of each of the multiple word segments and the determined relative positional scores; and encoding the arbitrary word segment based on the determined attention scores to obtain the positional encoding of the arbitrary word segment.

[0009] In one possible implementation, determining the head words and tail words included in the plurality of word segments, and the target entity types corresponding to the head words and tail words, based on the positional encoding of each word segment, includes: for any one of the preset at least one entity type, performing the following operations respectively: for any one of the plurality of word segments, determining a first probability that the arbitrary word segment is the head word corresponding to the arbitrary entity type, and a second probability that the arbitrary word segment is the tail word corresponding to the arbitrary entity type, based on the positional encoding of the arbitrary word segment and the head prediction model and tail prediction model corresponding to the arbitrary entity type; when there is a first probability that satisfies the preset first probability condition and a second probability that satisfies the preset second probability condition, determining the arbitrary entity type as the target entity type; and taking the word segment corresponding to the first probability that satisfies the preset first probability condition as the head word corresponding to the target entity type, and taking the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail word corresponding to the target entity type.

[0010] In one possible implementation, after determining the first probability that a word segment is a head segment corresponding to any entity type and the second probability that a word segment is a tail segment corresponding to any entity type based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to any entity type, the method further includes: performing head annotation on the word segment that satisfies the first probability condition and the tail annotation on the word segment that satisfies the second probability condition; when both the head annotation and the tail annotation exist, determining any entity type as the target entity type; the step of using the word segment that satisfies the first probability condition as the head segment corresponding to the target entity type and the word segment that satisfies the second probability condition as the tail segment corresponding to the target entity type includes: using the word segment containing the head annotation as the head segment corresponding to the target entity type; and using the word segment containing the tail annotation as the tail segment corresponding to the target entity type.

[0011] In one possible implementation, before determining the first probability that a word segment is a head segment corresponding to any entity type and the second probability that a word segment is a tail segment corresponding to any entity type based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to any entity type for the plurality of word segments, the method further includes: constructing a pointer matrix corresponding to any entity type for any entity type; the pointer matrix includes a head row and a tail row; the step of performing head annotation on word segments belonging to the first probability that satisfy a preset first probability condition and performing tail annotation on word segments belonging to the second probability that satisfy a preset second probability condition includes: when there is a first probability that satisfies the preset first probability condition among the first probabilities of the plurality of word segments, performing head annotation on the position corresponding to the corresponding word in the head row of the pointer matrix; when there is a second probability that satisfies the preset second probability condition among the second probabilities of the plurality of word segments, performing tail annotation on the position corresponding to the corresponding word in the tail row of the pointer matrix.

[0012] In one possible implementation, determining at least one target entity in the text to be identified based on the positions of the head words and tail words corresponding to the same target entity type in the text to be identified includes: for any one of the at least one target entity types, performing the following operations respectively: combining the head words, tail words, and word segments located between the head words and tail words corresponding to the any one entity type into a target entity.

[0013] Secondly, embodiments of this application provide an entity recognition device, including:

[0014] The acquisition unit is used to acquire multiple word segments included in the text to be recognized;

[0015] The processing unit is configured to: determine the position code of each segment based on its position in the text to be identified; determine the head segment and tail segment included in the plurality of segmented words, and the target entity type corresponding to the head segment and tail segment, based on the position code of each segmented word; wherein the head segment represents the segment located at the beginning position of any entity, and the tail segment represents the segment located at the end position of any entity; and determine at least one target entity included in the text to be identified based on the positions of the head segment and tail segment corresponding to the same target entity type in the text to be identified.

[0016] In one possible implementation, the processing unit determines the position code of each word based on its position in the text to be identified. Specifically, this is done by: determining the embedding vector corresponding to each of the multiple words based on their respective arrangement positions in the text to be identified; and determining the position code of each of the multiple words based on their respective embedding vectors and the relative positional relationships between the multiple words.

[0017] In one possible implementation, the processing unit determines the positional encoding of each of the multiple word segments based on their respective embedding vectors and the relative positional relationships between the multiple word segments. Specifically, this involves: obtaining a relative positional difference mapping of the text to be identified; the relative positional difference mapping includes the relative positional difference between every two word segments; for any one of the multiple word segments, performing the following operations: in the relative positional difference mapping, obtaining a reference relative positional difference between the arbitrary word segment and the other word segments based on the arrangement position of the arbitrary word segment; determining relative positional scores between the arbitrary word segment and the other word segments based on the obtained reference relative positional differences; the relative positional scores correspond one-to-one with the reference relative positional differences, and the relative positional scores are positively correlated with the reference relative positional differences; determining attention scores between the arbitrary word segment and the other word segments based on the embedding vectors of each of the multiple word segments and the determined relative positional scores; and encoding the arbitrary word segment based on the determined attention scores to obtain the positional encoding of the arbitrary word segment.

[0018] In one possible implementation, the processing unit determines the head words and tail words included in the plurality of word segments, as well as the target entity types corresponding to the head words and tail words, based on the positional encoding of each word segment. Specifically, it is used to: for any one of the preset at least one entity type, perform the following operations respectively: for any one of the plurality of word segments, based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the entity type, determine a first probability that the word segment is the head word corresponding to the entity type and a second probability that the word segment is the tail word corresponding to the entity type; when there is a first probability that satisfies the preset first probability condition and a second probability that satisfies the preset second probability condition, determine the entity type as the target entity type; and take the word segment corresponding to the first probability that satisfies the preset first probability condition as the head word corresponding to the target entity type, and take the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail word corresponding to the target entity type.

[0019] In one possible implementation, after the processing unit determines the first probability that the segmented word is a head segment corresponding to the arbitrary entity type and the second probability that the segmented word is a tail segment corresponding to the arbitrary entity type based on the positional encoding of the segmented word and the head prediction model and tail prediction model corresponding to the arbitrary entity type, it is further configured to: perform head annotation on the segmented word that satisfies the preset first probability condition and perform tail annotation on the segmented word that satisfies the preset second probability condition and the second probability condition; when both the head annotation and the tail annotation exist, determine the arbitrary entity type as the target entity type;

[0020] The processing unit uses the word segment corresponding to the first probability that satisfies the preset first probability condition as the head segment corresponding to the target entity type, and the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail segment corresponding to the target entity type. Specifically, it is used to: use the word segment containing the head annotation as the head segment corresponding to the target entity type; and use the word segment containing the tail annotation as the tail segment corresponding to the target entity type.

[0021] In one possible implementation, before the processing unit determines, for the plurality of word segments, the first probability that the word segment is a head segment corresponding to the arbitrary entity type and the second probability that the word segment is a tail segment corresponding to the arbitrary entity type based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the arbitrary entity type, it is further configured to: construct a pointer matrix corresponding to the arbitrary entity type for the arbitrary entity type; the pointer matrix includes a head row and a tail row;

[0022] The processing unit performs header annotation on the word segments belonging to the first probability that satisfy the preset first probability condition, and performs tail annotation on the word segments belonging to the second probability that satisfy the preset second probability condition. Specifically, it performs header annotation on the position corresponding to the word segment in the head row of the pointer matrix when there is a first probability that satisfies the preset first probability condition among the first probabilities of the multiple word segments; and performs tail annotation on the position corresponding to the word segment in the tail row of the pointer matrix when there is a second probability that satisfies the preset second probability condition among the second probabilities of the multiple word segments.

[0023] In one possible implementation, the processing unit determines at least one target entity in the text to be identified based on the positions of the head words and tail words corresponding to the same target entity type in the text to be identified. Specifically, it is used to perform the following operations for any one of the at least one target entity types: combine the head words, tail words, and word segments located between the head words and tail words corresponding to the any one entity type into a target entity.

[0024] Thirdly, embodiments of this application provide an electronic device, including:

[0025] Memory, used to store computer instructions;

[0026] A processor, connected to the memory, is configured to execute computer instructions in the memory, and, in executing the computer instructions, implement the method as described in any one of the first aspects.

[0027] Fourthly, embodiments of this application provide a computer-readable storage medium, comprising:

[0028] The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the computer to perform the method as described in any one of the first aspects.

[0029] The beneficial effects of this application are as follows:

[0030] This application provides an entity recognition method, apparatus, device, and storage medium. The method includes: acquiring multiple word segments included in a text to be recognized; determining the position code of each word segment based on its position in the text to be recognized; determining the head word and tail word included in the multiple word segments, and the target entity type corresponding to the head word and tail word, based on the position code of each word segment; determining at least one target entity included in the text to be recognized based on the position of the head word and tail word corresponding to the same target entity type in the text to be recognized, wherein the head word represents the word segment located at the beginning position of any entity, and the tail word represents the word segment located at the end position of any entity.

[0031] This application's embodiments, by determining the starting and ending words included in multiple word segments, can identify the start and end positions of entities. Therefore, it provides more refined contextual analysis and entity boundary recognition capabilities. Furthermore, since it does not directly identify the entire entity but rather identifies the target entity through its start and end positions, even in cases of nesting or overlap, this application only needs to identify the corresponding starting and ending words to assemble all entities included in the text, thereby improving the accuracy of entity recognition. Further, due to the improved accuracy of entity recognition, in the field of network security technology, it can significantly reduce false alarms and irrelevant alerts related to entities, thereby improving the focus and processing efficiency of relevant technical personnel on real threats.

[0032] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0033] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application.

[0034] Figure 1 A schematic diagram of the system architecture for the entity recognition method provided in the embodiments of this application;

[0035] Figure 2 An exemplary flowchart of an entity recognition method provided in an embodiment of this application;

[0036] Figure 3 This is a schematic diagram of the location encoding process provided in an embodiment of this application;

[0037] Figure 4 A schematic diagram of a pointer matrix provided in an embodiment of this application;

[0038] Figure 5 This is a schematic diagram of the annotation process provided in the embodiments of this application;

[0039] Figure 6 This is a schematic diagram illustrating the process of an entity recognition method provided in an embodiment of this application;

[0040] Figure 7 A schematic diagram of an entity recognition device provided in an embodiment of this application;

[0041] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0042] To facilitate understanding of the technical solutions provided in the embodiments of this application, the following describes the technical terms involved in the embodiments of this application.

[0043] (1) An entity is a word or phrase in text that has a specific meaning or proper name. They usually represent certain objects, people, places, organizations, times, etc. The goal of entity recognition is to identify these entities from the text and classify them into different categories.

[0044] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0045] The terms "first" and "second" in the embodiments of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more; the embodiments of this application do not impose any limitations.

[0046] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.

[0047] In the field of cybersecurity, entity recognition technology is a fundamental natural language processing technique. However, traditional entity recognition methods are typically based on rule-based or statistical learning models. These methods perform well when processing simple, well-formatted text, but their efficiency and accuracy often fall short when dealing with unstructured or semi-structured text specific to cybersecurity.

[0048] In recent years, with the development of deep learning technology, entity recognition methods based on neural networks have gradually emerged. For example, the BERT model can capture contextual relationships in text through a pre-trained bidirectional Transformer network, thereby improving the performance of entity recognition. However, BERT mainly relies on absolute positional encoding to process positional information in text, which still has limitations when processing text containing long-distance dependencies. Furthermore, when there is nesting or overlap between entities belonging to different entity types in the text, BERT cannot accurately identify all entities included in the text.

[0049] In view of this, embodiments of this application provide an entity recognition method, which includes: acquiring multiple word segments included in the text to be recognized; determining the position code of each word segment based on its position in the text to be recognized; determining the head words and tail words included in the multiple word segments, as well as the target entity types corresponding to the head words and tail words, based on the position code of each word segment; and finally determining at least one target entity included in the text to be recognized based on the positions of the head words and tail words corresponding to the same target entity type in the text to be recognized.

[0050] By identifying the starting and ending words in multiple word segments using the above method, the start and end positions of entities can be determined. This provides more refined contextual analysis and entity boundary recognition capabilities. Furthermore, since the entire entity is not directly identified, but rather the target entity is identified through its start and end positions, even in cases of nesting or overlap, this application can assemble all entities included in the text simply by identifying the corresponding starting and ending words, thereby improving the accuracy of entity recognition. Moreover, due to the improved accuracy of entity recognition, in the field of network security technology, it can significantly reduce false alarms and irrelevant alerts related to entities, thereby improving the focus and processing efficiency of relevant technical personnel on real threats.

[0051] See Figure 1This is a schematic diagram of the system architecture for the entity recognition method provided in this application embodiment. The system can be a server 100, including a memory 110, a processor 120, and a communication interface 130. The communication interface 130 can be used to acquire multiple word segments included in the text to be recognized. The processor 120 is the control center of the server 100, connecting various parts of the server 100 through various interfaces and lines. It executes various functions of the server 100 and processes data by running or executing software programs or modules stored in the memory 110 and calling data stored in the memory 110. When executing the entity recognition method provided in this application embodiment, the processor 120 can determine the position code of each word segment based on its position within the text to be recognized. Based on the position code of each word segment, it determines the head word and tail word segments included in the multiple word segments, as well as the target entity types corresponding to the head word and tail word segments; the head word segment represents the word segment located at the beginning position of any entity, and the tail word segment represents the word segment located at the end position of any entity. Based on the positions of the first and last words of the same target entity type in the text to be identified, at least one target entity in the text to be identified is determined.

[0052] Optionally, the processor 120 may include one or more processing units. The memory 110 may be a high-speed random access memory or a non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0053] It should be noted that the above Figure 1 The structure shown is merely an example, and the embodiments of this application are not limited thereto.

[0054] See Figure 2 This is an exemplary flowchart of an entity recognition method provided in an embodiment of this application. This process can be applied to... Figure 1 The server 100 shown may include the following processes:

[0055] S201, Obtain multiple word segments included in the text to be recognized.

[0056] The text to be identified can be text included in data such as network and system-generated security logs, malware descriptions, attacker strategies, and security vulnerability reports. Identifiable entities within this text include, but are not limited to, critical information such as IP addresses, domain names, hash values, vulnerability numbers, timestamps, user IDs, and operation codes.

[0057] In some embodiments, when the server obtains the text to be recognized, it can obtain the text to be recognized from the system that requires entity recognition. For example, it can obtain various security logs stored in a security log management system, and use each security log as the text to be recognized, and execute the entity recognition method provided in the embodiments of this application for each log.

[0058] In other embodiments, when the server obtains the text to be recognized, it can also obtain the text to be recognized that the user inputs in the terminal device and that needs to be recognized through the network, and then perform the entity recognition method provided in the embodiments of this application on the text to be recognized.

[0059] After obtaining the text to be recognized, the server can first perform word segmentation on the text to obtain multiple tokens. This word segmentation can also be performed by a word segmenter. The word segmenter can be included in the encoding model, such as WordPiece and SentencePiece in models like BERT. Alternatively, the word segmenter can be independent of the encoding model. For example, when the text to be recognized is Chinese, it can be segmented using jieba word segmentation, and then the segmented results can be input into the encoding model constructed in the embodiments of this application. This application does not limit this.

[0060] It should be noted that the word segmentation in this application can also be called word element or sub-word. Depending on the language and the word segmentation algorithm, the composition of each word segmentation can also be different. For example, for English characters in the text to be recognized, one word segmentation can correspond to one word, such as "apple", or the root of a word, such as "app". For Chinese characters in the text to be recognized, one word segmentation can correspond to one character, such as "date" can be divided into two words: "day" and "period". For Arabic numerals in the text to be recognized, one word segmentation can correspond to a string of numbers, such as "2021". In addition, one word segmentation can also correspond to a string composed of numbers and letters, such as "APT28".

[0061] S202, determine the position code of each word based on its position in the text to be recognized.

[0062] In one possible implementation, when the server determines the positional encoding of each word based on its position in the text to be recognized, it can determine the embedding vector corresponding to each word based on their respective positions in the text. Then, based on the embedding vectors of each word and the relative positional relationships between the words, the positional encoding of each word is determined. Here, the positional relationship can refer to the absolute position of the word.

[0063] In one example, when determining the embedding vectors corresponding to multiple word segments, the text to be recognized can be input into the encoding model. The encoding model performs token embeddings, sentence embeddings, and position embeddings on the text to be recognized to obtain the embedding vector corresponding to each word segment.

[0064] The encoding model used in this application is a BERT model that combines relative positional encoding and absolute positional encoding (Relative-absolute-Bidirectional Encoder Representations from Transformers, RaBERT). The input embedding operation in the RaBERT model is the same as that in the BERT model.

[0065] Specifically, word segmentation embedding can be achieved by using the WordPiece word segmentation algorithm in the RaBERT model to break down the text to be recognized into smaller units (such as roots, prefixes, or suffixes). These units can be called "words". For example, "playing" might be segmented into ['play', '##ing']. Each word has a corresponding embedding, which is obtained by looking up the vocabulary. Each word corresponds to a fixed-size vector (e.g., 768 dimensions) representing the semantic information of that word.

[0066] Sentence embedding, used when the text to be recognized consists of two sentences, determines whether each word in the text belongs to sentence A or sentence B. For example, for all words in sentence A, their sentence embedding can be set to 0, indicating that these words belong to sentence A; for all words in sentence B, their sentence embedding can be set to 1, indicating that these words belong to sentence B. When the text to be recognized consists of only one sentence, only E is used. A .

[0067] Positional embedding is used to add positional information to each word segment, representing the position of each word in the text to be recognized. Specifically, absolute positional encoding can be used to map each position to a position vector, and these position vectors are added to the word segmentation embedding so that the encoding model understands the sequential relationship between the words in the text to be recognized.

[0068] For each word segment, the above three embeddings are added together to obtain the embedding vector corresponding to the word segment, which satisfies formula (1).

[0069] E i = E Ti + E Si+ E Pi Formula (1)

[0070] In the formula, E i E represents the embedding vector of the i-th word segment. Ti E represents the word embedding of the i-th word. Si E represents the sentence embedding of the i-th word segment. Pi This indicates the embedding position of the i-th word segment.

[0071] It should be noted that the embedding vector corresponding to each word segment is usually 768-dimensional. In specific applications, the dimension can be configured in the encoding model according to actual needs, and this application does not limit it.

[0072] In some embodiments, when determining the positional encoding of multiple words in the RaBERT model based on their respective embedding vectors and relative positional relationships, the relative positional difference mapping of the text to be identified can be obtained first. The relative positional difference mapping includes the relative positional difference between every two words in the multiple words.

[0073] After obtaining the relative position difference mapping, the following operations can be performed on any one of the multiple word segments to determine the position encoding of each word segment:

[0074] In the relative position difference mapping, a reference relative position difference is obtained between any given word and all other words in a plurality of words, based on the word's position in the sequence. Based on these reference relative position differences, relative position scores are determined between the given word and all other words. Based on the embedding vectors of each word and the determined relative position scores, attention scores are determined between the given word and all other words. Finally, the given attention scores are used to encode the given word, resulting in its positional encoding. The relative position scores correspond one-to-one with the reference relative position differences, and these scores are positively correlated.

[0075] Specifically, the relative position difference mapping can be determined after determining the embedding vectors corresponding to each of the multiple word segments. The relative position difference mapping can be a relative position difference table. Assuming the text to be recognized includes n words, the word numbers can be 1 to n, and the relative position difference between two words i and j is Δ. ij =ij, where i and j both take values ​​from 1 to n. In this case, we can define a matrix R of dimension n, where the element in the i-th row and j-th column is Rij. ij This represents the reference relative position difference between i and j, and matrix R is the relative position difference table.

[0076] Furthermore, the data in the ij-th row of matrix R...i-j This is the reference relative position difference vector between i and j.

[0077] When calculating the relative position score, it can be done using formula (2).

[0078] S ij =Q i ·R i-j Formula (2)

[0079] In the formula, S ij The score is given by Q, representing the relative position between i and j. i Let R be the query vector for the i-th word segment. i-j Let i be the reference relative position difference vector between i and j.

[0080] Based on the embedding vectors corresponding to each of the multiple word segments and the determined relative position scores, the attention scores between any word segment and other words can be calculated using formula (3).

[0081]

[0082] In the formula, Q is the query vector, K is the key, V is the value, and S is the relative position score.

[0083] For example, assuming the text to be recognized includes tokenA, tokenB, and tokenC, when determining the positional encoding of tokenA, the relative positional difference between tokenA and tokenB, and between tokenA and tokenC, can be found in the relative positional difference mapping based on the arrangement position of tokenA in the text to be recognized.

[0084] Then, based on the found relative position difference, the relative position scores between tokenA and tokenB, and between tokenA and tokenC, are calculated using formula (2). Next, formula (3) is used to determine the attention scores between tokenA and tokenB, and between tokenA and tokenC. Finally, the positional encoding of tokenA is determined based on the attention scores.

[0085] Then, continue to determine the position codes of tokenB and tokenC respectively using the method described above.

[0086] See Figure 3 This is a schematic diagram of the location encoding process provided in an embodiment of this application. Figure 3 As shown, assume that the text to be recognized includes word segments T1 to T2. nIf the encoding model is the RaBERT model proposed in the embodiments of this application, then using the RaBERT model and the above-described positional encoding method, T1 can be positionally encoded to obtain C1, T2 to obtain C2, T3 to obtain C3, and so on, to obtain positional codes C1 to C2. n Among them, C1~C n The dimension can be 768.

[0087] The above method combines absolute and relative positional encoding within an attention mechanism, allowing the encoding model to consider both absolute and relative positions when parsing the relationships between word pairs. Absolute positional information provides information about the fixed location of words in the text, helping the model grasp the overall layout of the sentence and the sequential relationships between its components. Relative positional information emphasizes the distances and relationships between words, which is particularly important for understanding the deeper meaning of complex sentences. This dual positional encoding strategy provides a more comprehensive text understanding, enabling the model to more accurately capture and utilize long-distance dependencies, thereby improving the accuracy and efficiency of entity recognition.

[0088] S203, based on the positional encoding of each word segment, determine the head words and tail words included in multiple word segments, as well as the target entity types corresponding to the head words and tail words.

[0089] The first part of the word refers to the word at the beginning of any entity, and the last part of the word refers to the word at the end of any entity.

[0090] Before implementing the entity recognition method provided in this application embodiment, at least one entity type that may be included in the text to be recognized can be set according to the actual application scenario. For example, in the field of network security, entity types may include attack types, vulnerabilities, attackers, attack organizations, tools, etc. In addition, entity types such as time, location, and names may also be included, which are not limited in this application.

[0091] After setting at least one entity type, a corresponding head prediction model and a tail prediction model can be trained for each entity type to predict whether a word segment is a head segment corresponding to that entity type and whether a word segment is a tail segment corresponding to that entity type. The training methods can be found in related technologies, and will not be elaborated upon here.

[0092] In one possible implementation, S203 can be specifically executed as follows:

[0093] For any one of the at least one preset entity types, perform the following operations respectively:

[0094] For any one of multiple word segments, respectively based on the position encoding of any one of the word segments and the head prediction model and tail prediction model corresponding to any one entity type, determine the first probability that any one of the word segments is the head word segment corresponding to any one entity type, and the second probability that any one of the word segments is the tail word segment corresponding to any one entity type.

[0095] When there exists a first probability that meets the preset first probability condition and a second probability that meets the preset second probability condition, determine that any one entity type is the target entity type, and use the word segment corresponding to the first probability that meets the preset first probability condition as the head word segment corresponding to the target entity type, and use the word segment corresponding to the second probability that meets the preset second probability condition as the tail word segment corresponding to the target entity type. Here, the target entity type represents the entity type included in the text to be recognized.

[0096] For example, assume that the word segments included in the text to be recognized are respectively "black", "hacker", "group", "organization", "APT28". Then, for the attacker type in the entity types, based on the position encoding of "black", determine the first probability that "black" is the head word segment corresponding to the attacker type and the second probability that "black" is the tail word segment corresponding to the attacker type; based on the position encoding of "hacker", determine the first probability that "hacker" is the head word segment corresponding to the attacker type and the second probability that "hacker" is the tail word segment corresponding to the attacker type; based on the position encoding of "group", determine the first probability that "group" is the head word segment corresponding to the attacker type and the second probability that "group" is the tail word segment corresponding to the attacker type, and so on. In this way, the first probability and the second probability corresponding to each word segment can be obtained. Assume that the first probability of "APT28" meets the preset first probability condition and the second probability of "APT28" meets the preset second probability condition. Then, it can be determined that the attacker type is the target entity type, and "APT28" is the head word segment and tail word segment corresponding to the attacker type.

[0097] Specifically, in the head prediction model corresponding to any one entity type, the first probability that each word segment is the head word segment corresponding to any one entity type can be determined by formula (4).

[0098]

[0099] In the formula, represents the first probability that the i-th word segment is the head word segment corresponding to any one entity type, σ represents the activation function, x i represents the position encoding of the i-th word segment, W start represents the weight matrix in the trained head prediction model corresponding to any one entity type. b startThis represents the bias matrix in the trained head prediction model for any entity type.

[0100] In the tail prediction model corresponding to any entity type, the second probability of any word segment being the tail segment corresponding to any entity type can be determined by formula (5).

[0101]

[0102] In the formula, Let σ represent the first probability that the i-th word segment corresponds to any entity type as the tail segment, and let x represent the activation function. i W represents the positional encoding of the i-th word segment. end b represents the weight matrix in the trained tail prediction model for any entity type. end This represents the bias matrix in the trained tail prediction model for any entity type.

[0103] The weight matrix and bias matrix are obtained after the head prediction model and tail prediction model have been trained.

[0104] In one possible implementation, the preset first probability condition can be that the first probability is greater than or equal to a first probability threshold. Similarly, the preset second probability condition can be that the second probability is greater than or equal to a second probability threshold. Both the first and second probability thresholds can be set based on experience or actual circumstances. The first and second probability thresholds can be the same or different. For example, both the first and second probability thresholds can be 0.7, or the first probability threshold can be 0.6 and the second probability threshold can be 0.7, etc. This application does not limit this.

[0105] In some embodiments, after determining a first probability that each word segment corresponds to a head segment of any entity type and a second probability that each word segment corresponds to a tail segment of any entity type, the server can perform head annotation on words segmented by the first probability that satisfy the preset first probability condition and tail annotation on words segmented by the second probability that satisfy the preset second probability condition. When both head and tail annotations exist, any entity type is determined as the target entity type. In this case, after performing head and tail annotations, when determining head and tail segments, words containing head annotations can be used as head segments corresponding to the target entity type, and words containing tail annotations can be used as tail segments corresponding to the target entity type.

[0106] Optionally, when performing header and footer annotations, different numbers can be used for annotation. For example, when performing header annotation on a word that meets the preset first probability condition and belongs to the first probability, the word can be labeled as 1. When performing footer annotation on a word that meets the preset second probability condition and belongs to the second probability, the word can be labeled as 2.

[0107] In one possible implementation, before determining the first probability that each word segment corresponds to the head segment of any entity type, and the second probability that each word segment corresponds to the tail segment of any entity type, the server can also construct a pointer matrix corresponding to any entity type. This pointer matrix can include a head row and a tail row.

[0108] Specifically, for at least one preset entity type, the server can construct a corresponding pointer matrix, resulting in at least one pointer matrix including a header row and a footer row. The number of columns in the pointer matrix is ​​the same as the number of word segments in the text to be recognized. For example, assuming nine entity types are pre-configured, nine pointer matrices can be constructed, each including a header row and a footer row.

[0109] See Figure 4 This is a schematic diagram of a pointer matrix provided in an embodiment of this application. Assuming there are three entity types: entity type A, entity type B, and entity type C, and the text to be identified includes 10 words, the constructed pointer matrix is ​​as follows: Figure 4 As shown, entity type A, entity type B and entity type C each correspond to a pointer matrix with 2 rows and 10 columns, and each element in the matrix is ​​0.

[0110] In some embodiments, after constructing pointer matrices corresponding to each entity type, when performing header annotation on words belonging to a first probability that satisfy a preset first probability condition and tail annotation on words belonging to a second probability that satisfy a preset second probability condition, header annotation can be performed at the position corresponding to the corresponding word in the header row of the pointer matrix when there is a first probability that satisfies the preset first probability condition among the first probabilities of multiple words. Similarly, when there is a second probability that satisfies the preset second probability condition among the second probabilities of multiple words, tail annotation can be performed at the position corresponding to the corresponding word in the tail row of the pointer matrix.

[0111] Specifically, when performing header annotation on the corresponding word position in the head row of the pointer matrix, the corresponding word position in the head row of the pointer matrix can be marked as 1. Similarly, when performing tail annotation on the corresponding word position in the tail row of the pointer matrix, the corresponding word position in the head and tail rows of the pointer matrix can be marked as 1. Thus, after annotation, 1 indicates that the word is a header or tail word of the corresponding entity type, and 0 indicates that the word is not a header or tail word of the corresponding entity type.

[0112] based on Figure 4 The pointer matrix shown can be used to annotate the beginning and end words. Figure 5 This is a schematic diagram of the annotation process provided in an embodiment of this application. Assuming that after determining the first probability and the second probability of each word segment, the first probability of the third word segment being the head segment of entity type A is greater than the first probability threshold, then the third element in the head row of the pointer matrix corresponding to entity type A can be marked as 1, that is, the element in the first row and third column can be changed from 0 to 1; assuming that the second probability of the fourth word segment being the tail segment of entity type A is greater than the second probability threshold, then the fourth element in the tail row of the pointer matrix corresponding to entity type A can be marked as 1, that is, the element in the second row and fourth column can be changed from 0 to 1.

[0113] If the probability that the third word segment is the first word segment of entity type B is greater than the first probability threshold, then the third element in the first row of the pointer matrix corresponding to entity type B can be marked as 1, that is, the element in the first row and third column can be changed from 0 to 1. If the probability that the sixth word segment is the last word segment of entity type B is greater than the second probability threshold, then the sixth element in the last row of the pointer matrix corresponding to entity type B can be marked as 1, that is, the element in the second row and sixth column can be changed from 0 to 1.

[0114] If the first probability of each word segmented as the head part of entity type C is less than the first probability threshold, then the elements of the head row of the pointer matrix corresponding to entity type C are not modified. Similarly, if the second probability of each word segmented as the tail part of entity type C is less than the second probability threshold, then the elements of the tail row of the pointer matrix corresponding to entity type C are not modified. At this time, it can be determined that entity type C is not the target entity type, that is, the text to be identified does not contain entities of entity type C.

[0115] Based on the above scheme, by using the head and tail labels in the pointer matrix, these nested or complex entities can be effectively identified and classified, and the relationships between them can be understood. This helps relevant personnel to quickly obtain and analyze threat intelligence, improve response speed, and enhance the pertinence of preventive measures.

[0116] S204, Based on the positions of the head words and tail words corresponding to the same target entity type in the text to be identified, determine at least one target entity included in the text to be identified.

[0117] In one possible implementation, S204 can be executed as follows: for any one of the at least one target entity types, perform the following operations respectively: combine the head word, tail word, and word segmentation between the head word and tail word corresponding to any one entity type into a target entity.

[0118] In some embodiments, when an entity type corresponds to only one header word and one tail word, the header word, tail word, and word segmentation located between the header word and tail word corresponding to the entity type can be directly combined into the target entity.

[0119] For example, suppose the first word corresponding to the attacker type is the second word in the text to be identified, and the last word corresponding to the attacker type is the fourth word in the text to be identified. Then the second, third, and fourth words are combined into the target entity, and the entity type of the target entity is the attacker type.

[0120] In other embodiments, when an entity type corresponds to multiple head words or multiple tail words, the nearest head word and tail word among the head words and tail words corresponding to the entity type can be determined according to the principle of proximity, and the nearest head word and tail word, as well as the word segment located between the nearest head word and tail word, can be combined into the target entity.

[0121] For example, suppose the first word corresponding to the attack organization type is the second word in the text to be identified, and the last word corresponding to the attacker type is the fifth and eighth words in the text to be identified. Since the second word is closest to the fifth word, the second, third, fourth and fifth words are combined to form the target entity, and the entity type of the target entity is the attack organization type.

[0122] Below, in order to more clearly understand the solution proposed in the embodiments of this application, a method for entity recognition provided by this application will be introduced in conjunction with specific embodiments.

[0123] See Figure 6 This is a schematic diagram illustrating the process of an entity recognition method provided in an embodiment of this application.

[0124] Assuming the preset entity types include: attack organization, attacker, IP address, and date, and the text to be identified is: "The hacker group APT28 attacked the target company in October 2021," then word segmentation of the text to be identified yields: "hacker," "account," "group," "organization," "APT28," "in," "2021," "year," "10," "month," "attack," "strike," "target," "company." Then, positional encoding is performed on each word segment to obtain positional codes C1 to C2. 17 Then, using the method described above, calculate the probability p that each segmented word corresponds to the head segment of the attacking organization. i Astart , where p is the probability p of the tail segment corresponding to the attacking organization. i Aend Calculate the probability p that each segmented word corresponds to the attacker's head segment. i Bstart , where p is the probability p of the tail segment corresponding to the attacker. i Bend Calculate the probability p that each word segment corresponds to the header segment of the IP address. i Cstart , where p is the probability p of the last word corresponding to the IP address. i Cend Calculate the probability p that each word segment corresponds to the first word of the date. i Dstart p represents the probability p of the last word corresponding to the date. i Dend Where i takes values ​​from 1 to 17.

[0125] Assume p5 Astart If the probability exceeds the first probability threshold, then the 5th element in the header row of the pointer matrix corresponding to the attacking organization can be marked as 1; assuming p5 Aend If the probability is greater than the second probability threshold, then the fifth element in the last row of the pointer matrix corresponding to the attacking organization can be marked as 1.

[0126] p7 Dstart If the probability is greater than the first probability threshold, then the 7th element in the first row of the pointer matrix corresponding to the date can be marked as 1. Let's assume p 10 Dend If the probability is greater than the second probability threshold, then the 10th element in the last row of the pointer matrix corresponding to the date can be marked as 1.

[0127] After annotation, we can get the following: Figure 6The pointer matrix shown indicates that the target entities in the text to be identified are “APT28” and “October 2021”. The entity type of “APT28” is an attack organization, and the entity type of “October 2021” is a date.

[0128] Based on the same concept as the above method, see [link to relevant documentation]. Figure 7 This application provides an entity recognition device 700 capable of executing the steps of the above-described method. The device 700 includes an acquisition unit 701 and a processing unit 702. In one scenario:

[0129] The acquisition unit 701 is used to acquire multiple word segments included in the text to be recognized;

[0130] Processing unit 702 is configured to determine the position code of each segment based on its position in the text to be identified; determine the head segment and tail segment included in the plurality of segmented words, and the target entity type corresponding to the head segment and tail segment, based on the position code of each segmented word; the head segment represents the segment located at the beginning position of any entity, and the tail segment represents the segment located at the end position of any entity; and determine at least one target entity included in the text to be identified based on the positions of the head segment and tail segment corresponding to the same target entity type in the text to be identified.

[0131] In one possible implementation, the processing unit 702 determines the position code of each word based on its position in the text to be identified. Specifically, it is used to: determine the embedding vector corresponding to each of the multiple words based on their respective arrangement positions in the text to be identified; and determine the position code of each of the multiple words based on their respective embedding vectors and the relative positional relationship between the multiple words.

[0132] In one possible implementation, the processing unit 702 determines the positional encoding of each of the multiple word segments based on their respective embedding vectors and the relative positional relationships between the multiple word segments. Specifically, it is used to: obtain a relative positional difference mapping of the text to be identified; the relative positional difference mapping includes the relative positional difference between every two words in the multiple word segments; for any one of the multiple word segments, perform the following operations: in the relative positional difference mapping, based on the arrangement position of the arbitrary word segment, obtain a reference relative positional difference between the arbitrary word segment and each of the other words in the multiple word segments; based on the obtained reference relative positional differences, determine each relative positional score between the arbitrary word segment and each of the other words; the relative positional score corresponds one-to-one with the reference relative positional difference, and the relative positional score is positively correlated with the reference relative positional difference; based on the embedding vectors of each of the multiple word segments and the determined relative positional scores, determine each attentional score between the arbitrary word segment and each of the other words; based on the determined attentional scores, encode the arbitrary word segment to obtain the positional encoding of the arbitrary word segment.

[0133] In one possible implementation, the processing unit 702 determines the head words and tail words included in the plurality of word segments, as well as the target entity types corresponding to the head words and tail words, based on the positional encoding of each word segment. Specifically, it is used to: for any one of the preset at least one entity type, perform the following operations respectively: for any one of the plurality of word segments, based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the entity type, determine a first probability that the word segment is the head word corresponding to the entity type and a second probability that the word segment is the tail word corresponding to the entity type; when there is a first probability that satisfies the preset first probability condition and a second probability that satisfies the preset second probability condition, determine the entity type as the target entity type; and take the word segment corresponding to the first probability that satisfies the preset first probability condition as the head word corresponding to the target entity type, and take the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail word corresponding to the target entity type.

[0134] In one possible implementation, after the processing unit 702 determines the first probability that the segmented word is a head segment corresponding to the arbitrary entity type and the second probability that the segmented word is a tail segment corresponding to the arbitrary entity type based on the positional encoding of the segmented word and the head prediction model and tail prediction model corresponding to the arbitrary entity type, it is further configured to: perform head annotation on the segmented word that satisfies the preset first probability condition and perform tail annotation on the segmented word that satisfies the preset second probability condition and the second probability condition; when both the head annotation and the tail annotation exist, determine the arbitrary entity type as the target entity type;

[0135] The processing unit 702 uses the word segment corresponding to the first probability that satisfies the preset first probability condition as the head segment corresponding to the target entity type, and the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail segment corresponding to the target entity type. Specifically, it is used to: use the word segment containing the head annotation as the head segment corresponding to the target entity type; and use the word segment containing the tail annotation as the tail segment corresponding to the target entity type.

[0136] In one possible implementation, before the processing unit 702 determines, for the plurality of word segments, the first probability that the word segment is a head segment corresponding to the arbitrary entity type and the second probability that the word segment is a tail segment corresponding to the arbitrary entity type based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the arbitrary entity type, it is further configured to: construct a pointer matrix corresponding to the arbitrary entity type for the arbitrary entity type; the pointer matrix includes a head row and a tail row;

[0137] The processing unit 702 performs header annotation on the word segments belonging to the first probability that satisfy the preset first probability condition, and performs tail annotation on the word segments belonging to the second probability that satisfy the preset second probability condition. Specifically, it is used to: when there is a first probability that satisfies the preset first probability condition among the first probabilities of the multiple word segments, perform header annotation on the position corresponding to the corresponding word in the head row of the pointer matrix; and when there is a second probability that satisfies the preset second probability condition among the second probabilities of the multiple word segments, perform tail annotation on the position corresponding to the corresponding word in the tail row of the pointer matrix.

[0138] In one possible implementation, the processing unit 702 determines at least one target entity included in the text to be identified based on the positions of the head words and tail words corresponding to the same target entity type in the text to be identified. Specifically, it is used to perform the following operations for any one of the at least one target entity types: combine the head words, tail words, and word segments located between the head words and tail words corresponding to the any one entity type into a target entity.

[0139] Based on the same concept as the above method, see [link to relevant documentation]. Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device includes at least one processor 802 and a memory 801 connected or coupled to the at least one processor 802. In addition, the electronic device may also include a communication interface 803. The electronic device can interact with other devices through the communication interface 803.

[0140] For example, the communication interface 803 can be a transceiver, circuit, bus, module, pin, or other type of communication interface. When the electronic device is a chip-based device or circuit, the communication interface 803 in the electronic device can also be an input / output circuit, which can input information (or receive information) and output information (or send information). The processor can be an integrated processor, a microprocessor, an integrated circuit, or a logic circuit, and the processor can determine the output information based on the input information.

[0141] The coupling in this application embodiment is an indirect coupling or communication connection between devices, units, or modules, which can be electrical, mechanical, or other forms, used for information exchange between devices, units, or modules. The processor 802 may operate in conjunction with the memory 801 and the communication interface 803. This application does not limit the specific connection medium between the processor 802, the memory 801, and the communication interface 803.

[0142] Optional, see Figure 8 The processor 802, the memory 801, and the communication interface 803 are interconnected via a bus. This bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0143] In this embodiment, memory 801, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 801 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 801 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. Memory 801 in this embodiment may also be a circuit or any other device capable of implementing storage functions for storing instructions, computer programs, and / or data.

[0144] In this embodiment, the processor 802 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in this embodiment. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the entity recognition method disclosed in this embodiment can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0145] By designing and programming the processor 802, the code corresponding to the entity recognition method described in the foregoing embodiments can be embedded into the chip, so that the chip can execute the steps of the aforementioned entity recognition method when running. How to design and program the processor 802 is a well-known technique to those skilled in the art, and will not be described in detail here.

[0146] In one or more embodiments, memory 801 stores instructions that can be executed by at least one processor 802, which can implement the steps of any of the above methods by calling the instructions stored in memory 801 or a computer program.

[0147] This application also provides a computer-readable storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the steps of any of the above methods.

[0148] Based on the same inventive concept, this application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to execute any of the entity recognition methods discussed above. Since the principle by which the above-described computer program product solves the problem is similar to that of the entity recognition method, the implementation of the above-described computer program product can be referred to the implementation of the method, and repeated details will not be described again.

[0149] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0150] While specific embodiments of this application have been described above, those skilled in the art should understand that these are merely illustrative examples, and the scope of protection of this application is defined by the appended claims. Those skilled in the art can make various changes or modifications to these embodiments without departing from the principles and essence of this application, and all such changes and modifications fall within the scope of protection of this application. Although preferred embodiments of this application have been described, those skilled in the art, once they understand the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0151] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. An entity recognition method, characterized in that, include: Obtain multiple word segments from the text to be recognized; Based on the respective positions of the multiple word segments in the text to be identified, the position code of each word segment is determined; Based on the position encoding of each word segment, the head word and tail word included in the plurality of word segments are determined, as well as the target entity type corresponding to the head word and tail word; the head word represents the word segment located at the beginning position of any entity, and the tail word represents the word segment located at the end position of any entity. Based on the positions of the first and last words corresponding to the same target entity type in the text to be identified, at least one target entity included in the text to be identified is determined. The step of determining the head words and tail words included in the plurality of word segments, and the target entity types corresponding to the head words and tail words, based on the position encoding of each word segment, includes: For any one of the at least one preset entity types, perform the following operations respectively: For any one of the multiple word segments, based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the entity type, determine the first probability that the word segment is the head segment corresponding to the entity type and the second probability that the word segment is the tail segment corresponding to the entity type. When there exists a first probability that satisfies a preset first probability condition and a second probability that satisfies a preset second probability condition, the arbitrary entity type is determined to be the target entity type. The word segment corresponding to the first probability that satisfies the preset first probability condition is used as the head word segment corresponding to the target entity type, and the word segment corresponding to the second probability that satisfies the preset second probability condition is used as the tail word segment corresponding to the target entity type.

2. The method according to claim 1, characterized in that, The step of determining the position code of each word based on its position in the text to be identified includes: Based on the arrangement position of each of the multiple word segments in the text to be identified, the embedding vector corresponding to each of the multiple word segments is determined; Based on the embedding vectors corresponding to each of the multiple word segments and the relative positional relationships between the multiple word segments, the positional encoding of each of the multiple word segments is determined.

3. The method according to claim 2, characterized in that, Determining the position encoding of each of the multiple word segments based on their respective embedding vectors and the relative positional relationships between the multiple word segments includes: Obtain the relative position difference mapping of the text to be identified; the relative position difference mapping includes the relative position difference between every two words in the plurality of word segments; For any one of the multiple word segments, perform the following operations respectively: In the relative position difference mapping, the reference relative position difference between any one word and each of the other words in the plurality of words is obtained according to the arrangement position of any one word; Based on the obtained relative position differences of each reference, the relative position scores between any one word and each other word are determined; the relative position scores correspond one-to-one with the reference relative position differences, and the relative position scores are positively correlated with the reference relative position differences. Based on the embedding vectors corresponding to each of the multiple word segments and the determined relative position scores, the attention scores between any one word segment and the other words are determined. Based on the determined attention scores, any one of the word segments is encoded to obtain the positional code of that word segment.

4. The method according to claim 1, characterized in that, After determining the first probability that the segmented word is a head segment corresponding to any entity type and the second probability that the segmented word is a tail segment corresponding to any entity type based on the positional encoding of the segmented word and the head prediction model and tail prediction model corresponding to any entity type, the method further includes: Header annotation is performed on word segments that satisfy the first probability condition and belong to the first probability category, and tail annotation is performed on word segments that satisfy the second probability condition and belong to the second probability category. When both the header annotation and the tail annotation exist, determine any one of the entity types as the target entity type; The step of using the word segment corresponding to the first probability that satisfies the preset first probability condition as the head segment of the target entity type, and using the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail segment of the target entity type, includes: The word segment containing the header annotation is used as the header segment corresponding to the target entity type; The word segment containing the tail annotation is used as the tail segment corresponding to the target entity type.

5. The method according to claim 4, characterized in that, Before determining, for the plurality of word segments, a first probability that the word segment is a head segment corresponding to any entity type and a second probability that the word segment is a tail segment corresponding to any entity type, based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to any entity type, the method further includes: For any given entity type, construct a pointer matrix corresponding to that entity type; the pointer matrix includes a header row and a tail row; The step of performing header annotation on word segments that satisfy a preset first probability condition and a first probability assignment, and performing tail annotation on word segments that satisfy a preset second probability condition and a second probability assignment, includes: When there is a first probability that satisfies a preset first probability condition among the first probabilities of the multiple word segments, a header annotation is performed at the position corresponding to the word segment in the header row of the pointer matrix; When there is a second probability that satisfies a preset second probability condition among the second probabilities of the multiple word segments, a tail label is made at the position corresponding to the word segment in the tail row of the pointer matrix.

6. The method according to any one of claims 1-5, characterized in that, The step of determining at least one target entity in the text to be identified based on the positions of the head and tail words corresponding to the same target entity type in the text to be identified includes: For any one of the at least one target entity types, perform the following operations respectively: Combine the head words, tail words, and word segments between the head words and tail words corresponding to any one of the entity types into the target entity.

7. An entity recognition device, characterized in that, include: The acquisition unit is used to acquire multiple word segments included in the text to be recognized; The processing unit is configured to determine the position code of each word based on its position in the text to be identified. Based on the positional encoding of each word segment, the head words and tail words included in the plurality of word segments are determined, as well as the target entity types corresponding to the head words and tail words; the head words represent word segments located at the beginning position of any entity, and the tail words represent word segments located at the end position of any entity; based on the positions of the head words and tail words corresponding to the same target entity type in the text to be identified, at least one target entity included in the text to be identified is determined; Specifically, when the processing unit determines the head words and tail words included in the plurality of word segments, and the target entity types corresponding to the head words and tail words, based on the positional encoding of each word segment, it is configured to: for any one of the preset at least one entity type, perform the following operations respectively: for any one of the plurality of word segments, based on the positional encoding of the word segment and the head prediction model and tail prediction model corresponding to the entity type, determine a first probability that the word segment is the head word corresponding to the entity type, and a second probability that the word segment is the tail word corresponding to the entity type; when there is a first probability that satisfies the preset first probability condition and a second probability that satisfies the preset second probability condition, determine the entity type as the target entity type; and take the word segment corresponding to the first probability that satisfies the preset first probability condition as the head word corresponding to the target entity type, and take the word segment corresponding to the second probability that satisfies the preset second probability condition as the tail word corresponding to the target entity type.

8. An electronic device, characterized in that, include: Memory, used to store computer instructions; A processor, connected to the memory, is configured to execute computer instructions in the memory, and, in executing the computer instructions, implement the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, include: The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Named entity identification method and device, electronic equipment and storage medium

    CN115600596A

  • XES log intelligent conversion method and system

    CN115757325A