A BERT-based automatic hierarchical tree expansion method

Through the automatic hierarchical tree expansion method based on BERT, the corpus and ANNOY algorithm are used to optimize the expansion of hierarchical trees, which solves the problems of insufficient efficiency and accuracy in the existing technology and achieves more efficient and accurate hierarchical tree construction, which is suitable for Downstream natural language processing tasks.

CN114757147BActive Publication Date: 2024-08-27LIAONING TECHNICAL UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210350872.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-02
Publication Date
2024-08-27
Estimated Expiration
2042-04-02

AI Technical Summary

Technical Problem

Existing hierarchical tree expansion methods have deficiencies in efficiency and accuracy and cannot meet the needs of downstream natural language processing tasks, especially the limitations in width and depth expansion tasks.

Method used

The automatic hierarchical tree expansion method based on BERT is used to extract entity sets from the corpus and generate word vectors. BERT's MASK mechanism is used to generate class names. It is combined with the ANNOY algorithm for entity expansion and disambiguation to optimize the semantic representation of each entity space. Finally, Generate a hierarchical tree that meets user input requirements.

Benefits of technology

It improves the accuracy and efficiency of hierarchical tree expansion, can more accurately express the semantic information of each entity space, meets the needs of downstream tasks, and provides a more complete hierarchical tree structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114757147B
    Figure CN114757147B
Patent Text Reader

Abstract

The present invention discloses an automatic hierarchical tree expansion method based on BERT, comprising extracting entity sets through a corpus and generating word vectors of the entity sets, preliminarily completing each entity space corresponding to the hierarchical tree input by the user; using the MASK mechanism of BERT to generate the best class name for each entity space, and using the class name to guide the expansion to generate a candidate set for each entity space, by calculating the score of each candidate entity and the similarity score with the seed set, adding high-quality entities to the corresponding entity space; performing entity disambiguation, and obtaining a hierarchical tree expansion result. The automatic hierarchical tree expansion method based on BERT of the present invention utilizes a language model to understand the hierarchical tree result input by the user, obtains candidate words for each position, and performs filling, and finally obtains a hierarchical tree that meets the user input result requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data processing, and in particular relates to an automatic hierarchical tree expansion method based on BERT. Background Art

[0002] Hierarchical trees are widely used in many downstream natural language processing tasks. Due to the high cost of manual annotation and the uneven data quality, there is an urgent need for a method to automatically construct a hierarchical tree. At present, the existing hierarchical tree expansion method is mainly the "is-a" hierarchical relationship, which greatly limits the applicability in various real tasks. Therefore, the goal of the present invention is to allow the user to input a pre-set hierarchical tree context format for the task, and the system completes the entire hierarchical tree according to the format. However, the current expansion method does not achieve high accuracy and has low efficiency. It cannot meet the needs of downstream tasks well.

[0003] The two main tasks of hierarchical tree expansion are optimized. First, for width expansion, the BERT pre-trained model is used to assign a class name to each entity space, and the candidate entity is obtained through the class name, and finally filtered by ANNOY to obtain the width expansion result. Second, for depth expansion, Word2Vec is used to calculate the superior-female relationship score of two nodes. Summary of the invention

[0004] In view of the deficiencies in the prior art, the problem to be solved by the present invention is to provide an automatic hierarchical tree expansion method based on BERT, which utilizes the language model to understand the hierarchical tree results input by the user, obtains the candidate words for each position, and fills them in, and finally obtains a hierarchical tree that meets the user input result requirements.

[0005] In order to solve the above technical problems, the present invention is implemented by the following technical solutions:

[0006] The BERT-based automatic hierarchical tree expansion method provided by the present invention comprises the following steps:

[0007] S1: Extract entity sets from the corpus and generate word vectors for the entity sets, and preliminarily complete each entity space corresponding to the hierarchical tree input by the user;

[0008] S2: Use BERT’s MASK mechanism to generate the best class name for each entity space, and use the class name to guide the expansion to generate a candidate set for each entity space. After calculating the score of each candidate entity and the similarity score with the seed set, high-quality entities are added to the corresponding entity space.

