Entity disambiguation model training method, entity disambiguation method and device

文档序号:1953463 发布日期:2021-12-10 浏览:16次 中文

阅读说明:本技术 实体消歧模型训练、实体消歧方法及装置 (Entity disambiguation model training method, entity disambiguation method and device ) 是由 殷腾龙 于 2021-09-14 设计创作,主要内容包括:本申请提供一种实体消歧模型训练、实体消歧方法及装置。实体消歧模型训练方法包括:获取包括至少一个样本数据的样本数据集。每个样本数据包括:样本语句、样本语句的至少一个目标样本实体,以及,至少一个目标样本实体对应的样本候选语义实体子集。样本候选语义实体子集中包括每个目标样本实体对应的目标语义实体,以及,每个目标样本实体对应的至少一个非目标语义实体,目标语义实体与非目标语义实体属于同一知识图谱。使用样本数据集对实体消歧模型进行训练,得到训练好的实体消歧模型;训练好的实体消歧模型用于从目标实体对应的多个候选语义实体中获取该目标实体对应的目标语义实体。本申请提高了对目标语句进行语义理解的准确性。(The application provides an entity disambiguation model training method, an entity disambiguation method and an entity disambiguation device. The entity disambiguation model training method comprises the following steps: a sample data set comprising at least one sample data is acquired. Each sample data includes: the semantic entity analysis method comprises the steps of 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 comprises a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity, and the target semantic entities and the non-target semantic entities belong to the same knowledge graph. Training the entity disambiguation model by using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity. The method and the device improve the accuracy of semantic understanding of the target sentence.)

1. A method of training an entity disambiguation model, the method comprising:

obtaining a sample data set, the sample data set comprising at least one sample data, each sample data comprising: the semantic query system comprises 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, wherein the sample candidate semantic entity subset comprises a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity, and the target semantic entity and the non-target semantic entities belong to the same knowledge graph;

training an entity disambiguation model by using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

2. The method of claim 1, wherein training an entity disambiguation model using the sample data set comprises:

obtaining 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 entities comprise target semantic entities and non-target semantic entities corresponding to the target sample entities;

and training at least one trainable parameter matrix by using the word vector of each target sample entity and the entity vector of each candidate semantic entity corresponding to each target sample entity, wherein the entity disambiguation model is constructed based on the at least one trainable parameter matrix, and the trainable parameter matrix is trainable parameters in the entity disambiguation model.

3. The method of claim 2, wherein the entity disambiguation model comprises a first trainable parameter matrix and a second trainable parameter matrix, and wherein using the word vector for each of the target sample entities, the entity vector for each of the candidate semantic entities for each of the target sample entities, and training at least one trainable parameter matrix comprises:

aiming at any target sample entity of the same sample sentence, obtaining the correlation degree of 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;

obtaining a maximum correlation degree vector corresponding to the sample statement according to the correlation degree of the target sample entity and each candidate semantic entity corresponding to the target sample entity; wherein the maximum correlation vector corresponding to the sample statement includes: the maximum correlation degree corresponding to each target sample entity in the sample statement; the maximum correlation is: the maximum value of the correlation degrees of the target sample entity and each candidate semantic entity corresponding to the target sample entity;

obtaining semantic features of the sample sentences according to the maximum relevancy vectors corresponding to the sample sentences, the second trainable parameter matrix and word vectors of all target sample entities in the sample sentences;

and training the first trainable parameter matrix and the second trainable parameter matrix according to the semantic features of the sample sentence.

4. The method of claim 3, wherein obtaining semantic features of the sample sentence according to the maximum relevance vector corresponding to the sample sentence, the second trainable parameter matrix, and a word vector of each target sample entity in the sample sentence comprises:

normalizing the maximum correlation degree vector corresponding to the sample statement to obtain a target maximum correlation degree vector corresponding to the sample statement;

and taking the target maximum correlation vector, the second trainable parameter matrix and the product of the word vectors of all target sample entities in the sample statement as the semantic features of the sample statement.

5. The method of claim 3, wherein training the first trainable parameter matrix and the second trainable parameter matrix based on semantic features of the sample sentence comprises:

obtaining the associated characteristics of the sample sentences and the candidate semantic entities according to the semantic characteristics of the sample sentences and the inner product of the entity vectors of the candidate semantic entities corresponding to the target sample entities;

and training the first trainable parameter matrix and the second trainable parameter matrix according to the correlation characteristics of the sample statement and each candidate semantic entity and a preset loss function.

6. The method of any of claims 1-5, wherein the sample statement includes K initial sample entities, K being a positive integer greater than 1, and further comprising, prior to said training an entity disambiguation model using the sample data set:

inputting K initial sample entities of the sample statement into a preset contribution degree prediction model to obtain the contribution degree of each initial sample entity of the sample statement to the semantics of the sample statement;

and according to the ranking of the contribution degrees from large to small, taking R initial sample entities which are ranked R before the contribution degree of the semantics of the sample statement as target sample entities of the sample statement, wherein R is a positive integer which is greater than or equal to 1 and less than or equal to K.

7. A method of entity disambiguation, the method comprising:

acquiring at least one target entity of a target statement, and determining a plurality of candidate semantic entities corresponding to each target entity from a knowledge graph;

inputting each target entity and a 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 using the method of any of claims 1-6; the target semantic entity is any one of the plurality of candidate semantic entities;

and acquiring the semantics of the target statement according to the target semantic entity corresponding to each target entity.

8. The method of claim 7, wherein after obtaining the semantics of the target sentence, further comprising:

and executing a control instruction corresponding to the semantics according to the semantics of the target statement.

9. The method according to any one of claims 7-8, wherein the obtaining at least one target entity of the target sentence and the plurality of candidate semantic entities corresponding to each target entity determined from the knowledge-graph comprises:

acquiring each initial entity of the target statement;

if the number of the initial entities of the target statement is larger than the preset number of entities, acquiring the initial entities of the preset number of entities from the target statement as the target entities of the target statement; wherein the number of the preset entities is an integer greater than or equal to 1;

acquiring a plurality of initial candidate semantic entities corresponding to the target entity from a knowledge graph;

if the number of the initial candidate semantic entities corresponding to the target entity is greater than the number of the preset candidate semantic entities, acquiring the initial candidate semantic entities with the preset number of the candidate semantic entities from the initial candidate semantic entities as a plurality of candidate semantic entities corresponding to the target entity, wherein the number of the preset candidate semantic entities is an integer greater than 1.

10. The method according to any one of claims 7-8, wherein the obtaining at least one target entity of the target sentence and the determining a plurality of candidate semantic entities corresponding to each target entity from the knowledge-graph further comprise:

