Knowledge graph construction method and system based on large language model

Through the knowledge graph construction method and system based on large language model, the problem of low coverage of knowledge graph construction in the existing technology is solved, and the adaptability and accuracy of multiple scenarios are achieved. Through data collection, entity recognition and relationship extraction, combined with Relational connection and graph optimization build an accurate text entity relationship network, improving the correlation between model accuracy and identification results.

CN119168026AInactive Publication Date: 2024-12-20BEIJING XIPUHUOSI TECH CO LTD

Patent Information

Application Number
CN202411226345.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-12-20
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing knowledge graph construction methods have low coverage during the construction process, cannot adapt to the needs of multiple scenarios, and lack accurate text entity and entity relationship extraction.

Method used

A knowledge graph construction method and system based on large language models is adopted, and through data collection, entity recognition and relationship extraction, combined with relationship connection and graph optimization, an accurate text entity relationship network is built, and the model is iteratively optimized to improve graph integrity.

Benefits of technology

It improves the accuracy of large language models and the correlation between recognition results, can quickly extract structured information, and continuously improves the accuracy of the model through feedback iteration, adapting to the construction of knowledge graphs in multiple scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119168026A_ABST
    Figure CN119168026A_ABST
Patent Text Reader

Abstract

The invention provides a knowledge graph construction method and system based on a large language model, and relates to the technical field of data mining, the system comprises a data acquisition module, a data identification module and a graph construction module; the data acquisition module is used for acquiring text data from the public data set; the data identification module is used for performing entity identification and relation extraction on the obtained text data to obtain a text entity and an entity relation; the graph construction module is used for connecting a text entity and an entity relationship and performing structure optimization on a text entity relationship network to obtain an optimized knowledge graph; according to the method, extraction and relation extraction are performed on the text entities by training the large language model, and accurate text entities and entity relations are provided for construction of the knowledge graph, so that the problems that an existing knowledge graph is low in coverage in the construction process and multiple scenes cannot be constructed are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data mining technology, and in particular to a method and system for constructing a knowledge graph based on a large language model. Background Art

[0002] As an important cornerstone in the field of artificial intelligence, knowledge graphs aim to represent human knowledge in a structured manner and display the complex relationships between entities in the form of graphs. They not only promote the effective organization and utilization of information, but also provide strong support for applications such as intelligent question and answer, recommendation systems, and semantic search.

[0003] In the prior art, when constructing a knowledge graph, it is often directly and unilaterally set and extracted for a certain vertical field, which is unable to provide excellent knowledge graph construction according to changes in scenarios. Therefore, a knowledge graph construction method and system based on a large language model is needed to solve the above problems. Summary of the invention

[0004] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a method and system for constructing a knowledge graph based on a large language model. By training a large language model to extract text entities and relationships, accurate text entities and entity relationships are provided for constructing a knowledge graph, so as to solve the problem that the existing knowledge graph has low coverage during the construction process and cannot be constructed for multiple scenarios.

[0005] In order to achieve the above-mentioned object, the present invention is implemented through the following technical solutions: In the first aspect, a knowledge graph construction system based on a large language model, the system includes a data acquisition module, a data recognition module and a graph construction module;

[0006] The data acquisition module is used to obtain text data from a public data set;

[0007] The data recognition module is used to perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships;

[0008] The graph construction module includes a relation connection unit and a graph optimization unit, wherein the relation connection unit is used to connect text entities and entity relationships to obtain a text entity relationship network;

[0009] The graph optimization unit is used to perform structural optimization on the text entity relationship network to obtain an optimized knowledge graph.

[0010] Furthermore, the data recognition module includes a model building unit and an identification extraction unit, the model building unit is configured with a model building strategy, the model building strategy includes obtaining a large amount of text data from a database, setting it as training text data, cleaning the training text data, removing hypertext markup speech, special characters, extra spaces and irrelevant information, and obtaining cleaned training text data;

[0011] Build a model and use a large amount of clean training text data to pre-train the model to obtain a pre-trained model;

[0012] Obtain any cleaned training text data, determine the type system of named entities of the cleaned training text data, manually annotate the cleaned training text data, and obtain annotated training text data;

[0013] The pre-trained model is trained using labeled training text data to obtain a large language model.

[0014] Furthermore, the recognition and extraction unit is configured with a recognition and extraction strategy, which includes acquiring text data, cleaning the text data to obtain cleaned training text data, and performing named entity recognition on the cleaned training text data using a trained large language model to obtain text entities;