[0009] S3: Perform entity disambiguation and obtain the hierarchical tree expansion result.

[0010] Furthermore, in step S1, relevant documents are searched on the Internet and determined as positive samples, strong negative samples, irrelevant samples and background samples through manual review, and the samples are classified and added to the sensitive sample library, non-sensitive sample library, irrelevant sample library and background sample library.

[0011] Furthermore, the specific steps of step S1 are as follows:

[0012] Step S1.1: Use data mining to extract entities from the corpus as an extended entity set;

[0013] Step S1.2: Use the Word2Vec model to obtain the word vector corresponding to each entity;

[0014] Step S1.3: For each entity space, ANNOY or word vector similarity is used for preliminary expansion to more accurately represent the semantic information represented by its entity space.

[0015] Preferably, the specific steps of step S2 are as follows:

[0016] Step S2.1: For each entity space, find the possible class names and their scores of the entity space through BERT’s MLM task, and generate the best class name and negative class name set of the entity space through the scores;

[0017] Step S2.2: Use the best class name and negative class name set to expand each entity space, take the expanded entities as candidate sets, and calculate the score of each candidate entity;

[0018] Step S2.3: Use the ANNOY algorithm to calculate the similarity score between each candidate word and the seed entity, and add the weighted sum of the scores of the class name extension to obtain the extension set of each entity space.

[0019] Furthermore, the specific steps of step S3 are as follows:

[0020] Step S3.1: Count entities that appear more than twice in different entity spaces, i.e., ambiguous entities;

[0021] Step S3.2: For each entity, only the last position of the score is retained to generate the final hierarchical tree expansion result.

[0022] Furthermore, the specific steps of step S3.2 are:

[0023] First, if the entity is in the entities input by the user, discard the entity directly;

[0024] Second, give priority to preserving the ancestor entity among the ambiguous entities;

[0025] Third, entities with higher similarity scores to the seed entities in the entity space are retained.

[0026] From the above, the present invention has the following beneficial effects:

[0027] 1. First, extract entities from the corpus through data mining and Word2Vec and generate corresponding word vectors. Secondly, use the more efficient ANNOY model and word vector similarity to expand the tree structure input by the user on a small scale. Finally, generate candidate sets for each entity space through BERT-based class name expansion, filter the candidate sets using ANNOY, and then generate the final hierarchical tree expansion result after the entity disambiguation module.

[0028] 2. Expand a certain number of entities for each entity space in advance to more accurately express the semantic information of each entity space. This step is less difficult to expand, so a more efficient expansion method is selected to improve the overall expansion efficiency.

[0029] 3. Use the pre-trained model BERT as the basis for expansion to improve the accuracy of the expansion.

[0030] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following is a detailed description in combination with the preferred embodiments and the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings of the embodiment are briefly introduced below.

[0032] Figure 1 A flowchart of the BERT-based automatic hierarchical tree expansion method of the present invention;

[0033] Figure 2 It is a flowchart of the hierarchical tree expansion algorithm of the present invention. DETAILED DESCRIPTION

[0034] The following is a detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings, which is a part of this specification and illustrates the principles of the present invention through examples. Other aspects, features and advantages of the present invention will become clear from the detailed description. In the referenced drawings, the same or similar components in different figures are represented by the same reference numerals.

[0035] The present invention expands the hierarchical tree structure input by the user and returns a more complete hierarchical tree structure to the user. First, each entity space in the hierarchical tree is preliminarily completed based on ANNOY and Word2Vec to enhance the semantic information of each entity space. Secondly, the category expansion method based on BERT is used to expand each entity space separately. Finally, the expanded hierarchical tree is disambiguated and the final expansion result is returned to the user.

[0036] like Figure 1 and Figure 2 As shown, the BERT-based automatic hierarchical tree expansion method of the present invention comprises the following steps:

[0037] Step 1: Extract entity sets from the corpus and generate word vectors for the entity sets. Perform preliminary completion on each entity space corresponding to the hierarchical tree input by the user. The entity space is all entities under each entity node;

