Method and System for Converting a Relational Model to a Graph Model Based on an LLM Model

Through the LLM model analysis and optimization strategy, redundant nodes in the graph model are automatically identified and optimized, which solves the storage redundancy and query inefficiency caused by primary foreign key mapping, and improves the query performance and storage efficiency of the graph model.

CN120234345BActive Publication Date: 2025-08-01ZHEJIANG CHUANGLIN TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510711584.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-08-01
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

In the prior art, the relationship model to graph model based on primary foreign key mapping has problems of storage redundancy and inefficiency in query.

Method used

Using the LLM model-based method, the initial graph model is generated based on the master foreign key mapping by obtaining the relationship model to be transformed and query requirements, and the initial graph model is generated based on the primary foreign key mapping, and the query features are analyzed using optimization strategies and LLM models, and candidate objects are automatically identified and optimized to generate the target graph model.

Benefits of technology

It improves the query performance and storage utilization of the graph model, reduces redundant nodes, and optimizes the query path.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234345B_ABST
    Figure CN120234345B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for converting a relational model into a graph model based on an LLM model. The method includes the following steps: converting the relational model to be converted into an initial graph model based on the primary-foreign key mapping; iteratively optimizing the initial graph model based on the query requirements and various preset optimization strategies to obtain a target graph model. Among them, the method for optimizing the model based on the target optimization strategy is: enabling the LLM model to analyze the corresponding candidate optimization objects based on the corresponding first graph model, the query requirements, and the target optimization strategy, and generating corresponding analysis results based on the queried features corresponding to the optimizable objects; determining the corresponding target optimization objects based on the target optimization strategy and the analysis results, and performing optimization transformation based on the target optimization objects. The present invention can automatically complete the conversion from a relational model to a graph model and optimize the model according to query requirements, effectively improving query efficiency and storage utilization rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and particularly to a method and system for converting a relational model into a graph model based on an LLM model. Background Art

[0002] Currently, the relational model is usually converted into a graph model by using the primary-foreign key mapping method.

[0003] For example, in a method for converting a relational database into a graph database (publication number CN119336852A), it is proposed to generate corresponding points, edges, and indexes for the graph database according to the table names, foreign keys, and indexes of the relational database.

[0004] For example, in a database query method, device, medium, and computer program product (publication number CN118885507A), it is proposed to map data tables to nodes and map foreign key relationships to edges to convert the database into a graph model.

[0005] However, the graph model converted by direct mapping based on primary and foreign keys may still have problems of storage redundancy and low query efficiency. Summary of the Invention

[0006] To solve the above technical problems, the present invention is solved by the following technical solutions:

[0007] The present invention provides a method for converting a relational model into a graph model based on an LLM model, including the following steps:

[0008] Obtain the relational model to be converted and various query requirements;

[0009] Convert the relational model to be converted into an initial graph model based on the primary-foreign key mapping method;

[0010] Iteratively optimize the initial graph model based on the query requirements and various preset optimization strategies to obtain a target graph model, where the optimization strategies are used to indicate the queried features corresponding to the objects to be optimized;

[0011] Among them, taking the currently executed optimization strategy as the target optimization strategy, the method for optimizing the model based on the target optimization strategy is:

[0012] Let the LLM model analyze the corresponding candidate optimization objects based on the corresponding first graph model, the query requirements, and the target optimization strategy, and generate corresponding analysis results based on the queried features corresponding to the objects to be optimized. The first graph model is the initial graph model or the second graph model obtained from the previous optimization;

[0013] Determine the corresponding target optimization object based on the target optimization strategy and the analysis result, and perform an optimization transformation based on the target optimization object to obtain the corresponding second graph model.

[0014] The graph model obtained by direct mapping conversion based on the primary and foreign keys is affected by the data table, and there will be redundant intermediate nodes or unnecessary query levels, which will affect the query performance.

[0015] Through the design of the optimization strategy, this application guides the LLM model to analyze the query requirements, can automatically judge the candidate optimization objects that meet the optimization requirements, and can automatically optimize the graph model to make the query performance of the converted graph model better.

[0016] As an implementable manner:

[0017] The optimization strategy includes:

[0018] A problem generation strategy for generating corresponding problem description information, and the problem generation strategy includes corresponding problem description templates;

[0019] An optimization judgment rule for determining the target optimization object based on the analysis result output by the LLM model;

[0020] An execution rule for performing an optimization transformation on the obtained target optimization object.

[0021] As an implementable manner:

[0022] The problem generation strategy includes one or more groups of corresponding object determination rules and problem description templates;

[0023] During the process of optimizing the model based on the target optimization strategy:

[0024] Input the corresponding first graph model and query requirements into the LLM model;

[0025] Obtain the corresponding object to be analyzed from the first graph model based on the object determination rule;

[0026] Generate problem description information corresponding to the object to be analyzed one by one according to the obtained object to be analyzed and the corresponding problem description template, and send it to the LLM model;

[0027] Receive the analysis result output by the LLM model, and the analysis result corresponds to the object to be analyzed one by one.

[0028] As an implementable manner:

[0029] The object to be analyzed includes node types and attributes;

[0030] When the object to be analyzed is a node type or an attribute, the query type is used to indicate the access method involved in the corresponding object to be analyzed, and the access method includes traversal and positioning;

[0031] The problem description template includes a problem and options, and the query type of the object to be analyzed is classified and judged through the options.

[0032] As an implementable manner:

[0033] The optimization strategy includes a point-edge conversion strategy:

[0034] The steps for model optimization based on the point-edge conversion strategy are as follows:

[0035] Extract the node types corresponding to the nodes that are only connected to two neighbor nodes from the corresponding first graph model to obtain the object to be analyzed;

[0036] Input the first graph model and various query requirements into the LLM model;

[0037] Generate the problem description information corresponding to each object to be analyzed and input it into the LLM model;

[0038] Receive the analysis results output by the LLM model;

[0039] Based on the analysis results, regard the node types judged to be only traversed as the target optimization objects;

[0040] Convert all the nodes corresponding to the target optimization objects in the first graph model into edges to obtain the corresponding second graph model.

[0041] As an implementable manner:

[0042] The optimization strategy includes an attribute migration strategy;

[0043] The steps for model optimization based on the attribute migration strategy are as follows:

[0044] Input the corresponding first graph model and various query requirements into the LLM model;

[0045] Based on the node types in the first graph model, ask questions to the LLM model in turn to obtain the first analysis results corresponding to each node type and several second analysis results. The first analysis results are used to indicate the access method corresponding to the attributes of the node type, and the second analysis results are used to indicate the access method corresponding to the attributes in the node type;

[0046] When the access methods indicated by the corresponding first analysis results and second analysis results are both only traversal, regard the attributes corresponding to the second analysis results as the target optimization objects;

[0047] Convert each target optimization object in the first graph model into an edge attribute to obtain a corresponding second graph model.

[0048] As an implementable manner, the specific steps of sequentially asking questions to the LLM model based on the node types in the first graph model are as follows:

[0049] Take the currently extracted node type as the first object to be analyzed, and take each attribute under the node type as the second object to be analyzed;

[0050] Generate a first question description text corresponding to the first object to be analyzed and send it to the LLM model, and receive the first analysis result fed back by the LLM;

[0051] Based on the first analysis result, judge whether the corresponding access method is only traversal;

[0052] If so, sequentially generate second question description texts corresponding to each second object to be analyzed and send them to the LLM model, and receive each second analysis result fed back by the LLM model;

[0053] If not, complete the question asking for the current node type.

[0054] As an implementable manner:

[0055] The optimization strategy includes an index optimization strategy. The object to be analyzed corresponding to the index optimization strategy is the attribute value, and the corresponding query type is used to indicate the query method involved in querying the attribute value;

[0056] The steps for model optimization based on the index optimization strategy are as follows:

[0057] Take the corresponding question description template as the question description information;

[0058] The LLM model analyzes the query types of each attribute value based on the corresponding first graph model, query requirements, and the question description information, judges whether there are attribute values that can be queried by keyword matching, and obtains the attributes corresponding to such attribute values, and generates corresponding analysis results;

[0059] Based on the corresponding optimization judgment rule, determine the target optimization object from the attributes indicated by the analysis result;