[0015] Use the trained large language model to extract the relationships between text entities, predict the relationship types and relationship directions between entities, and obtain entity relationships.

[0016] Further, the relationship connection unit is configured with a relationship connection strategy, which includes obtaining text entities and text relations, creating a pre-connection for text entities with text relations, obtaining the relationship pointing in the pre-connection from the text relations, setting the pointed text entity as the pointing text entity, and setting the pointed text entity as the pointed text entity;

[0017] Get all pointing text entities and pointed text entities, and obtain the pointing text entity set and the pointed text entity set;

[0018] The same text entities in the pointing text entity set and the pointed text entity set are merged, and the integrated pointing text entity set and the pointed text entity set are reconnected to obtain a text entity relationship network, which includes multiple pointed text entities of the pointing text entity and multiple pointing text entities of the pointed text entity.

[0019] Furthermore, the graph optimization unit is configured with a relationship optimization strategy, which includes obtaining the text type between each text relationship from the text relationship, filling the text type into the text entity relationship network,

[0020] The text entity relationship network is optimized to obtain an optimized relationship network.

[0021] Furthermore, the optimization process includes obtaining three text entities that are continuously connected from the text entity relationship network, deleting the text entity in the middle of the connection, and then using the large language model to extract the relationship between the remaining two text entities;

[0022] When no entity relationship is extracted, the original connection remains unchanged;

[0023] When the entity relationship is extracted, the remaining two text entities are connected and the relationship type is filled in;

[0024] After optimizing all the texts in the text entity relationship network, an optimized relationship network is obtained.

[0025] Furthermore, the graph optimization unit is also configured with a relationship verification strategy, which includes obtaining the existing entities in the optimized relationship network and the knowledge graph, filling the text entities and entity relationships in the optimized relationship network into the knowledge graph, and obtaining a pre-knowledge graph;

[0026] The graph completeness of the pre-knowledge graph is evaluated, and the graph completeness is set as the ratio of the text entities filled in from the optimized relationship network to the existing entities in the knowledge graph as the graph completeness percentage;

[0027] When the graph completeness percentage is greater than or equal to the first ratio, setting the pre-knowledge graph to the optimized knowledge graph;

[0028] When the graph completeness percentage is less than the first ratio, the large language model is iterated in real time to reacquire text entities and text relations until the graph completeness percentage is greater than or equal to the first ratio.

[0029] In a second aspect, a method for constructing a knowledge graph based on a large language model is provided, the method comprising:

[0030] Step S1: Obtain text data from a public dataset;

[0031] Step S2: Perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships;

[0032] Step S3: Connect the text entities and entity relationships to obtain a text entity relationship network;

[0033] Step S4: Structural optimization of the text entity relationship network to obtain an optimized knowledge graph.

[0034] Beneficial effects of the present invention: The present invention first obtains text data from a public data set, and the text data is used to train a large language model and extract text entities. Obtaining text data from a public data set can ensure that the training set is sufficient, thereby improving the accuracy of the large language model;

[0035] The present invention also trains a large language model to perform entity recognition and relationship extraction on text data, which can quickly extract structured information from a large amount of text, accurately obtain text entities in the text, and improve the relevance and accuracy of the recognition results;

[0036] The present invention can also provide feedback on the results of the large language model by evaluating the knowledge graph, iterate the large language model in a timely manner, and continuously improve the accuracy of the large language model.

[0037] Advantages of additional aspects of the present invention will be given in part in the description of the following specific embodiments, and in part will become apparent from the following description, or will be learned through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0039] Figure 1 is a functional block diagram of the system of the present invention;

[0040] Figure 2 It is a schematic diagram of the relationship connection of the present invention;

[0041] Figure 3 The figure is a flow chart of the method steps of the present invention. DETAILED DESCRIPTION

[0042] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0043] It should be noted that the terms used herein are for describing specific embodiments only and are not intended to be limiting of exemplary embodiments according to the present invention.

[0044] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0045] Example 1, please refer to Figure 1 As shown, the present application provides a knowledge graph construction method and system based on a large language model, including a data acquisition module, a data recognition module and a graph construction module;

[0046] The data acquisition module is used to obtain text data from public data sets. In the specific implementation process, the text data is used to train the large language model and extract text entities. Choosing to obtain text data from public data sets can avoid the problem of inaccuracy of the large language model due to the small training set;

[0047] The data recognition module is used to perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships;

