A large language model-based graph database query processing system and method

By combining large language models with entity extraction and alignment techniques from graph databases, the problems of outdated knowledge bases and high fine-tuning costs are solved, enabling fast and intuitive graph database queries, providing more accurate query results, and reducing development costs and difficulty.

CN117076718BActive Publication Date: 2026-02-06BEIJING YIRUTUZHEN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311062558.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-22
Publication Date
2026-02-06
Estimated Expiration
2043-08-22

AI Technical Summary

Technical Problem

Existing large language models suffer from problems such as outdated knowledge bases, high cost of knowledge base fine-tuning, and increased demand for computing resources and storage space due to large model size when querying private/professional domain graph databases. Furthermore, the BERT model has performance limitations when processing long texts.

Method used

By combining a large language model with a graph database, and through the entity extraction module, entity alignment module, statement generation module, and data return module, specific prompts guide the model to perform entity extraction and alignment, generate query statements, and search in the graph database to generate more accurate report data.

Benefits of technology

It enables fast and intuitive querying of graph databases with low resources and a small number of samples, provides more accurate query results, reduces development costs and difficulty, overcomes the limitations of the BERT model, and allows for longer text input to obtain more information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117076718B_ABST
    Figure CN117076718B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on big language model's graph database query processing system and method, the system includes entity extraction module, for the query problem of acquisition is added given first hint, sent into big language model and carries out entity extraction;Entity alignment module, by the second hint obtained guide big language model will extract entity and the entity in graph database are aligned;Sentence generation module, according to alignment result, generates query sentence;Data return module, the generated query sentence is sent into graph database, and feedback data is returned;Report generation module, feedback data and query problem are substituted into the third hint of construction, generate new input hint, and the input hint is used as constraint, is transmitted to big language model;Its effect is: by hint, the associated information in graph database is fed to big model, realizes not to fine-tune for big model supplement knowledge, allow longer text input, generate more accurate reply.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of information query, and in particular to a graph database query processing system and method based on a large language model. BACKGROUND

[0002] A large language model refers to a natural language processing (NLP) model trained using a large amount of text data, which can automatically learn language rules and semantic knowledge, and can generate natural language text, answer questions, perform text classification, etc. Large language models usually require a large amount of computing resources and data for training, and the training data usually comes from a large amount of Internet text. After training is completed, these models can be used for various natural language processing tasks such as text generation, machine translation, text summarization, sentiment analysis, and question answering systems. The most popular large language models currently are GPT-4 and LaMAD.

[0003] A general-purpose large language model learns knowledge by processing a large amount of text data during training, but a large language model applied to a specific professional field (such as a query language in a private domain / professional field graph database) needs to be pre-trained using a knowledge base in that specific field and fine-tuned for language tasks in that field.

[0004] The current approach has the following two technical problems:

[0005] (1) The knowledge base may sometimes be outdated. For example, GPT-4's knowledge cutoff date is September 2021, which means that information about events and new scientific discoveries that occurred after that date cannot be answered;

[0006] (2) Knowledge base fine-tuning usually requires more human involvement and more computing resources. The larger the model, the higher the fine-tuning cost, the more computing resources and storage space required, and the longer the training time;

[0007] Secondly, the most commonly used language model for entity extraction, BERT, has many limitations. For example, the length of the input text is limited by the maximum sequence length of the BERT model, which can affect the performance of the model when processing long texts. SUMMARY

[0008] In view of the technical defects mentioned in the background art, the purpose of the embodiments of the present application is to provide a graph database query processing system and method based on a large language model.

[0009] The technical scheme provided by the application is as follows: a first aspect: a graph database query processing system based on a large language model, applied to a graph database, the system comprising:

[0010] An entity extraction module is configured to obtain a query question of a user, add a given first prompt to the query question, and send the query question to a preset large language model for processing to realize entity extraction, wherein the first prompt comprises at least one prompt sentence.

[0011] An entity alignment module is configured to guide the large language model to align the result of entity extraction and entities in the graph database by using a second prompt obtained, wherein the second prompt is generated based on a defined string.

[0012] A sentence generation module is configured to generate a query sentence of the graph database according to the alignment result.