[0060] In the first graph model, convert the target optimization object into a node type, and construct a node based on the attribute value corresponding to the target optimization object to obtain a corresponding second graph model.

[0061] The present invention also provides a system for converting a relationship model into a graph model based on an LLM model, including:

[0062] An input module for obtaining a relationship model to be converted and various query requirements;

[0063] A conversion module for converting the relationship model to be converted into an initial graph model based on the primary-foreign key mapping method;

[0064] An optimization module for iteratively optimizing the initial graph model based on the query requirements and a preset optimization strategy to obtain a target graph model, where the optimization strategy is used to indicate the queried features corresponding to the optimizable objects;

[0065] The optimization module:

[0066] For interacting with the LLM model, enabling the LLM model to analyze corresponding candidate optimization objects based on the queried features corresponding to the optimizable objects according to the corresponding first graph model, the query requirements, and the corresponding optimization strategy, and generate corresponding analysis results, where the first graph model is the initial graph model or the second graph model obtained from the previous optimization;

[0067] For determining a target optimization object based on the corresponding optimization strategy and the corresponding analysis result, and performing an optimization transformation on the graph model to be optimized based on the target optimization object.

[0068] As an implementable manner, it includes:

[0069] The optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule, and the problem generation strategy includes corresponding problem description templates;

[0070] The optimization module includes a decision-making unit and an execution unit;

[0071] The decision-making unit:

[0072] For generating corresponding problem description information based on the problem generation strategy;

[0073] For interacting with the LLM model, sending the corresponding graph model to be optimized, query requirements, and problem description information to the LLM model, and receiving the analysis results fed back by the LLM model;

[0074] For determining a target optimization object based on the optimization judgment rule and the corresponding analysis result;

[0075] The execution unit is used to perform an optimization transformation on the model to be optimized based on the execution rule and the corresponding target optimization object;

[0076] Due to the adoption of the above technical solutions, the present invention has remarkable technical effects:

[0077] The present invention can automatically complete the conversion from a relational model to a graph model and optimize the model according to query requirements, effectively improving query efficiency and storage utilization. Description of the Drawings

[0078] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0079] Figure 1 It is a schematic flowchart of model optimization based on a target optimization strategy in an embodiment. Detailed Description of the Embodiments

[0080] The following will further elaborate on the present invention in conjunction with embodiments. The following embodiments are explanations of the present invention, and the present invention is not limited to the following embodiments.

[0081] An embodiment of the present application provides a method for converting a relational model to a graph model based on an LLM model, including the following steps;

[0082] S100. Obtain the relational model to be converted and various query requirements;

[0083] It is configured by the user based on the business query scenario corresponding to the relational model to be converted;

[0084] The user can also convert the corresponding historical query statements into query texts expressed in natural language and screen out the query texts as query requirements.

[0085] S200. Convert the relational model to be converted into an initial graph model based on the method of primary-foreign key mapping;

[0086] Including:

[0087] Vertex mapping: Convert the primary key (PK) in the corresponding data table into a "vertex" of the graph model;

[0088] Edge mapping: Convert the foreign key (FK) relationship in the corresponding data table into an "edge" of the graph model;

[0089] Attribute mapping: Retain the fields in the table as the attributes of the corresponding vertex.

[0090] S300. Iteratively optimize the initial graph model based on the query requirements and various preset optimization strategies to obtain a target graph model;

[0091] The optimization strategy is used to indicate the queried features corresponding to the objects to be optimized.

[0092] The method of taking the currently executed optimization strategy as the target optimization strategy and performing model optimization based on the target optimization strategy is as follows:

[0093] Let the LLM model analyze the corresponding candidate optimization objects for the queried features corresponding to the optimizable objects based on the corresponding first graph model, the query requirement, and the target optimization strategy, and generate corresponding analysis results. The first graph model is the initial graph model or the second graph model obtained from the previous optimization;

[0094] Determine the corresponding target optimization object based on the target optimization strategy and the analysis result, and perform an optimization transformation based on the target optimization object to obtain the corresponding second graph model.

[0095] Due to the difficulty of characterizing optimizable situations, current optimization of graph models often requires human participation, that is, humans indicate the optimization objects and optimization schemes.