[0048] The data recognition module includes a model building unit and a recognition extraction unit. The model building unit is configured with a model building strategy. The model building strategy includes obtaining a large amount of text data from a database, setting it as training text data, cleaning the training text data, removing hypertext markup speech, special characters, extra spaces and irrelevant information, and obtaining cleaned training text data. In the specific implementation process, cleaning the training text data can ensure the purity and consistency of the data;

[0049] Build a model and use a large amount of clean training text data to pre-train the model to obtain a pre-trained model; in the specific implementation process, the constructed model needs to process large-scale text, so the GPT-4 model is selected for training;

[0050] Obtain any cleaned training text data, determine the type system of named entities of the cleaned training text data, manually annotate the cleaned training text data, and obtain annotated training text data; in the specific implementation process, the type system of named entities mainly includes names of people, places, institutions, time, date, currency, and percentage. In specific fields, specific named entity categories will also appear. For example, drug names will appear in the medical field. The type system is manually annotated and classified for different scenarios and fields;

[0051] The pre-trained model is trained using labeled training text data to obtain a large language model.

[0052] The recognition and extraction unit is configured with a recognition and extraction strategy, which includes acquiring text data, cleaning the text data to obtain cleaned training text data, and performing named entity recognition on the cleaned training text data using a trained large language model to obtain text entities;

[0053] Use the trained large language model to extract the relationship between text entities, predict the relationship type and relationship direction between entities, and obtain entity relationships;

[0054] The graph construction module includes a relation connection unit and a graph optimization unit. The relation connection unit is used to connect text entities and entity relationships to obtain a text entity relationship network.

[0055] See also Figure 2 As shown, the relationship connection unit is configured with a relationship connection strategy, which includes obtaining text entities and text relations, creating a pre-connection for text entities with text relations, obtaining the relationship pointing in the pre-connection from the text relations, setting the pointed text entity as the pointing text entity, and setting the pointed text entity as the pointed text entity; in a specific implementation process, for example, in a pre-connection, entity 1 is "Li Si", entity 2 is "a certain school", and the text relationship is "studying in", then the pointing text entity is "Li Si", and the pointed text entity is "a certain school";

[0056] Get all pointing text entities and pointed text entities, and obtain the pointing text entity set and the pointed text entity set;

[0057] The same text entities in the pointing text entity set and the pointed text entity set are merged, and the integrated pointing text entity set and the pointed text entity set are reconnected to obtain a text entity relationship network, which includes multiple pointed text entities of the pointing text entity and multiple pointing text entities of the pointed text entity; in a specific implementation process, for example, in one set of pre-connections, the pointing text entity is "Li Si" and the pointing text entity is "a certain school", and in another set of pre-connections, the pointing text entity is "Li Si" and the pointing text entity is "a certain region", then the pointing text entity "Li Si" is integrated to obtain the pointing text entity "Li Si" and two pointing text entities "a certain school" and "a certain region";

[0058] The graph optimization unit is used to optimize the structure of the text entity relationship network to obtain an optimized knowledge graph;

[0059] The graph optimization unit is configured with a relationship optimization strategy, which includes obtaining the text type between each text relationship from the text relationship, filling the text type into the text entity relationship network, optimizing the text entity relationship network, and obtaining an optimized relationship network;

[0060] The optimization process includes obtaining three text entities that are continuously connected from the text entity relationship network, deleting the text entity in the middle of the connection, and then using the large language model to extract the relationship between the remaining two text entities;

[0061] When no entity relationship is extracted, the original connection remains unchanged;

[0062] When the entity relationship is extracted, the remaining two text entities are connected and the relationship type is filled in. In the specific implementation process, for example, the three text entities that are connected continuously are "Li Si", "a certain school" and "a certain region". After deleting the middle text entity "a certain school", the large language model is used to extract the relationship between "Li Si" and "a certain region", and the entity relationship is "living in". In this case, "Li Si" and "a certain region" are connected and the relationship type "living in" is filled in.

[0063] The graph optimization unit is also configured with a relationship verification strategy, which includes obtaining the existing entities in the optimized relationship network and the knowledge graph, filling the text entities and entity relationships in the optimized relationship network into the knowledge graph, and obtaining a pre-knowledge graph;

[0064] The graph completeness of the pre-knowledge graph is evaluated, and the graph completeness is set as the ratio of the text entities filled in from the optimized relationship network to the existing entities in the knowledge graph as the graph completeness percentage;

[0065] When the graph completeness percentage is greater than or equal to the first ratio, the pre-knowledge graph is set as the optimized knowledge graph; in this embodiment, the first ratio is set to 95%, and in the specific implementation process, the first ratio can be adjusted according to the actual situation;