[0013] A data return module is configured to send the generated query sentence to the graph database for searching and return feedback data obtained, wherein the feedback data comprises node and edge information.

[0014] A report generation module is configured to substitute the feedback data and the query question into a third prompt constructed to generate a new input prompt, and transmit the input prompt to the large language model as a constraint, so that the large language model generates more accurate report data that is more related to data in the graph database, wherein the third prompt is generated based on a pre-defined prompt_template template.

[0015] Preferably, after the given first prompt is added, the entity is extracted from the given first prompt and a series of updates are provided by using few shot learning prompt, and each update has a format of [ENTITY, TYPE], wherein ENTITY is an entity name and TYPE is an entity type.

[0016] Preferably, the string comprises a string of cls_prompt, which contains a template of multiple questions and answers.

[0017] Preferably, the second prompt guides the large language model to align the result of entity extraction and entities in the graph database, specifically comprising the following steps:

[0018] The cls_prompt is constructed, and the cls_prompt is constructed by using a format method to convert a key list of node name node and prop_cls into a string and insert the string into a question template, so as to find a cls_prompt of a given word that is most semantically close to a given word list.

[0019] calling the large language model, inputting the constructed cls_prompt, to obtain a prediction result;

[0020] determining whether the prediction result is in the key of prop_cls, if yes, indicating that the entity and the node attribute in the graph database are correctly matched;

[0021] adding the corresponding node type, attribute, and predicted word / this entity to a triple list to achieve alignment with the entity in the graph database.

[0022] Preferably, the query statement is generated by the following steps:

[0023] When the match is correct, record the entity name, category, and attribute to obtain a triple, and record it in the corresponding triple list;

[0024] According to the recorded triples of each type in the previous step, a series of Cypher query statements are generated according to the Cypher rule and stored in a list to retrieve related entities of the corresponding entity name.

[0025] Preferably, the prompt_template template contains two placeholders for the node and edge information and the user's query question.

[0026] Second aspect: a graph database query processing method based on a large language model, applied to the graph database query processing system based on a large language model of the first aspect, the method comprising:

[0027] The entity extraction step of the large language model specifically comprises:

[0028] After obtaining the user's query question and adding a given first prompt to the query question, it is sent to the preset large language model for processing to achieve entity extraction; wherein the first prompt includes at least one prompt sentence;

[0029] The entity alignment step specifically comprises:

[0030] The second prompt is used to guide the large language model to align the entity extraction result with the entity in the graph database; wherein the second prompt is generated based on the defined string;

[0031] According to the alignment result, a query statement of the graph database is generated;

[0032] The generated query statement is sent to the graph database for searching, and the obtained feedback data is returned; wherein the feedback data includes node and edge information;

[0033] The feedback data and the query question are substituted into a third prompt constructed, a new input prompt is generated, and the input prompt is transmitted to the large language model as a constraint, so that the large language model generates more accurate report data related to the data in the graph database; wherein the third prompt is generated based on a pre-defined prompt_template template.

[0034] With the technical solution described above, the graph database query processing system and method based on a large language model are proposed, which combines a large language model and a graph database, uses a specific prompt to guide the large language model to perform entity extraction based on a user's query question, generate a high-quality related answer and entity alignment, then generate a query statement and search and recall the nodes and relationships required by the user in the graph database, and generate a new prompt to the large language model to generate a more accurate reply; thereby enabling the user to query the graph database through natural language without needing to master complex query languages; the user can more quickly and intuitively obtain the required information; in addition, by using a large language model, more accurate and more relevant query results can be provided;

[0035] Thus, without fine-tuning to supplement the knowledge of the large model, we can feed the graph database information to the large model through the prompt information to supplement the knowledge of the large model, and the large model generates more accurate replies according to the feedback of the graph database;

[0036] At the same time, the large language model we use allows longer text as input for entity extraction and alignment, which can accept longer text input compared to the existing BERT model, thereby obtaining more information, reducing development costs and difficulty, and overcoming the limitations of the BERT model. BRIEF DESCRIPTION OF DRAWINGS

[0037] Figure 1 A principle block diagram of a graph database query processing system based on a large language model provided by an embodiment of the present application;

[0038] Figure 2 A flowchart of a graph database query processing method based on a large language model provided by an embodiment of the present application. DETAILED DESCRIPTION

