Candidate entity generation model training method and device
By using feature extraction layer and pooling layer to process entity samples and text samples in the candidate entity generation model, calculating similarity and adjusting model parameters, the problem of manually constructing dictionary and design rules in the prior art is solved, and efficient candidate entity generation is achieved.
Patent Information
- Application Number
- CN202111288243.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-07-13
- Filing Date
- 2021-11-02
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2041-11-02
AI Technical Summary
In the prior art, the generation of candidate entities in entity linking tasks requires manual construction of dictionaries and design rules, resulting in waste of manpower and material resources and the inability to deal with the problem of unlogged words.
The candidate entity generation model training method is used to process the entity samples and entity description text samples through the feature extraction layer and the pooling layer, calculate the similarity between the entity embedding vector and the text embedding vector, and calculate the loss value based on the similarity, and adjust the model parameters until the training stop condition is reached.
It avoids the process of manually constructing dictionary and design rules, saves manpower and material resources, can effectively solve the problem of unlogged words, and improves the accuracy of candidate entities generation.
Smart Images

Figure CN114003732B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence in the field of computer technology, and in particular to a candidate entity generation model training method. The present application also relates to a candidate entity generation model training device, a candidate entity generation method, a candidate entity generation device, a computing device, and a computer-readable storage medium. Background Art
[0002] Artificial intelligence (AI) refers to the ability of engineered (i.e. designed and manufactured) systems to perceive the environment, as well as the ability to acquire, process, apply and represent knowledge. The development status of key technologies in the field of artificial intelligence includes key technologies such as machine learning, knowledge graphs, natural language processing, computer vision, human-computer interaction, biometrics, virtual reality / augmented reality, etc. With the development of computer technology, the fields of natural language processing (Natural Language Processing) and knowledge graphs have also developed rapidly. Natural language processing studies various theories and methods that can achieve effective communication between humans and computers using natural language. It refers to the use of computers to process the form, sound, meaning and other information of natural language, that is, the operation and processing of input, output, recognition, analysis, understanding, generation, etc. of characters, words, sentences and chapters. Knowledge graphs (Knowledge Graph), known as knowledge domain visualization or knowledge domain mapping maps in the library and information industry, are a series of various graphics that show the development process and structural relationship of knowledge. They use visualization technology to describe knowledge resources and their carriers, and to mine, analyze, construct, draw and display knowledge and their mutual connections. When processing natural language, in order to better understand the text, it is necessary to determine the knowledge graph corresponding to the text, that is, to identify the entities in the text and correspond the entity names in the text to the entities in the knowledge base, that is, to perform entity linking. Entity linking usually includes two modules: candidate entity generation and candidate entity ranking. Candidate entity generation, as the first threshold in the entity linking task, is of self-evident importance to entity linking.
[0003] In the prior art, maintenance dictionaries such as synonym dictionaries, alias dictionaries, and abbreviation-full name mapping dictionaries are generally constructed manually, and then candidate entities are directly matched according to the entity names in the text; or rules are manually designed to match candidate entities through heuristic patterns. However, the dictionary matching method requires manual search of national dictionaries such as synonyms, aliases, and abbreviations, which wastes manpower and material resources, and cannot handle the problem of unregistered words; the rule-based heuristic method requires dedicated design of a large number of rules, and the construction cost is large, time-consuming and labor-intensive. Therefore, an effective solution is urgently needed to solve the above problems. Summary of the invention
[0004] In view of this, the embodiment of the present application provides a candidate entity generation model training method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a candidate entity generation model training device, a candidate entity generation method, a candidate entity generation device, a computing device, and a computer-readable storage medium.
[0005] According to a first aspect of an embodiment of the present application, a candidate entity generation model training method is provided, wherein the candidate entity generation model includes a feature extraction layer and a pooling layer, and the method includes:
[0006] Receiving training samples, wherein the training samples include entity samples and entity description text samples;
[0007] Inputting the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing respectively to obtain an entity feature vector and a text feature vector;
[0008] Inputting the entity feature vector and the text feature vector into the pooling layer for pooling processing respectively to obtain an entity embedding vector and a text embedding vector;
[0009] Determine the similarity between the entity embedding vector and the text embedding vector, and calculate the loss value according to the similarity;
[0010] According to a second aspect of an embodiment of the present application, a candidate entity generation method is provided, comprising:
[0011] Obtain at least one entity description text and an entity library, wherein the entity library contains a plurality of entities;
[0012] Inputting the at least one entity description text and the entity library into a candidate entity generation model respectively, obtaining the similarity between the at least one entity description text and each entity respectively, wherein the candidate entity generation model is trained by the candidate entity generation model training method;
[0013] Entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text.
[0014] According to a third aspect of an embodiment of the present application, a candidate entity generation model training device is provided, wherein the candidate entity generation model includes a feature extraction layer and a pooling layer, and the candidate entity generation model training device includes:
[0015] A receiving module is configured to receive a training sample, wherein the training sample includes an entity sample and an entity description text sample;
[0016] A feature extraction module is configured to input the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing to obtain an entity feature vector and a text feature vector;
[0017] A pooling module is configured to input the entity feature vector and the text feature vector into the pooling layer for pooling processing to obtain an entity embedding vector and a text embedding vector;
[0018] A calculation module is configured to determine the similarity between the entity embedding vector and the text embedding vector, and calculate a loss value according to the similarity;
[0019] The training module is configured to adjust the parameters of the candidate entity generation model according to the loss value, and return to execute the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing respectively until the training stop condition is reached, thereby obtaining a candidate entity generation model that has completed the training.
[0020] According to a fourth aspect of an embodiment of the present application, a candidate entity generation device is provided, including:
[0021] An acquisition module is configured to acquire at least one entity description text and an entity library, wherein the entity library contains a plurality of entities;
[0022] An input module is configured to input the at least one entity description text and the entity library into a candidate entity generation model respectively, and obtain the similarity between the at least one entity description text and each entity respectively, wherein the candidate entity generation model is trained by the candidate entity generation model training method;
[0023] The determination module is configured to determine entities whose similarity with each entity description text is higher than a similarity threshold as candidate entities of each entity description text.
[0024] According to a fifth aspect of the embodiments of the present application, there is provided a method comprising:
[0025] Memory and processor;
[0026] The memory is used to store computer-executable instructions, and the processor implements the steps of the candidate entity generation model training method or the candidate entity generation method when executing the computer-executable instructions.
[0027] According to a sixth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, which, when executed by a processor, implement the steps of the candidate entity generation model training method or the candidate entity generation method.
[0028] According to a seventh aspect of an embodiment of the present application, a chip is provided, which stores computer instructions, and when the computer instructions are executed by the chip, the steps of the candidate entity generation model training method or the candidate entity generation method are implemented.
[0029] The candidate entity generation model training method provided by the present application receives training samples, wherein the training samples include entity samples and entity description text samples; the entity samples and the entity description text samples are respectively input into the feature extraction layer for feature extraction processing to obtain entity feature vectors and text feature vectors; the entity feature vectors and the text feature vectors are respectively input into the pooling layer for pooling processing to obtain entity embedding vectors and text embedding vectors; the similarity between the entity embedding vectors and the text embedding vectors is determined, and a loss value is calculated according to the similarity; the parameters of the candidate entity generation model are adjusted according to the loss value, and the step of inputting the entity samples and the description text samples into the feature extraction layer for feature extraction processing is returned to execute, until the training stop condition is reached, and a candidate entity generation model that has completed the training is obtained. The candidate entity generation model training method avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flowchart of a candidate entity generation model training method provided by an embodiment of the present application;
[0031] Figure 2 is a schematic diagram of a candidate entity generation model provided by an embodiment of the present application;
[0032] Figure 3 is a flowchart of a candidate entity generation method provided by an embodiment of the present application;
[0033] Figure 4 It is a flowchart of a candidate entity generation model training and candidate entity generation method applied to a Sentence-BERT network provided in an embodiment of the present application;
[0034] Figure 5 It is a structural schematic diagram of a candidate entity generation model training device provided in one embodiment of the present application;
[0035] Figure 6 is a schematic diagram of the structure of a candidate entity generation device provided in one embodiment of the present application;
[0036] Figure 7 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0037] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0038] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0039] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0040] First, the terms involved in one or more embodiments of the present invention are explained.
[0041] Entity: refers to things that exist objectively and can be distinguished from each other, such as real concrete things, subjects and key points.
[0042] Entity name: refers to a name that can represent or identify an entity, such as a person’s name, an organization’s name, a place’s name, and any other name that can identify an entity.
[0043] Entity linking refers to linking a given entity name that appears in a text to the corresponding entity in a given knowledge base. It is a bridge that connects unstructured web data to a structured knowledge base. Entity linking can enrich text semantic information and has broad application prospects in natural language processing, information retrieval and other fields. The research on entity linking is mainly divided into two parts: candidate entity generation and candidate entity ranking. Among them, candidate entity generation refers to generating a set of candidate entities that may be linked from a given entity name in a text; candidate entity ranking refers to sorting the entities in the candidate entity set and selecting the correct link object from them.
[0044] Sentence-BERT, a twin network that can quickly calculate semantic similarity.
[0045] In the present application, a candidate entity generation model training method is provided. The present application also relates to a candidate entity generation model training device, a candidate entity generation method, a candidate entity generation device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0046] Figure 1 A flowchart of a candidate entity generation model training method provided according to an embodiment of the present application is shown, wherein the candidate entity generation model includes a feature extraction layer and a pooling layer, and specifically includes the following steps:
[0047] Step 102: Receive training samples, where the training samples include entity samples and entity description text samples.
[0048] Specifically, the training samples can be any one of Chinese, Japanese, English, French, German, etc., or a combination of multiple languages, such as a combination of Chinese and English. The present application does not limit the language of the training samples. An entity sample is a word sample corresponding to an entity. For example, if the entity is stone, then the entity sample is the word "stone"; an entity description text sample refers to a text sample containing entity description content, such as "mineral concretions of irregular size and shape." Each training sample can contain one entity sample and at least one entity description text sample, that is, each entity sample can correspond to one entity description text sample, or can correspond to multiple entity description text samples.
[0049] In practical applications, before training the candidate entity generation model, it is necessary to prepare data, that is, to determine the training samples. Entities (entity samples) and entity descriptions (entity description text samples) can be selected from the knowledge base to form training samples, wherein the entity sample and the entity description text sample corresponding to the entity sample constitute a positive sample, and the entity sample and the entity description text sample that does not correspond to the entity sample constitute a negative sample. The training sample can be a positive sample, a negative sample, or a combination of a positive sample and a negative sample, that is, a training sample is a sample set that includes positive samples and / or negative samples. In this application, the type of training samples is not limited.
[0050] In a specific embodiment provided in the present application, the entity sample obtained is "tomato", and the entity description text sample is "tomato is an annual or perennial herb of the Solanaceae, Solanaceae, and Lycopersicon genus" as a positive sample; or the entity sample obtained is "building", and the entity description text sample is "a traditional Chinese courtyard-style building, with a layout of a courtyard with houses built on all four sides, enclosing the courtyard in the middle from all four sides" as a negative sample.
[0051] In addition, for the same entity sample, there can be multiple entity description text samples corresponding to the entity sample, and the entity sample and each entity description text sample corresponding to the entity sample constitute a positive sample. For example, the entity sample is the word "stone", and there are two entity description text samples corresponding to the entity sample "stone", namely "irregular mineral condensation of size and shape" and "small rock body that falls off from a large rock body when encountering external force", then "stone" and "irregular mineral condensation of size and shape" constitute a positive sample, and "stone" and "small rock body that falls off from a large rock body when encountering external force" constitute another positive sample. Similarly, for the same entity sample, there can be multiple entity description text samples that do not correspond to the entity sample, and the entity sample and each entity description text sample that does not correspond to the entity sample constitute a negative sample.
[0052] Obtaining entity samples and entity description text samples prepares data for training the candidate entity generation model, ensuring that the candidate entity generation model can be successfully trained based on the entity samples and entity description text samples.
[0053] Step 104: Input the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing to obtain an entity feature vector and a text feature vector.
[0054] On the basis of receiving the entity sample and the entity description text sample, the entity sample and the entity description text sample are further input into the feature extraction layer of the candidate entity generation model respectively, so as to perform feature extraction processing on the entity sample and the entity description text sample, thereby obtaining the entity feature vector and the text feature vector respectively.
[0055] Specifically, the entity sample is the word sample corresponding to the entity; the entity description text sample refers to the text sample containing the entity description content; the feature extraction layer refers to the processing layer that transforms the entity sample and the entity description text sample to extract the representative features of the entity sample and / or the entity description text sample. The feature extraction layer can be a language representation model, such as the BERT (Bidirectional Encoder Representations from Transformer) model; the entity feature vector refers to the hidden layer representation corresponding to the entity obtained after the entity sample is input into the feature extraction layer for processing; the text feature vector refers to the hidden layer representation corresponding to the entity description text sample obtained after the entity description text sample is input into the feature extraction layer for processing; the hidden layer representation is to abstract the features of the input entity feature vector or entity description text sample into another dimensional space to show the more abstract features of the entity feature vector or entity description text sample. In addition, the hidden layer representation can better perform linear division.
[0056] In practical applications, in order to obtain the feature vectors corresponding to the entity samples and the entity description text samples, the entity samples and the entity description text samples need to be respectively input into the feature extraction layer of the candidate entity generation model. After the feature extraction layer performs feature extraction processing on the entity samples and the entity description text samples respectively, it outputs the entity feature vector corresponding to the entity sample and the text feature vector corresponding to the entity description text sample.
[0057] In a specific embodiment provided in the present application, when the entity sample is "tomato" and the entity description text sample is "tomato, an annual or perennial herb of the order Tubulares, Solanaceae, and genus Lycoris", "tomato" and "tomato, an annual or perennial herb of the order Tubulares, Solanaceae, and genus Lycoris" can be respectively input into the feature extraction layer of the candidate entity generation model for feature extraction processing, thereby obtaining the entity feature vector corresponding to "tomato" and the text feature vector corresponding to "tomato, an annual or perennial herb of the order Tubulares, Solanaceae, and genus Lycoris".
[0058] In order to improve the efficiency and accuracy of feature extraction performed by the feature extraction layer, two sub-feature extraction layers with the same structure, parameter type and parameter number can be set in the feature extraction layer, that is, the feature extraction layer includes a first sub-feature extraction layer and a second sub-feature extraction layer with the same structure, parameter type and parameter number, so that one of the sub-feature extraction layers can perform feature extraction on entity samples, and the other sub-feature extraction layer can perform feature extraction on entity description text samples. The specific implementation process is as follows:
[0059] Input the entity sample into the first sub-feature extraction layer for feature extraction processing to obtain an entity feature vector;
[0060] The entity description text sample is input into the second sub-feature extraction layer for feature extraction processing to obtain a text feature vector.
[0061] Specifically, entity samples are word samples corresponding to entities; entity description text samples refer to text samples containing entity description content; the first sub-feature extraction layer and the second sub-feature extraction layer are exactly the same in structure, parameter type and number of parameters, such as setting two BERT models with exactly the same structure and parameters in the feature extraction layer of the candidate entity generation model, and setting two BERT models with the same structure, parameter type and number of parameters but different specific values of the parameters in the feature extraction layer of the candidate entity generation model.
[0062] In practical applications, see Figure 2 , Figure 2A schematic diagram of a candidate entity generation model provided by an embodiment of the present application is shown, wherein the feature extraction layer includes two sub-feature extraction layers: a first sub-feature extraction layer and a second sub-feature extraction layer. When extracting features from entity samples and entity description text samples, the entity samples need to be input into the first sub-feature extraction layer, and after the first sub-feature extraction layer extracts features from the entity samples, an entity feature vector corresponding to the entity samples is output; the entity description text sample is input into the second sub-feature extraction layer, and after the second sub-feature extraction layer extracts features from the entity description text sample, a text feature vector corresponding to the entity description text sample is output.
[0063] Continuing with the above example, the entity sample "tomato" is input into the first sub-feature extraction layer to obtain the entity feature vector corresponding to "tomato"; the entity description text sample "tomato is an annual or perennial herb of the order Tubulales, Solanaceae, and genus Lycoris" is input into the second sub-feature extraction layer to obtain the text feature vector corresponding to "tomato is an annual or perennial herb of the order Tubulales, Solanaceae, and genus Lycoris".
[0064] It should be noted that, in the present application, the entity sample can be first input into the first sub-feature extraction layer, and then the entity description text sample can be input into the second sub-feature extraction layer; the entity description text sample can also be first input into the second sub-feature extraction layer, and then the entity sample can be input into the first sub-feature extraction layer; and the entity description text sample can also be input into the second sub-feature extraction layer while the entity sample is input into the first sub-feature extraction layer. The present application does not limit this.
[0065] Step 106: Input the entity feature vector and the text feature vector into the pooling layer for pooling processing respectively to obtain the entity embedding vector and the text embedding vector.
[0066] After inputting the entity samples and entity description text samples into the feature extraction layer of the candidate entity generation model for feature extraction processing to obtain the entity feature vector and the text feature vector, the entity feature vector and the text feature vector are further input into the pooling layer of the candidate entity generation model to facilitate pooling processing of the entity feature vector and the text feature vector, thereby obtaining the entity embedding vector and the text embedding vector.
[0067] Specifically, the pooling layer is also called the downsampling layer, which can compress the input entity feature vector and text feature vector. On the one hand, it reduces the features and parameters, which can simplify the complexity of subsequent similarity calculations; on the other hand, it maintains a certain invariance of the entity feature vector and the text feature vector. Pooling is the process of removing redundant information and retaining key information; the entity embedding vector refers to the vector representation obtained after the entity feature vector is pooled; the text embedding vector refers to the vector representation obtained after the text feature vector is pooled.
[0068] In practical applications, without losing the features corresponding to the entity samples and the entity description text samples, in order to reduce the amount of data processing in the training process of the candidate entity generation model, the entity feature vector and the text feature vector can be respectively input into the pooling layer of the candidate entity generation model for pooling processing. After the pooling is completed, the pooling layer outputs the entity embedding vector corresponding to the entity feature vector and the text embedding vector corresponding to the text feature vector, that is, the entity embedding vector corresponding to the entity sample and the text embedding vector corresponding to the entity description text sample are output.
[0069] Continuing with the above example, the entity feature vector corresponding to the entity sample "tomato" and the text feature vector corresponding to the entity description text sample "tomato is an annual or perennial herb of the order Tubularales, Solanaceae, and genus Lycoris" are respectively input into the pooling layer of the candidate entity generation model to obtain the entity embedding vector corresponding to "tomato" and the text embedding vector corresponding to "tomato is an annual or perennial herb of the order Tubularales, Solanaceae, and genus Lycoris".
[0070] In order to improve the efficiency and accuracy of the pooling process performed by the pooling layer and further improve the efficiency of the candidate entity generation model training, two sub-pooling layers with the same structure, parameter type and parameter number can be set in the pooling layer, that is, the pooling layer includes a first sub-pooling layer and a second sub-pooling layer with the same structure, parameter type and parameter number, so that one of the sub-pooling layers can perform pooling on the entity feature vector and the other sub-pooling layer can perform pooling on the text feature vector. The specific implementation process is as follows:
[0071] Input the entity feature vector into the first sub-pooling layer for pooling processing to obtain the entity embedding vector;
[0072] The text feature vector is input into the second sub-pooling layer for pooling processing to obtain the text embedding vector.
[0073] Specifically, the first sub-pooling layer and the second sub-pooling layer are exactly the same in structure, parameter type and parameter quantity. For example, two Pooling layers with exactly the same structure and parameters are set in the pooling layer of the candidate entity generation model. For example, two Pooling layers with the same structure, parameter type and parameter quantity but different specific values of the parameters are set in the pooling layer of the candidate entity generation model.
[0074] In practical applications, see Figure 2 , the pooling layer includes two sub-pooling layers: the first sub-pooling layer and the second sub-pooling layer. When the entity feature vector and the text feature vector are pooled, the entity feature vector is input into the first sub-pooling layer, and after the first sub-pooling layer performs pooling on the entity feature vector, the entity embedding vector corresponding to the entity sample (entity feature vector) is output; the text feature vector is input into the second sub-pooling layer, and after the second sub-pooling layer performs pooling on the text feature vector, the text embedding vector corresponding to the entity description text sample (text feature vector) is output.
[0075] Continuing with the above example, the entity feature vector corresponding to the entity sample "tomato" is input into the first sub-pooling layer to obtain the entity embedding vector corresponding to "tomato"; the entity feature vector corresponding to the entity description text sample "tomato is an annual or perennial herb of the order Tubularales, Solanaceae, and genus Lycopersicon" is input into the second sub-pooling layer to obtain the text embedding vector corresponding to "tomato is an annual or perennial herb of the order Tubularales, Solanaceae, and genus Lycopersicon".
[0076] It should be noted that, in the present application, the entity feature vector can be first input into the first sub-pooling layer, and then the text feature vector can be input into the second sub-pooling layer; the text feature vector can be first input into the second sub-pooling layer, and then the entity feature vector can be input into the first sub-pooling layer; the text feature vector can also be input into the second sub-pooling layer while the entity feature vector is input into the first sub-pooling layer. The present application does not limit this.
[0077] When pooling entity embedding vectors and text embedding vectors, there are three commonly used pooling strategies: CLS vector (classification) strategy, average pooling (MEAN) strategy and maximum pooling (MAX) strategy, among which the average pooling strategy has the best effect. In order to improve the efficiency and accuracy of the pooling layer for pooling processing and further improve the efficiency of candidate entity generation model training, the average pooling strategy can also be used to pool the entity feature vector and the text feature vector, and then obtain the entity embedding vector and the text embedding vector, that is, the entity feature vector and the text feature vector are respectively input into the pooling layer, and the average pooling strategy of the pooling layer is used to obtain the entity embedding vector and the text embedding vector after average pooling processing.
[0078] In a specific embodiment provided by the present application, the entity feature vector corresponding to the entity sample "dining table" and the text feature vector corresponding to the entity description text sample "a table dedicated to eating" can be respectively input into the pooling layer of the candidate entity generation model. Afterwards, the pooling layer performs pooling processing on the entity feature vector corresponding to the entity sample "dining table" and the text feature vector corresponding to the entity description text sample "a table dedicated to eating" according to the average pooling strategy, thereby obtaining the entity embedding vector corresponding to "dining table" and the text embedding vector corresponding to "a table dedicated to eating".
[0079] Step 108: Determine the similarity between the entity embedding vector and the text embedding vector, and calculate the loss value based on the similarity.
[0080] After the entity feature vector and the text feature vector are respectively input into the pooling layer of the candidate entity generation model for pooling processing to obtain the entity embedding vector and the text embedding vector, the loss value is further calculated according to the similarity between the entity embedding vector and the text embedding vector.
[0081] Specifically, similarity represents the degree of similarity between the entity embedding vector and the text embedding vector. There are many ways to determine the similarity, such as cosine similarity, Manhattan distance, and Euclidean distance. The loss value is used to evaluate the difference between the predicted value (the desired effect) and the true value (the actual effect achieved) of the candidate entity generation model. There are many loss functions for calculating the loss value, such as cross entropy loss function, L1 norm loss function, maximum loss function, mean square error loss function, logarithmic loss function, etc.
[0082] In practical applications, after obtaining the entity embedding vector and the text embedding vector, the entity embedding vector and the text embedding vector are compared to calculate the similarity between the two. Figure 2 , the loss value is calculated based on the similarity between the entity embedding vector and the text embedding vector.
[0083] Continuing with the above example, after obtaining the entity embedding vector corresponding to “dining table” and the text embedding vector corresponding to “table for dining”, calculate the similarity between the entity embedding vector corresponding to “dining table” and the text embedding vector corresponding to “table for dining”, and determine the loss value based on the similarity.
[0084] Since cosine similarity mainly distinguishes the difference of vectors in terms of direction and is insensitive to absolute values, it is more conducive to reflecting the similarity and difference between entity embedding vectors and text embedding vectors. When determining the similarity between entity embedding vectors and text embedding vectors, the cosine similarity calculation method can be used to calculate the similarity between the embedding vector and the text embedding vector. For example, according to the cosine similarity calculation method, the cosine similarity between the entity embedding vector corresponding to "dining table" and the text embedding vector corresponding to "table for eating" is calculated.
[0085] In addition, in order to improve the data processing speed and thus improve the training speed of the candidate entity generation model, the mean absolute error (MAE) loss function can be used to calculate the loss value, that is, the absolute value error between the similarity and the preset target value is calculated to obtain the loss value of the similarity. The calculation process of the loss value is shown in Formula 1.
[0086]
[0087] In Formula 1, MAE represents the loss value; n represents the number of similarities; x i Represents the current similarity; y represents the preset target value, and y is 0 or 1 in the binary classification candidate entity generation model.
[0088] In a specific embodiment provided in the present application, the similarity is 0.8, and the preset target value is 1, then the loss value of the similarity is |0.8-1| / 1=0.2.
[0089] In one or more implementations of this embodiment, the training samples include positive samples and negative samples, wherein the positive samples include entity samples and entity description text samples corresponding to the entity samples, and the negative samples include entity samples and entity description text samples that do not correspond to the entity samples. Due to the difference between positive samples and negative samples, the target values used when calculating the loss value are also different, as follows:
[0090] When the training sample is a positive sample, the absolute value error between the similarity and the preset first target value is calculated to obtain a first loss value of the similarity;
[0091] When the training sample is a negative sample, the absolute value error is calculated between the similarity and the preset second target value to obtain a second loss value of the similarity;
[0092] The sum of the first loss value and the second loss value is determined as the loss value of the similarity.
[0093] Specifically, positive samples include entity samples and entity description text samples corresponding to the entity samples; negative samples include entity samples and entity description text samples that do not correspond to the entity samples; entity samples are word samples corresponding to the entities; entity description text samples refer to text samples containing entity description content.
[0094] In practical applications, after obtaining the similarity score between the entity embedding vector and the text embedding vector, the corresponding mean absolute error loss function is matched according to the label of the training sample, and the similarity is brought into the corresponding mean absolute error loss function for calculation to obtain the loss value. That is, when the training sample is a positive sample, the mean absolute error loss function with a first target value is matched according to the label of the positive sample, and the similarity is brought into the mean absolute error loss function with the first target value for calculation to obtain the first loss value; when the training sample is a negative sample, the mean absolute error loss function with a second target value is matched according to the label of the negative sample, and the similarity is brought into the mean absolute error loss function with the second target value for calculation to obtain the second loss value. The loss value obtained by adding the first loss value and the second loss value is the loss value of the similarity. In this way, it is beneficial to improve the similarity calculation ability of different types of entities and entity description texts of the candidate entity generation model, thereby improving the credibility of the candidate entity generation model in generating candidate entities.
[0095] It should be noted that, in the present embodiment, when calculating the loss value of similarity, the standard similarity is introduced, that is, the preset target value is compared with the obtained similarity to calculate the loss value. This avoids overfitting when calculating the loss value, optimizes the performance of the candidate entity generation model in calculating the similarity between the entity and the entity description text, and makes the effect of generating candidate entities more reliable.
[0096] Step 110: adjust the parameters of the candidate entity generation model according to the loss value, return to the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing, until the training stop condition is reached, and obtain the candidate entity generation model that has completed the training.
[0097] Based on the similarity between the entity embedding vector and the text embedding vector, the loss value is determined, and then the parameters of the candidate entity generation model are adjusted according to the loss value, and the training continues until the training stop condition is reached.
[0098] Specifically, the training stop condition refers to a factor that stops the process of training the candidate entity generation model. The training stop condition can be that the number of iterations reaches the target number of iterations, or that the loss value is less than a preset threshold.
[0099] In practical applications, after the loss value is determined, the loss value is back-propagated to adjust the parameters of the pooling layer and the feature extraction layer in the candidate entity generation model in turn. After the adjustment, the candidate entity generation model is trained again, and the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction is returned to the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing, and the steps are executed in sequence until the number of iterations reaches the target number of iterations, or the loss value is less than the preset threshold, at which time a completed candidate entity generation model is obtained.
[0100] In this embodiment, a target number of iterations or a preset threshold is set in advance. When the number of iterations of the candidate entity generation model reaches the target number of iterations, or the loss value is less than the preset threshold, it means that the candidate entity generation model has reached a certain level of generating candidate entities, that is, the training stop condition is reached. Therefore, the training of the candidate entity generation model is stopped.
[0101] The candidate entity generation model training method provided by the present application receives training samples, the training samples include entity samples and entity description text samples; inputs the entity samples and entity description text samples into the feature extraction layer for feature extraction processing, and obtains entity feature vectors and text feature vectors; inputs the entity feature vectors and text feature vectors into the pooling layer for pooling processing, and obtains entity embedding vectors and text embedding vectors; determines the similarity between the entity embedding vector and the text embedding vector, and calculates the loss value according to the similarity; adjusts the parameters of the candidate entity generation model according to the loss value, and returns to execute the step of inputting the entity samples and description text samples into the feature extraction layer for feature extraction processing, until the training stop condition is reached, and obtains the candidate entity generation model that has completed the training. The candidate entity generation model training method avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation.
[0102] Figure 3 A flowchart of a candidate entity generation method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0103] Step 302: Obtain at least one entity description text and an entity library, where the entity library contains multiple entities.
[0104] Specifically, the entity description text refers to text describing an entity, wherein the entity description text includes an entity name; an entity is a word corresponding to the entity.
[0105] In the embodiment provided in the present application, at least one entity description text obtained is "Sweet and delicious ice cream is my favorite", and the entity library contains eight entities: "ice cream", "popsicle", "dairy products", "spicy strips", "house", "frozen food", "sundae" and "mouse".
[0106] Step 304: input at least one entity description text and an entity library into a candidate entity generation model respectively to obtain the similarity between at least one entity description text and each entity respectively. The candidate entity generation model is trained by the above-mentioned candidate entity generation model training method.
[0107] In the embodiment provided in the present application, following the above example, the entity description text "Sweet and delicious ice cream is my favorite" and the entity library "ice cream", "pop-cake", "dairy products", "spicy strips", "house", "frozen food", "sundae" and "mouse" are respectively input into the candidate entity generation model to obtain the similarity between "Sweet and delicious ice cream is my favorite" and "ice cream", "pop-cake", "dairy products", "spicy strips", "house", "frozen food", "sundae" and "mouse" respectively.
[0108] Step 306: Entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text.
[0109] In the embodiment provided in the present application, following the above example, the first similarity between "sweet and delicious ice cream is my favorite" and "ice cream", the second similarity between "sweet and delicious ice cream is my favorite" and "popular popsicles", the third similarity between "sweet and delicious ice cream is my favorite" and "dairy products", the fourth similarity between "sweet and delicious ice cream is my favorite" and "spicy strips", the fifth similarity between "sweet and delicious ice cream is my favorite" and "house", the sixth similarity between "sweet and delicious ice cream is my favorite" and "frozen food", the seventh similarity between "sweet and delicious ice cream is my favorite" and "sundae", and the eighth similarity between "sweet and delicious ice cream is my favorite" and "mouse" are compared with the similarity threshold respectively. As a result, the first similarity, the second similarity, the third similarity, the sixth similarity and the seventh similarity are all greater than the similarity threshold, then "ice cream", "popular popsicles", "dairy products", "frozen food" and "sundae" are determined as candidate entities of "sweet and delicious ice cream is my favorite".
[0110] The candidate entity generation method provided by the present application obtains at least one entity description text and an entity library, wherein the entity library contains multiple entities; at least one entity description text and the entity library are respectively input into a candidate entity generation model to obtain the similarity between at least one entity description text and each entity, wherein the candidate entity generation model is obtained by training the candidate entity generation model training method described above; entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text. The candidate entity generation method avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation.
[0111] The following combination Figure 4 , taking the application of the candidate entity generation model training method and the candidate entity generation method provided in this application to the Sentence-BERT network as an example, the candidate entity generation training method and the candidate entity generation method are further explained. Among them, Figure 4 A flowchart of a candidate entity generation model training and candidate entity generation method applied to a Sentence-BERT network provided in an embodiment of the present application is shown, which specifically includes the following steps:
[0112] Step 402: Receive training samples, where the training samples include entity samples and entity description text samples.
[0113] Step 404: Input the entity sample into the first BERT model for feature extraction processing to obtain an entity feature vector, and input the entity description text sample into the second BERT model for feature extraction processing to obtain a text feature vector.
[0114] Among them, the first BERT model and the second BERT model have the same structure, parameter type and number of parameters.
[0115] Step 406: Input the entity feature vector to the first sub-pooling layer for pooling processing to obtain the entity embedding vector, and input the text feature vector to the second sub-pooling layer for pooling processing to obtain the text embedding vector.
[0116] The structure, parameter type and number of parameters of the first sub-pooling layer and the second sub-pooling layer are the same; the pooling process is average pooling process according to the average pooling strategy.
[0117] Step 408: Calculate the similarity between the entity embedding vector and the text embedding vector using the cosine similarity calculation method.
[0118] It should be noted that, when the training sample is a positive sample, the similarity is calculated with the preset first target value for absolute value error to obtain the first loss value of the similarity; when the training sample is a negative sample, the similarity is calculated with the preset second target value for absolute value error to obtain the second loss value of the similarity. The sum of the first loss value and the second loss value is determined as the loss value of the similarity.
[0119] Step 410: perform absolute value error calculation on the similarity and the preset target value to obtain a similarity loss value.
[0120] Step 412: Adjust the parameters of the candidate entity generation model according to the loss value.
[0121] Step 414: Determine whether the training stop condition is met.
[0122] If not, execute step 404; if so, execute step 416.
[0123] Step 416: Obtain a candidate entity generation model that has completed training.
[0124] Step 418: Obtain at least one entity description text and an entity library, where the entity library contains multiple entities.
[0125] Step 420: Input at least one entity description text and an entity library into the trained candidate entity generation model respectively.
[0126] Step 422: The candidate entity generation model that has completed the training outputs the similarity between at least one entity description text and each entity.
[0127] Step 424: Entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text.
[0128] The candidate entity generation model training and candidate entity generation method applied to the Sentence-BERT network provided in the present application comprises the following steps: receiving training samples, the training samples comprising entity samples and entity description text samples; inputting the entity samples and the entity description text samples into the feature extraction layer for feature extraction processing, respectively, to obtain entity feature vectors and text feature vectors; inputting the entity feature vectors and the text feature vectors into the pooling layer for pooling processing, respectively, to obtain entity embedding vectors and text embedding vectors; determining the cosine similarity between the entity embedding vectors and the text embedding vectors, and calculating the loss value according to the similarity; adjusting the parameters of the candidate entity generation model according to the loss value, and obtaining a candidate entity generation model that has completed training after the training stop condition is reached; obtaining at least one entity description text and an entity library containing multiple entities; respectively inputting the at least one entity description text and the entity library into the candidate entity generation model that has completed training; and determining entities whose similarity with each entity description text is higher than a similarity threshold as candidate entities of each entity description text. This method applied to the Sentence-BERT network avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation.
[0129] Corresponding to the above-mentioned candidate entity generation model training method embodiment, the present application also provides a candidate entity generation model training device embodiment, Figure 5 FIG. 1 is a schematic diagram showing a structure of a candidate entity generation model training device provided by an embodiment of the present application. Figure 5 As shown, the candidate entity generation model includes a feature extraction layer and a pooling layer, and the device includes:
[0130] A receiving module 502 is configured to receive a training sample, wherein the training sample includes an entity sample and an entity description text sample;
[0131] The feature extraction module 504 is configured to input the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing to obtain an entity feature vector and a text feature vector;
[0132] A pooling module 506 is configured to input the entity feature vector and the text feature vector into the pooling layer for pooling processing to obtain an entity embedding vector and a text embedding vector;
[0133] A calculation module 508 is configured to determine a similarity between the entity embedding vector and the text embedding vector, and calculate a loss value according to the similarity;
[0134] The training module 510 is configured to adjust the parameters of the candidate entity generation model according to the loss value, and return to execute the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing respectively until the training stop condition is reached, thereby obtaining a candidate entity generation model that has completed the training.
[0135] In one or more implementations of this embodiment, the feature extraction layer includes a first sub-feature extraction layer and a second sub-feature extraction layer having the same structure, parameter type and parameter number;
[0136] The feature extraction module 504 is further configured to:
[0137] Inputting the entity sample into the first sub-feature extraction layer for feature extraction processing to obtain an entity feature vector;
[0138] The entity description text sample is input into the second sub-feature extraction layer for feature extraction processing to obtain a text feature vector.
[0139] In one or more implementations of this embodiment, the pooling layer includes a first sub-pooling layer and a second sub-pooling layer having the same structure, parameter type and parameter number;
[0140] The pooling module 506 is further configured to:
[0141] Inputting the entity feature vector into the first sub-pooling layer for pooling processing to obtain an entity embedding vector;
[0142] The text feature vector is input into the second sub-pooling layer for pooling processing to obtain a text embedding vector.
[0143] In one or more implementations of this embodiment, the pooling module 506 is further configured to:
[0144] Inputting the entity feature vector and the text feature vector into the pooling layer respectively, and using the average pooling strategy of the pooling layer to obtain the entity embedding vector and the text embedding vector after average pooling processing;
[0145] The determining the similarity between the entity embedding vector and the text embedding vector comprises:
[0146] The similarity between the entity embedding vector and the text embedding vector is calculated using a cosine similarity calculation method.
[0147] In one or more implementations of this embodiment, the training module 510 is further configured to:
[0148] An absolute value error is calculated between the similarity and a preset target value to obtain a loss value of the similarity.
[0149] In one or more implementations of this embodiment, the training samples include positive samples and negative samples, the positive samples include entity samples and entity description text samples corresponding to the entity samples, and the negative samples include entity samples and entity description text samples that do not correspond to the entity samples;
[0150] The calculation module 508 is further configured to:
[0151] When the training sample is a positive sample, performing an absolute value error calculation between the similarity and a preset first target value to obtain a first loss value of the similarity;
[0152] In the case where the training sample is a negative sample, performing an absolute value error calculation between the similarity and a preset second target value to obtain a second loss value of the similarity;
[0153] The sum of the first loss value and the second loss value is determined as the loss value of the similarity.
[0154] In one or more implementations of this embodiment, the training stop condition includes:
[0155] The number of iterations reaches the target number of iterations, or the loss value is less than a preset threshold.
[0156] The candidate entity generation model training device provided by the present application receives training samples, the training samples include entity samples and entity description text samples; inputs the entity samples and entity description text samples into the feature extraction layer for feature extraction processing, and obtains entity feature vectors and text feature vectors; inputs the entity feature vectors and text feature vectors into the pooling layer for pooling processing, and obtains entity embedding vectors and text embedding vectors; determines the similarity between the entity embedding vector and the text embedding vector, and calculates the loss value according to the similarity; adjusts the parameters of the candidate entity generation model according to the loss value, and returns to execute the step of inputting the entity samples and description text samples into the feature extraction layer for feature extraction processing, until the training stop condition is reached, and obtains the candidate entity generation model that has completed the training. The candidate entity generation model training device avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation.
[0157] The above is a schematic scheme of a candidate entity generation model training device of the present embodiment. It should be noted that the technical scheme of the candidate entity generation model training device and the technical scheme of the candidate entity generation model training method mentioned above belong to the same concept. For details not described in detail in the technical scheme of the candidate entity generation model training device, please refer to the description of the technical scheme of the candidate entity generation model training method mentioned above. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0158] Corresponding to the above-mentioned candidate entity generation method embodiment, the present application also provides a candidate entity generation device embodiment, Figure 6 FIG. 1 is a schematic diagram showing the structure of a candidate entity generation device provided by an embodiment of the present application. Figure 6 As shown, the device comprises:
[0159] An acquisition module 602 is configured to acquire at least one entity description text and an entity library, wherein the entity library contains a plurality of entities;
[0160] An input module 604 is configured to input the at least one entity description text and the entity library into a candidate entity generation model respectively, and obtain the similarity between the at least one entity description text and each entity respectively, wherein the candidate entity generation model is trained by the candidate entity generation model training method;
[0161] The determination module 606 is configured to determine entities whose similarity with each entity description text is higher than a similarity threshold as candidate entities of each entity description text.
[0162] The candidate entity generation device provided by the present application obtains at least one entity description text and an entity library, wherein the entity library contains multiple entities; at least one entity description text and the entity library are respectively input into a candidate entity generation model to obtain the similarity between at least one entity description text and each entity, wherein the candidate entity generation model is obtained by training the candidate entity generation model training method described above; entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text. The candidate entity generation device avoids the process of manually constructing dictionaries and designing rules, saves a lot of manpower and material resources, can effectively solve the problem of unregistered words, and is convenient and fast, simple and efficient to operate, and improves the accuracy of candidate entity generation.
[0163] The above is a schematic scheme of a candidate entity generation device of the present embodiment. It should be noted that the technical scheme of the candidate entity generation device and the technical scheme of the candidate entity generation method mentioned above belong to the same concept. For details not described in detail in the technical scheme of the candidate entity generation device, please refer to the description of the technical scheme of the candidate entity generation method mentioned above. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0164] Figure 7 The block diagram of a computing device 700 according to an embodiment of the present specification is shown. The components of the computing device 700 include but are not limited to a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and the database 750 is used to store data.
[0165] The computing device 700 also includes an access device 740 that enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 740 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0166] In one embodiment of the present specification, the above components of the computing device 700 and Figure 7 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 7 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0167] The computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 700 may also be a mobile or stationary server.
[0168] The processor 720 is used to execute computer executable instructions of the candidate entity generation model training method or the candidate entity generation method.
[0169] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the candidate entity generation model training method or the candidate entity generation method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the candidate entity generation model training method or the candidate entity generation method mentioned above.
[0170] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, are used for the candidate entity generation model training method or the candidate entity generation method.
[0171] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the candidate entity generation model training method or the candidate entity generation method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the candidate entity generation model training method or the candidate entity generation method mentioned above.
[0172] An embodiment of the present application discloses a chip storing computer instructions, which, when executed by a processor, implement the candidate entity generation model training method or the steps of the candidate entity generation method as described above.
[0173] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0174] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0175] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0176] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0177] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A candidate entity generation model training method, characterized in that: The candidate entity generation model includes a feature extraction layer and a pooling layer, and the method includes: Receive a training sample, wherein the training sample includes an entity sample and an entity description text sample, wherein the entity description text sample refers to a text sample containing entity description content, and the entity sample corresponds to at least one of the entity description text samples; Inputting the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing respectively to obtain an entity feature vector and a text feature vector; Inputting the entity feature vector and the text feature vector into the pooling layer for pooling processing respectively to obtain an entity embedding vector and a text embedding vector; Determine the similarity between the entity embedding vector and the text embedding vector, and calculate the loss value according to the similarity; The parameters of the candidate entity generation model are adjusted according to the loss value, and the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing is returned to execute until the training stop condition is reached, thereby obtaining a candidate entity generation model that has completed training.
2. The method according to claim 1, characterized in that The feature extraction layer includes a first sub-feature extraction layer and a second sub-feature extraction layer having the same structure, parameter type and parameter quantity; The step of inputting the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing to obtain an entity feature vector and a text feature vector comprises: Inputting the entity sample into the first sub-feature extraction layer for feature extraction processing to obtain the entity feature vector; The entity description text sample is input into the second sub-feature extraction layer for feature extraction processing to obtain the text feature vector.
3. The method according to claim 1 or 2, characterized in that: The pooling layer includes a first sub-pooling layer and a second sub-pooling layer having the same structure, parameter type and parameter quantity; The step of inputting the entity feature vector and the text feature vector into the pooling layer for pooling processing to obtain an entity embedding vector and a text embedding vector comprises: Inputting the entity feature vector into the first sub-pooling layer for pooling processing to obtain the entity embedding vector; The text feature vector is input into the second sub-pooling layer for pooling processing to obtain the text embedding vector.
4. The method according to claim 1, characterized in that: The step of inputting the entity feature vector and the text feature vector into the pooling layer for pooling processing to obtain an entity embedding vector and a text embedding vector comprises: Inputting the entity feature vector and the text feature vector into the pooling layer respectively, and using the average pooling strategy of the pooling layer to obtain the entity embedding vector and the text embedding vector after average pooling processing; Accordingly, determining the similarity between the entity embedding vector and the text embedding vector includes: The similarity between the entity embedding vector and the text embedding vector is calculated using a cosine similarity calculation method.
5. The method according to claim 1, characterized in that The calculating the loss value according to the similarity comprises: An absolute value error is calculated between the similarity and a preset target value to obtain a loss value of the similarity.
6. The method according to claim 5, characterized in that The training samples include positive samples and negative samples, the positive samples include entity samples and entity description text samples corresponding to the entity samples, and the negative samples include entity samples and entity description text samples that do not correspond to the entity samples; The calculating the absolute value error between the similarity and a preset target value to obtain the loss value of the similarity includes: When the training sample is a positive sample, performing an absolute value error calculation between the similarity and a preset first target value to obtain a first loss value of the similarity; In the case where the training sample is a negative sample, performing an absolute value error calculation on the similarity and a preset second target value to obtain a second loss value of the similarity; The sum of the first loss value and the second loss value is determined as the loss value of the similarity.
7. The method according to claim 1, characterized in that The training stop condition includes: The number of iterations reaches the target number of iterations, or the loss value is less than a preset threshold.
8. A candidate entity generation method, characterized in that: include: Obtain at least one entity description text and an entity library, wherein the entity library contains a plurality of entities; Inputting the at least one entity description text and the entity library into a candidate entity generation model respectively, and obtaining the similarity between the at least one entity description text and each entity respectively, wherein the candidate entity generation model is trained by the training method according to any one of claims 1 to 7; Entities whose similarity with each entity description text is higher than a similarity threshold are respectively determined as candidate entities of each entity description text.
9. A candidate entity generation model training device, characterized in that: The candidate entity generation model includes a feature extraction layer and a pooling layer, and the candidate entity generation model training device includes: A receiving module is configured to receive a training sample, wherein the training sample includes an entity sample and an entity description text sample, wherein the entity description text sample refers to a text sample containing entity description content, and the entity sample corresponds to at least one of the entity description text samples; A feature extraction module is configured to input the entity sample and the entity description text sample into the feature extraction layer for feature extraction processing to obtain an entity feature vector and a text feature vector; A pooling module is configured to input the entity feature vector and the text feature vector into the pooling layer for pooling processing to obtain an entity embedding vector and a text embedding vector; A calculation module is configured to determine the similarity between the entity embedding vector and the text embedding vector, and calculate a loss value according to the similarity; The training module is configured to adjust the parameters of the candidate entity generation model according to the loss value, and return to execute the step of inputting the entity sample and the description text sample into the feature extraction layer for feature extraction processing respectively until the training stop condition is reached, thereby obtaining a candidate entity generation model that has completed the training.
10. A candidate entity generation device, characterized in that: include: An acquisition module is configured to acquire at least one entity description text and an entity library, wherein the entity library contains a plurality of entities; An input module, configured to input the at least one entity description text and the entity library into a candidate entity generation model respectively, to obtain the similarity between the at least one entity description text and each entity respectively, wherein the candidate entity generation model is trained by the training method according to any one of claims 1 to 7; The determination module is configured to determine entities whose similarity with each entity description text is higher than a similarity threshold as candidate entities of each entity description text.
11. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the method described in any one of claims 1-7 or 8.
12. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by the processor, the steps of the method described in any one of claims 1 to 7 or 8 are implemented.
Citation Information
Patent Citations
Candidate entity sorting method, training method and related device
CN110795527A
Vertical domain entity chain finger system based on multipath recall
CN112231449A
Image similarity determination and model training method and device, equipment and medium
CN112633420A