receiving a voice signal input by a user;

and carrying out voice recognition on the voice signal to obtain the target sentence.

11. An apparatus for training an entity disambiguation model, the apparatus comprising:

an obtaining module, configured to obtain a sample data set, where the sample data set includes at least one sample data, and each sample data includes: the semantic query system comprises 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, wherein the sample candidate semantic entity subset comprises a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity, and the target semantic entity and the non-target semantic entities belong to the same knowledge graph;

the training module is used for training the entity disambiguation model by using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

12. An entity disambiguation apparatus, the apparatus comprising:

the system comprises a first acquisition module, a second acquisition module and a semantic analysis module, wherein the first acquisition module is used for acquiring at least one target entity of a target sentence and a plurality of candidate semantic entities corresponding to each target entity determined from a knowledge graph;

the processing module is used for inputting each target entity and a 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 using the method of any of claims 1-6; the target semantic entity is any one of the plurality of candidate semantic entities;

and the second acquisition module is used for acquiring the semantics of the target statement according to the target semantic entities corresponding to the target entities.

Technical Field

The embodiment of the application relates to a natural language processing technology. And more particularly, to entity disambiguation model training, entity disambiguation methods, and apparatuses.

Background

The electronic device such as the smart television or the smart refrigerator can receive the voice signal of the user and perform corresponding operation according to the voice signal (for example, output related recommendation, or control the electronic device to perform corresponding operation, etc.). Taking the smart television as an example, after receiving the voice signal of the user, the smart television can convert the voice signal into a corresponding sentence. Then, the smart television can perform semantic understanding on the statement to obtain the semantic corresponding to the statement. According to the corresponding semantics of the statement, the smart television can perform corresponding operations.

The existing semantic understanding method for sentences is mainly semantic understanding based on knowledge graph. The semantic understanding based on the knowledge graph comprises three main steps: 1. identifying a target entity in the statement; 2. acquiring a plurality of candidate semantic entities for explaining the target entity from a preset knowledge graph; 3. the semantics corresponding to the target entity are obtained from the candidate semantic entities (this step is also called entity disambiguation).

However, the existing entity disambiguation method has the problem of poor accuracy, and further, the accuracy of semantic understanding of the sentence may be poor.

Disclosure of Invention

The exemplary embodiment of the application provides an entity disambiguation model training method, an entity disambiguation method and an entity disambiguation device, which can improve the accuracy of semantic understanding of sentences.

In a first aspect, the present application provides a method for training an entity disambiguation model, the method comprising:

obtaining a sample data set, the sample data set comprising at least one sample data, each sample data comprising: the semantic query system comprises 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, wherein the sample candidate semantic entity subset comprises a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity, and the target semantic entity and the non-target semantic entities belong to the same knowledge graph;

training an entity disambiguation model by using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

In some embodiments, said training an entity disambiguation model using said sample data set comprises:

obtaining 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 entities comprise target semantic entities and non-target semantic entities corresponding to the target sample entities;

and training at least one trainable parameter matrix by using the word vector of each target sample entity and the entity vector of each candidate semantic entity corresponding to each target sample entity, wherein the entity disambiguation model is constructed based on the at least one trainable parameter matrix, and the trainable parameter matrix is trainable parameters in the entity disambiguation model.

In some embodiments, the entity disambiguation model comprises a first trainable parameter matrix and a second trainable parameter matrix, the training at least one trainable parameter matrix using the word vector for each of the target sample entities, the entity vector for each candidate semantic entity corresponding to each of the target sample entities comprises:

aiming at any target sample entity of the same sample sentence, obtaining the correlation degree of 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;

obtaining a maximum correlation degree vector corresponding to the sample statement according to the correlation degree of the target sample entity and each candidate semantic entity corresponding to the target sample entity; wherein the maximum correlation vector corresponding to the sample statement includes: the maximum correlation degree corresponding to each target sample entity in the sample statement; the maximum correlation is: the maximum value of the correlation degrees of the target sample entity and each candidate semantic entity corresponding to the target sample entity;

obtaining semantic features of the sample sentences according to the maximum relevancy vectors corresponding to the sample sentences, the second trainable parameter matrix and word vectors of all target sample entities in the sample sentences;

and training the first trainable parameter matrix and the second trainable parameter matrix according to the semantic features of the sample sentence.

In some embodiments, the obtaining semantic features of the sample sentence according to the maximum relevance vector corresponding to the sample sentence, the second trainable parameter matrix, and the word vector of each target sample entity in the sample sentence includes:

normalizing the maximum correlation degree vector corresponding to the sample statement to obtain a target maximum correlation degree vector corresponding to the sample statement;

and taking the target maximum correlation vector, the second trainable parameter matrix and the product of the word vectors of all target sample entities in the sample statement as the semantic features of the sample statement.

In some embodiments, the training the first trainable parameter matrix, the second trainable parameter matrix, according to semantic features of the sample statement comprises:

obtaining the associated characteristics of the sample sentences and the candidate semantic entities according to the semantic characteristics of the sample sentences and the inner product of the entity vectors of the candidate semantic entities corresponding to the target sample entities;

and training the first trainable parameter matrix and the second trainable parameter matrix according to the correlation characteristics of the sample statement and each candidate semantic entity and a preset loss function.

In some embodiments, the sample statement includes K initial sample entities, where K is a positive integer greater than 1, and further includes, before the training an entity disambiguation model using the sample data set:

inputting K initial sample entities of the sample statement into a preset contribution degree prediction model to obtain the contribution degree of each initial sample entity of the sample statement to the semantics of the sample statement;

and according to the ranking of the contribution degrees from large to small, taking R initial sample entities which are ranked R before the contribution degree of the semantics of the sample statement as target sample entities of the sample statement, wherein R is a positive integer which is greater than or equal to 1 and less than or equal to K.

In a second aspect, the present application provides a method of entity disambiguation, the method comprising:

acquiring at least one target entity of a target statement, and determining a plurality of candidate semantic entities corresponding to each target entity from a knowledge graph;

inputting each target entity and a 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 obtained by training using the method according to any one of the first aspect; the target semantic entity is any one v of the candidate semantic entities

And acquiring the semantics of the target statement according to the target semantic entity corresponding to each target entity.

In some embodiments, after obtaining the semantics of the target sentence, the method further includes:

and executing a control instruction corresponding to the semantics according to the semantics of the target statement.

In some embodiments, the obtaining at least one target entity of the target sentence and the plurality of candidate semantic entities corresponding to each target entity determined from the knowledge-graph includes:

acquiring each initial entity of the target statement;