[0038] Step 2: Use BERT's MASK mechanism to generate the best class name for each entity space. Generate a candidate set for each entity space using the class name-guided expansion method. After calculating the score of each candidate entity and the similarity score with the seed set, add high-quality entities to the corresponding entity space;

[0039] Step 3: After step 2, an entity may be in two or more different entity spaces. Therefore, entity disambiguation is required to obtain a hierarchical tree expansion result.

[0040] The specific steps of step 1 are as follows:

[0041] Step 1.1: Use data mining to extract entities from the corpus as an extended entity set;

[0042] Step 1.2: Use the Word2Vec model to obtain the word vector corresponding to each entity;

[0043] Step 1.3: For each entity space, use ANNOY or word vector similarity to perform preliminary expansion to more accurately represent the semantic information represented by its entity space. The choice of the two methods is determined by the scale of existing entities in each entity space.

[0044] The specific steps of step 2 are as follows:

[0045] Step 2.1: For each entity space, find the possible class names and their scores of the entity space through BERT’s MLM task, and generate the best class name and negative class name set of the entity space through the scores;

[0046] Step 2.2: Use the best class name and negative class name set to expand each entity space, take the expanded entities as candidate sets, and calculate the score of each candidate entity;

[0047] Step 2.3: Use the ANNOY algorithm to calculate the similarity score between each candidate word and the seed entity, and add it to the weighted sum of the scores of the class name extension to obtain the expansion set of each entity space.

[0048] The specific steps of step 3 are as follows:

[0049] Step 3.1: Count the entities that appear more than twice in different entity spaces, i.e., ambiguous entities;

[0050] Step 3.2: For each entity, only the last position with the highest score is retained to generate the final hierarchical tree expansion result. The specific steps are: first, if the entity is in the entity input by the user, the entity is directly discarded; second, the ancestor entity in the ambiguous entity is retained first; third, the entity with a higher similarity score with the seed entity in the entity space is retained.

[0051] 1) Physical space completion

[0052] In the present invention, each entity space corresponding to the user input hierarchical tree Y is subjected to small batch entity expansion. Since the expansion scale is small, the more efficient ANNOY-based entity expansion method and Word2Vec-based entity expansion method are selected, and each entity space P is used to expand the entity space. i Choose different expansion methods based on the entity size.

[0053] a. Entity expansion method based on ANNOY

[0054] The ANNOY-based entity expansion method performs entity expansion on the entity space P with n entities. First, all entities in all candidate entity sets E are encoded, where the encoding method can be Word2Vec, Glove, etc. Secondly, the entity encoding is input into the ANNOY database. Finally, for the entity space P, n entities are selected as the seed set S, and the nearest neighbor entities and similarity scores of each seed entity s are found through ANNOY, and the entities are ranked according to the similarity scores, which are recorded as L. The final score of each candidate entity e is calculated according to the ranking list, and the specific calculation method is as follows:

[0055]

[0056] Among them, r i For entity e in list L iThe main reason for expansion through ANNOY is that for small-scale entity expansion methods, the accuracy of most entity expansion methods can meet the expected requirements, so the efficiency of entity expansion is given priority. ANNOY uses a binary tree data structure for query, which greatly improves the efficiency of query.

[0057] b. Entity completion method based on Word2Vec

[0058] For entity spaces where the number of entities does not reach n, the entity completion method based on Word2Vec is used. Figure 2 As shown in Figure 1, the subordinate entity space of entity e2 cannot be expanded by ANNOY. Instead, the abstract word vector e of entity P in the entity space P is obtained by combining the superior and subordinate relationship of the sibling entity space with the properties of Word2Vec. v (Red nodes in the figure). For a space with t neighbor entities that meet the conditions, e v The specific calculation process is as follows:

[0059]

[0060] in, is the parent node word vector of neighbor entity space i, is the average word vector of the neighbor entity space nodes, e f is the parent node of the current entity space. v As the central word vector of the entity space, a ranked list of similar entities is generated based on ANNOY, and the top-k entities with the highest ranking are taken as the entity completion results.

