Entity linking method, device, equipment and storage medium based on large language model
Through the entity linking method based on large language models, the dependence problem on a large amount of training data in the prior art is solved, efficient entity linking is achieved, and resource requirements and operational complexity are reduced.
Patent Information
- Application Number
- CN202411883141.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-04
AI Technical Summary
Existing entity linking technologies require a large amount of training data, resulting in the development of high-performance entity linking technologies being limited by data and hardware resources.
The entity linking method based on the large language model is adopted, and the problem text and knowledge graph are constructed, the entity and first-order subgraph embedded representation are calculated, the similarity calculation is performed, the candidate entities are screened, and the large language model is used to determine the most relevant entities.
Reduce dependence on large amounts of training data, avoid additional entity recognition and disambiguation operations, and improve the efficiency and performance of entity links.
Smart Images

Figure CN119761371A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of entity linking technology, and in particular to an entity linking method, device, equipment and storage medium based on a large language model. Background Art
[0002] Typically, entity linking consists of two parts: a candidate word generation module and an entity disambiguation module. The purpose of the former is to select a suitable subset of named entities from the knowledge base that can be associated with a given text entity type in the input text. This set of candidate entity subsets is then handed over to the latter module, whose goal is to select and assign the most appropriate entity to the entity type. Existing research shows that learning better entity types and semantic representations of entities is the key to improving the composition of the above two modules and obtaining better results. Therefore, the development of entity linking technology from rule matching to representation learning to the application of neural networks is to better learn the rich information of the subgraph composed of entities, entity types, and entity relationships in the knowledge graph. However, a common problem with existing entity linking is that a large amount of training data is required for better performance of entity linking, usually millions of annotated corpora, which makes the development of high-performance entity linking technology likely to be affected by data and hardware resources.
[0003] Therefore, an entity linking method, device, equipment and storage medium based on a large language model are developed to solve the above problems. Summary of the invention
[0004] The present invention proposes an entity linking method, device, equipment and storage medium based on a large language model to solve the problem that the existing entity linking method requires a large amount of training data.
[0005] The present invention achieves the above-mentioned purpose through the following technical solutions:
[0006] The present invention provides an entity linking method based on a large language model, comprising:
[0007] Construct question text and knowledge graph;
[0008] Calculate entity embedding representation and first-order subgraph embedding representation of entities in the knowledge graph according to the entities in the knowledge graph;
[0009] Encode the question text to obtain a text embedding representation;
[0010] Concatenating the entity embedding representation and the first-order subgraph embedding representation to obtain an embedding representation concatenation;
[0011] Performing similarity calculations on the concatenation of the embedding representations corresponding to all entities in the knowledge graph and the text embedding representations in sequence to obtain similarity calculation results;
[0012] According to the similarity calculation result, all entities in the knowledge graph are screened based on the argmax function, and a preset number of entities in the question text with top rankings in the similarity calculation results are output as candidate entities;
[0013] The candidate entities are input into a large language model, and the candidate entities most relevant to the entities in the question text are output.
[0014] Furthermore, obtaining an entity embedding representation and a first-order subgraph embedding representation according to the knowledge embedding representation of the knowledge graph includes:
[0015] Embedding entities of the knowledge graph through the GLOVE model;
[0016] The entities of the knowledge graph are learned through a relationship-based graph attention network to obtain first-order subgraph embedding representation learning.
[0017] Furthermore, for the entity Entity embedding representation The calculation formula is as follows:
[0018]
[0019] The calculation formula for learning the entities of the knowledge graph through the relationship-based graph attention network is as follows:
[0020]
[0021] in, Representing Entities The first-order subgraph embedding representation at this layer is represents the Relu activation function, express The set of neighbor entities of Representing Entities and In order to project entity embeddings onto different relations and construct relation-specific embeddings, The calculation method is as follows:
[0022]
[0023] Where I is the identity matrix, Representing Entities and The relation embedding representation of T represents transposition. Representing Entities and The attention coefficient is calculated as follows:
[0024]
[0025] in Representing Entities and The complementary edge embedding representation of , represents the embedding representation of the u-th entity, represents a two-dimensional matrix and T represents transpose.
[0026] Furthermore, the question text is encoded to obtain the following calculation formula for text embedding representation:
[0027]
[0028] represents the text embedding representation, Represents the question text.
[0029] Furthermore, according to the similarity calculation result, all entities in the knowledge graph are screened based on the argmax function, and the calculation formula for outputting a preset number of entities in the question text with top similarity calculation results as candidate entities is as follows:
[0030]
[0031] in, represents the concatenation of the embedding representation of the entity and the first-order subgraph embedding, Sim represents the similarity calculation, argmax represents the entity of the knowledge graph corresponding to the first K similarity calculation results, k is a preset value, represents the candidate entity.
[0032] Furthermore, the candidate entity is input into the large language model, and the calculation formula for outputting the candidate entity most relevant to the entity is:
[0033]
[0034] in, represents large language model reasoning, represents all the candidate entities, Represents the candidate entity that is most relevant to the entity in the question text.
[0035] The present invention also provides an entity linking device based on a large language model, comprising:
[0036] A construction module, wherein the construction module is used to construct question text and knowledge graph;
[0037] A first computing module, the first computing module is used to calculate the entity embedding representation and the first-order subgraph embedding representation of the entity in the knowledge graph according to the entity in the knowledge graph;
[0038] An encoding module, the encoding module is used to encode the question text to obtain a text embedding representation;
[0039] A splicing module, the splicing module is used to splice the entity embedding representation and the first-order subgraph embedding representation to obtain an embedded representation splicing;
[0040] A second calculation module, the second calculation module is used to sequentially perform similarity calculations on the embedding representation concatenation and the text embedding representation corresponding to all entities in the knowledge graph to obtain a similarity calculation result;
[0041] A screening module, the screening module is used to screen all entities in the knowledge graph based on the similarity calculation result and the argmax function, and output candidate entities corresponding to the entities in the question text;
[0042] An output module is used to input the candidate entities into a large language model and output the candidate entities that are most relevant to the entities in the question text.
[0043] The present invention also provides an entity linking device based on a large language model, comprising:
[0044] Memory for storing computer programs;
[0045] A processor is used to implement the steps of the entity linking method based on a large language model when executing the computer program.
[0046] The present invention also provides a storage medium, which is a readable storage medium. A computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the entity linking method based on a large language model are implemented.
[0047] The beneficial effects of the present invention are:
[0048] The entity linking method, device, equipment and storage medium based on a large language model proposed in the present invention solve the problem that from the perspective of entity linking from text to knowledge graph, it is usually necessary to use a model to perform entity recognition on the text, search for candidate entities for entities, disambiguate candidate entities, and require a large amount of knowledge graph alignment data for training. Compared with traditional methods, this method avoids the need for additional models for entity recognition and entity disambiguation operations, and avoids the need for large amounts of data training. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is a flow chart of a method for entity linking based on a large language model for this application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0051] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0053] In the description of the present invention, it should be understood that the terms "upper", "lower", "inside", "outside", "left", "right", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings, or are directions or positional relationships in which the product of the invention is usually placed when in use, or are directions or positional relationships commonly understood by those skilled in the art. These directions or positional relationships are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as a limitation on the present invention.
[0054] Furthermore, the terms “first”, “second”, etc. are merely used for distinguishing descriptions and should not be understood as indicating or implying relative importance.
[0055] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms such as "setting" and "connection" should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0056] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings.
[0057] In order to link the commodity entity mentioned in the question text query to the correct entity in the knowledge graph G, an entity linking method based on a large language model is adopted. The method mainly uses the text vector and the vector of the entity and its subgraph in the knowledge graph to calculate the similarity, obtains the candidate entity of the entity in the text, and then determines the most relevant candidate entity through the large language model. The large language model in the present invention can be selected from large language models such as Qwen2.57B, Qwen2.514B and chatglm-6b, which are open source large models.
[0058] like Figure 1 As shown, the present invention provides an entity linking method based on a large language model, comprising:
[0059] S1: Construct question text and knowledge graph;
[0060] Specifically, we construct a text query about a product question and a product knowledge graph G = (E, R, T), where E, R, and T represent the set of entities, relations, and triples, respectively. Each triple is expressed in the form of , where r∈R is the head entity and tail entity relationship.
[0061] S2: Calculate entity embedding representation and first-order subgraph embedding representation of entities in the knowledge graph according to the entities in the knowledge graph;
[0062] Specifically, the GLOVE model is used to embed entities. Entity embedding representation The calculation formula is as follows:
[0063]
[0064] express Model;
[0065] For first-order subgraph embedding representation learning, using a relation-based graph attention network can better learn the relational representation between entities. The first-order subgraph embedding of The calculation formula is as follows:
[0066]
[0067] in, Representing Entities The subgraph embedding representation at this layer is represents the Relu activation function, express The set of neighbor entities of Representing Entities and In order to project entity embeddings onto different relations and construct relation-specific embeddings. The calculation method is as follows:
[0068]
[0069] Where I is the identity matrix, Representing Entities and The relation embedding representation of . Representing Entities and The attention coefficient is calculated as follows:
[0070]
[0071] in Representing Entities and The complementary edge embedding representation of represents the embedding representation of the u-th entity, Represents a two-dimensional matrix, which is a trainable parameter, and T represents transpose.
[0072] S3: Encode the question text to obtain a text embedding representation;
[0073] Specifically, the text query is encoded to obtain the text embedding representation , the calculation method is as follows;
[0074]
[0075] express Model;
[0076] S4: concatenating the entity embedding representation and the first-order subgraph embedding representation to obtain a concatenated embedding representation;
[0077] S5: performing similarity calculation on the concatenation of the embedding representations corresponding to all entities in the knowledge graph and the text embedding representations in sequence to obtain a similarity calculation result;
[0078] S6: According to the similarity calculation result, all entities in the knowledge graph are screened based on the argmax function, and a preset number of entities in the question text with top rankings in the similarity calculation results are output as candidate entities;
[0079] Specifically, calculate the similarity and take the top K results. The calculation method is as follows:
[0080]
[0081] in, Embedding means concatenation, Sim means similarity calculation, and argmax means taking the first K results. The similarity calculation method uses cosine similarity, which can better represent the similarity between vectors. The value of K is usually 5.
[0082] S7: Use the large language model LLM to infer the final result and determine the entities in the text query The equivalent entity is .
[0083] The final result is obtained by using the large language model LLM reasoning to determine the entities in the text query. The equivalent entity is , this method not only utilizes LLM’s own powerful background knowledge, but also reduces time-consuming reasoning calculations. The calculation method is as follows:
[0084] .
[0085] represents large language model reasoning, represents all the candidate entities, Represents the candidate entity that is most relevant to the entity in the question text
[0086] The present invention also provides an entity linking device based on a large language model, comprising:
[0087] A construction module, wherein the construction module is used to construct question text and knowledge graph;
[0088] A first computing module, the first computing module is used to calculate the entity embedding representation and the first-order subgraph embedding representation of the entity in the knowledge graph according to the entity in the knowledge graph;
[0089] An encoding module, the encoding module is used to encode the question text to obtain a text embedding representation;
[0090] A splicing module, the splicing module is used to splice the entity embedding representation and the first-order subgraph embedding representation to obtain an embedded representation splicing;
[0091] A second calculation module, the second calculation module is used to sequentially perform similarity calculations on the embedding representation concatenation and the text embedding representation corresponding to all entities in the knowledge graph to obtain a similarity calculation result;
[0092] A screening module, the screening module is used to screen all entities in the knowledge graph based on the similarity calculation result and the argmax function, and output candidate entities corresponding to the entities in the question text;
[0093] An output module is used to input the candidate entities into a large language model and output the candidate entities that are most relevant to the entities in the question text.
[0094] The present invention also provides an entity linking device based on a large language model, comprising:
[0095] Memory for storing computer programs;
[0096] A processor is used to implement the steps of the entity linking method based on a large language model when executing the computer program.
[0097] The present invention also provides a storage medium, which is a readable storage medium. A computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the entity linking method based on a large language model are implemented.
[0098] The present invention is further described below by using specific examples:
[0099] Step 1: Pre-build the product knowledge graph and question text: "Looking for an Apple watch suitable for sports." The product knowledge graph contains various products (such as different models of Apple watches, Huawei watches), brands (such as Apple, Samsung, Garmin, Huawei), categories (such as smart watches), features (such as waterproof, GPS function, etc.), and the relationships between them.
[0100] Step 2: The GLOVE model is used to embed entities, and the first-order subgraph structural features of these entities are learned using the graph attention network (GAT) with added relationships to obtain entity embedding representations and first-order subgraph embedding representations. This enables the model to capture the relationship information between products and their associated entities, such as the connection between a specific model of Apple Watch and its accessories or related functions.
[0101] Step 3: Encode the user-entered question text "Looking for an Apple Watch suitable for exercise" into a text embedding representation The GLOVE model is used in this process to understand the semantics in natural language.
[0102] Step 4: Concatenate the entity embedding representation and the first-order subgraph embedding representation to obtain an embedding representation concatenation;
[0103] Step 5: perform similarity calculation on the embedding representation concatenation and the text embedding representation corresponding to all entities in the knowledge graph in sequence to obtain a similarity calculation result;
[0104] Step 6: According to the similarity calculation result, all entities in the knowledge graph are screened based on the argmax function, and a preset number of entities in the question text with top similarity calculation results are output as candidate entities;
[0105] The model uses cosine similarity calculation method to calculate text embedding Embedded with all entities in the knowledge graph and subgraph embedding representation By comparing, the most relevant entities are found, i.e., those products that not only match in name but are also highly relevant based on their characteristics and associations. The top 5 most similar vector results are selected as Top1, Top2, Top3, Top4, and Top5, where:
[0106] The vector representation results of Top1:AppleWatchUltra2,Top2:AppleWatchS10,Top3:AppleWatchS9,Top4:AppleWatchS8,Top5:AppleWatchSE are as follows:
[0107] ((top1,T1),(top2,T2),(top3,T3),(top4,T4),(top5,T5)).
[0108] Step 7: Use the Large Language Model (LLM) to further reason and ensure that the selected entity is indeed the best explanation of the user's query. In this example, the Large Language Model (LLM) will evaluate which options best meet the requirements of "suitable for exercise" and determine the equivalent entity corresponding to the "Apple watch" in the text query. The specific model is Apple Watch Ultra 2.
[0109] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An entity linking method based on a large language model, characterized in that: include: Construct question text and knowledge graph; Calculate entity embedding representation and first-order subgraph embedding representation of entities in the knowledge graph according to the entities in the knowledge graph; Encode the question text to obtain a text embedding representation; Concatenating the entity embedding representation and the first-order subgraph embedding representation to obtain an embedding representation concatenation; Performing similarity calculations on the concatenation of the embedding representations and the text embedding representations corresponding to all entities in the knowledge graph in sequence to obtain similarity calculation results; According to the similarity calculation result, all entities in the knowledge graph are screened based on the argmax function, and a preset number of entities in the question text with top rankings in the similarity calculation results are output as candidate entities; The candidate entities are input into a large language model, and the candidate entities most relevant to the entities in the question text are output.
2. According to the entity linking method based on a large language model according to claim 1, it is characterized in that: According to the knowledge embedding representation of the knowledge graph, an entity embedding representation and a first-order subgraph embedding representation are obtained, including: Embedding entities of the knowledge graph through the GLOVE model; The entities of the knowledge graph are learned through a relationship-based graph attention network to obtain first-order subgraph embedding representation learning.
3. According to the entity linking method based on a large language model as described in claim 2, it is characterized in that: For entities Entity embedding representation The calculation formula is as follows: , express Model; The calculation formula for learning the entities of the knowledge graph through the relationship-based graph attention network is as follows: , in, Representing Entities The first-order subgraph embedding representation at this layer is represents the Relu activation function, express The set of neighbor entities of Representing Entities and The relationship transformation matrix, The calculation method is as follows: , Where I is the identity matrix, Representing Entities and The relation embedding representation of T represents transposition. Representing Entities and The attention coefficient is calculated as follows: , in Representing Entities and The complementary edge embedding representation of represents the embedding representation of the u-th entity, represents a two-dimensional matrix and T represents transpose.
4. The entity linking method based on a large language model according to claim 1, characterized in that: The question text is encoded to obtain the calculation formula for text embedding representation as follows: , represents the text embedding representation, Represents the question text, express Model.
5. The entity linking method based on a large language model according to claim 4, characterized in that: According to the similarity calculation results, all entities in the knowledge graph are screened based on the argmax function, and the calculation formula for outputting a preset number of entities in the question text with top similarity calculation results as candidate entities is as follows: , in, represents the concatenation of the embedding representation of the entity and the first-order subgraph embedding, Sim represents the similarity calculation, argmax represents the entity of the knowledge graph corresponding to the first K similarity calculation results, k is a preset value, represents the candidate entity.
6. The entity linking method based on a large language model according to claim 1, characterized in that: The candidate entity is input into the large language model, and the calculation formula for outputting the candidate entity most related to the entity is: , in, represents large language model reasoning, represents all the candidate entities, Represents the candidate entity that is most relevant to the entity in the question text.
7. An entity linking device based on a large language model, characterized in that: include: A construction module, wherein the construction module is used to construct question text and knowledge graph; A first computing module, the first computing module is used to calculate the entity embedding representation and the first-order subgraph embedding representation of the entity in the knowledge graph according to the entity in the knowledge graph; An encoding module, the encoding module is used to encode the question text to obtain a text embedding representation; A splicing module, the splicing module is used to splice the entity embedding representation and the first-order subgraph embedding representation to obtain an embedded representation splicing; A second calculation module, the second calculation module is used to sequentially perform similarity calculations on the embedding representation concatenation and the text embedding representation corresponding to all entities in the knowledge graph to obtain a similarity calculation result; A screening module, the screening module is used to screen all entities in the knowledge graph based on the similarity calculation result and the argmax function, and output candidate entities corresponding to the entities in the question text; An output module is used to input the candidate entities into a large language model and output the candidate entities that are most relevant to the entities in the question text.
8. An entity linking device based on a large language model, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of an entity linking method based on a large language model as described in any one of claims 1 to 6 when executing the computer program.
9. A storage medium, characterized in that: The storage medium is a readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the entity linking method based on a large language model as described in any one of claims 1 to 6 are implemented.