Knowledge graph automatic construction query method and system based on large language model
By automatically constructing and querying knowledge graphs using large language models, the high cost problem in the construction and use of knowledge graphs is solved, thereby reducing costs and improving reliability, and enabling self-updating.
Patent Information
- Application Number
- CN202311330300.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-13
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-10-13
AI Technical Summary
The construction and use of knowledge graphs involve high costs, including human resources costs for experts and annotation, computing power costs, education costs, and development costs.
Large language models are used for data cleaning, ontology construction, and entity disambiguation. Through the inductive, inferential, and text generation capabilities of large language models, knowledge graphs are automatically constructed and queried, replacing traditional manual operations.
It reduces the cost of building and using knowledge graphs, improves their reliability and usability, and enables them to self-update.
Smart Images

Figure CN117273136B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the application field of knowledge graph, and in particular to a knowledge graph automatic construction and query method and system for futures, especially financial futures, based on a large language model. BACKGROUND
[0002] The wide application of high-tech represented by big data and artificial intelligence in the financial industry has not only provided financial practitioners with rich decision-making means, but also accumulated a large amount of structured and unstructured data.
[0003] Knowledge graph can break through multi-dimensional heterogeneous data and solve the problem of data islandization. By abstracting structured and unstructured data into structured triples, users can analyze different data under a unified framework. At the same time, knowledge graph can be used to condense and iterate expert knowledge, and its reasoning and judgment capabilities can be used to clarify risk context, disassemble risk sources, and improve the response and disposal capabilities to risks.
[0004] However, the current construction and use of knowledge graph still face the following challenges:
[0005] In terms of construction, the construction process of a knowledge graph usually includes the following steps: ontology construction, data collection, data annotation, relationship extraction, entity disambiguation, etc. Therefore, the construction cost of a knowledge graph mainly comes from the following aspects: the cost of experts and annotators, and the cost of computing power for extraction and disambiguation.
[0006] In terms of use, when using a knowledge graph, it needs to interact with a graph database. If business personnel are allowed to interact with the graph database directly through the graph database query language, it will bring the cost of educating business personnel. If developers are allowed to develop an intermediate layer for interaction, it will bring additional development costs.
[0007] Therefore, how to reduce the cost and increase the efficiency in terms of construction and use is a problem that needs to be solved in the industry. SUMMARY
[0008] The following gives a brief summary of one or more aspects to provide a basic understanding of these aspects. This summary is not an exhaustive overview of all contemplated aspects, and neither is it intended to identify key or critical elements of all aspects nor to delineate the scope of any or all aspects. Its only purpose is to give some concepts of one or more aspects in a simplified form as a prelude to the more detailed description given later.
[0009] The present application aims to solve the above problems and provides a knowledge graph automatic construction and query method and system based on a large language model, which can reduce the construction cost of a knowledge graph and the use cost of a knowledge graph.
[0010] The technical scheme of the present application is as follows: The present application discloses a knowledge graph automatic construction query method based on a large language model, which comprises the following steps:
[0011] Step 1: Collecting original data and preprocessing the collected original data;
[0012] Step 2: Constructing a heterogeneous graph based on the preprocessed data;
[0013] Step 3: Using the heterogeneous graph constructed in Step 2 to obtain a query result.
[0014] According to an embodiment of the knowledge graph automatic construction query method based on a large language model of the present application, the original data is divided into structured data and unstructured data.
[0015] According to an embodiment of the knowledge graph automatic construction query method based on a large language model of the present application, the preprocessing of the structured data in Step 1 further comprises the following steps:
[0016] After the structured data is accessed from a data interface for the first time, the metadata of the structured data is extracted;
[0017] Then, example data is extracted from the structured data, and the metadata and the example data are used as prompt data to instruct the large language model to construct possible triplets;
[0018] Finally, the constructed triplets are automatically constructed in batches through a script after being revised by a business.
[0019] According to an embodiment of the knowledge graph automatic construction query method based on a large language model of the present application, the preprocessing of the unstructured data in Step 1 further comprises the following steps:
[0020] After the unstructured data is cleaned by removing format tags, special characters and a deduplication algorithm, the unstructured data is input into the large language model in a streaming manner under the guidance of a prompt, and triplets are returned, wherein the prompt is in a thinking chain mode.
[0021] According to an embodiment of the knowledge graph automatic construction query method based on a large language model of the present application, Step 2 further comprises the following steps:
[0022] Firstly, when constructing the ontology, the knowledge graph adopts a top-down method for construction with the help of an automatic ontology construction tool;
[0023] Then, the triplets are fused into the graph after determining the ontology, wherein entity disambiguation and coreference resolution tasks are performed during the fusion process to identify and distinguish different entities in the text and locate the entities referred to by pronouns, wherein the model based on the attention mechanism and the large language model are combined during the entity disambiguation and coreference resolution.
[0024] Finally, after obtaining the similarity and the large language model suggestion, the final similarity is calculated by using a weighted method, and whether the final similarity obtained by calculation exceeds the similarity threshold is used to obtain the final heterogeneous graph, and the final heterogeneous graph is stored in the graph database.
[0025] According to an embodiment of the knowledge graph automatic construction query method based on the large language model, based on the model of the attention mechanism, first, the bidirectional gate recurrent unit is used to encode the text where the word is located, then the information at different positions in the input sequence is focused through the attention mechanism, finally, the attention weight vector is weighted and summed with the output of the encoder to generate the context vector, that is, the word meaning representation, for the obtained word meaning representation, the similarity is calculated through the cosine similarity to obtain the first similarity.
[0026] Based on the similarity judgment of the large language model, the context where the entity exists is first extracted, and a prompt is constructed, and the second similarity is obtained through the large language model.
[0027] According to an embodiment of the knowledge graph automatic construction query method based on the large language model, step 3 further comprises:
[0028] In the use of the heterogeneous graph, the input is a human natural language question, first, a prompt is constructed, then the prompt constructed by the input question is input to the large language model, and the corresponding query statement is generated by the large language model, after obtaining the generated query statement, the final query result is obtained after automatic parsing and running.
[0029] The application also discloses a knowledge graph automatic construction query system based on a large language model, the system comprising:
[0030] A data acquisition and preprocessing module acquires original data and preprocesses the acquired original data;
[0031] A heterogeneous graph construction module constructs a heterogeneous graph based on the preprocessed data;
[0032] A heterogeneous graph use module uses the heterogeneous graph constructed by the heterogeneous graph construction module to obtain a query result.
[0033] According to an embodiment of the knowledge graph automatic construction query system based on the large language model, the original data is divided into structured data and unstructured data.
[0034] According to an embodiment of the knowledge graph automatic construction query system based on the large language model, the preprocessing of the structured data in the data acquisition and preprocessing module is further configured as:
[0035] After the structured data is first accessed from the data interface, the metadata of the structured data is first extracted.
[0036] Further, the example data is extracted from the structured data, and the metadata and the example data thereof are used as prompt data to instruct the large language model to construct possible triples;
[0037] Finally, the constructed triples are automatically constructed in batches through scripts after being revised by the business.
[0038] According to an embodiment of the large language model-based knowledge graph automatic construction query system, the preprocessing of the unstructured data in the data acquisition and preprocessing module further includes:
[0039] After the unstructured data is cleaned by removing format tags, special characters and deduplication algorithms, the unstructured data is input into the large language model in a streaming manner under the prompt guidance, and triples are returned, wherein the prompt guidance is in the form of a thought chain.
[0040] According to an embodiment of the large language model-based knowledge graph automatic construction query system, the heterogeneous graph construction module is further configured to:
[0041] First, when constructing the ontology, the knowledge graph is constructed in a top-down manner with the help of an automatic ontology construction tool;
[0042] Then, after determining the ontology, the triples are fused into the graph, wherein entity disambiguation and coreference resolution tasks are performed during the fusion process to identify and distinguish different entities in the text and locate the entities referred to by pronouns, wherein the model based on the attention mechanism and the large language model are combined during the entity disambiguation and coreference resolution.
[0043] Finally, after obtaining the similarity and the suggestion of the large language model, the final similarity is calculated by using a weighted method, and the final heterogeneous graph is obtained based on whether the final similarity calculated exceeds the similarity threshold, and is stored in the graph database.
[0044] According to an embodiment of the large language model-based knowledge graph automatic construction query system, the model based on the attention mechanism first encodes the text in which the word is located using a bidirectional gated recurrent unit, then focuses on the information at different positions in the input sequence through the attention mechanism, and finally performs weighted summation on the attention weight vector and the output of the encoder to generate a context vector, i.e., a word sense representation. For the obtained word sense representation, the similarity is calculated by cosine similarity to obtain a first similarity.
[0045] The similarity judgment based on the large language model first extracts the context in which the entity exists and constructs a prompt to obtain a second similarity through the large language model.
[0046] According to an embodiment of the knowledge graph automatic construction query system based on a large language model, the heterogeneous graph using module is further configured to:
[0047] During the use of the heterogeneous graph, the input is a human natural language question, a prompt is first constructed, and the prompt constructed by the input question is input to the large language model, a corresponding query statement is generated by the large language model, and after the generated query statement is obtained, the final query result is obtained after automatic analysis and operation.
[0048] Compared with the prior art, the present application has the following beneficial effects: the present application is based on the inductive ability of a large language model (a deep neural network model constructed through large-scale training data and parameters, which can complete tasks such as answering questions, providing information, and conducting conversations) to extract entities and triples from massive unstructured data in view of construction cost; the reasoning ability of the large language model can be used for ontology construction and entity disambiguation. The present application is based on the text generation ability of a large language model to convert the natural language input by business personnel into a query language that can be understood by a machine in view of use cost.
[0049] Specifically, the technical scheme of the present application has the following innovations:
[0050] 1. The present application uses a large language model to replace the data cleaning and ontology construction work in the traditional knowledge graph, replaces the expert work through the accumulated knowledge and inductive ability in the large language model training, and replaces the labor-intensive labeling work through the text understanding ability of the large language model.
[0051] 2. The present application uses the reasoning ability of the large language model to assist in strengthening the entity disambiguation and coreference resolution work of the knowledge graph, and increases the reliability and accuracy of the knowledge graph.
[0052] 3. The present application uses the text generation ability of the large language model to generate structured knowledge graph query statements, reduces the development and use cost, and improves the usability of the knowledge graph.
[0053] 4. The knowledge graph constructed by the present application integrates dynamic public opinion information and static entity information, and integrates the stream and batch update methods, and has self-updating and correcting ability. BRIEF DESCRIPTION OF DRAWINGS
[0054] The above features and advantages of the present application can be better understood after reading the detailed description of the embodiments of the present application in conjunction with the following drawings. In the drawings, the components are not necessarily drawn to scale, and components having similar related properties or features can have the same or similar reference numerals.
[0055] Figure 1A flow chart of an embodiment of the method for automatically constructing a knowledge graph based on a large language model according to the present application is shown.
[0056] Figure 2 A flow chart of an embodiment of the method for automatically constructing a knowledge graph based on a large language model according to the present application is shown. Figure 1 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown.
[0057] Figure 3 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown. Figure 1 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown.
[0058] Figure 4 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown. Figure 1 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown.
[0059] Figure 5 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown. Figure 1 A detailed flow chart of the sub-process of structured data preprocessing in the method embodiment shown.
[0060] Figure 6 A schematic diagram of an embodiment of the system for automatically constructing a knowledge graph based on a large language model according to the present application is shown. DETAILED DESCRIPTION
[0061] The present application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. Note that the aspects described below in conjunction with the accompanying drawings and specific embodiments are merely exemplary and should not be understood as limiting the scope of protection of the present application in any way.
[0062] Figure 1 A flow chart of an embodiment of the method for automatically constructing a knowledge graph based on a large language model according to the present application is shown. Please refer to Figure 1 The implementation steps of the method of the present embodiment are described in detail as follows.
[0063] Step S1: Collecting raw data and preprocessing the collected raw data.
[0064] The raw data is divided into structured data and unstructured data, which need to be processed separately. Take the financial futures scenario as an example (the same below), the structured data includes the static information of financial products obtained from the financial database, including financial futures, indexes, government bonds, stock plates, and listed company information. The unstructured data includes news text data and self-media text data, as well as related information of publishers, publishing time, and publishing channels.
[0065] For the detailed flow of the preprocessing of the structured data described above, please refer to Figure 2 After the structured data is accessed from the data interface for the first time, the metadata of the structured data is extracted in order to construct triples.
[0066] Small batches of example data are extracted from structured data, and the metadata and its example data are used as prompt data to instruct the large language model to construct possible triples. Prompt refers to the input text or question provided by the user or system to the large language model. The prompt can be a complete sentence, a question, or a fragment, which is used to guide the large language model to generate relevant responses or complete specific tasks.
[0067] For example:
[0068]
[0069] Finally, the constructed triples are revised by business, and the revision content includes, for example, removing unreasonable relationships such as (name, tenure, current tenure) and (employment qualification number, association, investment consulting employment certificate number), and then automatically constructing in batches through scripts.
[0070] For the detailed process of preprocessing of the above unstructured data, refer to Figure 3 The details are as follows.
[0071] Unstructured data is news text and self-media text obtained from various channels. After the data cleaning steps of removing format tags, special characters, and simhash deduplication algorithm, the unstructured data (i.e. text data) is input into the large language model in a streaming manner under the guidance of the prompt, and triples are returned. The prompt in this step is in the form of a thinking chain, which guides the large language model to extract after providing a thinking link.
[0072] For example, when extracting the shareholder and tenure relationship graph:
[0073]
[0074] Step 2: Constructing a heterogeneous graph based on preprocessed data.
[0075] First, when constructing the ontology, the financial futures market knowledge graph uses an automatic ontology construction tool to construct the knowledge graph in a top-down manner, i.e. first learning and defining the ontology from the data source, including the concept model and the relationship between models. After evaluation and iteration, the graph infrastructure is determined, and then the entities are added to the ontology.
[0076] Then, after determining the ontology, the triples are merged into the graph. In the fusion process, entity disambiguation and coreference resolution tasks are performed to identify and distinguish different entities in the text and locate the entities referred to by pronouns. For example Figure 4 As shown, when performing entity disambiguation and coreference resolution, a model based on attention mechanism and a large language model are combined.
[0077] Based on the attention mechanism model, first, the text where the word is located is encoded by using the bidirectional gate recurrent unit, and then the information at different positions in the input sequence is focused by using the attention mechanism. Finally, the attention weight vector is weighted and summed with the output of the encoder to generate a context vector, i.e., a word sense representation. For the obtained word sense representation, similarity S1 is obtained by calculating the similarity through cosine similarity.
[0078] Based on the similarity judgment of the large language model, the context where the entity exists is extracted, and a prompt is constructed, for example, the prompt is "Based on the above two texts, what is the probability that 'name' in the text points to the same entity?". The similarity S2 is obtained by using the large language model.
[0079] For example:
[0080]
[0081] After obtaining the similarity and the suggestion of the large language model, the final similarity S = x1*S1+x2*S2 is calculated by using the weighted method, wherein x1+x2 = 1, and the values of x1 and x2 are determined according to the performance of the large model in actual operation. It is judged whether the final similarity obtained by calculation exceeds the similarity threshold value, and the final heterogeneous graph is obtained and stored in the graph database.
[0082] Step S3: using the heterogeneous graph constructed in step S2 to obtain the query result.
[0083] As shown in Figure 5 When the heterogeneous graph is used, the input is a natural language question in human language. First, a prompt is constructed, such as "According to the above question, extract the entity and relationship in the text and generate the corresponding query sentence". Then, the prompt constructed by the input question is input into the large language model, and the corresponding query sentence is generated by the large language model. After obtaining the generated query sentence, the final query result is obtained after automatic parsing and running.
[0084] Figure 6 The principle of an embodiment of the knowledge graph automatic construction query system based on the large language model of the application is shown. Please refer to Figure 6 The system of the embodiment includes a data acquisition and preprocessing module, a heterogeneous graph construction module, and a heterogeneous graph use module.
[0085] The data acquisition and preprocessing module acquires raw data and pre-processes the acquired raw data.
[0086] The original data is divided into structured data and unstructured data, and both need to be processed separately. Taking the financial futures scenario as an example (the same below), the structured data includes the static information of financial products obtained from the financial database, including financial futures, indexes, government bonds, stock plates, and listed company information. Unstructured data includes news text data and self-media text data, as well as related information about the publisher, publication time, and publication channel.
[0087] The preprocessing of structured data in the data collection and preprocessing module is further configured to:
[0088] After the structured data is accessed from the data interface for the first time, the metadata of the structured data is extracted;
[0089] Then, a small amount of example data is extracted from the structured data, and the metadata and its example data are used as prompt data to instruct the large language model to construct possible triples. The prompt refers to the input text or question provided by the user or system to the large language model, and the prompt can be a complete sentence, a question, or a fragment, which is used to guide the large language model to generate relevant responses or complete specific tasks;
[0090] Finally, after the constructed triples are revised by business, they are automatically constructed in batches through scripts. The revision content may include, for example, removing unreasonable relationships such as (name, tenure, current tenure) and (professional qualification number, association, investment consulting professional certificate number).
[0091] The preprocessing of unstructured data in the data collection and preprocessing module further includes:
[0092] After the unstructured data (i.e., text data) is cleaned by removing format tags, special characters, and simhash de-duplication algorithms, the unstructured data (i.e., text data) is input into the large language model in a streaming manner under the guidance of the prompt, and triples are returned. The prompt guidance is in the form of a thinking chain, which guides the large language model to extract after providing a thinking link.
[0093] The heterogeneous graph construction module constructs a heterogeneous graph based on the preprocessed data.
[0094] The heterogeneous graph construction module is further configured to:
[0095] First, when constructing the ontology, the financial futures market knowledge graph uses an automatic ontology construction tool to construct the knowledge graph in a top-down manner, i.e., first learning and defining the ontology from the data source, including the concept model and the relationship between models. After evaluation and iteration, the graph infrastructure is determined, and then the entities are added to the ontology.
[0096] Then, after determining the ontology, the triples are fused into the graph. During the fusion process, entity disambiguation and coreference resolution tasks need to be performed to identify and distinguish different entities in the text and locate the entities referred to by pronouns. As shown in Figure 4 When performing entity disambiguation and coreference resolution, a model based on attention mechanism and a large language model are combined.
[0097] The model based on attention mechanism first encodes the text in which the word is located using a bidirectional gated recurrent unit, then focuses on the information at different positions in the input sequence through an attention mechanism, and finally performs weighted summation on the attention weight vector and the output of the encoder to generate a context vector, i.e., a word sense representation. For the obtained word sense representation, similarity S1 is obtained by calculating the cosine similarity.
[0098] The similarity judgment based on the large language model first extracts the context in which the entity exists and constructs a prompt, such as "Based on the above two texts, please determine the probability that the 'name' in the text refers to the same entity?" The similarity S2 is obtained through the large language model.
[0099] After obtaining the similarity and the suggestion of the large language model, a weighted method is used to calculate the final similarity S = x1*S1 + x2*S2, where x1 + x2 = 1, and the values of x1 and x2 are determined according to the performance of the large model in actual operation. Determine whether the final similarity calculated exceeds the similarity threshold, obtain the final heterogeneous graph, and store it in the graph database.
[0100] The heterogeneous graph using module uses the heterogeneous graph constructed by the heterogeneous graph construction module to obtain query results.
[0101] The heterogeneous graph using module is further configured to:
[0102] When using the heterogeneous graph, the input is a human natural language question, first construct a prompt, such as "According to the above question, please extract the entities and relationships in the text and generate the corresponding query statement". Then input the prompt constructed by the input question into the large language model, and generate the corresponding query statement by the large language model. After obtaining the generated query statement, the final query result is obtained after automatic parsing and running.
[0103] The above embodiments take the financial futures market knowledge graph construction and use scenario as an example, but the present application is not limited to the construction and use of the graph in this scenario, and is also applicable to the construction of heterogeneous graphs of structured data and unstructured data in other fields.
[0104] Although the above methods are illustrated and described as a series of acts for simplicity, it is understood that the methods are not limited by the order of acts, as some acts can take place in different orders and / or concurrently with other acts from that illustrated and described herein. For example, acts depicted earlier in the process can be re-ordered later in the process. Further, some acts can take place concurrently, an example of which is described in further detail below.
[0105] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality, without reference to a specific
[0106] The various illustrative logical blocks, modules, and circuits described in connection with the embodiments disclosed herein can be implemented or performed with a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor can be a microprocessor, but in the alternative, the processor can be any conventional processor, controller, microcontroller, or state machine. A processor can also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
[0107] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium can be integral to the processor. The processor and the storage medium can reside in an ASIC. The ASIC can reside in a user terminal. In the alternative, the processor and the storage medium can reside as discrete components in a user terminal.
[0108] In one or more exemplary embodiments, the functions described can be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functions can be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media can be any available media that can be accessed by a computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0109] The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A large language model-based knowledge graph automatic construction query method, characterized in that, The method comprises: Step 1: collecting raw data and preprocessing the collected raw data, wherein the raw data is divided into structured data and unstructured data; Step 2: constructing a heterogeneous graph based on the preprocessed data; Step 3: using the heterogeneous graph constructed in step 2 to obtain query results; Wherein, the preprocessing of structured data in step 1 further comprises: After the structured data is first accessed from the data interface, the metadata of the structured data is extracted first; Then, the example data is extracted from the structured data, and the metadata and its example data are used as prompt data to instruct the large language model to construct possible triples; Finally, after the constructed triples are corrected by business, they are automatically constructed in batches through scripts; Wherein, step 2 further comprises: First, during ontology construction, the knowledge graph uses an automatic ontology construction tool to construct in a top-down manner; Then, after determining the ontology, the triples are fused into the graph, wherein entity disambiguation and coreference resolution tasks are performed during the fusion process to identify and distinguish different entities in the text and locate the entities referred to by pronouns, wherein the model based on attention mechanism and the large language model are combined during entity disambiguation and coreference resolution; Finally, after obtaining the similarity and the suggestion of the large language model, the final similarity is calculated by using a weighted method, and the final heterogeneous graph is obtained based on whether the final similarity calculated exceeds the similarity threshold, and is stored in the graph database; Wherein, the model based on attention mechanism first encodes the text where the word is located using a bidirectional gated recurrent unit, then focuses on the information at different positions in the input sequence through attention mechanism, and finally generates a context vector, i.e. word sense representation, by weighting the sum of the attention weight vector and the output of the encoder. For the obtained word sense representation, the first similarity is calculated by cosine similarity; The similarity judgment based on the large language model first extracts the context in which the entity exists and constructs a prompt to obtain the second similarity through the large language model.
2. The large language model-based knowledge graph automatic construction query method according to claim 1, characterized in that, The preprocessing of unstructured data in step 1 further comprises: After the unstructured data is cleaned by removing format tags, special characters and de-duplication algorithm, the unstructured data is input into the large language model in a streaming manner under the guidance of the prompt, and triples are returned, wherein the prompt is in the form of a thinking chain.
3. The large language model-based knowledge graph automatic construction query method according to claim 1, characterized in that, Step 3 further comprises: When the heterogeneous graph is used, the input is a natural language question in human language, first construct a prompt, then input the prompt constructed from the input question into the large language model, and generate the corresponding query statement from the large language model, and obtain the final query result after automatic parsing and running.
4. A large language model-based knowledge graph automatic construction query system, characterized in that, The system comprises: A data collection and preprocessing module for collecting raw data and preprocessing the collected raw data, wherein the raw data is divided into structured data and unstructured data; A heterogeneous graph construction module for constructing a heterogeneous graph based on the preprocessed data; A heterogeneous graph usage module for using the heterogeneous graph constructed by the heterogeneous graph construction module to obtain query results; Wherein, the preprocessing of structured data in the data collection and preprocessing module is further configured to: The structured data is first extracted metadata of the structured data after being accessed from the data interface for the first time; Then, example data is extracted from the structured data, and the metadata and the example data thereof are used as prompt data to instruct the large language model to construct possible triples; Finally, the constructed triples are automatically constructed in batches through scripts after being modified by business; The heterogeneous graph construction module is further configured to: First, during ontology construction, the knowledge graph is constructed by an automatic ontology construction tool in a top-down manner; Then, after determining the ontology, the triples are fused into the graph, wherein entity disambiguation and coreference resolution tasks are performed during the fusion process to identify and distinguish different entities in the text and locate the entities referred to by pronouns, wherein the model based on the attention mechanism and the large language model are combined during the entity disambiguation and coreference resolution; Finally, after obtaining the similarity and the suggestion of the large language model, the final similarity is calculated by using a weighted method, and the final heterogeneous graph is obtained based on whether the final similarity calculated exceeds a similarity threshold, and is stored in a graph database; The model based on the attention mechanism first encodes the text where the word is located using a bidirectional gated recurrent unit, then focuses on the information at different positions in the input sequence through the attention mechanism, and finally performs weighted summation on the attention weight vector and the output of the encoder to generate a context vector, i.e., a word sense representation. For the obtained word sense representation, the first similarity is calculated by using cosine similarity; The similarity judgment based on the large language model first extracts the context in which the entity exists and constructs a prompt to obtain a second similarity through the large language model.
5. The large language model-based knowledge graph automatic construction query system according to claim 4, characterized in that, The preprocessing of the unstructured data in the data acquisition and preprocessing module further includes: After the unstructured data is cleaned by removing format tags, special characters, and a deduplication algorithm, the unstructured data is input into the large language model in a streaming manner under the guidance of a prompt, and triples are returned, wherein the prompt guidance is in the form of a thinking chain. 6.The big language model based knowledge graph automatic construction query system according to claim 4, characterized in that, The heterogeneous graph usage module is further configured to: During the use of the heterogeneous graph, the input is a natural language question in human language, a prompt is first constructed, and then the input question is input into the large language model to generate a corresponding query statement, and finally the query result is obtained after automatic parsing and running.
Citation Information
Patent Citations
Document book semantic retrieval system based on knowledge graph
CN115563313A
Domain knowledge graph construction method and system based on generative large language model
CN116860987A