if the number of the initial entities of the target statement is larger than the preset number of entities, acquiring the initial entities of the preset number of entities from the target statement as the target entities of the target statement; wherein the number of the preset entities is an integer greater than or equal to 1;

acquiring a plurality of initial candidate semantic entities corresponding to the target entity from a knowledge graph;

if the number of the initial candidate semantic entities corresponding to the target entity is greater than the number of the preset candidate semantic entities, acquiring the initial candidate semantic entities with the preset number of the candidate semantic entities from the initial candidate semantic entities as a plurality of candidate semantic entities corresponding to the target entity, wherein the number of the preset candidate semantic entities is an integer greater than 1.

In some embodiments, before the obtaining at least one target entity of the target sentence and the plurality of candidate semantic entities corresponding to each target entity determined from the knowledge-graph, the method further includes:

receiving a voice signal input by a user;

and carrying out voice recognition on the voice signal to obtain the target sentence.

In a third aspect, the present application provides an apparatus for training an entity disambiguation model, the apparatus comprising:

an obtaining module, configured to obtain a sample data set, where the sample data set includes at least one sample data, and each sample data includes: the semantic query system comprises 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, wherein the sample candidate semantic entity subset comprises a target semantic entity corresponding to each target sample entity and at least one non-target semantic entity corresponding to each target sample entity, and the target semantic entity and the non-target semantic entities belong to the same knowledge graph;

the training module is used for training the entity disambiguation model by using the sample data set to obtain a trained entity disambiguation model; the trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

In a fourth aspect, the present application provides an entity disambiguation apparatus, the apparatus comprising:

the system comprises a first acquisition module, a second acquisition module and a semantic analysis module, wherein the first acquisition module is used for acquiring at least one target entity of a target sentence and a plurality of candidate semantic entities corresponding to each target entity determined from a knowledge graph;

the processing module is used for inputting each target entity and a 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 obtained by training using the method according to any one of the first aspect; the target semantic entity is any one of the plurality of candidate semantic entities;

and the second acquisition module is used for acquiring the semantics of the target statement according to the target semantic entities corresponding to the target entities.

In a fifth aspect, the present application provides an electronic device, comprising: at least one processor, a memory;

the memory stores computer-executable instructions;

the at least one processor executes computer-executable instructions stored by the memory to cause the electronic device to perform the method of any of the first or second aspects.

In a sixth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions that, when executed by a processor, implement the method of any one of the first or second aspects.

In a seventh aspect, the present application provides a computer program product comprising a computer program that, when executed by a processor, implements the method of any of the first or second aspects.

The entity disambiguation model training method and the entity disambiguation method and device provided by the application train the entity disambiguation model by using at least one target sample entity comprising a sample statement and a sample data set of a sample candidate semantic entity subset corresponding to the target sample entity. The sample candidate semantic entity subset comprises a target semantic entity corresponding to the target sample entity and a non-target semantic entity. And training the entity disambiguation model through the sample data set, so that the entity disambiguation model can learn the association relationship between each target sample entity of the sample sentence and 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 entity number associated with the candidate semantic entity, the semantic of the sentence is determined by using the trained entity disambiguation model, and when the semantic of the target entity is determined, the semantic accuracy of the target entity is improved by combining the characteristics of the target sentence in which the target entity is located, namely the accuracy of entity disambiguation is improved, and the accuracy of semantic understanding of the target sentence is improved.

Drawings

In order to more clearly illustrate the embodiments of the present application or the implementation manner in the related art, a brief description will be given below of the drawings required for the description of the embodiments or the related art, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art according to the drawings.

FIG. 1 is a schematic view of a scenario in which a user interacts with a display device in a voice manner according to the present application;

FIG. 2 is a schematic flow chart illustrating a method for training an entity disambiguation model provided in the present application;

FIG. 3 is a schematic flow chart of another method for training an entity disambiguation model provided herein;

FIG. 4 is a schematic flow chart illustrating a method for training an entity disambiguation model provided herein;

FIG. 5 is a schematic flow chart of an entity disambiguation method provided herein;

FIG. 6 is a schematic diagram of an apparatus 400 for training an entity disambiguation model provided in the present application;

fig. 7 is a schematic structural diagram of an entity disambiguation apparatus 500 provided in the present application;

fig. 8 is a schematic structural diagram of an electronic device provided in the present invention.

Detailed Description

To make the objects, embodiments and advantages of the present application clearer, the following description of exemplary embodiments of the present application will clearly and completely describe the exemplary embodiments of the present application with reference to the accompanying drawings in the exemplary embodiments of the present application, and it is to be understood that the described exemplary embodiments are only a part of the embodiments of the present application, and not all of the embodiments.

All other embodiments, which can be derived by a person skilled in the art from the exemplary embodiments described herein without inventive step, are intended to be within the scope of the claims appended hereto. In addition, while the disclosure herein has been presented in terms of one or more exemplary examples, it should be appreciated that aspects of the disclosure may be implemented solely as a complete embodiment.

It should be noted that the brief descriptions of the terms in the present application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of the present application. These terms should be understood in their ordinary and customary meaning unless otherwise indicated.

The terms "first", "second", "third", and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between similar or analogous objects or entities and are not necessarily meant to define a particular order or sequence Unless otherwise indicated. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein.

Furthermore, the terms "comprises" and "comprising," as well as any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or device that comprises a list of elements is not necessarily limited to those elements explicitly listed, but may include other elements not expressly listed or inherent to such product or device.

The term "module" as used herein refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and/or software code that is capable of performing the functionality associated with that element.

The following explains the concept of nouns to which the present application relates:

knowledge graph: a knowledge-graph includes at least two entities (which may also be referred to as nodes) and whether there is an associative relationship between the different entities.

Semantic contribution degree the semantic contribution degree refers to the degree of influence of a word in a sentence on the sentence semantics. For example, the influence of the semantic terms such as "one", "two", "o", etc. on the sentence semantics is generally small, that is, the contribution of these semantic terms to the sentence semantics is small.

With the development of scientific technology, more and more electronic devices can perform voice interaction with users. Taking the above electronic device as a display device (e.g., a smart television) as an example, fig. 1 is a schematic view of a scene where a user performs voice interaction with the display device according to the present application. As shown in fig. 1, the display device 200 may receive a voice signal of a user and perform a corresponding operation on the display device 200 according to the voice signal.

Illustratively, the display device 200 may perform content recommendation related to the semantics, or play video related to the semantics, or perform control such as volume adjustment, for example, according to the semantics corresponding to the user voice signal.