[0039] The specific embodiments of the present application will be described in detail below, and it should be noted that the embodiments described herein are only for illustration and do not limit the present application. In the following description, a large number of specific details are set forth in order to provide a thorough understanding of the present application. However, it is obvious to those skilled in the art that the present application does not necessarily have to be implemented with these specific details.

[0040] It should be noted that the terms "first", "second", and the like in the description and claims of the application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances to describe the embodiments of the application described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0041] Throughout the specification, reference to "one embodiment", "an embodiment", "one example", or "an example" means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment of the application. Therefore, the phrases "in one embodiment", "in an embodiment", "one example", or "an example" appearing throughout the specification do not necessarily all refer to the same embodiment or example. In addition, specific features, structures, or characteristics can be combined in any appropriate combination and / or subcombination in one or more embodiments or examples.

[0042] It should be noted that the technical terms of the present embodiment have their usual meanings understood by those skilled in the art, unless otherwise stated.

[0043] Prompt engineering: Prompt engineering is a technique that can guide large language models to generate specific types of output by designing specific input prompts.

[0044] Entity extraction: Entity extraction, also known as named entity recognition (NER), is the process of automatically identifying and extracting entities with specific meanings from text, such as names, organizations, locations, times, dates, etc.

[0045] Entity alignment: Entity alignment is the process of aligning different identifiers representing the same entity in different data sources. In the case of multiple data sources or knowledge graphs, the same entity may have different identifiers, which can cause difficulties in data integration and query. Therefore, entity alignment aims to identify these same entities and map them to the same identifier, thereby eliminating potential confusion and redundancy.

[0046] As shown in Figure 1 A graph database query processing system based on a large language model provided by an embodiment of the application, characterized by being applied to a graph database, the system comprises:

[0047] an entity extraction module configured to obtain a query question of a user, add a given first prompt to the query question, and send the query question to a preset large language model for processing to implement entity extraction, wherein the first prompt includes at least one prompt sentence;

[0048] an entity alignment module configured to guide the large language model to align a result of the entity extraction and entities in the graph database by using a second prompt obtained, wherein the second prompt is generated based on a defined string;

[0049] a sentence generation module configured to generate a query sentence of the graph database according to the alignment result;

[0050] a data return module configured to send the generated query sentence to the graph database for searching and return feedback data obtained, wherein the feedback data includes node and edge information;

[0051] a report generation module configured to substitute the feedback data and the query question into a third prompt constructed to generate a new input prompt, and transmit the input prompt to the large language model as a constraint, so that the large language model generates more accurate report data that is more related to data in the graph database, wherein the third prompt is generated based on a pre-defined prompt_template template.

[0052] In this embodiment, the large language model is taken as an example of GPT, and a user proposes a query question through natural language.

[0053] In implementation, after the given first prompt is added, the entity is extracted from the given first prompt and a series of updates are provided through few shot learning prompt, and each update has a format of [ENTITY, TYPE], wherein ENTITY is an entity name and TYPE is an entity type.

[0054] Specifically, in this embodiment, there are multiple prompt sentences, and a 7-shot learning prompt is used, which describes a task to help the large model understand the user's intention, that is, to extract entities from the given prompt and provide a series of updates.

[0055] Based on multiple prompt-updates demonstration examples, the GPT is instructed to extract / infer entities from the examples and update the list, and the GPT is prompted that the entity name should contain as many characters as possible and try not to separate the words, but combine them together to represent the complete meaning.

[0056] The meaning of Prompt is prompt, and some examples are given in the prompt to show how to extract entities and generate updates from the given prompt. For example, for the prompt "What base stations does China Mobile produce?", the entity "China Mobile" can be extracted and its type can be determined as "company". Therefore, the corresponding update is [[“China Mobile”, “company”]]. The following is an example of a Prompt (i.e. the first prompt). Example:

[0057] question: What base stations does China Mobile produce?

[0058] answer: [ ["China Mobile", "company" ]]

[0059] question: Please introduce the company Alibaba

[0060] answer: [ ["Alibaba", "company" ]]

[0061] question: Do you know the company Tencent?

[0062] answer: [ ["Tencent", "company" ]]