[0096] In this embodiment, based on the queried features as the determination features of the optimizable objects, and using the LLM model to analyze the graph paths involved in various query requirements in the graph model to be optimized (the graph paths do not involve specific nodes and reflect the query paths based on node types), analyze the candidate optimization objects according to each graph path, automatically identify the candidate optimization objects that meet the corresponding queried features, so as to automatically determine the target optimization object based on the optimization strategy and automatically perform an optimization transformation on the graph model.

[0097] As an implementable manner, the optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule:

[0098] The problem generation strategy includes corresponding problem description templates, which are used to generate corresponding problem description information to guide the LLM model to perform corresponding analysis. The problem description information is used to indicate the object to be analyzed and is also used to indicate all or part of the queried features corresponding to the optimizable objects;

[0099] The optimization judgment rule is used to determine the target optimization object based on the analysis result output by the LLM model;

[0100] The execution rule is used to perform an optimization transformation based on the target optimization object.

[0101] Indicate the queried features of the optimizable objects based on the problem generation strategy and / or the optimization judgment rule.

[0102] As another implementable manner, the problem generation strategy includes one or more groups of corresponding object determination rules and problem description templates; the object determination rules are used to determine the object to be analyzed.

[0103] As an implementable manner, referring to Figure 1 , the process of optimizing the model based on the target optimization strategy includes:

[0104] S310. Input the corresponding first graph model and each query requirement into the LLM model;

[0105] When the first graph model is the same as the previous first graph model, there is no need to output it again, and just continue to ask questions to the LLM model;

[0106] In this embodiment, the first graph model is a graph model of json type.

[0107] S320. Obtain the corresponding object to be analyzed from the first graph model based on the object determination rule;

[0108] In this embodiment, the types of the objects to be analyzed include node type, attribute, and attribute value.

[0109] S330. Generate problem description information corresponding to the object to be analyzed one by one according to the obtained object to be analyzed and the corresponding problem description template, and send it to the LLM model;

[0110] The problem description information is used to guide the LLM model to analyze the queried type of the corresponding object to be analyzed;

[0111] When the object to be analyzed is a node type or an attribute:

[0112] The queried type is used to indicate the access method involved in the corresponding object to be analyzed, and the access method includes traversal and positioning;

[0113] The corresponding problem description template includes questions and options, and the queried type of the object to be analyzed is classified and judged through the options;

[0114] When the optimization strategy only involves one object to be analyzed, the object to be analyzed is the candidate optimization object, and the options include the queried features of the corresponding optimizable object (for example, one option is only traversal);

[0115] When the optimization strategy designs multiple objects to be analyzed, it means that the queried features of the corresponding optimizable object include multiple sub-features, and each object to be analyzed involves one sub-feature. At this time, the options are used to include the corresponding one sub-feature.

[0116] Although it is possible to directly ask questions about the queried features of the optimizable object and let the LLM model judge whether the candidate optimization model meets the queried features, when the queried features are relatively complex, the LLM model is prone to misjudgment. In this embodiment, through structured options for guidance, the LLM model is allowed to select the corresponding category, which can ensure the accuracy of the analysis result.

[0117] When the object to be analyzed is an attribute value, the corresponding query type to be queried is used to indicate the query method involved in querying the attribute value;

[0118] S340. Receive the analysis result output by the LLM model;

[0119] The analysis result corresponds one-to-one with the object to be analyzed.

[0120] S350. Determine the target optimization object based on the optimization judgment rule and the analysis result;

[0121] When there is no target optimization object, it is determined not to optimize and the next optimization strategy is executed.

[0122] S360. Perform an optimization transformation on the corresponding first graph model based on the execution rule and the target optimization object to obtain the corresponding second graph model.

[0123] In this embodiment, the optimization strategy includes a point-edge conversion strategy, an attribute migration strategy, and an index optimization strategy.

[0124] In the point-edge conversion strategy, the query feature of the object to be optimized is only the traversed node type;

[0125] The steps for model optimization based on the point-edge conversion strategy are as follows:

[0126] 110. Input the corresponding first graph model and various query requirements into the LLM model;

[0127] 120. Based on the corresponding object determination rule, extract the node type corresponding to the node that is only connected to two neighbor nodes from the first graph model, and use the obtained node type as the object to be analyzed, and the object to be analyzed is the candidate optimization object;

