The entity chain refers to a method and device, an electronic device, and a storage medium
By pre-training a neural network model to extract semantic features of candidate entities, the problem of low accuracy in entity chaining is solved, and high-accuracy chaining is achieved even when text information is insufficient.
Patent Information
- Application Number
- CN202210556843.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-05-20
AI Technical Summary
The accuracy of entity chaining in existing technologies is low, especially when there are few context entities.
By acquiring the first semantic features of the entity to be linked and the entity features of the candidate entities, a neural network model such as BERT is used for pre-training to extract the semantic features of the candidate entities, and the target entity is determined by similarity calculation.
Even with limited or in-depth textual information, it achieves high entity chain indexing accuracy, enhancing the rationality of candidate entity features.
Smart Images

Figure CN114969362B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to an entity linking method and device, an electronic device, and a storage medium. BACKGROUND
[0002] Entity linking is a basic and core technology for knowledge graph construction and application, and is used to map entities mentioned in text to a given knowledge base. The entity linking method in the related art includes: (1) a method based on literal and text similarity: similarity between entities is calculated by using indicators such as edit distance, Dice coefficient, Jaccard similarity, cosine similarity, relative entropy, Kullback-Leibler divergence, and probabilistic model similarity. This method is simple and has strong interpretability, but does not perform deep mining on corpus and entities, and only performs linking based on literal meaning, so the accuracy is not high; (2) a method based on entity relevance: the relevance of entities in the context and candidate entities is compared, and the candidate entity with high relevance to the context entity is more likely to be the target entity. This method can play a certain role when there are sufficient entities in the context, but when there are few entities in the context, the role of this method is limited, and the accuracy is not high.
[0003] At present, no effective solution has been proposed for the problem of low accuracy of entity linking in the above related art. SUMMARY
[0004] The present application provides an entity linking method and device, an electronic device, and a storage medium to at least solve the technical problem of low accuracy of entity linking in the related art.
[0005] According to an aspect of an embodiment of the present application, an entity linking method is provided, including: obtaining a first semantic feature of a to-be-linked entity and an entity feature corresponding to each candidate entity in a plurality of candidate entities, wherein the first semantic feature is used to indicate the semantics of a first text in which the to-be-linked entity is located, and for each candidate entity, the entity feature corresponding to the candidate entity is obtained after pre-training according to a training text in which the candidate entity is located, and is used to represent the semantics of the training text in which the candidate entity is located; determining a target entity feature from all entity features through the first semantic feature, and determining a candidate entity corresponding to the target entity feature as a recall entity; and determining a target entity to which the to-be-linked entity is linked from the recall entity according to the similarity between the recall entity and the to-be-linked entity.
[0006] According to another aspect of the embodiments of the present application, an entity chain pointing device is also provided, comprising: an acquisition module, configured to acquire a first semantic feature of a to-be-pointed entity and an entity feature corresponding to each candidate entity in a plurality of candidate entities, wherein the first semantic feature is used to indicate a semantic of a first text in which the to-be-pointed entity is located, and for each candidate entity, the entity feature corresponding to the candidate entity is a feature used to represent a semantic of a training text in which the candidate entity is located, and is obtained after pre-training of the training text; a recall module, configured to determine a target entity feature from all the entity features through the first semantic feature, and determine a candidate entity corresponding to the target entity feature as a recall entity; and a determination module, configured to determine a target entity to which the to-be-pointed entity points from the recall entity according to a similarity between the recall entity and the to-be-pointed entity.
[0007] According to another aspect of the embodiments of the present application, a storage medium is also provided, comprising a stored program, and the program performs the above method when running.
[0008] According to another aspect of the embodiments of the present application, an electronic device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor performs the above method through the computer program.
[0009] According to an aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of any of the embodiments of the above method.
[0010] The scheme can be applied to the technical field of knowledge graph to perform knowledge fusion. In the embodiments of the present application, a first corpus semantic feature of a to-be-chain-pointing entity and an entity feature corresponding to each candidate entity in a plurality of candidate entities are obtained, wherein the first corpus semantic feature is used to indicate the semantics of a first text in which the to-be-chain-pointing entity is located, and for each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained after pre-training of a training text in which the candidate entity is located, and is used to represent the semantics of the training text in which the candidate entity is located; a target entity feature is determined from all the entity features through the first corpus semantic feature, and a candidate entity corresponding to the target entity feature is determined as a recall entity; and a target entity result of a chain pointer of the to-be-chain-pointing entity is determined from the recall entity according to the similarity between the recall entity and the to-be-chain-pointing entity. In the manner, the semantic feature of the training text in which the candidate entity is located after training of the training text is used as the entity feature of the candidate entity to perform entity chain pointing. The semantic of the candidate entity is deeply mined when the entity feature of the candidate entity is obtained, and the rationality of the entity feature used to represent the candidate entity feature is enhanced. Even if the text information in which the to-be-chain-pointing entity is located is less or the semantic cannot be deeply mined, the chain pointing with high accuracy can also be realized, and thus the technical problem of low accuracy of entity chain pointing in the related art is solved. BRIEF DESCRIPTION OF DRAWINGS
[0011] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application and illustrate embodiments of the present application and the description thereof, and do not constitute improper limitations to the present application. In the drawings:
[0012] Figure 1 is a schematic diagram of a hardware environment of an entity chain pointing method according to an embodiment of the present application;
[0013] Figure 2 is a flowchart of an optional entity chain pointing method according to an embodiment of the present application;
[0014] Figure 3 is a schematic diagram of an optional entity chain pointing device according to an embodiment of the present application; and
[0015] Figure 4 is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION
[0016] In order to make the person skilled in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should be within the scope of protection of the present application.
[0017] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0018] First, some nouns or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
[0019] Entity chain refers to: also known as entity linking, a task of identifying entity mention (an entity mention refers to an entity, that is, a word representing an entity) in unstructured data, and finding the entity represented by the entity mention from a knowledge base (domain word library, knowledge graph, etc.).
[0020] Fully connected layer: the fully connected layer is used to map the distributed features obtained from the previous layer to the sample label space, and plays the role of "classifier".
[0021] Loss function: used to evaluate the difference between the predicted value of the model and the true value. Commonly used loss functions in neural networks include cross-entropy function, negative log-likelihood loss function, mean square error function, etc.
[0022] Word vector model: in the present application, the word vector model refers to a neural network language model in the field of natural language processing technology, which is used to model the context of a target word and the relationship between the context and the target word through neural network technology, and obtain a feature vector for feature representation of the semantic of the target word.
[0023] Masking words: In order to solve the problem that unidirectional language models cannot perceive text context bidirectionally, a bidirectional autoencoder pre-trained model is adopted. Instead of using the preceding text to predict the word at each position, the [MASK] symbol is directly used to replace the predicted word, and then the context is used to predict the word. In this application, the masking word is the [MASK] symbol.
[0024] According to one aspect of the embodiments of this application, a method embodiment for entity chaining is provided.
[0025] Optionally, in this embodiment, the above-described entity chaining method can be applied to, for example, Figure 1 The hardware environment shown consists of terminal 101 and server 103. Figure 1 As shown, server 103 is connected to terminal 101 via a network and can be used to provide entity linking services for the terminal or clients installed on the terminal. Database 105 can be set up on the server or independently of the server to provide data storage services for server 103. The aforementioned network includes, but is not limited to, wide area networks (WANs), metropolitan area networks (MANs), or local area networks (LANs). Terminal 101 is not limited to PCs, mobile phones, tablets, etc. The entity linking method of this application embodiment can be executed by server 103, by terminal 101, or by both server 103 and terminal 101. Specifically, the entity linking method of this application embodiment can also be executed by a client installed on terminal 101. The following description uses the execution of an entity linking method of this application embodiment on a server as an example.
[0026] Figure 2 This is a flowchart of an optional entity chaining method according to an embodiment of this application, such as... Figure 2 As shown, the method may include the following steps:
[0027] Step S202: Obtain the first semantic feature of the entity to be linked and the entity feature corresponding to each candidate entity among multiple candidate entities. The first semantic feature is used to indicate the semantics of the first text in which the entity to be linked is located. For each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained after pre-training based on the training text in which the candidate entity is located, which is used to represent the semantics of the training text in which the candidate entity is located.
[0028] Step S204: Determine the target entity feature from all entity features using the first semantic feature, and identify the candidate entity corresponding to the target entity feature as the recall entity;
[0029] Step S206: Based on the similarity between the recalled entities and the entity to be linked, determine the target entity to be linked from the recalled entities.
[0030] The aforementioned entity chaining method can be applied to applications such as knowledge graph construction, information event extraction, and intelligent question answering. Through steps S202 to S206, the semantic features of the training text containing the candidate entities obtained after training the training text are used as the entity features of the candidate entities for entity chaining. In obtaining the entity features of the candidate entities, the semantics of the candidate entities are deeply mined, enhancing the rationality of the entity features used to represent the candidate entities. Even if the text containing the entity to be chained has limited information or cannot undergo deep semantic mining, high-accuracy chaining can still be achieved, thus solving the technical problem of low accuracy in entity chaining in related technologies.
[0031] In the technical solution provided in step S202, the server obtains the first semantic feature of the entity to be linked and the entity feature corresponding to each candidate entity among multiple candidate entities. The first semantic feature is used to indicate the semantics of the first text in which the entity to be linked is located. For each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained by pre-training based on the training text in which the candidate entity is located, which is used to represent the semantics of the training text in which the candidate entity is located.
[0032] The first semantic feature of the entity to be linked can be a feature vector extracted by a neural network language model and used to represent the semantics of the entity to be linked in the first text. The neural network language model can be one of the following models or an improved version thereof: (1) BERT (Bidirectional Encoder Representations from Transformers) model; (2) ELMo (Embedding from Language Models) model; (3) GPT (Generative Pre-Training) model.
[0033] Optionally, in this embodiment, the server replaces the entity to be linked in the first text with a masking word to obtain the second text; and uses a word vector model to extract the semantic features of the masking word in the second text to obtain the first semantic feature.
[0034] Specifically, the server replaces one of the chain-of-reference entities in the first text with [MASK] to obtain a second text; replacing the chain-of-reference entity with the masking word can solve the problem that the one-way language model cannot perceive the context of the text bidirectionally, and the output vector of the position of [MASK] in the second text is extracted by using the BERT model to obtain the first semantic feature. The BERT model is a bidirectional self-encoding pre-training model that can more thoroughly capture the bidirectional relationship in the sentence, solving the problem that the one-way language model cannot perceive the context of the text bidirectionally, and instead of predicting the word at each position using the previous text, the [MASK] symbol is directly used to replace the predicted word, and then the context is used to predict the word, which can learn a better feature representation vector for the chain-of-reference entity.
[0035] As an optional embodiment, before obtaining the first semantic feature of the chain-of-reference entity and the entity feature corresponding to each candidate entity in the plurality of candidate entities, the server pre-processes the first training text to obtain a plurality of second training texts, wherein the first training text is a training text in which the candidate entities and the entity types of the candidate entities have been labeled, and each second training text contains a masking word used to replace the candidate entity in the second training text; the first word vector model is trained for type identification using the plurality of second training texts to obtain a second word vector model; the second word vector model is trained for entity identification using the plurality of second training texts to obtain a third word vector model; and the third word vector model is used to extract the entity feature corresponding to each candidate entity in the training text.
[0036] The above type identification training and entity identification training are used to optimize the word vector model, replace one of the candidate entities in the first training text with a masking word, and then use the optimized word vector model for feature representation, so that the word vector model learns a better feature representation vector for the candidate entity. The word vector model can be one of the following models or improved versions thereof, including but not limited to: (1) BERT (Bidirectional Encoder Representations from Transformers) model; (2) ELMo (Embedding from Language Models) model; (3) ALBERT (ALite BERT) model; (4) self-encoding language model.
[0037] Optionally, in the present embodiment, the masking word is also used to replace the non-entity in the second training text, and the server performs a word segmentation operation on the first training text to obtain a first segmented text, wherein the vocabulary in the first segmented text includes non-entities and candidate entities; the specified word in the first segmented text is masked by the masking word to obtain a second training text corresponding to the specified word, wherein the specified word is any one of all non-entities and all candidate entities.
[0038] Specifically, the server can use [MASK] as a masking word to perform a masking operation on the segmented text, and obtain a new second training text for each specified word masked.
[0039] The above operation performs a masking operation on all entities and non-entity words in the first training text, and obtains a plurality of second training texts used as input data for training the word vector model. The candidate entities are not only represented by features, but also the non-entities are represented by features, so that the trained word vector model can learn better feature representation vectors for the candidate entities.
[0040] Optionally, in the present embodiment, the masking word is also used to replace the non-entity in the second training text, and the server extracts the first feature of the masking word in each second training text using the first word vector model; for each masking word, the first feature of the masking word is input into the first fully connected layer to obtain the predicted type of the masking word; according to the predicted type of the masking word and the labeled type corresponding to the masking word, the parameters of the first word vector model are adjusted to obtain a second word vector model, wherein the predicted type is a non-entity type of a non-entity or an entity type of a candidate entity.
[0041] Specifically, the server uses the BERT model to extract the output vector of the position of [MASK] in the second text where it is located in each second training text, and inputs it into a fully connected layer to predict the type of [MASK]. The type can include all entity types to which all candidate entities belong and non-entity types. According to the gap between the predicted type and the pre-labeled type, training and optimization are performed until the cross-entropy loss function converges and no longer decreases.
[0042] Optionally, in the present embodiment, the second word vector model is used to extract features of the masking word in each second training text to obtain a second feature corresponding to each second training text. After the second feature is input into the first fully connected layer, if the predicted type of the masking word is an entity type, the second feature of the masking word is input into the second fully connected layer to obtain the predicted entity of each masking word. According to the predicted type of the masking word and the labeled entity corresponding to the masking word, the parameters of the second word vector model are adjusted to obtain a third word vector model.
[0043] Specifically, the server extracts the output vector of the position of [MASK] in the second text in which the position of [MASK] is located in each second training text using the type-identified BERT model trained, inputs the output vector into a fully connected layer, and predicts the corresponding candidate entity of [MASK]. The server performs training and optimization according to the gap between the predicted entity and the pre-labeled entity until the cross-entropy loss function converges and no longer decreases. The output vector of [MASK] at the last optimization in this step can be saved as the entity feature corresponding to the candidate entity, and the word vector model at the last optimization is the third word vector model.
[0044] In the technical solution provided in step S204, the server determines the target entity feature from all entity features through the first semantic feature, and determines the candidate entity corresponding to the target entity feature as the recall entity.
[0045] As an optional embodiment, the first global feature corresponding to each candidate entity in the plurality of candidate entities is obtained, wherein for each candidate entity, the first global feature is used to represent the global information of the candidate entity in the first text in the case that the to-be-chain-pointing entity is the candidate entity; for each candidate entity, the first semantic feature, the first global feature corresponding to the candidate entity, and the entity feature corresponding to the candidate entity are spliced to obtain spliced features, and the spliced features are input into the third fully connected layer to obtain the recall entity.
[0046] Specifically, a candidate entity is used to replace the to-be-chain-pointing entity, and the [cls] vector (i.e., the first global feature) is obtained by inputting the to-be-chain-pointing entity into the BERT model; the [MASK] output vector of the to-be-chain-pointing entity, the [cls] vector, and the [MASK] output vector of the candidate entity at the last optimization of the word vector model are spliced and input into a fully connected layer, and the fully connected layer outputs 0 and 1, and output 1 represents being recalled.
[0047] In the technical solution provided in step S206, the server determines the target entity pointed to by the to-be-chain-pointing entity from the recall entities according to the similarity between the recall entity and the to-be-chain-pointing entity.
[0048] As an optional embodiment, the server obtains the cosine similarity between each recall entity in all recall entities and the to-be-chain-pointing entity; determines a target cosine similarity from all cosine similarities according to the cosine similarities corresponding to all recall entities, wherein the target cosine similarity is not less than other cosine similarities except the target cosine similarity among all cosine similarities; and takes the recall entity corresponding to the target cosine similarity as the target entity, wherein the target entity is the chain pointing result of the to-be-chain-pointing entity.
[0049] Optionally, in addition to the cosine similarity, the edit distance, the Dice coefficient, the Jaccard similarity, the relative entropy, the Kullback-Leibler divergence, and the probabilistic model similarity can be used to obtain the similarity between the recall entity and the entity to be pointed.
[0050] As an optional embodiment, the technical solution of the present application is described below in conjunction with the specific embodiments:
[0051] The present solution enhances the rationality of the knowledge representation vector of the standard entity by inputting the design of the representation and setting the pre-training task, and improves the accuracy of the entity pointing by designing the recall and ranking strategies. The following data is required: (1) a standard entity table including multiple entities (i.e., candidate entities) and the categories of the entities (i.e., the entity types of the candidate entities); (2) training data (i.e., the first training text) containing the entities in the standard entity table, and the text data with the positions and types of the entities annotated; and (3) text with only the entities (i.e., the entities to be pointed) annotated, i.e., the entities in the text need to be pointed to the standard entities in the data (1).
[0052] Step one: perform a word segmentation operation on the part of the data (2) other than all the entities.
[0053] Step two: perform a language masking operation on the text after word segmentation (i.e., the first segmented text). First, replace the entities in the text with [mask] (i.e., a masking word) one by one, and obtain a new text data for each masked entity. In addition, select a number of words obtained after word segmentation, and perform a masking operation on the selected words to obtain a number of new text data. That is, all entities and non-entity words in the text are masked to obtain all new text data (i.e., the second training text).
[0054] Step three: input the data obtained by step two into the Bert model as training data. The Bert model will record the position of [mask] when the data is input, and will also take out the corresponding vector in the output vector (i.e., the first feature).
[0055] Step four: pre-training task 1 (category recognition pre-training): take out the output vector of the [mask] position of the Bert, input it into a fully connected layer, and predict the category of [mask]. The categories include the entity types contained in the data (1) and the non-entity (word) categories, and the loss function is the cross-entropy loss function.
[0056] Step five: training optimization for pre-training task 1 until the Loss converges and no longer decreases.
[0057] Step six: after the Loss no longer decreases, pre-training task 2 (entity recognition pre-training) is performed: the model identifies the [mask] vector of the entity to further predict which entity it is according to the predicted entity type. The specific method is also to input the entity [mask] vector into the fully connected layer, and use the fully connected layer to predict the specific entity, but only within the predicted entity type. The number of neurons output by the fully connected layer is equal to the number of entities of the entire data (1), but for example, the predicted entity type is type 1, and type 1 has 100 entities, then only the first 100 neurons are taken in this step. The value is normalized by softmax and the final prediction is made, and the loss function is still the cross-entropy loss function.
[0058] Step seven: continue training pre-training task 2 until the Loss converges and no longer decreases, and save the vector of each standard entity (i.e. entity features of candidate entities).
[0059] Step eight: recall:
[0060] 1. Input the [mask] of a certain entity to be chained in data (3) into the Bert model to obtain the Bert representation vector of the entity (i.e. the first semantic feature);
[0061] 2. Replace the to-be-chained entity with the standard entity and input it into the Bert model to obtain the [cls] vector (i.e. the first global feature);
[0062] 3. Concatenate the to-be-chained entity vector, [cls] vector and standard entity vector and input them into a fully connected layer, and the fully connected layer outputs 0 and 1, with output 1 representing being recalled;
[0063] 4. Repeat the above recall steps for all standard entities in the standard entity table to obtain a recall entity set for the to-be-chained entity.
[0064] Step nine: ranking:
[0065] Rank all entities in the recall entity set according to the cosine similarity with the to-be-chained entity, and take the top 1 (i.e. the highest cosine similarity) as the chain pointing result.
[0066] The scheme adjusts the model by designing the input representation and the pre-training task, so that the model mines deeper semantic information of the entity, obtains the representation vector of the standard entity, and enhances the rationality of the knowledge representation vector of the standard entity. Meanwhile, the recall and ranking strategies are designed to complete the entity chain pointing, and the problems of no pre-training process, insufficient mining and utilization of context information, and poor effect on complex knowledge entity chain pointing in the related technology of entity chain pointing are solved.
[0067] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0068] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, and of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device) to execute the methods described in the embodiments of the present application.
[0069] According to another aspect of the embodiments of the present application, an entity chain pointing device for implementing the above-mentioned entity chain pointing method is also provided. Figure 3 is a schematic diagram of an optional entity chain pointing device according to an embodiment of the present application, as shown in Figure 3 The device can include:
[0070] The acquisition module 32 is configured to acquire a first semantic feature of the entity to be pointed and an entity feature corresponding to each candidate entity in the plurality of candidate entities, wherein the first semantic feature is used to indicate the semantics of the first text in which the entity to be pointed is located, and for each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained after pre-training according to the training text in which the candidate entity is located, and is used to represent the semantics of the training text in which the candidate entity is located.
[0071] The recall module 34 is configured to determine a target entity feature from all entity features through the first semantic feature, and determine a candidate entity corresponding to the target entity feature as a recall entity.
[0072] The determining module 36 is configured to determine the target entity of the chain indicating entity from the recall entity according to the similarity between the recall entity and the chain indicating entity.
[0073] It should be noted that the obtaining module 32 in this embodiment can be configured to perform step S202 in the embodiments of the present application, the recalling module 34 in this embodiment can be configured to perform step S204 in the embodiments of the present application, and the determining module 36 in this embodiment can be configured to perform step S206 in the embodiments of the present application.
[0074] It should be noted that the above modules have the same examples and application scenarios as the corresponding steps, but are not limited to the above disclosed contents. It should be noted that the above modules as part of the device can run in the hardware environment as shown in Figure 1 and can be implemented by software or hardware.
[0075] Through the above modules, the technical problem of low accuracy of entity chain indication in the related art can be solved.
[0076] Optionally, the obtaining module 32 is further configured to replace the chain indicating entity in the first text with a masking word to obtain a second text; and extract semantic features of the masking word in the second text by using a word vector model to obtain first semantic features.
[0077] As an optional embodiment, the obtaining module 32 further includes: a preprocessing unit configured to preprocess the first training text to obtain a plurality of second training texts, wherein the first training text is a training text in which candidate entities and entity types of the candidate entities are labeled, and each second training text contains a masking word, which is used to replace a candidate entity in the second training text; a type identification training unit configured to perform type identification training on the first word vector model by using the plurality of second training texts to obtain a second word vector model; an entity identification training unit configured to perform entity identification training on the second word vector model by using the plurality of second training texts to obtain a third word vector model; and an entity feature extraction unit configured to extract entity features corresponding to each candidate entity in the training text by using the third word vector model.
[0078] Optionally, the masking word is further used to replace non-entities in the second training text, and the preprocessing unit is further configured to: perform a word segmentation operation on the first training text to obtain a first segmented text, wherein the words in the first segmented text include non-entities and candidate entities; and mask specified words in the first segmented text by using the masking word to obtain the second training text corresponding to the specified words, wherein the specified words are any one of all non-entities and all candidate entities.
[0079] Optionally, the masking word is also used to replace the non-entity in the second training text, and the type recognition training unit is further configured to: extract first features of the masking word in each second training text by using the first word vector model; input the first features of the masking word into the first full connection layer to obtain a predicted type of the masking word for each masking word; and adjust parameters of the first word vector model according to the predicted type of the masking word and a labeled type corresponding to the masking word to obtain a second word vector model, wherein the predicted type is a non-entity type of the non-entity or an entity type of the candidate entity.
[0080] Optionally, the entity recognition training unit is further configured to: extract features of the masking word in each second training text by using the second word vector model to obtain second features corresponding to each second training text; input the second features of the masking word into the second full connection layer to obtain a predicted entity of each masking word in a case that the predicted type of the masking word is the entity type after the second features are input into the first full connection layer; and adjust parameters of the second word vector model according to the predicted type of the masking word and a labeled entity corresponding to the masking word to obtain a third word vector model.
[0081] As an optional embodiment, the recall module 34 further includes: a global feature acquisition unit, configured to acquire first global features corresponding to each candidate entity in the plurality of candidate entities, wherein for each candidate entity, the first global feature is used to represent global information of the candidate entity in the first text in a case that the to-be-chain-pointing entity is the candidate entity; a concatenation unit, configured to concatenate the first semantic feature, the first global feature corresponding to the candidate entity and the entity feature corresponding to the candidate entity to obtain a concatenated feature for each candidate entity; and a recall unit, configured to input the concatenated feature into the third full connection layer to obtain a recall entity.
[0082] As an optional embodiment, the determination module 36 further includes: a similarity acquisition unit, configured to acquire a cosine similarity between each recall entity in all recall entities and the to-be-chain-pointing entity; a sorting unit, configured to determine a target cosine similarity from all cosine similarities according to the cosine similarities corresponding to all recall entities, wherein the target cosine similarity is not less than other cosine similarities except the target cosine similarity among all cosine similarities; and a chain pointing unit, configured to take the recall entity corresponding to the target cosine similarity as a target entity, wherein the target entity is a chain pointing result of the to-be-chain-pointing entity.
[0083] It should be noted that the above modules and the corresponding steps achieve the same examples and application scenarios as the above embodiments, but are not limited to the above disclosed contents. It should be noted that the above modules as part of the device can run in the hardware environment as shown in Figure 1 The hardware environment includes a network environment.
[0084] According to another aspect of the embodiments of this application, a server or terminal for implementing the above-described entity chaining method is also provided.
[0085] Figure 4 This is a structural block diagram of a terminal according to an embodiment of this application, such as... Figure 4 As shown, the terminal may include: one or more ( Figure 4 Only one of the following is shown: processor 401, memory 403, and transmission device 405, as shown in the image. Figure 4 As shown, the terminal may also include input / output devices 407.
[0086] The memory 403 can be used to store software programs and modules, such as the program instructions / modules corresponding to the entity chaining method and apparatus in this embodiment. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 403, thereby implementing the aforementioned entity chaining method. The memory 403 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 403 may further include memory remotely located relative to the processor 401, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0087] The aforementioned transmission device 405 is used to receive or send data via a network, and can also be used for data transfer between the processor and memory. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 405 includes a Network Interface Controller (NIC), which can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 405 is a radio frequency (RF) module used for wireless communication with the Internet.
[0088] Specifically, memory 403 is used to store application programs.
[0089] The processor 401 can invoke an application stored in the memory 403 through the transmission device 405 to perform the following steps: obtaining a first semantic feature of a to-be-pointing entity and an entity feature corresponding to each candidate entity in a plurality of candidate entities, wherein the first semantic feature is used to indicate a semantic of a first text in which the to-be-pointing entity is located, and for each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained after pre-training of a training text in which the candidate entity is located, and is used to represent a semantic of the training text; determining a target entity feature from all entity features through the first semantic feature, and determining a candidate entity corresponding to the target entity feature as a recall entity; and determining a target entity pointed by the to-be-pointing entity from the recall entity according to a similarity between the recall entity and the to-be-pointing entity.
[0090] By adopting the embodiment of the present application, an entity pointing scheme is provided. By taking the semantic feature of the training text in which the candidate entity is located after training of the training text as the entity feature of the candidate entity for entity pointing, the semantic of the candidate entity is deeply mined when the entity feature of the candidate entity is obtained, and the rationality of the entity feature used to represent the candidate entity feature is enhanced. Even if the text information in which the to-be-pointing entity is located is less or the semantic cannot be deeply mined, the pointing can also be accurate, thereby solving the technical problem of low accuracy of entity pointing in the related art.
[0091] Optionally, specific examples in the embodiment can refer to the examples described in the above-described embodiments, and the embodiment will not be described herein again.
[0092] Those skilled in the art can understand that Figure 4 The structure shown is only schematic, and the terminal can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a mobile Internet device (MID), a PAD, and the like. Figure 4 It does not limit the structure of the electronic device. For example, the terminal can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 4 It does not limit the structure of the electronic device. For example, the terminal can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 4 It does not limit the structure of the electronic device. For example, the terminal can further include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure.
[0093] Those skilled in the art can understand that all or part of the steps of the various methods in the above-described embodiments can be instructed by a program to terminal device related hardware, and the program can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0094] The embodiment of the present application also provides a storage medium. Optionally, in the embodiment, the storage medium can be used to execute the program code of the entity chain pointing method.
[0095] Optionally, in the embodiment, the storage medium can be located on at least one of the network devices in the network shown in the above embodiment.
[0096] Optionally, in the embodiment, the storage medium is configured to store program code for executing the following steps:
[0097] S1, obtaining a first semantic feature of a to-be-chain-pointed entity and an entity feature corresponding to each candidate entity in a plurality of candidate entities, wherein the first semantic feature is used to indicate the semantics of a first text in which the to-be-chain-pointed entity is located, and for each candidate entity, the entity feature corresponding to the candidate entity is a feature obtained after pre-training according to a training text in which the candidate entity is located, and is used to represent the semantics of the training text in which the candidate entity is located;
[0098] S2, determining a target entity feature from all the entity features through the first semantic feature, and determining a candidate entity corresponding to the target entity feature as a recall entity;
[0099] S3, determining a target entity to which the to-be-chain-pointed entity points from the recall entity according to the similarity between the recall entity and the to-be-chain-pointed entity.
[0100] Optionally, the specific examples in the embodiment can refer to the examples described in the above embodiments, and the embodiment will not be described here.
[0101] Optionally, in the embodiment, the storage medium can include but is not limited to a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0102] The serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
[0103] The integrated units in the above embodiments, if realized in the form of software function units and sold or used as independent products, can be stored in the above computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or the whole or part of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application.
[0104] In the above-described embodiments of the present application, the description of each embodiment is focused on each aspect, and the part not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0105] In several embodiments provided in the present application, it should be understood that the disclosed client can be implemented by other manners. Among them, the above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between units or modules, and can be electrical or other forms.
[0106] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment.
[0107] In addition, each functional unit in each embodiment of the present application can be integrated in a processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0108] The above is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. An entity chain referencing method, characterized by, The method comprises the following steps: preprocessing a first training text to obtain a plurality of second training texts, wherein the first training text is a training text in which candidate entities and entity types of the candidate entities are labeled, each of the second training texts contains a mask word, and the mask word is used to replace the candidate entities in the second training texts; performing type identification training on a first word vector model using the plurality of second training texts to obtain a second word vector model; performing entity identification training on the second word vector model using the plurality of second training texts to obtain a third word vector model, comprising: performing feature extraction on the mask word in each of the second training texts using the second word vector model to obtain second features corresponding to each of the second training texts; after the second features are input into a first full connection layer, if a predicted type of the mask word is an entity type, inputting the second features of the mask word into a second full connection layer to obtain a predicted entity of each of the mask words; adjusting parameters of the second word vector model according to the predicted type of the mask word and a labeled entity corresponding to the mask word to obtain the third word vector model; extracting entity features corresponding to each of the candidate entities in the training text using the third word vector model; obtaining a first semantic feature of a to-be-pointed entity and entity features corresponding to each of a plurality of candidate entities, wherein the first semantic feature is used to indicate semantics of a first text in which the to-be-pointed entity is located, and for each of the candidate entities, the entity feature corresponding to the candidate entity is a feature obtained after pre-training of a second training text in which the candidate entity is located and used to represent semantics of the training text in which the candidate entity is located; determining a target entity feature from all the entity features through the first semantic feature, and determining the candidate entity corresponding to the target entity feature as a recall entity; determining a target entity pointed by the to-be-pointed entity from the recall entity according to a similarity between the recall entity and the to-be-pointed entity.
2. The method of claim 1, wherein, The mask word is also used to replace non-entities in the second training texts, and the preprocessing of the first training text to obtain a plurality of second training texts comprises: performing a word segmentation operation on the first training text to obtain a first segmented text, wherein words in the first segmented text include non-entities and the candidate entities; masking specified words in the first segmented text by the mask word to obtain the second training texts corresponding to the specified words, wherein the specified words are any one of all the non-entities and all the candidate entities.
3. The method of claim 1, wherein, The mask word is also used to replace non-entities in the second training texts, and the performing of the type identification training on the first word vector model using the plurality of second training texts to obtain the second word vector model comprises: extracting first features of the mask words in each of the second training texts using the first word vector model; for each of the mask words, inputting the first features of the mask words into a first full connection layer to obtain a predicted type of the mask words. According to the prediction type of the mask word and the label type corresponding to the mask word, the parameters of the first word vector model are adjusted to obtain the second word vector model, wherein the prediction type is a non-entity type of the non-entity or an entity type of the candidate entity.
4. The method of claim 1, wherein, The first semantic feature of the to-be-chain entity is obtained, including: The to-be-chain entity in the first text is replaced with a mask word to obtain a second text; The semantic feature of the mask word in the second text is extracted by using a word vector model to obtain the first semantic feature.
5. The method of claim 1, wherein, The target entity feature is determined from all the entity features through the first semantic feature, and the candidate entity corresponding to the target entity feature is determined as a recall entity, including: A first global feature corresponding to each of the candidate entities is obtained, wherein for each of the candidate entities, the first global feature is used to represent the global information of the candidate entity in the first text under the condition that the to-be-chain entity is the candidate entity. For each of the candidate entities, the first semantic feature, the first global feature corresponding to the candidate entity, and the entity feature corresponding to the candidate entity are spliced to obtain a spliced feature, and the spliced feature is input into a third fully connected layer to obtain the recall entity.
6. The method of claim 1, wherein, The target entity to which the to-be-chain entity chain points is determined from the recall entity according to the similarity between the recall entity and the to-be-chain entity, including: The cosine similarity between each of the recall entities and the to-be-chain entity is obtained. According to the cosine similarities corresponding to all the recall entities, a target cosine similarity is determined from all the cosine similarities, wherein the target cosine similarity is not less than other cosine similarities except the target cosine similarity among the all cosine similarities. The recall entity corresponding to the target cosine similarity is taken as the target entity, wherein the target entity is the chain pointing result of the to-be-chain entity.
7. A physical chain finger device, characterized by including: The pre-processing unit is configured to pre-process a first training text to obtain a plurality of second training texts, wherein the first training text is a training text in which candidate entities and entity types of the candidate entities are labeled, each of the second training texts contains a masking word, and the masking word is used to replace the candidate entities in the second training text; the first word vector model is trained by using the plurality of second training texts to obtain a second word vector model; the second word vector model is trained by using the plurality of second training texts to obtain a third word vector model, including: extracting features of the masking word in each of the second training texts by using the second word vector model to obtain second features corresponding to each of the second training texts; after the second features are input into a first full connection layer, if a predicted type of the masking word is an entity type, the second features of the masking word are input into a second full connection layer to obtain a predicted entity of each of the masking words; parameters of the second word vector model are adjusted according to the predicted type of the masking word and a labeled entity corresponding to the masking word to obtain the third word vector model; and entity features corresponding to each of the candidate entities in the training text are extracted by using the third word vector model; The acquisition module is configured to acquire a first semantic feature of a to-be-pointed entity and entity features corresponding to each of a plurality of candidate entities, wherein the first semantic feature is used to indicate semantics of a first text in which the to-be-pointed entity is located, and for each of the candidate entities, the entity feature corresponding to the candidate entity is a feature obtained after pre-training of a second training text in which the candidate entity is located and used to represent semantics of a training text in which the candidate entity is located; The recall module is configured to determine a target entity feature from all the entity features by using the first semantic feature, and determine a candidate entity corresponding to the target entity feature as a recall entity; The determination module is configured to determine a target entity to which the to-be-pointed entity points from the recall entity according to a similarity between the recall entity and the to-be-pointed entity.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the steps of the entity pointing method of any one of claims 1 to 6 by using the computer program.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the entity pointing method of any one of claims 1 to 6.
Citation Information
Patent Citations
Entity chain pointing method, device and equipment and storage medium
CN111428507A