[0063] question: What products does the company Alpha Egg produce?

[0064] answer: [ ["Alpha Egg", "product" ], ["Alpha Egg", "company" ]]

[0065] question: Introduce the Huawei base station

[0066] answer: [ ["Huawei base station", "product" ]]

[0067] question: What businesses does Mobile MiGu have in Beijing?

[0068] answer: [ ["Mobile MiGu", "company" ], ["Beijing", "city" ]]

[0069] question: What are the main companies in the chip industry?

[0070] answer: [ ["chip industry", "industry" ]]

[0071] question: What new energy companies are located in Hefei?

[0072] answer: [ ["Hefei", "city" ], ["new energy", "industry" ]]

[0073] The entire example paragraph above is a prompt, including multiple prompt sentences, each containing a corresponding question and answer; this prompt helps and guides the large data model to extract entities from the given prompts.

[0074] Further, the string includes a cls_prompt string containing a template of multiple questions and answers; these questions and answers aim to help the model understand how to find a given word that is semantically closest to a given word list; through this prompt, we guide the large model to align entities in user natural language with entities in a graph database; specifically including the following steps:

[0075] Construct the cls_prompt, which is constructed using the format method, converting the node name node and the key list of prop_cls into a string, and inserting it into the question template, to find a cls_prompt that is semantically closest to a given word in a given word list;

[0076] Call the large language model and pass in the constructed cls_prompt to get the prediction result;

[0077] Determine whether the prediction result is in the key of prop_cls; if so, it indicates that the entity and the node attribute in the graph database have been correctly matched;

[0078] Add the corresponding node type, attribute, and predicted word / this entity to a triple list to align with the entity in the graph database.

[0079] This part uses GPT for semantic matching, mainly relying on the transfer ability of GPT, and according to the few-shot learning, aligns the entity that the user wants to query with the entity in the graph database. Among them, the construction of cls_prompt first gives two example prompts, in the format "Question: What is the closest word in the word list corresponding to the word?" Answer: "word"

[0080] Use the format method to construct cls_prompt, convert the node name node and the key list of prop_cls into a string, and insert it into the question template; prop_cls is a dictionary used to store the mapping relationship between attribute values in the node attribute column and corresponding attribute names. For example, prop_cls = {'Beijing': 'city name', 'Shanghai': 'city name'}

[0081] In this way, a cls_prompt similar to "Question: Find the word that is semantically closest to 'capital' in ['Beijing', 'New Beijing', 'Haidian'] " is formed;

[0082] Call the GPT model, pass in the constructed cls_prompt, and get the prediction result. For example, the answer is: 'Beijing'

[0083] Determine whether the prediction result 'Beijing' is in the key of prop_cls; if it is, add (node type, attribute, predicted word / entity) to a triple list (used in the following process)

[0084] If not, give a warning that the prediction result cannot match the attribute column.

[0085] Based on the above process, if the prediction result 'Beijing' is in the key of prop_cls, that is, the user's entity alignment matches the node attribute in our graph database, record the entity name, category and attribute to generate a Cypher query; then add (node type, attribute name, predicted word) to a triple list according to the node type (ntype).

[0086] Specifically, the query statement is generated by the following steps:

[0087] When the match is correct, record the entity name, category and attribute to get the triple, and record it in the corresponding triple list;

[0088] According to the triple of each type recorded in the last step, a series of Cypher query statements are generated according to the Cypher rule and stored in a list to retrieve related entities of the corresponding entity name.

[0089] It should be noted that each triple represents a node, and a series of Cypher query statements are generated according to the cypher rule (rule based) and stored in a list, which are used to retrieve at least one relationship path between the entity type (such as: city) and other types of entities;