[0128] 130. Generate corresponding problem description information based on the object to be analyzed and the corresponding problem description template;

[0129] In this embodiment, the problem description information is:

[0130] Question: Determine which of the following types the target node type belongs to in the query:

[0131] Options: 1. Directly located (i.e., queried by ID or attribute); 2. Only traversed; 3. Neither; 4. Both;

[0132] 140. Send the problem description information to the LLM model, and the LLM model generates the corresponding analysis result;

[0133] 150. Based on the corresponding optimization judgment rules, the access mode is extracted to only traverse the objects to be analyzed, and the corresponding target optimization object is obtained;

[0134] That is, the query feature of the corresponding optimizable object is that the access mode is only traversal;

[0135] 160. Based on corresponding execution rules, convert all nodes corresponding to the target optimization object in the first graph model into edges to obtain a corresponding second graph model.

[0136] That is, convert node types to edge types, convert nodes to corresponding edges, and convert node attributes to corresponding edge attributes.

[0137] The graph model converted based on primary and foreign key mapping may contain redundant node types. These nodes are only intermediate nodes connecting other nodes, and various query requirements will not directly locate these nodes. Therefore, corresponding optimization strategies should be set based on the structure of these nodes and the query characteristics.

[0138] This embodiment can automatically identify such points that only serve as intermediate nodes through the point-edge conversion strategy and convert them into edges, thereby reducing redundancy and improving query performance.

[0139] The attribute migration strategy includes a problem description template for analyzing node types and a problem description template for analyzing attributes. The type of the optimized object is attribute, and the corresponding query characteristics are: the attribute access mode of the node type is traversal only, and the node itself is only traversal visible;

[0140] As an implementable method, the steps of performing model optimization based on the attribute migration strategy are as follows:

[0141] 210. Input the corresponding first graph model and various query requirements into the LLM model;

[0142] 220. Ask the LLM model questions sequentially based on the node types in the first graph model to obtain a first analysis result and a plurality of second analysis results corresponding to each node type, wherein the first analysis result is used to indicate an access method corresponding to an attribute of the node type, and the second analysis result is used to indicate an access method corresponding to a corresponding attribute in the node type;

[0143] 230. When the access mode indicated by the corresponding first analysis result and the second analysis result is traversal only, the attribute corresponding to the second analysis result is used as the target optimization object;

[0144] 240. Convert each target optimization object in the first graph model into an edge attribute to obtain a corresponding second graph model.

[0145] As another implementable manner, the specific steps of sequentially asking questions to the LLM model based on the node types in the first graph model are as follows:

[0146] 221. Take the currently extracted node type as the first object to be analyzed, and take each attribute under the node type as the second object to be analyzed;

[0147] The second analysis object is the corresponding candidate optimization object.

[0148] 222. Generate the first question description text corresponding to the first object to be analyzed and send it to the LLM model, and receive the first analysis result fed back by the LLM;

[0149] In this embodiment, the first question description text is:

[0150] Question: Determine which of the following types the target node type belongs to in the query:

[0151] Options: 1. Directly locate the attributes of this point; 2. Only traverse the attributes of this point; 3. Do not involve the attributes of this point; 4. Locate and traverse simultaneously.

[0152] 223. Based on the first analysis result, determine whether the corresponding access method is only traversal;

[0153] 224. If so, sequentially generate the second question description text corresponding to each second object to be analyzed and send it to the LLM model, and receive the second analysis results fed back by the LLM model;

[0154] In this embodiment, the second question description text is:

[0155] Question: Determine which of the following types the target attribute belongs to in the query:

[0156] Options: 1. Directly locate; 2. Only traverse visible; 3. Do not involve; 4. Locate and traverse simultaneously.

[0157] 225. If not, complete the question for the current node type.

[0158] The graph model obtained by conversion based on the direct mapping of the primary and foreign keys may have unnecessary query levels. For example, there is an auxiliary table for storing supplementary information in the relational model; for example, in the financial loan scenario, the loan amount applied by the user is inconsistent with the actual approved loan amount. The corresponding loan information is stored through the loan table, and the corresponding loan amount and loan time are stored through the loan disbursement node. In actual business queries, only the loan disbursement node will be accessed through the loan node to read the amount. If its node attributes are converted into edge attributes, there is no need to traverse the loan disbursement node during the corresponding query;