In some embodiments, as shown in fig. 1, the display apparatus 200 may transmit a voice signal of a user to the server 400 through the internet after receiving the voice signal. The server 400 may first determine the semantics of the speech signal. Then, according to the semantic meaning of the voice signal, an operation instruction corresponding to the voice signal is determined, and the operation instruction is sent to the display device 200. Then, the display apparatus 200 may control the display apparatus 200 according to the operation instruction.

In some embodiments, the display device 200 may further store a voice signal processing algorithm therein. Through the voice signal processing algorithm, the display apparatus 200 can acquire the semantics of the user voice signal. Then, the display device 200 may determine an operation instruction corresponding to the voice signal according to the semantic meaning of the voice signal, and then control the display device 200 according to the operation instruction.

It should be understood that fig. 1 is only an exemplary illustration of a voice interaction scenario, taking an electronic device as an example of a display device. In a specific implementation, the electronic device may be, for example, another terminal having a processing function, a server, or the like. For example, smart homes such as smart televisions, smart refrigerators, and smart stereos, or electronic devices such as mobile phones, tablet computers, notebook computers, desktop computers, and smart watches.

As mentioned above, after receiving a voice signal of a user, the electronic device needs to determine the corresponding semantics of the voice signal before performing corresponding operations. For the process of determining the corresponding semantics of the speech signal, in some embodiments, the electronic device may first convert the received speech signal into a corresponding sentence. Then, the electronic device can perform semantic understanding on the sentence to obtain the semantic corresponding to the sentence (i.e. the semantic corresponding to the voice signal).

The existing semantic understanding method for sentences is mainly semantic understanding based on knowledge graph. The semantic understanding based on the knowledge graph comprises the following three main steps:

1. and entity recognition, wherein the entity recognition refers to recognizing each word in a sentence and taking each word in the sentence as a target entity of the sentence.

Illustratively, taking the sentence "i want to buy the skin of the game character" as an example, the electronic device can identify the target entities of the sentence, such as "i", "want", "buy", "game", "character", "skin", and the like, through the entity identification algorithm.

2. And entity linking, wherein entity linking refers to acquiring a plurality of candidate semantic entities associated with any target entity in a preset knowledge graph. The candidate semantic entities may be used to interpret the target entity, that is, the candidate semantic entities may be used as semantics of the target entity.

For example, in the example of the "skin" target entity in the above example sentence, the electronic device may obtain, in the preset knowledge graph, a plurality of entities having an association relationship with the "skin" entity as candidate semantic entities of the "skin". For example, the semantic entity candidates for "skin" may include "organ", "game", "charm" and so on.

3. The entity is disambiguated. Entity disambiguation refers to determining a semantic entity capable of expressing a target entity corresponding to a target entity from a plurality of candidate semantic entities of the target entity.

For example, taking the candidate semantic entities corresponding to the "skin" target entity as "organs", "games", "accessories" waiting to select semantic entities as an example, the electronic device needs to determine the semantic entities of "skin" from the "organs", "games", "accessories" waiting to select semantic entities by an entity disambiguation method.

At present, the existing entity disambiguation method mainly comprises: for any candidate semantic entity, determining the number of entities in the knowledge-graph associated with the candidate semantic entity. And taking the candidate semantic entity with the largest number of associated entities as the semantic entity of the target entity.

However, in fact, there may also be candidate semantic entities whose actual semantics of the target entity are not the largest number of associated entities. Therefore, the accuracy of determining the semantic entities of the target entity based on the number of the entities in the knowledge graph, which are associated with the candidate semantic entities, is poor, and the accuracy of performing semantic understanding on the sentence where the target entity is located may be poor.

Illustratively, still taking the example that the candidate semantic entities corresponding to the "skin" target entity include "organ", "game", "ornament" waiting for selecting semantic entities, it is assumed that the number of entities associated with each of the candidate semantic entities is as shown in table 1 below:

TABLE 1

Serial number Candidate semantic entities Number of associated entities
1 Organ Number 1
2 Game machine Number 2
3 Ornament (A) Number 3

As shown in Table 1, assuming that number 1 is greater than number 2 and number 2 is greater than number 3, the semantic entity of "skin" can be determined to be an "organ". That is, the skin in the sentence refers to an organ, and the semantic is different from the actual semantic (the actual semantic should be a game ornament) that the "skin" in the sentence is intended to express. Therefore, the existing entity disambiguation methods are less accurate.

The inventor finds through research that the accurate semantics of the target entity are often related to other entities in the sentence in which the target entity is located. For example, the exact semantic meaning of "skin" in the above example is a game ornament, while a game ornament entity exists in the sentence where "skin" is located.

In view of this, the present application provides a method for determining a semantic entity of a target entity based on a sentence where the target entity is located to improve accuracy of entity disambiguation. The method inputs each target entity of a target sentence and the candidate semantic entities corresponding to each target entity into a trained entity disambiguation model to obtain the target semantic entities of each target entity in the target sentence. The trained entity disambiguation model is obtained by training each target sample entity based on the sample sentence and the candidate semantic entity corresponding to each target sample entity. By the method, the target semantic entities of the target entities can be determined by combining the target entities of the target sentences, the influence of other entities in the target sentences where the target entities are located on the semantics of the target entities is considered, and compared with the prior art that the semantic entities of the target entities are determined only on the basis of the entity number associated with each candidate semantic entity in the knowledge graph, the method improves the accuracy of determining the semantics of the target entities, namely the accuracy of entity disambiguation, and further improves the accuracy of semantic understanding of the target sentences.

It should be understood that the main body of the training method of the entity disambiguation model may be the same electronic device or different electronic devices.

The following describes in detail a technical solution for training the entity disambiguation model according to the present application with reference to specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.

Fig. 2 is a schematic flowchart of a training method of an entity disambiguation model provided in the present application. As shown in fig. 2, the method comprises the steps of:

s101, acquiring a sample data set.

Wherein the sample data set comprises at least one sample data. Each of the above sample data includes: the semantic entity analysis method comprises the steps of 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 entities and the non-target semantic entities belong to the same knowledge graph.

In the sample data set, the number of target sample entities of different sample statements may be the same or different. The number of non-target semantic entities corresponding to different target sample entities may be the same or different. The "different target sample entities" may be target sample entities belonging to the same sample sentence, or may be target sample entities belonging to different sample sentences.

The target semantic entity corresponding to the target sample entity refers to the actual semantics of the target sample entity. The at least one non-target semantic entity corresponding to the target sample entity refers to a candidate semantic entity except the target semantic entity in the candidate semantic entities corresponding to the target sample entity. In some embodiments, the knowledge graph may be constructed based on the terms of at least one website and the association relationship between different terms, for example. It should be understood that the present application is not limited to the implementation of constructing the above-described knowledge graph. In specific implementation, the existing implementation manner of constructing the knowledge graph may be referred to, and details are not repeated herein.