[0061] 2) Extension method based on class name

[0062] In the present invention, it is introduced how to expand each entity space based on the class name, which is divided into three steps: class name generation, class name selection and entity expansion based on the class name.

[0063] a. Class name generation

[0064] The goal of the class name generation module is to input an entity set in the entity space and generate a set of candidate class names for these entities. First, note that the goal of class name generation is similar to the homonym detection task. Therefore, six Hearst patterns are used to construct class detection queries. More specifically, three entities in the current one and a Hearst pattern are randomly selected to construct a query. For example, "[MASK]such as Np1, Np2, and Np3.". Among them, Np1, Np2, and Np1 are three random entities in the entity space, and [MASK] is the position predicted by the language model, that is, the position of the class name. By repeating such a random selection process, a set of queries can be constructed and input into the pre-trained language model (BERT) to obtain entities at positions marked by [MASK].

[0065] The above method can only generate unigram class names, which does not meet practical needs. The specific solution is to construct a new query by adding each retrieved word after [MASK] after querying the LM for the first time and retrieving the top K most likely words. For example, "[MASK]Class1 such as Np1, Np2, and Np3." This process is repeated up to three times, and the class names of all generated noun phrases are retained.

[0066] b. Class name selection

[0067] In this module, the candidate class names generated above will be sorted to select a best class name that represents the entire entity set, and some negative class names will be used in the next module to filter out wrong entities.

[0068] First, we introduce a corpus-based similarity measure between candidate entities e and class names c. Given a class name c, we first construct six entity queries in six Hearst patterns, with the position of [MASK] as the entity. We input the six queries into the language model and obtain the entity set of the six queries, namely X c In addition, using X e To represent the set of all entities e in the seed set. The similarity between e and c is defined as:

[0069]

[0070]

[0071] where cos(x, x′) is the cosine similarity between two vectors x and x0. The inner max operator finds the maximum similarity between each occurrence of e and a set of entity probe queries constructed based on c. The outer max operator identifies the top k most similar queries to e and then takes their average as the final similarity between entity e and class name c. This is similar to finding the k best occurrences of entity e that match any probe query of category c, so it improves on previous similarity measures that only exploit context-free representations of entities and class names.

[0072] After defining the entity class similarity score, we can select an entity in the current set and get a ranked list of candidate class names based on their similarity to the entity. Then, given an entity set, we get |E| ranked lists L1, L2, ..., L |E| Finally, all these lists are aggregated into a final class name ranking list according to the scores, and the first-ranked class name is selected as the positive class name, denoted as c p , and select the class name c that ranks lower than the positive class name in each list p The class name set of N .

[0073] c. Entity extension based on class name

[0074] In this module, using the positive class name c selected above p and negative class name set C N to help select new entities to add to the collection. Each entity i The score of is calculated by the two scores. The first score function is the entity e i With the class name c p The score is calculated as follows:

[0075]

[0076] Where M k is defined in Equation (3). Since this score only looks at the top-k best entities in the corpus, this score is called a local score. The second scoring function calculates the similarity between each candidate entity and the existing entities in the current set based on their context-free representations. Given the current entity set E, we first extract several entities from E, denoted as E s , and then calculate each candidate entity e i The score is calculated as follows:

[0077]

[0078] Because it uses a context-independent representation, better reflects the overall position of the entity in the embedding space, and measures the entity-entity similarity in a more global sense, it becomes a global score. Such a global score complements the above local scores, and its geometric average is used to finally rank all candidate entities:

[0079]

[0080] As the expansion process iterates, the set may contain wrong entities, resulting in semantic drift. Therefore, a new ranking algorithm is developed to improve the quality and robustness of entity selection by leveraging the negative class names selected above. First, repeatedly sample E from the current entity space E. s , a total of T times, and T entity ranking lists are obtained. Secondly, T category ranking lists are obtained according to the class name sorting process. Finally, qualified entities are screened out. Intuitively, an entity belonging to the target semantic class should meet two conditions: (1) it appears in the first few places of multiple entity ranking lists; (2) in its corresponding class ranking list, the selected positive class name c p Should be ranked above any negative class names in . Combining these two criteria, a rank aggregate score is defined as follows:

[0081]

[0082] in is an indicator function, r i It is entity e i Ranking list of L i The ranking in, finally, the collection of the last entity space with the top ranked entities is selected.

[0083] 3) Entity Disambiguation

[0084] In this work, for each task-relevant entity, the goal is to find its single best position in the hierarchical tree of the output of . Therefore, when an entity is found to appear in multiple positions during the tree expansion of , it is necessary to disambiguate the entity, i.e., find the best position where the entity should be located to resolve such conflicts.

[0085] Given a set of conflicting nodes C, corresponding to different locations of the same entity, apply the following three rules to select the best location from this set. First, if the entity is in the entities input by the user, directly select the entity and skip the following two steps. Otherwise, for each pair of nodes in C, check whether one of the nodes is the ancestor of the other node, and only keep the ancestor node. Finally, calculate the score of each remaining node e∈C as follows:

[0086]

[0087] Where sib(e) represents the set of all sibling nodes of e and par(e) represents its parent node. The skip pattern features in SK are selected based on their cumulative strength with the entities in sib(e). This equation essentially captures the joint similarity of a node with its sibling nodes and its parent node. The node with the highest confidence score will be selected. Finally, for each unselected node in C, the entire subtree where its root is located is deleted, all sibling nodes added after it are cut, and put into the "child list" of its parent node.

[0088] Finally, a hierarchical tree that satisfies the user input is returned.

[0089] In the present invention, the two tasks of width expansion and depth expansion of hierarchical tree construction are improved. For depth expansion, the entities of each entity space are expanded in small batches based on the ANNOY algorithm to more accurately express the semantics of the entity space. For width expansion, a class name is given to each entity space based on BERT, and then the entity space is expanded based on the class name.

[0090] The above is only a preferred embodiment of the present invention, which certainly cannot be used to limit the scope of rights of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and changes can be made without departing from the principle of the present invention, and these improvements and changes are also regarded as the protection scope of the present invention.

Claims

1. A BERT-based automatic hierarchical tree expansion method, characterized in that: The following steps are involved: S1: Extract entity sets from the corpus and generate word vectors for the entity sets, and preliminarily complete each entity space corresponding to the hierarchical tree input by the user; S2: Use BERT’s MASK mechanism to generate the best class name for each entity space, and use the class name to guide the expansion to generate a candidate set for each entity space. After calculating the score of each candidate entity and the similarity score with the seed set, high-quality entities are added to the corresponding entity space. S3: Perform entity disambiguation and obtain hierarchical tree expansion results; The specific steps of step S1 are as follows: Step S1.1: Use data mining to extract entities from the corpus as an extended entity set; Step S1.2: Use the Word2Vec model to obtain the word vector corresponding to each entity; Step S1.3: For each entity space, use ANNOY or word vector similarity to perform preliminary expansion to more accurately represent the semantic information represented by its entity space; The specific steps of step S2 are as follows: Step S2.1: For each entity space, find the possible class names and their scores of the entity space through BERT’s MLM task, and generate the best class name and negative class name set of the entity space through the scores; Step S2.2: Use the best class name and negative class name set to expand each entity space, take the expanded entities as candidate sets, and calculate the score of each candidate entity; Step S2.3: Use the ANNOY algorithm to calculate the similarity score between each candidate word and the seed entity, and add the weighted sum of the scores of the class name extension to obtain the extension set of each entity space; The specific steps of step S3 are as follows: Step S3.1: Count entities that appear more than twice in different entity spaces, i.e., ambiguous entities; Step S3.2: For each entity, only the last position of the score is retained to generate the final hierarchical tree expansion result; The specific steps of step S3.2 are: First, if the entity is in the entities input by the user, discard the entity directly; Second, give priority to preserving the ancestor entity among the ambiguous entities; Third, entities with higher similarity scores to the seed entities in the entity space are retained.