[0159] In this embodiment, through the attribute migration strategy, attributes that are only traversed and queried and whose nodes cannot be located are automatically identified, and such attributes are converted from node attributes to edge attributes to optimize the reading path and improve the access efficiency.

[0160] In this embodiment, the object to be analyzed corresponding to the index optimization strategy is the attribute value;

[0161] The steps for model optimization based on the index optimization strategy are as follows:

[0162] Use the corresponding problem description template as the problem description information;

[0163] The LLM model analyzes the queried types of each attribute value based on the corresponding first graph model, query requirements, and the problem description information, determines whether there are attribute values queried by keyword matching, and obtains the attributes corresponding to such attribute values to generate the corresponding analysis results;

[0164] Based on the corresponding optimization judgment rules, determine the target optimization object from the attributes indicated by the analysis results; those skilled in the art can set the corresponding rules according to actual needs to further screen the attributes indicated by the analysis results. For example, the number of categories corresponding to the attribute values can be counted, and the attributes with the number of categories less than the preset value can be used as the target optimization objects.

[0165] In the first graph model, convert the target optimization object into a node type, and construct a node based on the attribute value corresponding to the target optimization object to obtain the corresponding second graph model.

[0166] This embodiment can avoid full-graph scanning of the corresponding attribute values through the index optimization strategy, speed up the positioning speed, and improve the performance and maintainability of the overall graph database.

[0167] And when an attribute value is shared by multiple points, converting it into a point can reduce duplicate storage and improve query efficiency. Another embodiment of this application provides a system for converting a relational model to a graph model based on an LLM model, including:

[0168] An input module for obtaining the relational model to be converted and various query requirements;

[0169] A conversion module for converting the relational model to be converted into an initial graph model based on the master-slave key mapping;

[0170] An optimization module for iteratively optimizing the initial graph model based on the query requirements and a preset optimization strategy to obtain a target graph model, where the optimization strategy is used to indicate the queried features corresponding to the optimizable objects;

[0171] The optimization module:

[0172] For interacting with an LLM model, enabling the LLM model to analyze corresponding candidate optimization objects based on the corresponding first graph model, the query requirement, and the corresponding optimization strategy, and generate corresponding analysis results based on the queried features corresponding to the optimizable object. The first graph model is an initial graph model or a second graph model obtained from the previous optimization.

[0173] For determining a target optimization object based on the corresponding optimization strategy and the corresponding analysis result, and performing an optimization transformation on the graph model to be optimized based on the target optimization object.

[0174] As an implementable manner:

[0175] The optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule. The problem generation strategy includes corresponding problem description templates.

[0176] The optimization module includes a decision-making unit and an execution unit.

[0177] The decision-making unit:

[0178] For generating corresponding problem description information based on the problem generation strategy.

[0179] For interacting with the LLM model, sending the corresponding graph model to be optimized, the query requirement, and the problem description information to the LLM model, and receiving the analysis result fed back by the LLM model.

[0180] For determining a target optimization object based on the optimization judgment rule and the corresponding analysis result.

[0181] The execution unit is used to perform an optimization transformation on the model to be optimized based on the execution rule and the corresponding target optimization object.

[0182] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.

[0183] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, devices, or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.

[0184] The present invention is described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or in one block or multiple blocks.

[0185] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or in one block or multiple blocks.

[0186] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, such that a series of operating steps are executed on the computer or other programmable terminal device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or in one block or multiple blocks.

[0187] It should be noted that:

[0188] The phrase "an embodiment" or "embodiments" mentioned in the specification means that the specific features, structures, or characteristics described in connection with the embodiments are included in at least one embodiment of the present invention. Therefore, the phrases "an embodiment" or "embodiments" that appear throughout the specification do not necessarily all refer to the same embodiment.

[0189] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed as including the preferred embodiments as well as all changes and modifications that fall within the scope of the present invention.