As a possible implementation, the electronic device may directly receive a sample data set input by a user. For example, the electronic device may receive a sample data set input by a User through an Application Programming Interface (API) or a Graphical User Interface (GUI).

As another possible implementation, the electronic device may also receive at least one sample sentence input by the user. After receiving the sample sentences input by the user, the electronic device may obtain at least one target sample entity of each sample sentence through a preset entity recognition algorithm (which may also be referred to as a word segmentation algorithm).

For example, the preset entity recognition algorithm may be an ansj entity recognition algorithm, a jieba entity recognition algorithm, a hand entity recognition algorithm, an entity recognition algorithm based on a Long Short Term Memory network (LSTM), an entity recognition algorithm based on a Conditional Random Field (CRF), and the like. The specific implementation manner of each preset entity identification algorithm may refer to the existing implementation manner, and is not described herein again.

In this implementation manner, after acquiring at least one target sample entity of a sample sentence, the electronic device may acquire a sample candidate semantic entity subset corresponding to each target sample entity from the knowledge graph through a preset entity link algorithm. The preset entity link algorithm is used for acquiring a candidate semantic entity corresponding to a target sample entity according to the target sample entity. The preset entity linking algorithm may refer to the existing implementation manner, and is not described herein again.

After determining the sample candidate semantic entity subset, the electronic device may receive a positive sample label, or a negative sample label, entered by the user for a different candidate semantic entity. The candidate semantic entity with the positive sample label is a target semantic entity corresponding to the target sample entity, and the candidate semantic entity with the negative sample label is a non-target semantic entity corresponding to the target sample entity. It should be understood that the present application does not limit the specific form of the positive and negative swatch labels described above. Illustratively, a positive sample label may be represented by the number "1", for example. The negative example label may be represented by the number "0", for example.

Then, the sample statement acquired by the electronic device, 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 may be used as a sample data set.

S102, training the entity disambiguation model by using the sample data set to obtain the trained entity disambiguation model.

The trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

In some embodiments, the entity disambiguation model described above may be an existing neural network model. The electronic device may train the neural network model using the sample data set to obtain a trained entity disambiguation model.

In some embodiments, the entity disambiguation model may be further constructed based on at least one trainable parameter matrix. In this implementation, the entity disambiguation model is trained using the sample data set, or in other words, the at least one trainable parameter matrix is trained using the sample data set, so as to change the value of each trainable parameter matrix until the trained entity disambiguation model is obtained.

In some embodiments, the entity disambiguation model described above may be pre-stored by the user in the electronic device.

As a possible implementation, after obtaining the sample data set, the electronic device may directly use the sample data set to train the entity disambiguation model.

As another possible implementation manner, the target sample entity of the sample statement in the sample data set may be an entity with a higher 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 may further use an entity with a higher contribution degree to the semantics of the sample sentence as a target sample entity of the sample sentence. The entity disambiguation model is trained by the target sample entity based on the sample statement with higher semantic contribution, so that the data volume of data using the target sample entity is reduced, and the speed of training the entity disambiguation model is improved. In addition, because the entity which is deleted from the sample data set and has low contribution degree to the semantics of the sample statement, that is, the deleted entity has small influence on the semantic understanding of the statement, the accuracy of training the entity disambiguation model can still be ensured by the method.

In this implementation, 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, the electronic device may input the K initial sample entities of the sample statement to a preset contribution degree prediction model, so as to obtain a contribution degree of each initial sample entity of the sample statement to semantics of the sample statement. For example, the preset contribution prediction model may be an existing attention mechanism model constructed based on a neural network. The attention mechanism model may output, based on the input statement, the degree of contribution of each entity in the statement to the semantics of the statement.

Then, the electronic device may use R initial sample entities ranked R before the contribution degree to the semantics of the sample sentence as target sample entities of the sample sentence according to the ranking of the contribution degrees from large to small. Wherein R is a positive integer greater than or equal to 1 and less than or equal to K.

If the number of target sample entities of a sample statement is greater than K, in some embodiments, the electronic device may further divide the sample statement whose number of target sample entities is greater than K into a plurality of sample statements, so that the number of target sample entities of each sample statement is less than or equal to K. The electronic device may then use the sample data set to train the entity disambiguation model in the manner described above.

In this embodiment, the entity disambiguation model is trained using a sample data set comprising a sample statement, at least one target sample entity of the sample statement, and a subset of sample candidate semantic entities corresponding to the target sample entity. The sample candidate semantic entity subset comprises a target semantic entity corresponding to the target sample entity and a non-target semantic entity. And training the entity disambiguation model through the sample data set, so that the entity disambiguation model can learn the association relationship between each target sample entity of the sample sentence and 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 entity number associated with the candidate semantic entity, the semantic of the sentence is determined by using the trained entity disambiguation model, and when the semantic of the target entity is determined, the semantic accuracy of the target entity is improved by combining the characteristics of the target sentence in which the target entity is located, namely the accuracy of entity disambiguation is improved, and the accuracy of semantic understanding of the target sentence is improved.

The following describes in detail how the entity disambiguation model is trained using the sample data set described above. Fig. 3 is a schematic flowchart of another training method for entity disambiguation models provided in the present application. As shown in fig. 3, the method comprises the steps of:

s201, obtaining 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 entities comprise target semantic entities and non-target semantic entities corresponding to the target sample entities.

In some embodiments, the electronic device may input the target sample entity and the candidate semantic entity into a preset word vector generation model, so as to obtain a word vector of the target sample entity and an entity vector of the candidate semantic entity. The preset word vector generation model is used for generating a word vector corresponding to an input entity according to the entity.

For example, the preset Word vector generation model may be any existing Word2vec (full Word to vector) model.

It should be understood that the present application does not limit the dimension of the word vector of the target sample entity and the dimension of the entity vector of the candidate semantic entity. Illustratively, the dimension of the word vector of the target sample entity, and the dimension of the entity vector of the candidate semantic entity may each be 300 dimensions.

S202, training at least one trainable parameter matrix by using the word vector of each target sample entity and the entity vector of each candidate semantic entity corresponding to each target sample entity.

Wherein the entity disambiguation model is constructed based on the at least one trainable parameter matrix. The trainable parameter matrix is the trainable parameters in the entity disambiguation model.

In the following, taking an example that the entity disambiguation model includes a first trainable parameter matrix and a second trainable parameter matrix, how the electronic device uses the word vector of each target sample entity, the entity vector of each candidate semantic entity corresponding to each target sample entity, and trains the first trainable parameter matrix and the second trainable parameter matrix will be described in detail.

