Entity Disambiguation Model Training, Entity Disambiguation Method and Device
By training the entity disambiguation model and determining the semantics of the target entity based on the characteristics of the target statement, the problem of insufficient accuracy of the entity disambiguation method in the prior art is solved, and the accuracy of semantic understanding and user experience are improved.
Patent Information
- Application Number
- CN202111071940.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-14
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-09-14
AI Technical Summary
The existing entity disambiguation methods are poor in semantic understanding, resulting in insufficient accuracy in semantic understanding of sentences.
By constructing an entity disambiguation model, using the sample dataset to train the model, so that it can learn the association relationship between the target entity and the candidate semantic entity, and combine the characteristics of the target statement to determine the semantics of the target entity.
It improves the accuracy of entity disambiguation, thereby improving the accuracy of semantic understanding of the target statements and improving user experience.
Smart Images

Figure CN113780004B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to natural language processing technologies. More specifically, it relates to a method and device for training an entity disambiguation model and an entity disambiguation method. Background Art
[0002] Electronic devices such as smart TVs or smart refrigerators can receive voice signals from users and perform corresponding operations according to the voice signals (such as outputting relevant recommendations or controlling the electronic devices to perform corresponding operations, etc.). Taking a smart TV as an example, after receiving a voice signal from a user, the smart TV can convert the voice signal into a corresponding sentence. Then, the smart TV can perform semantic understanding on the sentence to obtain the semantics corresponding to the sentence. According to the semantics corresponding to the sentence, the smart TV can perform corresponding operations.
[0003] The existing methods for semantic understanding of sentences are mainly semantic understanding based on knowledge graphs. Among them, semantic understanding based on knowledge graphs includes three main steps: 1. Identify the target entity in the sentence; 2. Obtain multiple candidate semantic entities that explain the target entity in a preset knowledge graph; 3. Obtain the semantics corresponding to the target entity from the above multiple candidate semantic entities (this step is also called entity disambiguation).
[0004] However, the existing entity disambiguation methods have the problem of poor accuracy, which may lead to poor accuracy in semantic understanding of sentences. Summary of the Invention
[0005] Exemplary embodiments of the present application provide a method and device for training an entity disambiguation model and an entity disambiguation method, which can improve the accuracy of semantic understanding of sentences.
[0006] In a first aspect, the present application provides a method for training an entity disambiguation model, the method including:
[0007] Obtain a sample data set, the sample data set includes at least one sample data, each sample data includes: a sample sentence, at least one target sample entity of the sample sentence, and a subset of sample candidate semantic entities corresponding to the at least one target sample entity, the subset of sample candidate semantic entities includes a target semantic entity corresponding to each target sample entity, and at least one non-target semantic entity corresponding to each target sample entity, the target semantic entity and the non-target semantic entity belong to the same knowledge graph;
[0008] Use the sample data set to train the entity disambiguation model to obtain a trained entity disambiguation model; the trained entity disambiguation model is used to obtain the target semantic entity corresponding to the target entity from multiple candidate semantic entities corresponding to the target entity.
[0009] In some embodiments, training the entity disambiguation model using the sample data set includes:
[0010] Obtaining the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity in each sample data; the candidate semantic entities include the target semantic entity and non-target semantic entities corresponding to the target sample entity;
[0011] Using the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix, the entity disambiguation model is constructed based on the at least one trainable parameter matrix, and the trainable parameter matrix is the trainable parameter in the entity disambiguation model.
[0012] In some embodiments, the entity disambiguation model includes a first trainable parameter matrix and a second trainable parameter matrix, and using the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix includes:
[0013] For any target sample entity in the same sample sentence, according to the word vector of the target sample entity, the entity vectors of each candidate semantic entity corresponding to the target sample entity, and the first trainable parameter matrix, obtaining the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity;
[0014] According to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity, obtaining the maximum relevance vector corresponding to the sample sentence; wherein, the maximum relevance vector corresponding to the sample sentence includes: the maximum relevance corresponding to each target sample entity in the sample sentence; the maximum relevance is: the maximum value among the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity;
[0015] According to the maximum relevance vector corresponding to the sample sentence, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample sentence, obtaining the semantic feature of the sample sentence;
[0016] According to the semantic feature of the sample sentence, training the first trainable parameter matrix and the second trainable parameter matrix.
[0017] In some embodiments, obtaining the semantic feature of the sample sentence according to the maximum relevance vector corresponding to the sample sentence, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample sentence includes:
[0018] Normalize the maximum correlation vector corresponding to the sample statement to obtain the target maximum correlation vector corresponding to the sample statement;
[0019] Take the product of the target maximum correlation vector, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement as the semantic feature of the sample statement.
[0020] In some embodiments, the training of the first trainable parameter matrix and the second trainable parameter matrix according to the semantic feature of the sample statement includes:
[0021] Obtain the association feature between the sample statement and each candidate semantic entity according to the inner product of the semantic feature of the sample statement and the entity vectors of each candidate semantic entity corresponding to each target sample entity;
[0022] Train the first trainable parameter matrix and the second trainable parameter matrix according to the association feature between the sample statement and each candidate semantic entity and a preset loss function.
[0023] In some embodiments, the sample statement includes K initial sample entities, where K is a positive integer greater than 1. Before training the entity disambiguation model using the sample data set, it further includes:
[0024] Input the K initial sample entities of the sample statement into a preset contribution prediction model to obtain the contribution of each initial sample entity of the sample statement to the semantics of the sample statement;
[0025] According to the ranking of the contributions from large to small, take the top R initial sample entities with the highest contribution to the semantics of the sample statement as the target sample entities of the sample statement, where R is a positive integer greater than or equal to 1 and less than or equal to K.
[0026] In a second aspect, the present application provides an entity disambiguation method, and the method includes:
[0027] Obtain at least one target entity of the target statement and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph;
[0028] Input each target entity and the multiple candidate semantic entities corresponding to each target entity into the trained entity disambiguation model to obtain the target semantic entity corresponding to each target entity; where the trained entity disambiguation model is trained by using the method described in any item of the first aspect; the target semantic entity is any one of the multiple candidate semantic entities v
[0029] Obtain the semantics of the target statement according to the target semantic entities corresponding to the respective target entities.
[0030] In some embodiments, after obtaining the semantics of the target statement, the following is further included:
[0031] Execute the control instruction corresponding to the semantics according to the semantics of the target statement.
[0032] In some embodiments, obtaining at least one target entity of the target statement, and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge graph includes:
[0033] Obtain each initial entity of the target statement;
[0034] If the number of initial entities of the target statement is greater than the preset entity number, obtain the initial entities with the preset entity number from the target statement as the target entities of the target statement; wherein, the preset entity number is an integer greater than or equal to 1.
[0035] Obtain a plurality of initial candidate semantic entities corresponding to the target entity from the knowledge graph;
[0036] If the number of initial candidate semantic entities corresponding to the target entity is greater than the preset candidate semantic entity number, obtain the initial candidate semantic entities with the preset candidate semantic entity number from the initial candidate semantic entities as the plurality of candidate semantic entities corresponding to the target entity, wherein the preset candidate semantic entity number is an integer greater than 1.
[0037] In some embodiments, before obtaining at least one target entity of the target statement, and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge graph, the following is further included:
[0038] Receive a voice signal input by a user;
[0039] Perform speech recognition on the voice signal to obtain the target statement.
[0040] In a third aspect, the present application provides a training device for an entity disambiguation model, the device includes:
[0041] An acquisition module for acquiring a sample data set, where the sample data set includes at least one sample data, and each sample data includes: a sample statement, at least one target sample entity of the sample statement, and a sample candidate semantic entity subset corresponding to the at least one target sample entity. The sample candidate semantic entity subset includes a target semantic entity corresponding to each target sample entity, and at least one non-target semantic entity corresponding to each target sample entity. The target semantic entity and the non-target semantic entity belong to the same knowledge graph;
[0042] A training module for training an entity disambiguation model using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used to obtain the target semantic entity corresponding to a target entity from multiple candidate semantic entities corresponding to the target entity.
[0043] In a fourth aspect, the present application provides an entity disambiguation device, and the device includes:
[0044] A first acquisition module for acquiring at least one target entity of a target statement, and multiple candidate semantic entities corresponding to each target entity determined from a knowledge graph;
[0045] A processing module for inputting each target entity and multiple candidate semantic entities corresponding to each target entity into the trained entity disambiguation model to obtain the target semantic entity corresponding to each target entity; wherein, the trained entity disambiguation model is trained by using the method described in any item of the first aspect; the target semantic entity is any one of the multiple candidate semantic entities;
[0046] A second acquisition module for acquiring the semantics of the target statement according to the target semantic entities corresponding to the target entities.
[0047] In a fifth aspect, the present application provides an electronic device, including: at least one processor and a memory;
[0048] The memory stores computer execution instructions;
[0049] The at least one processor executes the computer execution instructions stored in the memory, so that the electronic device executes the method described in any item of the first aspect or the second aspect.
[0050] In a sixth aspect, the present application provides a computer-readable storage medium, on which computer execution instructions are stored. When the computer execution instructions are executed by a processor, the method described in any item of the first aspect or the second aspect is implemented.
[0051] In a seventh aspect, the present application provides a computer program product, including a computer program which, when executed by a processor, implements the method according to any one of the first aspect or the second aspect.
[0052] The entity disambiguation model training, entity disambiguation method and device provided by the present application use a sample data set including sample statements, at least one target sample entity of the sample statements, and a sample candidate semantic entity subset corresponding to the target sample entity to train the entity disambiguation model. The sample candidate semantic entity subset includes the target semantic entity corresponding to the target sample entity and non-target semantic entities. By training the entity disambiguation model with the above sample data set, the entity disambiguation model can learn the association relationships between the respective target sample entities of the sample statements and between the target sample entities and the candidate semantic entities. Therefore, compared with the prior art in which the semantic entity of the target entity is determined only based on the number of entities associated with the candidate semantic entity, the present application determines the semantics of the statement by using the trained entity disambiguation model. When determining the semantics of a target entity, the features of the target statement in which the target entity is located are combined, improving the accuracy of determining the semantics of the target entity, that is, improving the accuracy of entity disambiguation, and further improving the accuracy of semantic understanding of the target statement. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the embodiments of the present application or the implementation manners in the related art, the following will briefly introduce the drawings required to be used in the description of the embodiments or the related art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings.
[0054] Figure 1 It is a schematic diagram of a scenario where a user performs voice interaction with a display device provided by the present application;
[0055] Figure 2 It is a schematic flowchart of a method for training an entity disambiguation model provided by the present application;
[0056] Figure 3 It is a schematic flowchart of another method for training an entity disambiguation model provided by the present application;
[0057] Figure 4 It is a schematic flowchart of yet another method for training an entity disambiguation model provided by the present application;
[0058] Figure 5 It is a schematic flowchart of a method for entity disambiguation provided by the present application;
[0059] Figure 6 It is a schematic structural diagram of a training device 400 for an entity disambiguation model provided by the present application;
[0060] Figure 7 Schematic diagram of a physical disambiguation device 500 provided for this application;
[0061] Figure 8 Schematic diagram of an electronic device provided for this invention. Specific embodiments
[0062] To make the objectives, embodiments and advantages of this application clearer, the following will clearly and completely describe the exemplary embodiments of this application with reference to the accompanying drawings in the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only a part rather than all of the embodiments of this application.
[0063] Based on the exemplary embodiments described in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope protected by the appended claims of this application. In addition, although the disclosed content in this application is introduced according to one or several exemplary instances, it should be understood that each aspect of these disclosed contents can also constitute a complete embodiment alone.
[0064] It should be noted that the brief description of the terms in this application is only for the convenience of understanding the embodiments described next, rather than intending to limit the embodiments of this application. Unless otherwise specified, these terms should be understood in their ordinary and general meanings.
[0065] The terms "first", "second", "third", etc. in the specification, claims and the above-mentioned drawings of this application are used to distinguish similar or homogeneous objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be interchanged under appropriate circumstances, for example, it is possible to implement according to an order other than those given in the illustration or description of the embodiments of this application.
[0066] In addition, the terms "include" and "have" and any variations thereof are intended to cover but not exclude inclusion. For example, a product or device including a series of components does not necessarily have to be limited to those components clearly listed, but may include other components not clearly listed or inherent to these products or devices.
[0067] The term "module" used in this application refers to any known or later-developed hardware, software, firmware, artificial intelligence, fuzzy logic, or a combination of hardware or / and software code that can perform functions related to that element.
[0068] The following explains the noun concepts related to this application:
[0069] Knowledge Graph: A knowledge graph includes at least two entities (which can also be referred to as nodes), and whether there is an association relationship between different entities.
[0070] Semantic contribution degree: The semantic contribution degree refers to the degree of influence of the words in a sentence on the semantics of the sentence. For example, modal particles such as "ah", "ne", "a" generally have a relatively small influence on the semantics of a sentence, that is, the semantic contribution degree of these modal particles to the sentence semantics is small.
[0071] With the development of science and technology, more and more electronic devices can perform voice interaction with users. Taking the above-mentioned electronic device as a display device (such as a smart TV) as an example, exemplarily, Figure 1 This is a schematic diagram of a scenario where a user interacts with a display device provided by this application. As Figure 1 shown, the display device 200 can receive the user's voice signal and perform corresponding operations on the display device 200 according to the voice signal.
[0072] Exemplarily, the display device 200 can, for example, perform content recommendation related to the semantics corresponding to the user's voice signal, or play a video related to the semantics, or perform control such as volume adjustment.
[0073] In some embodiments, as Figure 1 shown, after receiving the user's voice signal, the display device 200 can transmit the voice signal to the server 400 through the Internet. The server 400 can first determine the semantics of the voice signal. Then, according to the semantics of the voice signal, determine the operation instruction corresponding to the voice signal, and send the operation instruction to the display device 200. Then, the display device 200 can control the display device 200 according to the operation instruction.
[0074] In some embodiments, a voice signal processing algorithm can also be stored in the above-mentioned display device 200. Through this voice signal processing algorithm, the display device 200 can obtain the semantics of the user's voice signal. Then the display device 200 can determine the operation instruction corresponding to the voice signal according to the semantics of the voice signal, and further control the display device 200 according to the operation instruction.
[0075] It should be understood that Figure 1 only an exemplary description of the voice interaction scenario is given by taking an electronic device as a display device. In specific implementation, the above-mentioned electronic device can also be, for example, other terminals with processing functions, or servers, etc. Such as smart home appliances such as smart TVs, smart refrigerators, smart speakers, or electronic devices such as mobile phones, tablets, laptops, desktop computers, smart watches.
[0076] As described above, after receiving a user's voice signal, an electronic device needs to determine the semantics corresponding to the voice signal before performing corresponding operations. In some embodiments, for the process of determining the semantics corresponding to the voice signal, the electronic device can first convert the received voice signal into a corresponding sentence. Then, the electronic device can perform semantic understanding on the sentence to obtain the semantics corresponding to the sentence (i.e., the semantics corresponding to the voice signal).
[0077] Existing methods for semantic understanding of sentences mainly rely on knowledge graph-based semantic understanding. Among them, knowledge graph-based semantic understanding includes the following three main steps:
[0078] 1. Entity recognition. Entity recognition refers to identifying each word in a sentence and taking each word in the sentence as a target entity of the sentence.
[0079] Exemplarily, taking the sentence "I want to buy game character skins" as an example, through an entity recognition algorithm, the electronic device can identify target entities such as "I", "want", "buy", "game", "character", and "skins" in the sentence.
[0080] 2. Entity linking. Entity linking refers to, for any target entity, obtaining multiple candidate semantic entities associated with the target entity in a preset knowledge graph. Among them, the multiple candidate semantic entities can all be used to explain the target entity, that is, the multiple candidate semantic entities can all be used as the semantics of the target entity.
[0081] Exemplarily, taking the "skins" target entity in the above example sentence as an example, the electronic device can obtain multiple entities associated with the "skins" entity in the preset knowledge graph as candidate semantic entities for "skins". Exemplarily, candidate semantic entities for "skins" can include candidate semantic entities such as "organ", "game", and "ornament".
[0082] 3. Entity disambiguation. Entity disambiguation refers to determining, from multiple candidate semantic entities of a target entity, the semantic entity corresponding to the target entity that can express the target entity.
[0083] Exemplarily, taking the candidate semantic entities corresponding to the above "skins" target entity including candidate semantic entities such as "organ", "game", and "ornament" as an example, the electronic device needs to use an entity disambiguation method to determine the semantic entity of "skins" from candidate semantic entities such as "organ", "game", and "ornament".
[0084] Currently, existing entity disambiguation methods mainly include: for any candidate semantic entity, determining the number of entities associated with the candidate semantic entity in the knowledge graph. Taking the candidate semantic entity with the largest number of associated entities as the semantic entity of the target entity.
[0085] However, in fact, it is also possible that the actual semantics of the target entity is not the candidate semantic entity with the largest number of associated entities. Therefore, determining the semantic entity of the target entity based solely on the number of entities associated with the candidate semantic entity in the knowledge graph has poor accuracy, which may in turn lead to poor accuracy in semantic understanding of the sentence where the target entity is located.
[0086] Exemplarily, still taking the candidate semantic entities corresponding to the above-mentioned "skin" target entity including candidate semantic entities such as "organ", "game", and "ornament" as an example, assume that the number of entities associated with each of the above candidate semantic entities is as shown in Table 1 below:
[0087] Table 1
[0088] Serial number Candidate semantic entity Number of associated entities 1 Organ Quantity 1 2 Game Quantity 2 3 Ornament Quantity 3
[0089] As shown in Table 1, assuming that Quantity 1 is greater than Quantity 2, and Quantity 2 is greater than Quantity 3, then it can be determined that the semantic entity of "skin" is "organ". That is to say, the skin in this sentence refers to an organ, which is different from the actual semantics that "skin" in this sentence wants to express (the actual semantics should be game ornament). Therefore, the accuracy of the existing entity disambiguation method is poor.
[0090] The inventors found through research that the accurate semantics of the target entity is often related to other entities in the sentence where the target entity is located. For example, the accurate semantics of "skin" in the above example is game ornament, and there is a game ornament entity in the sentence where "skin" is located.
[0091] In view of this, the present application provides a method for determining the semantic entity of a target entity based on the sentence where the target entity is located to improve the accuracy of entity disambiguation. This method inputs each target entity of the target sentence, as well as the candidate semantic entities corresponding to each target entity, into a trained entity disambiguation model to obtain the target semantic entity of each target entity in the target sentence. Among them, the above-mentioned trained entity disambiguation model is trained based on each target sample entity of the sample sentence, as well as the candidate semantic entities corresponding to each target sample entity. Through the above method, the target semantic entity of each target entity can be determined by combining each target entity of the target sentence, considering the influence of other entities in the target sentence where the target entity is located on the semantics of the target entity. Compared with the prior art that determines the semantic entity of the target entity only based on the number of entities associated with each candidate semantic entity in the knowledge graph, the present application improves the accuracy of determining the semantics of the target entity, that is, improves the accuracy of entity disambiguation, and further improves the accuracy of semantic understanding of the target sentence.
[0092] It should be understood that the execution subject of the above-mentioned method for training the entity disambiguation model and the execution subject of the above-mentioned entity disambiguation method can be the same electronic device or different electronic devices.
[0093] The technical solution of training the above-mentioned entity disambiguation model in the present application will be described in detail below with reference to specific embodiments. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0094] Figure 2 It is a schematic flowchart of a method for training an entity disambiguation model provided by the present application. As Figure 2 shown, the method includes the following steps:
[0095] S101. Obtain a sample data set.
[0096] Among them, the above-mentioned sample data set includes at least one sample data. Each of the above sample data includes: a sample statement, at least one target sample entity of the sample statement, and a sample candidate semantic entity subset corresponding to at least one target sample entity. The sample candidate semantic entity subset includes the target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity. The above target semantic entity and non-target semantic entity belong to the same knowledge graph.
[0097] In the above sample data set, the number of target sample entities in different sample statements can be the same or different. The number of non-target semantic entities corresponding to different target sample entities can be the same or different. The above "different target sample entities" can be target sample entities belonging to the same sample statement or target sample entities belonging to different sample statements.
[0098] The target semantic entity corresponding to the above target sample entity refers to the actual semantics of the target sample entity. The at least one non-target semantic entity corresponding to the above target sample entity refers to the candidate semantic entities other than the target semantic entity among the candidate semantic entities corresponding to the target sample entity. In some embodiments, the above knowledge graph can be constructed, for example, based on the entries of at least one website and the association relationships between different entries. It should be understood that the present application does not limit the implementation manner of constructing the above knowledge graph. When specifically implemented, the existing implementation manner of constructing the knowledge graph can be referred to, and the present application will not elaborate here.
[0099] As a possible implementation, the electronic device can directly receive the sample data set input by the user. Exemplarily, the electronic device can receive the sample data set input by the user through an Application Programming Interface (API) or a Graphical User Interface (GUI).
[0100] As another possible implementation, the electronic device can also receive at least one sample statement input by the user. After receiving the sample statement input by the user, the electronic device can obtain at least one target sample entity of each sample statement through a preset entity recognition algorithm (which can also be called a word segmentation algorithm).
[0101] Exemplarily, the above-mentioned preset entity recognition algorithm can be, for example, the ansj entity recognition algorithm, the jieba entity recognition algorithm, the hanlp entity recognition algorithm, the entity recognition algorithm based on Long Short Term Memory (LSTM), the entity recognition algorithm based on conditional random field (CRF), etc. The specific implementation manners of the above-mentioned preset entity recognition algorithms can refer to the existing implementation manners and will not be elaborated here.
[0102] In this implementation manner, after the electronic device obtains at least one target sample entity of the sample statement, it can obtain a sample candidate semantic entity subset corresponding to each target sample entity from the above knowledge graph through a preset entity linking algorithm. The above-mentioned preset entity linking algorithm is used to obtain the candidate semantic entity corresponding to the target sample entity. The specific implementation manner of the preset entity linking algorithm can refer to the existing implementation manner and will not be elaborated here.
[0103] After determining the sample candidate semantic entity subset, the electronic device can receive the positive sample label or the negative sample label input by the user for different candidate semantic entities. Among them, the candidate semantic entity with the positive sample label is the target semantic entity corresponding to the target sample entity, and the candidate semantic entity with the negative sample label is the non-target semantic entity corresponding to the target sample entity. It should be understood that the specific forms of the above positive sample label and negative sample label are not limited in this application. Exemplarily, the positive sample label can be represented by the number "1", for example. The negative sample label can be represented by the number "0", for example.
[0104] Then, the sample statement, at least one target sample entity of the sample statement, and the sample candidate semantic entity subset corresponding to at least one target sample entity obtained by the above electronic device can be used as the sample data set.
[0105] S102. Train an entity disambiguation model using a sample data set to obtain a trained entity disambiguation model.
[0106] Among them, the above-mentioned trained entity disambiguation model is used to obtain the target semantic entity corresponding to the target entity from multiple candidate semantic entities corresponding to the target entity.
[0107] In some embodiments, the above-mentioned entity disambiguation model can be an existing neural network model. The electronic device can use the above-mentioned sample data set to train the neural network model to obtain a trained entity disambiguation model.
[0108] In some embodiments, the above-mentioned entity disambiguation model can also be constructed based on at least one trainable parameter matrix. In this implementation, training the entity disambiguation model using the sample data set can also be said to be training the above-mentioned at least one trainable parameter matrix using the sample data set to change the values of each trainable parameter matrix until a trained entity disambiguation model is obtained.
[0109] In some embodiments, the above-mentioned entity disambiguation model can be pre-stored in the electronic device by the user.
[0110] As a possible implementation, after obtaining the sample data set, the electronic device can directly use the sample data set to train the entity disambiguation model.
[0111] As another possible implementation, the target sample entity of the sample statement in the above-mentioned sample data set can be an entity with a relatively high contribution degree to the semantics of the sample statement. In this implementation, before training the entity disambiguation model using the sample data set, the electronic device can first use the entity with a relatively high contribution degree to the semantics of the sample statement as the target sample entity of the sample statement. By training the entity disambiguation model based on the target sample entity with a relatively high contribution degree to the semantics of the sample statement, the amount of data using the target sample entity is reduced, and the training speed of the entity disambiguation model is improved. In addition, since the entity with a relatively low contribution degree to the semantics of the sample statement is deleted from the sample data set, that is, the deleted entity has a relatively small impact on the semantic understanding of the statement, the accuracy of training the entity disambiguation model can still be guaranteed by the above method.
[0112] In this implementation manner, taking a sample statement including K initial sample entities as an example (where K is a positive integer greater than 1), in some embodiments, before training an entity disambiguation model using a sample data set, an electronic device may input the K initial sample entities of the sample statement into a preset contribution prediction model to obtain the contribution of each initial sample entity of the sample statement to the semantics of the sample statement. Exemplarily, the above-mentioned preset contribution prediction model may be, for example, an existing attention mechanism model constructed based on a neural network. This attention mechanism model may output the contribution of each entity in the statement to the semantics of the statement based on the input statement.
[0113] Then, the electronic device may rank the R initial sample entities with the top R contributions to the semantics of the sample statement in descending order of contribution as the target sample entities of the sample statement. Wherein, R is a positive integer greater than or equal to 1 and less than or equal to K.
[0114] If the number of target sample entities of the sample statement is greater than the above-mentioned K, in some embodiments, the electronic device may also divide the sample statement with the number of target sample entities greater than K into multiple sample statements so that the number of target sample entities of each sample statement is less than or equal to K. Then, the electronic device may refer to the above method to train the entity disambiguation model using the sample data set.
[0115] In this embodiment, an entity disambiguation model is trained using a sample data set including a sample statement, at least one target sample entity of the sample statement, and a sample candidate semantic entity subset corresponding to the target sample entity. Wherein, the sample candidate semantic entity subset includes the target semantic entity corresponding to the target sample entity and non-target semantic entities. By training the entity disambiguation model using the above sample data set, the entity disambiguation model can learn the association relationship between each target sample entity of the sample statement, the target sample entity, and the candidate semantic entity. Therefore, compared with the prior art in which the semantic entity of the target entity is determined only based on the number of candidate semantic entity associations, in this application, by using the trained entity disambiguation model to determine the semantics of the statement, when determining the semantics of a target entity, the characteristics of the target statement where the target entity is located are combined, improving the accuracy of determining the semantics of the target entity, that is, improving the accuracy of entity disambiguation, and further improving the accuracy of semantic understanding of the target statement.
[0116] The following will detail how to train the entity disambiguation model using the above sample data set. Figure 3 It is a schematic flowchart of another method for training an entity disambiguation model provided by this application. As Figure 3 shown, this method includes the following steps:
[0117] S201. Obtain the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity in each sample data.
[0118] Among them, the above-mentioned candidate semantic entities include the target semantic entity and non-target semantic entities corresponding to the target sample entity.
[0119] In some embodiments, the electronic device may input the above-mentioned target sample entity and candidate semantic entities into a preset word vector generation model to obtain the word vector of the target sample entity and the entity vectors of the candidate semantic entities. The above-mentioned preset word vector generation model is used to generate the word vector corresponding to the input entity according to the input entity.
[0120] Exemplarily, the above-mentioned preset word vector generation model may be, for example, any existing Word2vec (fully called word to vector) model.
[0121] It should be understood that this application does not limit the dimension of the word vector of the above-mentioned target sample entity and the dimension of the entity vector of the candidate semantic entity. Exemplarily, the dimension of the word vector of the target sample entity and the dimension of the entity vector of the candidate semantic entity may both be 300 dimensions.
[0122] S202. Use the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix.
[0123] Among them, the entity disambiguation model is constructed based on the above-mentioned at least one trainable parameter matrix. The trainable parameter matrix is the trainable parameter in the entity disambiguation model.
[0124] Taking the entity disambiguation model including a first trainable parameter matrix and a second trainable parameter matrix as an example below, how the electronic device uses the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train the first trainable parameter matrix and the second trainable parameter matrix will be described in detail.
[0125] Figure 4 It is a schematic flowchart of another training method of the entity disambiguation model provided by this application. As a possible implementation manner, the above step S202 may include the following steps:
[0126] S2021. For any target sample entity in the same sample sentence, obtain the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity according to the word vector of the target sample entity, the entity vectors of each candidate semantic entity corresponding to the target sample entity, and the first trainable parameter matrix.
[0127] Among them, the higher the relevance between the target sample entity and the candidate semantic entity, the closer the candidate semantic entity is to the actual semantics of the target sample entity.
[0128] As a possible implementation, the electronic device can obtain the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity according to the word vector of the target sample entity, the entity vector of each candidate semantic entity corresponding to the target sample entity, and the first trainable parameter matrix through the following formula (1).
[0129]
[0130] Among them, x ω represents the matrix composed of the word vectors of all target sample entities of the sample sentence. A represents the first trainable parameter matrix. x e represents the matrix composed of the entity vectors of each candidate semantic entity corresponding to the above-mentioned target sample entities. U(ω) represents the relevance between each target sample entity of the sample sentence and each candidate semantic entity corresponding to the target sample entity. It should be understood that the present application does not limit the initial value of the above-mentioned first trainable parameter matrix. Exemplarily, the electronic device can determine the initial value of the first trainable parameter matrix by random means, for example.
[0131] S2022. Obtain the maximum relevance vector corresponding to the sample sentence according to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity.
[0132] The maximum relevance vector corresponding to the above sample sentence includes: the maximum relevance corresponding to each target sample entity in the sample sentence. The maximum relevance is the maximum value among the relevances between the target sample entity and each candidate semantic entity corresponding to the target sample entity.
[0133] Exemplarily, the electronic device can obtain the maximum relevance vector corresponding to the sample sentence according to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity through the following formula (2).
[0134] u(ω) = maxU(ω) (2)
[0135] Among them, u(ω) represents the maximum relevance vector corresponding to the sample sentence. max represents obtaining the maximum relevance corresponding to each target sample entity in U(ω).
[0136] S2023. Obtain the semantic feature of the sample sentence according to the maximum relevance vector corresponding to the sample sentence, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample sentence.
[0137] As a possible implementation, the electronic device may normalize the maximum correlation vector corresponding to the sample statement, and then determine the semantic feature of the sample statement according to the second trainable parameter matrix and the word vectors of each target sample entity in the sample statement. By normalizing the maximum correlation vector corresponding to the sample statement, the difference in the magnitudes of different values in the maximum correlation vector can be reduced, avoiding the situation where only the large values have an impact on the training process due to excessive magnitude differences, and improving the accuracy of training the entity disambiguation model.
[0138] In this implementation, in some embodiments, the electronic device may first normalize the maximum correlation vector corresponding to the sample statement to obtain the target maximum correlation vector corresponding to the sample statement. Exemplarily, the electronic device may normalize any value of the maximum correlation vector corresponding to the sample statement through the following formula (3).
[0139]
[0140] Where r represents any value of the maximum correlation vector corresponding to the sample statement. R is the number of target sample entities of the sample statement mentioned above (that is, the dimension of the maximum correlation vector). β(r) represents the normalization result of any value of the maximum correlation vector.
[0141] By normalizing each value of the maximum correlation vector corresponding to the sample statement through the above formula (3), the target maximum correlation vector β(ω) corresponding to the sample statement can be obtained.
[0142] Then, the electronic device may use the product of the target maximum correlation vector, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement as the semantic feature of the sample statement. In some embodiments, the electronic device may obtain the semantic feature of the sample statement through the following formula (4).
[0143] x c = β(ω)Bx ω (4)
[0144] Where β(ω) represents the target maximum correlation vector corresponding to the sample statement, B represents the second trainable parameter matrix, and x ω represents the matrix composed of the word vectors of all target sample entities of the sample statement. x c represents the semantic feature of the sample statement. It should be understood that the present application does not limit the initial value of the above second trainable parameter matrix. Exemplarily, the electronic device may determine the initial value of the second trainable parameter matrix by random means.
[0145] S2024. Train the first trainable parameter matrix and the second trainable parameter matrix according to the semantic features of the sample sentence.
[0146] As a possible implementation, the electronic device can first obtain the association features between the sample sentence and each candidate semantic entity based on the semantic features of the sample sentence and the inner product of the entity vectors of each candidate semantic entity corresponding to each target sample entity. In some embodiments, the electronic device can obtain the association features between the sample sentence and each candidate semantic entity through the following formula (5).
[0147]
[0148] where, x e represents the matrix composed of the entity vectors of each candidate semantic entity corresponding to each target sample entity of the sample sentence. x c represents the semantic feature of the sample sentence. represents the association feature between the sample sentence and each candidate semantic entity.
[0149] Then, the electronic device can train the first trainable parameter matrix and the second trainable parameter matrix according to the above-mentioned association features between the sample sentence and each candidate semantic entity and a preset loss function.
[0150] In some embodiments, the above-mentioned preset loss function can be, for example, a maximum margin method loss function, or other existing types of loss functions, etc. Taking the above-mentioned preset loss function as the maximum margin method loss function as an example, the preset loss function can be expressed as follows by the following formula (6):
[0151]
[0152] where, γ represents the variable in the preset loss function, that is to say, during the training process, the value of γ is variable. In some embodiments, the value of γ can change according to a preset rule. The preset rule can refer to the change rule of γ in the existing maximum margin method loss function and will not be elaborated here. e * represents the matrix composed of the entity vectors of the target semantic entities corresponding to each target sample entity. e represents the matrix composed of the entity vectors of the non-target semantic entities corresponding to each target sample entity. C represents the semantic feature of the sample sentence. represents the association feature between the sample sentence and the target semantic entity, represents the association feature between the sample sentence and the non-target semantic entity. f represents the value of the loss function. During the model training process, as the number of training rounds increases, the f can first gradually decrease and then change within a preset range.
[0153] During the training process, the gradient descent algorithm can be used to update the parameter values of the first trainable parameter matrix and the second trainable parameter matrix described above.
[0154] It should be understood that the above embodiments take the entity disambiguation model including the first trainable parameter matrix and the second trainable parameter matrix as an example for an exemplary description of how to train the entity disambiguation model. In specific implementation, the entity disambiguation model may further include one trainable parameter matrix or more than two trainable parameter matrices, which is not limited in this application. When the entity disambiguation model further includes one trainable parameter matrix or more than two trainable parameter matrices, the specific implementation manner can refer to the method described in the above embodiments and will not be elaborated here.
[0155] After obtaining the trained entity disambiguation model, the trained entity disambiguation model can be used to obtain the target semantic entity corresponding to the target entity from multiple candidate semantic entities corresponding to the target entity.
[0156] In this embodiment, the word vectors of each target sample entity of the sample sentence, the entity vectors of each candidate semantic entity corresponding to the target sample entity, and the trainable parameter matrix can be used to characterize the semantic features of the sample sentence. Through the above method, when training the entity disambiguation model, the entity disambiguation model can continuously learn the association relationship between the semantic features of the sample sentence and the entity vectors of each candidate semantic entity corresponding to the target sample entity, so that the trained entity disambiguation model has the ability to combine the sample sentence to determine the target semantic entity corresponding to the target entity, thereby improving the accuracy of determining the semantics of the target entity.
[0157] The following will specifically describe in detail how to use the trained entity disambiguation model to perform entity disambiguation in this application with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be elaborated in some embodiments.
[0158] Figure 5 It is a schematic flowchart of an entity disambiguation method provided by this application. As Figure 5 shown, the method includes the following steps:
[0159] S301. Obtain at least one target entity of the target sentence, and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph.
[0160] As a first possible implementation manner, before step S301, the electronic device may first obtain the target sentence, and then according to the obtained target sentence, obtain at least one target entity of the target sentence, and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph.
[0161] In this implementation manner, in some embodiments, the electronic device may receive a voice signal input by a user, and obtain a target statement by performing speech recognition on the voice signal. Exemplarily, the electronic device may perform speech recognition on the voice signal through a trained neural network model pre-stored in the electronic device to obtain the target statement corresponding to the voice signal. Among them, the above-mentioned trained neural network model may convert the voice signal into a target statement.
[0162] In some embodiments, the electronic device may also receive a target statement input by a user. Exemplarily, the electronic device may receive the target statement input by the user through, for example, a GUI or an API.
[0163] After obtaining the target statement, in some embodiments, the electronic device may obtain at least one target entity of the target statement through a preset entity recognition algorithm; and obtain multiple candidate semantic entities corresponding to each target entity from the knowledge graph through a preset entity linking algorithm. The specific implementation manner may refer to the method described in the foregoing embodiments and will not be elaborated herein.
[0164] As a second possible implementation manner, the electronic device may directly receive at least one target entity of the target statement input by the user. Then, through a preset entity linking algorithm, obtain multiple candidate semantic entities corresponding to each target entity from the knowledge graph.
[0165] As a third possible implementation manner, the electronic device may directly receive at least one target entity of the target statement input by the user, and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph.
[0166] As a fourth possible implementation manner, the electronic device may also limit the number of target entities of the above-mentioned target statement to avoid the sentence of the target statement processed by the electronic device being too long, resulting in a decrease in the accuracy of semantic understanding of the statement, and improve the accuracy of semantic understanding of the target statement. The electronic device may also limit the number of candidate semantic entities corresponding to the target entity to improve the efficiency of determining the target semantic entity corresponding to the target entity.
[0167] In this implementation manner, exemplarily, the electronic device may first obtain each initial entity of the target statement. Among them, all words of the target statement may be used as the initial entities of the target statement. Then, the electronic device may determine whether the number of initial entities of the target statement is greater than a preset entity number.
[0168] If the number of initial entities is greater than the preset number of entities, the electronic device may obtain the preset number of initial entities from the target statement as the target entities of the target statement. Wherein, the preset number of entities is an integer greater than or equal to 1. In some embodiments, the electronic device may use the first preset number of initial entities of the target statement as the target entities of the target statement.
[0169] If the number of initial entities is less than or equal to the preset number of entities, for example, the electronic device may use the initial entities of the target statement as the target entities of the target statement.
[0170] After obtaining the target entities of the target statement, for example, the electronic device may obtain multiple initial candidate semantic entities corresponding to the target entities from the knowledge graph. Then, the electronic device may determine whether the number of initial candidate semantic entities corresponding to the target entity is greater than the preset number of candidate semantic entities.
[0171] If the number of initial candidate semantic entities corresponding to the target entity is greater than the preset number of candidate semantic entities, the electronic device may obtain the preset number of initial candidate semantic entities from the initial candidate semantic entities as the multiple candidate semantic entities corresponding to the target entity. Wherein, the preset number of candidate semantic entities is an integer greater than 1.
[0172] In some embodiments, the electronic device may randomly select the preset number of initial candidate semantic entities from the above initial candidate semantic entities as the multiple candidate semantic entities corresponding to the target entity. Alternatively, the electronic device may also select the preset number of initial candidate semantic entities from the above initial candidate semantic entities through a preset preprocessing method for candidate semantic entities as the multiple candidate semantic entities corresponding to the target entity. Wherein, the preset preprocessing method for candidate semantic entities is used to select a preset number of candidate semantic entities from multiple initial candidate semantic entities.
[0173] If the number of initial candidate semantic entities corresponding to the target entity is less than or equal to the preset number of candidate semantic entities, for example, the electronic device may use the initial candidate semantic entities corresponding to the target entity as the candidate semantic entities corresponding to the target entity.
[0174] S302. Input each target entity and the multiple candidate semantic entities corresponding to each target entity into the trained entity disambiguation model to obtain the target semantic entity corresponding to each target entity.
[0175] Wherein, the trained entity disambiguation model is trained by using the entity disambiguation model training method described in any of the above embodiments. The above target semantic entity is any one of the multiple candidate semantic entities.
[0176] S303. Obtain the semantics of the target statement according to the target semantic entities corresponding to the respective target entities.
[0177] The target semantic entity corresponding to a target entity can represent the semantics of that target entity. In some embodiments, an electronic device may, for example, use the target semantic entities corresponding to the respective target entities as the semantics of the target statement.
[0178] In this embodiment, a trained entity disambiguation model is used to determine the target semantic entities of the respective target entities in the target statement. Compared with the prior art, the features of the target statement where the target entity is located are combined, improving the accuracy of determining the target semantic entity of the target entity, that is, improving the accuracy of semantic understanding of the target entity, and thus improving the accuracy of determining the semantics of the target statement according to the target entity, and therefore also improving the user experience.
[0179] As a possible implementation, after the electronic device obtains the semantics of the target statement, the electronic device may further execute a control instruction corresponding to the semantics according to the semantics of the target statement.
[0180] In some embodiments, a mapping relationship between semantics and control instructions may be pre-stored in the electronic device, for example. After obtaining the semantics of the target statement, the electronic device may determine the control instruction corresponding to the semantics of the target statement according to the semantics of the target statement and the mapping relationship between semantics and control instructions. After determining the control instruction, the electronic device may execute the control instruction so that the electronic device can operate according to the control instruction.
[0181] Exemplarily, taking the semantics of the above target statement as "turn up the volume" as an example, the electronic device may determine that the control instruction corresponding to this semantics is to turn up the volume of the speaker. Therefore, the electronic device can control the volume of the speaker to increase.
[0182] In some embodiments, the above control instruction may also be, for example, an instruction for controlling the electronic device to interact with other electronic devices.
[0183] Exemplarily, taking the semantics of the above target statement as "play song E", the electronic device may send the semantics of the target statement to the server to obtain the playback resource corresponding to song E from the server.
[0184] Figure 6 This is a schematic structural diagram of a training device 400 for an entity disambiguation model provided by the present application. As Figure 6 shown, the device 400 may include: an acquisition module 401, a training module 402. Among them,
[0185] An acquisition module 401 for acquiring a sample data set. The sample data set includes at least one sample data, and each sample data includes: a sample statement, at least one target sample entity of the sample statement, and a subset of sample candidate semantic entities corresponding to the at least one target sample entity. The subset of sample candidate semantic entities includes a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity. The target semantic entity and the non-target semantic entity belong to the same knowledge graph.
[0186] A training module 402 for training an entity disambiguation model using the sample data set to obtain a trained entity disambiguation model. The trained entity disambiguation model is used to obtain the target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.
[0187] In some embodiments, the training module 402 is specifically configured to obtain word vectors of each target sample entity in each sample data and entity vectors of each candidate semantic entity corresponding to each target sample entity; use the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix. The candidate semantic entities include the target semantic entity and the non-target semantic entity corresponding to the target sample entity. The entity disambiguation model is constructed based on the at least one trainable parameter matrix. The trainable parameter matrix is a trainable parameter in the entity disambiguation model.
[0188] In some embodiments, the training module 402 is specifically configured to, for any target sample entity in the same sample statement, obtain the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity according to the word vector of the target sample entity, the entity vectors of each candidate semantic entity corresponding to the target sample entity, and the first trainable parameter matrix; obtain the maximum relevance vector corresponding to the sample statement according to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity; obtain the semantic feature of the sample statement according to the maximum relevance vector corresponding to the sample statement, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement; and train the first trainable parameter matrix and the second trainable parameter matrix according to the semantic feature of the sample statement.
[0189] The maximum relevance vector corresponding to the sample statement includes: the maximum relevance corresponding to each target sample entity in the sample statement; the maximum relevance is the maximum value among the relevances between the target sample entity and each candidate semantic entity corresponding to the target sample entity.
[0190] In some embodiments, the training module 402 is specifically configured to normalize the maximum correlation vector corresponding to the sample statement to obtain a target maximum correlation vector corresponding to the sample statement; and use the product of the target maximum correlation vector, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement as the semantic feature of the sample statement.
[0191] In some embodiments, the training module 402 is specifically configured to obtain the association feature between the sample statement and each candidate semantic entity according to the inner product of the semantic feature of the sample statement and the entity vectors of each candidate semantic entity corresponding to each target sample entity; and train the first trainable parameter matrix and the second trainable parameter matrix according to the association feature between the sample statement and each candidate semantic entity and a preset loss function.
[0192] In some embodiments, the sample statement includes K initial sample entities. In this implementation manner, the obtaining module 401 is further configured to input the K initial sample entities of the sample statement into a preset contribution prediction model before training the entity disambiguation model using the sample data set, to obtain the contribution of each initial sample entity of the sample statement to the semantics of the sample statement; and use the R initial sample entities with the top R contributions to the semantics of the sample statement in descending order of contribution as the target sample entities of the sample statement. Wherein, K is a positive integer greater than 1. R is a positive integer greater than or equal to 1 and less than or equal to K.
[0193] The training device 400 for the entity disambiguation model provided in this embodiment can execute the above-mentioned embodiment of the training method for the entity disambiguation model, and its implementation principle and technical effects are similar, and will not be described in detail here.
[0194] Figure 7 FIG. is a schematic structural diagram of an entity disambiguation device 500 provided in the present application. As Figure 7 shown, the device 500 may include: a first obtaining module 501, a processing module 502, and a second obtaining module 503. Wherein,
[0195] The first obtaining module 501 is configured to obtain at least one target entity of a target statement, and a plurality of candidate semantic entities corresponding to each target entity determined from a knowledge graph.
[0196] A processing module 502 is configured to input each of the target entities and a plurality of candidate semantic entities corresponding to each of the target entities into the trained entity disambiguation model, so as to obtain a target semantic entity corresponding to each of the target entities. Wherein, the trained entity disambiguation model is trained by using the method described in any of the foregoing embodiments. The target semantic entity is any one of the plurality of candidate semantic entities.
[0197] A second acquisition module 503 is configured to acquire the semantics of the target statement according to the target semantic entity corresponding to each target entity.
[0198] In some embodiments, the entity disambiguation device 500 may further include an execution module 504, configured to execute a control instruction corresponding to the semantics according to the semantics of the target statement after acquiring the semantics of the target statement.
[0199] In some embodiments, the first acquisition module 501 is specifically configured to acquire each initial entity of the target statement; when the number of initial entities of the target statement is greater than a preset entity number, acquire a preset number of initial entities from the target statement as the target entities of the target statement. Acquire a plurality of initial candidate semantic entities corresponding to the target entity from the knowledge graph; when the number of initial candidate semantic entities corresponding to the target entity is greater than a preset candidate semantic entity number, acquire a preset number of initial candidate semantic entities from the initial candidate semantic entities as the plurality of candidate semantic entities corresponding to the target entity. Wherein, the preset entity number is an integer greater than or equal to 1. The preset candidate semantic entity number is an integer greater than 1.
[0200] In some embodiments, the entity disambiguation device 500 may further include a receiving module 505, configured to receive a voice signal input by a user before acquiring at least one target entity of the target statement and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge graph; perform speech recognition on the voice signal to obtain the target statement.
[0201] The entity disambiguation device 500 provided in this embodiment can execute the entity disambiguation method embodiment described above, and its implementation principle and technical effect are similar, and will not be elaborated here.
[0202] Figure 8 It is a schematic structural diagram of an electronic device provided by the present invention. As Figure 8 shown, the electronic device 600 may include: at least one processor 601 and a memory 602. Wherein,
[0203] The memory 602 is used to store a program. Specifically, the program may include program code, and the program code includes computer operation instructions.
[0204] The memory 602 may include high-speed RAM memory and may also include non-volatile memory, such as at least one disk memory.
[0205] The processor 601 is configured to execute the computer-executable instructions stored in the memory 602 to implement the training method or entity disambiguation method of the entity disambiguation model described in the foregoing method embodiments. Among them, the processor 601 may be a central processing unit (CPU for short), or an application specific integrated circuit (ASIC for short), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0206] Optionally, the electronic device 600 may further include a communication interface 603. In a specific implementation, if the communication interface 603, the memory 602, and the processor 601 are implemented independently, the communication interface 603, the memory 602, and the processor 601 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0207] Optionally, in a specific implementation, if the communication interface 603, the memory 602, and the processor 601 are integrated on a chip, the communication interface 603, the memory 602, and the processor 601 may communicate through an internal interface.
[0208] The present invention also provides a computer-readable storage medium, which may include: various media that can store program codes, such as a USB flash drive, a portable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc. Specifically, the computer-readable storage medium stores program instructions for the methods in the foregoing embodiments.
[0209] The present application also provides a program product, which includes execution instructions stored in a readable storage medium. At least one processor of the electronic device can read the execution instructions from the readable storage medium, and the execution of the execution instructions by at least one processor enables the electronic device to implement the training method or the entity disambiguation method of the entity disambiguation model provided by the above various embodiments.
[0210] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the various embodiments of the present application.
[0211] For the sake of convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussions are not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. According to the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are for the purpose of better explaining the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
Claims
1. A training method for an entity disambiguation model, characterized in that The method includes: Obtaining a sample data set, where the sample data set includes at least one sample data, and each sample data includes: a sample statement, at least one target sample entity of the sample statement, and a subset of sample candidate semantic entities corresponding to the at least one target sample entity. The subset of sample candidate semantic entities includes a target semantic entity corresponding to each target sample entity, and at least one non-target semantic entity corresponding to each target sample entity. The target semantic entity and the non-target semantic entity belong to the same knowledge graph; Obtaining word vectors of each target sample entity and entity vectors of each candidate semantic entity corresponding to each target sample entity in each sample data; the candidate semantic entities include the target semantic entity and the non-target semantic entity corresponding to the target sample entity; Using the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix, and obtaining a trained entity disambiguation model; the entity disambiguation model is constructed based on the at least one trainable parameter matrix, the trainable parameter matrix is a trainable parameter in the entity disambiguation model, and the trained entity disambiguation model is used to obtain the target semantic entity corresponding to a target entity from multiple candidate semantic entities corresponding to the target entity; The entity disambiguation model includes a first trainable parameter matrix and a second trainable parameter matrix, and the using the word vectors of each target sample entity and the entity vectors of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix includes: For any target sample entity in the same sample statement, obtaining the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity according to the word vector of the target sample entity, the entity vectors of each candidate semantic entity corresponding to the target sample entity, and the first trainable parameter matrix; Obtaining a maximum relevance vector corresponding to the sample statement according to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity; wherein, the maximum relevance vector corresponding to the sample statement includes: the maximum relevance corresponding to each target sample entity in the sample statement; the maximum relevance is the maximum value among the relevances between the target sample entity and each candidate semantic entity corresponding to the target sample entity; Obtaining the semantic feature of the sample statement according to the maximum relevance vector corresponding to the sample statement, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement; Training the first trainable parameter matrix and the second trainable parameter matrix according to the semantic feature of the sample statement.
2. The method according to claim 1, wherein The obtaining the semantic feature of the sample statement according to the maximum relevance vector corresponding to the sample statement, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement includes: Normalize the maximum correlation vector corresponding to the sample statement to obtain the target maximum correlation vector corresponding to the sample statement; Use the product of the target maximum correlation vector, the second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement as the semantic feature of the sample statement.
3. The method according to claim 1, wherein The training of the first trainable parameter matrix and the second trainable parameter matrix according to the semantic feature of the sample statement includes: Obtain the association feature between the sample statement and each candidate semantic entity according to the inner product of the semantic feature of the sample statement and the entity vectors of each candidate semantic entity corresponding to each target sample entity; Train the first trainable parameter matrix and the second trainable parameter matrix according to the association feature between the sample statement and each candidate semantic entity and a preset loss function.
4. The method according to any one of claims 1 to 3, characterized in that, The sample statement includes K initial sample entities, where K is a positive integer greater than 1. Before training the entity disambiguation model using the sample data set, it further includes: Input the K initial sample entities of the sample statement into a preset contribution prediction model to obtain the contribution of each initial sample entity of the sample statement to the semantics of the sample statement; According to the ranking of the contributions from large to small, use the top R initial sample entities with the highest contributions to the semantics of the sample statement as the target sample entities of the sample statement, where R is a positive integer greater than or equal to 1 and less than or equal to K.
5. A method for entity disambiguation, characterized in that The method includes: Obtain at least one target entity of the target statement and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph; Input each target entity and the multiple candidate semantic entities corresponding to each target entity into the trained entity disambiguation model to obtain the target semantic entity corresponding to each target entity; where the trained entity disambiguation model is trained by the method described in any one of claims 1-4; the target semantic entity is any one of the multiple candidate semantic entities; Obtain the semantics of the target statement according to the target semantic entities corresponding to each target entity.
6. The method according to claim 5, wherein After obtaining the semantics of the target statement, it further includes: Execute the control instruction corresponding to the semantics according to the semantics of the target statement.
7. The method according to any one of claims 5-6, characterized in that, The obtaining of at least one target entity of the target statement and multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph includes: Obtain each initial entity of the target statement; If the number of initial entities of the target statement is greater than the preset entity number, obtain the initial entities with the preset entity number from the target statement as the target entities of the target statement; where the preset entity number is an integer greater than or equal to 1; Obtain multiple initial candidate semantic entities corresponding to the target entity from the knowledge graph; If the number of initial candidate semantic entities corresponding to the target entity is greater than the preset number of candidate semantic entities, obtain the initial candidate semantic entities with the preset number of candidate semantic entities from the initial candidate semantic entities as the multiple candidate semantic entities corresponding to the target entity, where the preset number of candidate semantic entities is an integer greater than 1.
8. The method according to any one of claims 5-6, characterized in that, Before obtaining at least one target entity of the target statement and the multiple candidate semantic entities corresponding to each target entity determined from the knowledge graph, it further includes: Receiving a voice signal input by a user; Performing speech recognition on the voice signal to obtain the target statement.
9. A training device for an entity disambiguation model, characterized in that, The device includes: An acquisition module, configured to acquire a sample data set, where the sample data set includes at least one sample data, and each sample data includes: a sample statement, at least one target sample entity of the sample statement, and a sample candidate semantic entity subset corresponding to the at least one target sample entity. The sample candidate semantic entity subset includes a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity. The target semantic entity and the non-target semantic entity belong to the same knowledge graph; A training module, configured to obtain a word vector of each target sample entity in each sample data and an entity vector of each candidate semantic entity corresponding to each target sample entity; the candidate semantic entity includes a target semantic entity and a non-target semantic entity corresponding to the target sample entity; use the word vector of each target sample entity and the entity vector of each candidate semantic entity corresponding to each target sample entity to train at least one trainable parameter matrix to obtain a trained entity disambiguation model; the trained entity disambiguation model is used to obtain the target semantic entity corresponding to the target entity from the multiple candidate semantic entities corresponding to the target entity; The training module is further configured to, for any target sample entity of the same sample statement, obtain the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity according to the word vector of the target sample entity, the entity vector of each candidate semantic entity corresponding to the target sample entity, and a first trainable parameter matrix; obtain the maximum relevance vector corresponding to the sample statement according to the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity; where the maximum relevance vector corresponding to the sample statement includes: the maximum relevance corresponding to each target sample entity in the sample statement; the maximum relevance is the maximum value among the relevance between the target sample entity and each candidate semantic entity corresponding to the target sample entity; obtain the semantic feature of the sample statement according to the maximum relevance vector corresponding to the sample statement, a second trainable parameter matrix, and the word vectors of each target sample entity in the sample statement; train the first trainable parameter matrix and the second trainable parameter matrix according to the semantic feature of the sample statement.
10. An entity disambiguation device, characterized in that, The device includes: A first acquisition module, configured to acquire at least one target entity of a target statement, and a plurality of candidate semantic entities corresponding to each target entity determined from a knowledge graph; A processing module, configured to input each of the target entities and the plurality of candidate semantic entities corresponding to each target entity into the trained entity disambiguation model to obtain a target semantic entity corresponding to each target entity; wherein, the trained entity disambiguation model is trained by using the method according to any one of claims 1-4; the target semantic entity is any one of the plurality of candidate semantic entities; A second acquisition module, configured to acquire the semantics of the target statement according to the target semantic entities corresponding to the respective target entities.
Citation Information
Patent Citations
Vertical domain entity disambiguation method fusing topic model and convolutional neural network
CN112069826A
Statement processing method and device, electronic equipment and storage medium
CN112164391A