[0190] In addition, it should be noted that for the specific embodiments described in this specification, the shapes and names of the components can be different. Any equivalent or simple changes made according to the structure, features, and principles described in the inventive concept of this invention patent are included within the protection scope of this invention patent. Those skilled in the technical field to which this invention pertains can make various modifications, supplements, or use similar methods for substitution to the specific embodiments described, as long as they do not deviate from the structure of this invention or exceed the scope defined by this claims, they should all fall within the protection scope of this invention.

Claims

1. A method for converting a relational model to a graph model based on an LLM model, characterized in that, It includes the following steps: Obtain the relationship model to be converted and various query requirements; Convert the relationship model to be converted into an initial graph model based on the primary-foreign key mapping method; Iteratively optimize the initial graph model based on the query requirements and various preset optimization strategies to obtain a target graph model, where the optimization strategy is used to indicate the queried features corresponding to the optimizable objects; Among them, taking the currently executed optimization strategy as the target optimization strategy, the method for optimizing the model based on the target optimization strategy is: Let the LLM model analyze the corresponding candidate optimization objects based on the corresponding first graph model, the query requirements, and the target optimization strategy, and generate corresponding analysis results based on the queried features corresponding to the optimizable objects. The first graph model is the initial graph model or the second graph model obtained from the previous optimization; Based on the target optimization strategy and the analysis results, automatically identify candidate optimization objects that meet the corresponding queried features to determine the corresponding target optimization objects, and perform optimization transformation based on the target optimization objects to obtain the corresponding second graph model; Among them, the optimization strategy includes a question generation strategy for generating corresponding question description information, and the question description information is used to guide the LLM model to analyze the queried types of the corresponding objects to be analyzed: When the object to be analyzed is a node type or an attribute, the corresponding queried type is used to indicate the access method involved in the corresponding object to be analyzed; When the corresponding object to be analyzed is an attribute value, the corresponding queried type is used to indicate the query method involved in querying the attribute value.

2. The method for converting a relationship model to a graph model based on an LLM model according to claim 1, characterized in that: The question generation strategy includes corresponding question description templates; The optimization strategy further includes: An optimization judgment rule for determining target optimization objects based on the analysis results output by the LLM model; An execution rule for performing optimization transformation on the obtained target optimization objects.

3. The method for converting a relationship model to a graph model based on an LLM model according to claim 2, characterized in that: The question generation strategy includes one or more groups of corresponding object determination rules and question description templates; During the process of optimizing the model based on the target optimization strategy: Input the corresponding first graph model and query requirements into the LLM model; Obtain the corresponding objects to be analyzed from the first graph model based on the object determination rules; Generate question description information corresponding to the objects to be analyzed one by one according to the obtained objects to be analyzed and the corresponding question description templates, and send them to the LLM model; Receive the analysis results output by the LLM model, and the analysis results correspond to the objects to be analyzed one by one.

4. The method for converting a relationship model to a graph model based on an LLM model according to claim 3, characterized in that: When the object to be analyzed is a node type or an attribute, the corresponding question description template includes questions and options, and the queried type of the object to be analyzed is classified and judged through the options.

5. The method for converting a relationship model to a graph model based on an LLM model according to claim 4, characterized in that: The optimization strategy includes a point-edge conversion strategy: The steps for optimizing the model based on the point-edge conversion strategy are as follows: Extract the node types corresponding to the nodes that are only connected to two neighbor nodes from the corresponding first graph model to obtain the objects to be analyzed; Input the first graph model and various query requirements into the LLM model; Generate the problem description information corresponding to each object to be analyzed and input it into the LLM model; Receive the analysis results output by the LLM model; Based on the analysis results, determine the target optimization object as the node type that is judged to be only traversed; Convert all the nodes corresponding to the target optimization object in the first graph model into edges to obtain the corresponding second graph model.

6. The method for converting a relationship model into a graph model based on the LLM model according to claim 5, wherein: The optimization strategy includes an attribute migration strategy; The steps for optimizing the model based on the attribute migration strategy are as follows: Input the corresponding first graph model and various query requirements into the LLM model; Based on the node types in the first graph model, sequentially ask questions to the LLM model to obtain the first analysis results corresponding to each node type and several second analysis results. The first analysis result is used to indicate the accessed manner corresponding to the attributes of the node type, and the second analysis result is used to indicate the accessed manner corresponding to the attributes in the node type; When the accessed manners indicated by the corresponding first analysis result and second analysis result are both only traversal, take the attribute corresponding to the second analysis result as the target optimization object; Convert each target optimization object in the first graph model into an edge attribute to obtain the corresponding second graph model.