Fig. 4 is a schematic flowchart of a training method of an entity disambiguation model provided in the present application. As a possible implementation manner, the step S202 may include the following steps:

s2021, for any target sample entity of the same sample sentence, obtaining a correlation 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.

Wherein, the higher the degree of correlation between the target sample entity and the candidate semantic entity is, the closer the candidate semantic entity is to the actual semantics of the target sample entity.

As a possible implementation manner, the electronic device may obtain, according to the word vector of the target sample entity, the entity vectors of the candidate semantic entities corresponding to the target sample entity, and the first trainable parameter matrix, the correlation degree between the target sample entity and each candidate semantic entity corresponding to the target sample entity through the following formula (1).

Wherein x isωA matrix of word vectors representing all target sample entities of a sample statement. A denotes a first trainable parameter matrix. x is the number ofeAn entity direction representing each candidate semantic entity corresponding to each target sample entityA matrix of quantities. U (ω) represents the degree of correlation 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 initial values of the first trainable parameter matrix are not limited in this application. For example, the electronic device may determine the initial values of the first trainable parameter matrix in a random manner, for example.

S2022, obtaining a maximum correlation vector corresponding to the sample statement according to the correlation of the target sample entity and each candidate semantic entity corresponding to the target sample entity.

The maximum correlation vector corresponding to the sample statement includes: and the maximum correlation corresponding to each target sample entity in the sample statement. The maximum correlation degree is the maximum value in the correlation degrees of the target sample entity and each candidate semantic entity corresponding to the target sample entity.

For example, the electronic device may 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 through the following formula (2).

u(ω)=maxU(ω) (2)

Wherein u (ω) represents the maximum correlation vector corresponding to the sample statement. max represents the maximum correlation corresponding to each target sample entity in the acquisition U (ω).

S2023, obtaining semantic features of the sample sentences according to the maximum correlation degree vector corresponding to the sample sentences, the second trainable parameter matrix and word vectors of all target sample entities in the sample sentences.

As a possible implementation manner, after normalizing the maximum relevance vector corresponding to the sample sentence, the electronic device may determine the semantic features of the sample sentence according to the second trainable parameter matrix and the word vectors of each target sample entity in the sample sentence. By carrying out normalization processing on the maximum correlation degree vector corresponding to the sample sentence, the size difference of different values in the maximum correlation degree vector can be reduced, the influence of a value with a large value on a training process due to overlarge size difference is avoided, and the accuracy of training the entity disambiguation model is improved.

In some embodiments, the electronic device may first perform normalization processing on the maximum relevance vector corresponding to the sample statement to obtain a target maximum relevance vector corresponding to the sample statement. For example, the electronic device may perform normalization processing on any value of the maximum relevance vector corresponding to the sample statement through the following formula (3).

Where r represents any value of the maximum correlation vector corresponding to the sample statement. R is the number of target sample entities (i.e. the dimension of the maximum correlation vector) of the sample statement. β (r) represents a result of normalization processing of any value of the maximum correlation degree vector.

Each value of the maximum correlation vector corresponding to the sample sentence is normalized by the above formula (3), and the target maximum correlation vector β (ω) corresponding to the sample sentence can be obtained.

The electronic device may then take the target maximum relevance vector, the second trainable parameter matrix, and a product of the word vectors for each target sample entity in the sample statement as semantic features of the sample statement. In some embodiments, the electronic device may obtain the semantic features of the sample sentence by equation (4) below.

xc=β(ω)Bxω (4)

Wherein β (ω) represents a target maximum correlation vector corresponding to the sample statement, B represents a second trainable parameter matrix, xωA matrix of word vectors representing all target sample entities of a sample statement. x is the number ofcRepresenting semantic features of the sample sentence. It should be understood that the initial values of the second trainable parameter matrix are not limited in this application. For example, the electronic device may determine the initial values of the second trainable parameter matrix in a random manner, for example.

S2024, training the first trainable parameter matrix and the second trainable parameter matrix according to the semantic features of the sample sentences.

As a possible implementation manner, the electronic device may first obtain the associated features of the sample sentence and each candidate semantic entity according to the inner product of the semantic features of the sample sentence and the entity vectors of each candidate semantic entity corresponding to each target sample entity. In some embodiments, the electronic device may obtain the association characteristics of the sample sentence and each candidate semantic entity through the following formula (5).

Wherein x iseAnd the matrix is composed of entity vectors of candidate semantic entities corresponding to target sample entities of the sample statement. x is the number ofcRepresenting semantic features of the sample sentence.And representing the associated characteristics of the sample statement and each candidate semantic entity.

Then, the electronic device may train the first trainable parameter matrix and the second trainable parameter matrix according to the association features of the sample statement and each candidate semantic entity and a preset loss function.

In some embodiments, the predetermined loss function may be, for example, a maximum-spacing-method loss function, or other existing types of loss functions. Taking the preset loss function as the maximum interval method loss function as an example, the preset loss function can be represented by the following formula (6), for example:

where γ represents a variable in the preset loss function, that is, the value of γ is variable during training. In some embodiments, the value of γ may be the rootAnd changing according to a preset rule. The preset rule may refer to a variation rule of γ in the existing maximum interval method loss function, and is not described herein again. e.g. of the type*And the matrix is composed of entity vectors of the target semantic entities corresponding to all the target sample entities. And e represents a matrix formed by entity vectors of non-target semantic entities corresponding to all target sample entities. C represents the semantic features of the sample sentence.Representing the associated features of the sample statement and the target semantic entity,representing the associated features of the sample statement and the non-target semantic entities. f represents the value of the loss function. In the model training process, as the number of training rounds increases, the f can be gradually reduced and then changed within a preset range.

In the training process, a gradient descent algorithm can be adopted for the first trainable parameter matrix and the second trainable parameter matrix to update the parameter values.

It should be understood that the above embodiments are exemplary illustrations of how the entity disambiguation model may be trained, taking as an example the inclusion of a first trainable parameter matrix and a second trainable parameter matrix in the entity disambiguation model. In a specific implementation, the entity disambiguation model may further include one trainable parameter matrix component, and more than two trainable parameter matrices, which is not limited in the present application. When the entity disambiguation model further includes one trainable parameter matrix, or more than two trainable parameter matrices, the specific implementation manner thereof may refer to the method described in the above embodiment, and details are not described herein again.

After the trained entity disambiguation model is obtained, the entity disambiguation model may be used to obtain a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