[0066] When the graph completeness percentage is less than the first ratio, the large language model is iterated in real time to reacquire text entities and text relations until the graph completeness percentage is greater than or equal to the first ratio.

[0067] Example 2, please refer to Figure 3 As shown, a method for constructing a knowledge graph based on a large language model includes:

[0068] Step S1: Obtain text data from a public dataset;

[0069] Step S2: Perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships;

[0070] Step S2 includes the following sub-steps:

[0071] Step S201: a large amount of text data is obtained from a database, set as training text data, and the training text data is cleaned to remove hypertext markup speech, special characters, extra spaces and irrelevant information to obtain cleaned training text data;

[0072] Step S202: construct a model, and use a large amount of cleaned training text data to pre-train the model to obtain a pre-trained model;

[0073] Step S203: obtaining any cleaned training text data, determining the type system of the named entities of the cleaned training text data, and manually annotating the cleaned training text data to obtain annotated training text data;

[0074] Step S204: training the pre-trained model using the annotated training text data to obtain a large language model;

[0075] Step S205: Acquire text data, and clean the text data to obtain cleaned training text data;

[0076] Step S206: Use the trained large language model to perform named entity recognition on the cleaned training text data to obtain text entities;

[0077] Use the trained large language model to extract the relationship between text entities, predict the relationship type and relationship direction between entities, and obtain entity relationships;

[0078] Step S3: Connect the text entities and entity relationships to obtain a text entity relationship network; Step S3 includes the following sub-steps:

[0079] Step S301: obtaining text entities and text relations, creating a pre-connection for text entities with text relations, obtaining the relation pointing in the pre-connection from the text relations, setting the pointed text entity as the pointing text entity, and setting the pointed text entity as the pointed text entity;

[0080] Step S302: Acquire all pointing text entities and pointed text entities to obtain a pointing text entity set and a pointed text entity set;

[0081] Step S303: merging the same text entities in the pointing text entity set and the pointed text entity set, and reconnecting the integrated pointing text entity set and the pointed text entity set to obtain a text entity relationship network, wherein the text entity relationship network includes multiple pointed text entities of the pointing text entity and multiple pointing text entities of the pointed text entity;

[0082] Step S4: Optimize the structure of the text entity relationship network to obtain an optimized knowledge graph. Step S4 includes the following sub-steps:

[0083] Step S401: obtaining the text type between each text relationship from the text relationship, and filling the text type into the text entity relationship network;

[0084] Step S402: Optimizing the text entity relationship network to obtain an optimized relationship network;

[0085] Step S402 includes the following sub-steps:

[0086] Step S40201: Acquire three text entities that are continuously connected from the text entity relationship network;

[0087] Step S40202: After deleting the text entity in the middle of the connection, use the large language model to extract the relationship between the remaining two text entities;

[0088] When no entity relationship is extracted, the original connection remains unchanged;

[0089] When the entity relationship is extracted, the remaining two text entities are connected and the relationship type is filled in;

[0090] Step S40203: Optimizing all texts in the text entity relationship network to obtain an optimized relationship network;

[0091] Step S403: Obtain existing entities in the optimized relationship network and the knowledge graph, fill the text entities and entity relationships in the optimized relationship network into the knowledge graph, and obtain a pre-knowledge graph;

[0092] Step S404: Evaluate the graph integrity of the pre-knowledge graph, and set the graph integrity as the ratio of the text entities filled in from the optimized relationship network to the existing entities in the knowledge graph as the graph integrity percentage;

[0093] When the graph completeness percentage is greater than or equal to the first ratio, the pre-knowledge graph is set as the optimized knowledge graph;

[0094] When the graph completeness percentage is less than the first ratio, the large language model is iterated in real time to reacquire text entities and text relations until the graph completeness percentage is greater than or equal to the first ratio.

[0095] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Wherein, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (Static Random Access Memory, SRAM for short), an electrically erasable programmable read-only memory (EEPROM for short), an erasable programmable read-only memory (EPROM for short), a programmable read-only memory (PROM for short), a read-only memory (ROM for short), a magnetic memory, a flash memory, a magnetic disk or an optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0096] The above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A knowledge graph construction system based on a large language model, It is characterized in that It includes data acquisition module, data recognition module and graph construction module; The data acquisition module is used to obtain text data from a public data set; The data recognition module is used to perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships; The graph construction module includes a relation connection unit and a graph optimization unit, wherein the relation connection unit is used to connect text entities and entity relationships to obtain a text entity relationship network; The graph optimization unit is used to perform structural optimization on the text entity relationship network to obtain an optimized knowledge graph.