7. The method for converting a relational model to a graph model based on an LLM model according to claim 6, wherein The specific steps for sequentially asking questions to the LLM model based on the node types in the first graph model are as follows: Take the currently extracted node type as the first object to be analyzed, and take each attribute under the node type as the second object to be analyzed; Generate the first problem description text corresponding to the first object to be analyzed and send it to the LLM model, and receive the first analysis result generated and fed back by the LLM; Based on the first analysis result, judge whether the corresponding accessed manner is only traversal; If so, sequentially generate the second problem description texts corresponding to each second object to be analyzed and send them to the LLM model, and receive the second analysis results fed back by the LLM model; If not, complete the questioning of the current node type.

8. The method for converting a relationship model into a graph model based on the LLM model according to claim 2, wherein: The optimization strategy includes an index optimization strategy, and the object to be analyzed corresponding to the index optimization strategy is the attribute value; The steps for optimizing the model based on the index optimization strategy are as follows: Take the corresponding problem description template as the problem description information; The LLM model analyzes the query types of each attribute value based on the corresponding first graph model, query requirements, and the problem description information, judges whether there are attribute values that are queried by keyword matching, and obtains the attributes corresponding to such attribute values, and generates the corresponding analysis results; Based on the corresponding optimization judgment rules, determine the target optimization object from the attributes indicated by the analysis results; In the first graph model, convert the target optimization object into a node type, and construct a node based on the attribute value corresponding to the target optimization object to obtain a corresponding second graph model.

9. A system for converting a relational model to a graph model based on an LLM model, characterized in that , including: An input module for obtaining a relationship model to be converted and various query requirements; A conversion module for converting the relationship model to be converted into an initial graph model based on the master-foreign key mapping method; An optimization module for iteratively optimizing the initial graph model based on the query requirements and a preset optimization strategy to obtain a target graph model, where the optimization strategy is used to indicate the queried features corresponding to the optimizable objects; The optimization module: For interacting with the LLM model, enabling the LLM model to analyze corresponding candidate optimization objects based on the corresponding first graph model, the query requirements, and the corresponding optimization strategy, and generate corresponding analysis results based on the queried features corresponding to the optimizable objects. The first graph model is the initial graph model or the second graph model obtained from the previous optimization; For automatically identifying candidate optimization objects that meet the corresponding queried features based on the corresponding optimization strategy and the corresponding analysis results to determine the target optimization object, and optimizing and transforming the graph model to be optimized based on the target optimization object; Among them, the optimization strategy includes a question generation strategy for generating corresponding question description information, and the question description information is used to guide the LLM model to analyze the queried types of corresponding objects to be analyzed: When the object to be analyzed is a node type or an attribute, the corresponding queried type is used to indicate the access method involved in the corresponding object to be analyzed; When the corresponding object to be analyzed is an attribute value, the corresponding queried type is used to indicate the query method involved in querying the attribute value.

10. The system for converting a relationship model to a graph model based on the LLM model according to claim 9, characterized in that: The optimization strategy further includes an optimization judgment rule and an execution rule; The question generation strategy includes a corresponding question description template; The optimization module includes a decision-making unit and an execution unit; The decision-making unit: For generating corresponding question description information based on the question generation strategy; For interacting with the LLM model, sending the corresponding graph model to be optimized, query requirements, and question description information to the LLM model, and receiving the analysis results fed back by the LLM model; For determining the target optimization object based on the optimization judgment rule and the corresponding analysis results; The execution unit is used to optimize and transform the model to be optimized based on the execution rule and the corresponding target optimization object.

Citation Information

Patent Citations

  • Database query method and device, medium and computer program product

    CN118885507A

  • Method for converting relational database into graph database

    CN119336852A

  • Power diagram model generation method and device, computer equipment and medium

    CN115374145A

  • Tumor knowledge base construction system and method based on large model and cue word optimization

    CN119168040A