In this embodiment, the word vectors of the target sample entities of the sample sentence, the entity vectors of the candidate semantic entities corresponding to the target sample entities, and the trainable parameter matrix may be used to characterize the semantic features of the sample sentence. By the method, when the entity disambiguation model is trained, the entity disambiguation model can continuously learn the incidence relation between the semantic features of the sample sentences and the entity vectors of the candidate semantic entities corresponding to the target sample entity, so that the trained entity disambiguation model has the capability of determining the target semantic entities corresponding to the target entity by combining the sample sentences, and the accuracy of determining the semantics of the target entity is improved.

How to use the trained entity disambiguation model for entity disambiguation in the present application will be described in detail with reference to specific embodiments below. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.

Fig. 5 is a flowchart illustrating an entity disambiguation method provided in the present application. As shown in fig. 5, the method comprises the steps of:

s301, at least one target entity of the target statement is obtained, and a plurality of candidate semantic entities corresponding to the target entities are determined from the knowledge graph.

As a first possible implementation manner, before step S301, the electronic device may first acquire a target sentence, and then acquire at least one target entity of the target sentence according to the acquired target sentence, and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge graph.

In this implementation manner, in some embodiments, the electronic device may receive a voice signal input by a user, and perform voice recognition on the voice signal to obtain the target sentence. For example, the electronic device may perform speech recognition on a speech signal through a trained neural network model stored in the electronic device in advance to obtain a target sentence corresponding to the speech signal. The trained neural network model can convert the voice signal into a target statement.

In some embodiments, the electronic device may also receive a target sentence input by the user. Illustratively, the electronic device may receive a target sentence input by a user, for example, through a GUI, an API, or the like.

After obtaining the target sentence, in some embodiments, the electronic device may obtain at least one target entity of the target sentence through a preset entity recognition algorithm; and acquiring a plurality of candidate semantic entities corresponding to each target entity from the knowledge graph through a preset entity link algorithm. The specific implementation manner may refer to the method described in the foregoing embodiment, and details are not described herein.

As a second possible implementation, the electronic device may directly receive at least one target entity of the target sentence input by the user. And then acquiring a plurality of candidate semantic entities corresponding to each target entity from the knowledge graph through a preset entity link algorithm.

As a third possible implementation manner, the electronic device may directly receive at least one target entity of the target sentence input by the user, and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge graph.

As a fourth possible implementation manner, the electronic device may further limit the number of target entities of the target sentence, so as to avoid that the sentence length of the target sentence processed by the electronic device is too long, which leads to a decrease in the accuracy of semantic understanding of the sentence, and improve the accuracy of semantic understanding of the target sentence. The electronic device may further 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.

In this implementation, for example, the electronic device may first obtain each initial entity of the target sentence. All words of the target sentence can be used as initial entities of the target sentence. Then, the electronic device may determine whether the number of initial entities of the target sentence is greater than a preset number of entities.

If the number of the initial entities is greater than the preset number of entities, the electronic device may obtain the initial entities with the preset number of entities from the target sentence as the target entities of the target sentence. Wherein, the number of the preset entities is an integer greater than or equal to 1. In some embodiments, the electronic device may take a preset number of initial entities before the target sentence as the target entity of the target sentence.

If the number of the 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 sentence as the target entities of the target sentence.

After obtaining the target entity of the target sentence, the electronic device may, for example, obtain a plurality of initial candidate semantic entities corresponding to the target entity 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 a preset number of candidate semantic entities.

If the number of the initial candidate semantic entities corresponding to the target entity is greater than the number of the preset candidate semantic entities, the electronic device may obtain the initial candidate semantic entities with the preset number of the candidate semantic entities from the initial candidate semantic entities as a plurality of candidate semantic entities corresponding to the target entity. Wherein, the number of the preset candidate semantic entities is an integer greater than 1.

In some embodiments, the electronic device may randomly select an initial candidate semantic entity with a preset number of candidate semantic entities from the initial candidate semantic entities as a plurality of candidate semantic entities corresponding to the target entity. Or, the electronic device may further select an initial candidate semantic entity with a preset number of candidate semantic entities from the initial candidate semantic entities by using a preset candidate semantic entity preprocessing method, and use the initial candidate semantic entity as a plurality of candidate semantic entities corresponding to the target entity. The preset candidate semantic entity preprocessing method is used for selecting a preset number of candidate semantic entities from a plurality of initial candidate semantic entities.

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.

S302, inputting each target entity and a plurality of 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.

The trained entity disambiguation model is obtained by adopting the entity disambiguation model training method in any one of the embodiments. The target semantic entity is any one of a plurality of candidate semantic entities.

S303, obtaining the semantics of the target sentence according to the target semantic entities corresponding to the target entities.

The target semantic entity corresponding to the target entity may represent the semantics of the target entity. In some embodiments, the electronic device may, for example, treat the corresponding target semantic entity of each target entity as the semantic of the target statement.

In this embodiment, the target semantic entities of the target sentence are determined by the trained entity disambiguation model. Compared with the prior art, the method and the device have the advantages that the characteristics of the target sentence where the target entity is located are combined, the accuracy of determining the target semantic entity of the target entity is improved, namely, the accuracy of semantic understanding of the target entity is improved, the accuracy of determining the semantics of the target sentence according to the target entity is improved, and therefore user experience is improved.

As a possible implementation manner, after the electronic device acquires the semantics of the target sentence, the electronic device may further execute a control instruction corresponding to the semantics according to the semantics of the target sentence.

In some embodiments, for example, a mapping relationship between semantics and control instructions may be stored in the electronic device in advance. After obtaining the semantics of the target sentence, the electronic device may determine, according to the semantics of the target sentence and the mapping relationship between the semantics and the control instruction, the control instruction corresponding to the semantics of the target sentence. After determining the control instruction, the electronic device may execute the control instruction so that the electronic device may operate according to the control instruction.

For example, in the case that the semantic of the target sentence is "turn up the volume", the electronic device may determine that the control instruction corresponding to the semantic is to turn up the volume of the speaker. Thus, the electronic device may control the volume of the speaker to increase.

In some embodiments, the control instruction may also be an instruction for controlling the electronic device to interact with other electronic devices, for example.

For example, if the semantic of the target sentence is "play E song", the electronic device may send the semantic of the target sentence to the server to obtain a play resource corresponding to the E song from the server.

Fig. 6 is a schematic structural diagram of a training apparatus 400 for an entity disambiguation model provided in the present application. As shown in fig. 6, the apparatus 400 may include: an acquisition module 401 and a training module 402. Wherein the content of the first and second substances,

an obtaining module 401, configured to obtain a sample data set. Wherein the set of sample data comprises at least one sample data, each comprising: the semantic entity recognition method comprises 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 comprises 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 402, configured to train the entity disambiguation model using the sample data set, to obtain a trained entity disambiguation model. The trained entity disambiguation model is used for acquiring a target semantic entity corresponding to a target entity from a plurality of candidate semantic entities corresponding to the target entity.