2. A knowledge graph construction system based on a large language model according to claim 1, It is characterized in that The data recognition module includes a model building unit and an identification extraction unit, wherein the model building unit is configured with a model building strategy, wherein the model building strategy includes obtaining a large amount of text data from a database, setting it as training text data, cleaning the training text data, removing hypertext markup speech, special characters, redundant spaces and irrelevant information, and obtaining cleaned training text data; Build a model and use a large amount of clean training text data to pre-train the model to obtain a pre-trained model; Obtain any cleaned training text data, determine the type system of named entities of the cleaned training text data, manually annotate the cleaned training text data, and obtain annotated training text data; The pre-trained model is trained using labeled training text data to obtain a large language model.

3. A knowledge graph construction system based on a large language model according to claim 2, It is characterized in that The recognition and extraction unit is configured with a recognition and extraction strategy, which includes acquiring text data, cleaning the text data to obtain cleaned training text data, and performing named entity recognition on the cleaned training text data using a trained large language model to obtain text entities; Use the trained large language model to extract the relationships between text entities, predict the relationship types and relationship directions between entities, and obtain entity relationships.

4. A knowledge graph construction system based on a large language model according to claim 3, It is characterized in that The relationship connection unit is configured with a relationship connection strategy, which includes obtaining text entities and text relations, creating a pre-connection for text entities with text relations, obtaining the relationship pointing in the pre-connection from the text relations, setting the pointed text entity as the pointing text entity, and setting the pointed text entity as the pointed text entity; Get all pointing text entities and pointed text entities, and obtain the pointing text entity set and the pointed text entity set; The same text entities in the pointing text entity set and the pointed text entity set are merged, and the integrated pointing text entity set and the pointed text entity set are reconnected to obtain a text entity relationship network, which includes multiple pointed text entities of the pointing text entity and multiple pointing text entities of the pointed text entity.

5. A knowledge graph construction system based on a large language model according to claim 4, It is characterized in that The graph optimization unit is configured with a relationship optimization strategy, which includes obtaining the text type between each text relationship from the text relationship, filling the text type into the text entity relationship network, The text entity relationship network is optimized to obtain an optimized relationship network.

6. A knowledge graph construction system based on a large language model according to claim 5, It is characterized in that The optimization process includes obtaining three text entities that are continuously connected from the text entity relationship network, deleting the text entity in the middle of the connection, and then using the large language model to extract the relationship between the remaining two text entities; When no entity relationship is extracted, the original connection remains unchanged; When the entity relationship is extracted, the remaining two text entities are connected and the relationship type is filled in; After optimizing all the texts in the text entity relationship network, an optimized relationship network is obtained.

7. A knowledge graph construction system based on a large language model according to claim 6, It is characterized in that The graph optimization unit is also configured with a relationship verification strategy, which includes obtaining the existing entities in the optimized relationship network and the knowledge graph, filling the text entities and entity relationships in the optimized relationship network into the knowledge graph, and obtaining a pre-knowledge graph; The graph completeness of the pre-knowledge graph is evaluated, and the graph completeness is set as the ratio of the text entities filled in from the optimized relationship network to the existing entities in the knowledge graph as the graph completeness percentage; When the graph completeness percentage is greater than or equal to the first ratio, setting the pre-knowledge graph to the optimized knowledge graph; When the graph completeness percentage is less than the first ratio, the large language model is iterated in real time to reacquire text entities and text relations until the graph completeness percentage is greater than or equal to the first ratio.

8. A method for constructing a knowledge graph based on a large language model applicable to any one of claims 1 to 7, It is characterized in that The method comprises: Step S1: Obtain text data from a public dataset; Step S2: Perform entity recognition and relationship extraction on the acquired text data to obtain text entities and entity relationships; Step S3: Connect the text entities and entity relationships to obtain a text entity relationship network; Step S4: Structural optimization of the text entity relationship network to obtain an optimized knowledge graph.

Citation Information

Patent Citations

  • Knowledge graph construction method and device, equipment and storage medium

    CN116860997A

  • Method for constructing computer education knowledge graph based on knowledge graph

    CN117875412A

  • Deep reading method and system based on knowledge graph

    CN118193748A

Cited By

  • Cultural domain dynamic ontology intelligent construction method based on large model

    CN120893444A

  • A large model-based cultural field dynamic ontology intelligent construction method

    CN120893444B

  • Cross-platform knowledge graph construction method and construction system

    CN121597847A

  • A cross-platform knowledge graph construction method and a construction system

    CN121597847B