[0090] For example, MATCH p=(n:company)-[*1..2]-(e:city)WHERE n.name='douban'e.name='beijing'RETURN p. That is: return all paths from the node with label 'company' and 'name' attribute value 'douban' to the node with label 'city' and 'name' 'beijing' through 1 to 2 relationships. If both types of tuples have results (such as the nodes of city and company are in the library), we generate a query to retrieve the relationship between the "city" entity and the "company" type entity. If only one type (such as the "city" tuple, we only generate a query to retrieve the relationship between entities of this type (city and city).

[0091] Then we use the prompt_template template to generate a prompt called report_prompt, which is substituted into the node information and edge information returned by the previous query and the original user question (query question), so as to help the large data model generate more accurate and more relevant report to the data in our graph database.

[0092] The above scheme combines a large language model and a graph database, uses a specific prompt to guide the large language model to perform entity extraction on a user query, generate a high-quality relevant answer and entity alignment, then generate a query statement and search and recall the nodes and relationships required by the user in the graph database; thereby enabling the user to query the graph database through natural language without needing to master complex query language; the user can quickly and intuitively obtain the required information; in addition, by using a large language model, more accurate and more relevant query results can be provided;

[0093] Thus, without fine-tuning to supplement the knowledge of the large model, we can feed the information of the graph database to the large model through the prompt statement in the prompt to supplement the knowledge of the large model, and the large model generates more accurate replies according to the feedback of the graph database;

[0094] At the same time, the large language model used by us allows longer text as input for entity extraction and alignment, and can accept longer text input compared to the existing BERT model, thereby obtaining more information, reducing development cost and difficulty, and overcoming the limitations of the BERT model.

[0095] Based on the same inventive concept, referring to Figure 2 The embodiment of the application also provides a graph database query processing method based on a large language model, which is applied to the graph database query processing system based on the large language model described above, and the method comprises the following steps:

[0096] S101, an entity extraction step of a large language model, specifically comprising:

[0097] By obtaining the query question of the user and adding a given first prompt to the query question, the query question is sent to a preset large language model for processing to realize entity extraction; wherein the first prompt comprises at least one prompt sentence;

[0098] S102, an entity alignment step, specifically comprising:

[0099] The second prompt obtained is used to guide the large language model to align the results of entity extraction with the entities in the graph database; wherein the second prompt is generated based on a defined string;

[0100] S103, generating a query statement of the graph database according to the alignment result;

[0101] S104, sending the generated query statement into the graph database for searching and returning obtained feedback data; wherein the feedback data includes node and edge information;

[0102] S105, substituting the feedback data and the query question into the constructed third prompt to generate a new input prompt, and transmitting the input prompt as a constraint to the large language model, so that the large language model generates more accurate and more relevant report data to the data in the graph database; wherein the third prompt is generated based on a pre-defined prompt_template template.

[0103] Further, to better understand the user's intention, the method further comprises:

[0104] After adding the given first prompt, the entity is also extracted from the given first prompt and a series of updates are provided by the few shot learning prompt, and each update has a [ENTITY, TYPE] format; wherein ENTITY is the entity name and TYPE is the entity type.

[0105] The second prompt guides the large language model to align the entity extraction result with the entity in the graph database, specifically including the following steps:

[0106] The cls_prompt is constructed, and the cls_prompt is constructed using the format method to convert the node name node and the key list of prop_cls into a string and insert it into the question template, so as to find a cls_prompt that is semantically closest to a given word in a given word list;

[0107] The large language model is called and the constructed cls_prompt is transmitted to obtain a prediction result;

[0108] It is judged whether the prediction result is in the key of prop_cls, if yes, it means that the entity and the node attribute in the graph database are correctly matched;

[0109] The corresponding node type, attribute, and predicted word / this entity are added to a triple list to realize alignment with the entity in the graph database.

[0110] In this embodiment, the introduced prompt and the prompt statement corresponding to each prompt are all help the large model to understand the customer's intention.

[0111] It should be noted that the specific implementation steps and beneficial effects in the method embodiment can refer to the description of the foregoing system embodiment, and will not be repeated here.

[0112] Through the above scheme, the following advantages are achieved:

[0113] 1. No fine-tuning is needed to supplement the knowledge of large language models. We can feed the graph database information to the large model through prompts in the case of low resources and a small number of samples, which can supplement the knowledge of the large model, and generate more accurate replies according to the graph database.

[0114] 2. Reduce development costs. Compared with customizing or fine-tuning the traditional language model (BERT) to do NER and entity alignment, we perform prompt engineering on the large model, which reduces the development cost and difficulty, and obtains an accuracy comparable to that of a supervised model.

[0115] 3. Longer input. The large language model we use allows longer text as input (2048 tokens) to do NER and entity alignment, which can accept longer text input compared with the existing BERT model, thereby obtaining more information and generating more accurate replies.

[0116] 4. Low resources and small samples. By using the prompt engineering technique, we can use the large language model to extract and align entities in the case of low resources (without fine-tuning) and only a small number of samples / zero samples.

[0117] In several embodiments provided in the present application, it should be understood that the disclosed system and method can be implemented in other ways. For example, the above-described embodiments are only illustrative, and can be implemented in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in a general manner in the above description. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0118] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A graph database query processing system based on a large language model, characterized in that, The system, applied to graph databases, includes: The entity extraction module is used to obtain the user's query question, add a given first hint to the query question, and send it to a preset large language model for processing to achieve entity extraction; wherein, the first hint includes at least one hint statement; An entity alignment module is used to guide the large language model to align the entity extraction results with the entities in the graph database using a second prompt; wherein the second prompt is generated based on a defined string; The statement generation module is used to generate query statements for the graph database based on the alignment results; The data return module is used to send the generated query statement into the graph database for searching and return the obtained feedback data; wherein, the feedback data includes node and edge information; The report generation module is used to input the feedback data and query question into the constructed third prompt, generate a new input prompt, and transmit the input prompt as a constraint to the large language model. The third prompt is generated based on a predefined prompt_template. The prompt_template is used to generate a prompt called report_prompt, which incorporates the node and edge information returned by the previous query and the original user question. The prompt_template contains two placeholders, used to respectively incorporate the node and edge information and the user's query question. After adding a given first prompt, entities are also extracted from the given first prompt via a few-shot learning prompt, and a series of updates are provided, each with the format [ENTITY,TYPE]; where ENTITY is the entity name and TYPE is the entity type. The string includes the string cls_prompt, which contains templates for multiple questions and answers.