In some embodiments, the training module 402 is specifically 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; and training at least one trainable parameter matrix by using the word vector of each target sample entity and the entity vector of each candidate semantic entity corresponding to each target sample entity. The candidate semantic entities comprise target semantic entities and non-target semantic entities corresponding to the target sample entities. The entity disambiguation model is constructed based on the at least one trainable parameter matrix. The trainable parameter matrix is trainable parameters in the entity disambiguation model.

In some embodiments, the training module 402 is specifically configured to, for any target sample entity of the same sample sentence, obtain a correlation degree 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; obtaining a maximum correlation degree vector corresponding to the sample statement according to the correlation degree of the target sample entity and each candidate semantic entity corresponding to the target sample entity; obtaining semantic features of the sample sentences according to the maximum relevancy vectors corresponding to the sample sentences, the second trainable parameter matrix and word vectors of all target sample entities in the sample sentences; and training the first trainable parameter matrix and the second trainable parameter matrix according to the semantic features of the sample sentence.

Wherein the maximum correlation vector corresponding to the sample statement includes: the maximum correlation degree corresponding to each target sample entity in the sample statement; the maximum correlation is: and the maximum value of the correlation degrees of the target sample entity and each candidate semantic entity corresponding to the target sample entity.

In some embodiments, the training module 402 is specifically configured to perform normalization processing on the maximum correlation vector corresponding to the sample sentence, so as to obtain a target maximum correlation vector corresponding to the sample sentence; and taking the target maximum correlation vector, the second trainable parameter matrix and the product of the word vectors of all target sample entities in the sample statement as the semantic features of the sample statement.

In some embodiments, the training module 402 is specifically configured to obtain, according to an inner product of the semantic features of the sample sentence and entity vectors of candidate semantic entities corresponding to the target sample entities, associated features of the sample sentence and the candidate semantic entities; and training the first trainable parameter matrix and the second trainable parameter matrix according to the correlation characteristics of the sample statement and each candidate semantic entity and a preset loss function.

In some embodiments, the sample statement includes K initial sample entities. In this implementation, the obtaining module 401 is further configured to, before the entity disambiguation model is trained by using the sample data set, input K initial sample entities of the sample sentence into a preset contribution degree prediction model, to obtain a contribution degree of each initial sample entity of the sample sentence to semantics of the sample sentence; and according to the ranking of the contribution degrees from large to small, taking R initial sample entities which are ranked R before the contribution degree of the semantics of the sample statement as target sample entities of the sample statement. Wherein K is a positive integer greater than 1. And R is a positive integer which is greater than or equal to 1 and less than or equal to K.

The training apparatus 400 for entity disambiguation models provided in this embodiment may implement the above-described embodiments of the method for training entity disambiguation models, and its implementation principle and technical effect are similar, which are not described herein again.

Fig. 7 is a schematic structural diagram of an entity disambiguation apparatus 500 provided in the present application. As shown in fig. 7, the apparatus 500 may include: a first obtaining module 501, a processing module 502 and a second obtaining module 503. Wherein the content of the first and second substances,

the first obtaining module 501 is configured to obtain at least one target entity of a target sentence, and a plurality of candidate semantic entities corresponding to each target entity determined from a knowledge graph.

A processing module 502, configured to input each target entity 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 obtained by training with the method according to any of the preceding embodiments. The target semantic entity is any one of the plurality of candidate semantic entities.

A second obtaining module 503, configured to obtain semantics of the target statement according to a target semantic entity corresponding to each target entity.

In some embodiments, the entity disambiguation apparatus 500 may further include an execution module 504, configured to, after obtaining the semantics of the target sentence, execute the control instruction corresponding to the semantics according to the semantics of the target sentence.

In some embodiments, the first obtaining module 501 is specifically configured to obtain each initial entity of the target statement; and when the number of the initial entities of the target statement is greater than the preset number of entities, acquiring the initial entities of the preset number of entities from the target statement as the target entities of the target statement. Acquiring a plurality of initial candidate semantic entities corresponding to the target entity from a knowledge graph; when the number of the initial candidate semantic entities corresponding to the target entity is larger than the number of the preset candidate semantic entities, acquiring the initial candidate semantic entities with the preset number of the candidate semantic entities from the initial candidate semantic entities as a plurality of candidate semantic entities corresponding to the target entity. Wherein the number of the preset entities is an integer greater than or equal to 1. The number of candidate semantic entities is preset to be an integer larger than 1.

In some embodiments, the entity disambiguation apparatus 500 may further include a receiving module 505 for receiving a speech signal input by a user before acquiring at least one target entity of the target sentence and a plurality of candidate semantic entities corresponding to each target entity determined from the knowledge-graph; and carrying out voice recognition on the voice signal to obtain the target sentence.

The entity disambiguation apparatus 500 of this embodiment may implement the above embodiment of the entity disambiguation method, and the implementation principle and technical effect thereof are similar, and are not described herein again.

Fig. 8 is a schematic structural diagram of an electronic device provided in the present invention. As shown in fig. 8, the electronic device 600 may include: at least one processor 601 and memory 602. Wherein the content of the first and second substances,

a memory 602 for storing programs. In particular, the program may include program code including computer operating instructions.

The memory 602 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.

The processor 601 is configured to execute computer-executable instructions stored in the memory 602 to implement the entity disambiguation model training method or the entity disambiguation method described in the foregoing method embodiments. The processor 601 may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present invention.

Optionally, the electronic device 600 may also 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 connected to each other through a bus and perform communication with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. Buses may be classified as address buses, data buses, control buses, etc., but do not represent only one bus or type of bus.

Optionally, in a specific implementation, if the communication interface 603, the memory 602, and the processor 601 are integrated into a chip, the communication interface 603, the memory 602, and the processor 601 may complete communication through an internal interface.

The present invention also provides a computer-readable storage medium, which may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and in particular, the computer-readable storage medium stores program instructions, and the program instructions are used in the method in the foregoing embodiments.

The present application also provides a program product comprising execution instructions stored in a readable storage medium. The at least one processor of the electronic device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the electronic device to implement the entity disambiguation model training method or the entity disambiguation method provided by the various embodiments described above.

Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

The foregoing description, for purposes of explanation, has been presented in conjunction with specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the embodiments to the precise forms disclosed above. Many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles and the practical application, to thereby enable others skilled in the art to best utilize the embodiments and various embodiments with various modifications as are suited to the particular use contemplated.

24页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于语义模型的Handle存量标识解析方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!