2. The graph database query processing system based on a large language model according to claim 1, characterized in that, The second prompt guides the large language model to align the entity extraction results with the entities in the graph database, specifically including the following steps: Construct the cls_prompt using the format method, convert the node name node and the key list of prop_cls into strings, and insert them into the question template to find the cls_prompt of a given word that is semantically closest to a given word in a given word list; The large language model is invoked, and the constructed cls_prompt is passed in to obtain the prediction results; Determine whether the prediction result is in the key of prop_cls. If it is, it means that the entity and the node attribute in the graph database have achieved a correct match. The corresponding node type, attribute, and predicted word / entity are added to a list of triples to align with the entities in the graph database.

3. The graph database query processing system based on a large language model according to claim 2, characterized in that, The query statement is generated through the following steps: If a match is found to be correct, the entity name, category, and attribute are recorded to obtain a triple, and then recorded in the corresponding triple list. Based on the triples of various types recorded in the previous step, a series of Cypher query statements are generated according to Cypher rules and stored in a list to retrieve relevant entities with corresponding entity names.

4. A graph database query processing method based on a large language model, characterized in that, The method applied to the graph database query processing system based on a large language model as described in claim 1 includes: The entity extraction steps of a large language model specifically include: By acquiring the user's query question and adding a given first hint to the query question, the query question is sent to a preset large language model for processing to achieve entity extraction; wherein, the first hint includes at least one hint statement; The entity alignment steps specifically include: The obtained second prompt guides the large language model to align the entity extraction results with the entities in the graph database; wherein, the second prompt is generated based on a defined string; Based on the alignment results, generate query statements for the graph database; The generated query statement is sent to the graph database for searching, and the obtained feedback data is returned; wherein, the feedback data includes node and edge information; The feedback data and query question are substituted into the constructed third prompt to generate a new input prompt, which is then used as a constraint and transmitted to the large language model. The third prompt is generated based on a predefined prompt_template.

5. The graph database query processing method based on a large language model according to claim 4, characterized in that, The method further includes: After adding a given first prompt, entities are also extracted from the given first prompt via a few-shot learning prompt, and a series of updates are provided, each with the format [ENTITY,TYPE], where ENTITY is the entity name and TYPE is the entity type.

Citation Information

Patent Citations

  • Implementation method for automatically generating complex graph database query statement service

    CN116340584A

  • Graph data query language translation method and system oriented to knowledge base questions and answers

    CN116521823A