Method and system for converting relation model into graph model based on LLM model
Through the relationship model to graph model method based on LLM model, the graph model is automatically identified and optimized using query requirements optimization strategies, the problems of storage redundancy and query inefficiency are solved, and query performance and storage utilization are improved.
Patent Information
- Application Number
- CN202510711584.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-05-29
AI Technical Summary
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.
The LLM model is used to convert the relationship model into the initial graph model through primary foreign key mapping, and the initial graph model is iteratively optimized based on query requirements and preset optimization strategies. The LLM model is used to analyze the query characteristics of candidate optimization objects, automatically identify and optimize the target optimization object, and generate the target graph model.
It improves the query performance and storage utilization of the graph model, reduces redundant intermediate nodes and unnecessary query levels, and improves query efficiency.
Smart Images

Figure CN120234345A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular, 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 main 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 of 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 the main foreign key 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: The present invention proposes a method for converting a relational model into a graph model based on an LLM model, including the following steps: Obtain the relational model to be converted and various query requirements; Convert the relational model to be converted into an initial graph model based on the main 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 strategies are 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; 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.
[0007] The graph model obtained by direct mapping based on the main foreign key is affected by data tables, and redundant intermediate nodes or unnecessary query levels will appear, thus affecting query performance; Through the design of the optimization strategy, this application guides the LLM model to analyze query requirements, can automatically determine 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.
[0008] As an implementable manner: The optimization strategy includes: A problem generation strategy for generating corresponding problem description information, and the problem generation strategy includes corresponding problem description templates; An optimization judgment rule for determining a target optimization object based on the analysis result output by the LLM model; An execution rule for performing optimization transformation on the obtained target optimization object.
[0009] As an implementable manner: The problem generation strategy includes one or more groups of corresponding object determination rules and problem description templates; During the process of model optimization based on the target optimization strategy: Input the corresponding first graph model and query requirements into the LLM model; Obtain corresponding objects to be analyzed from the first graph model based on the object determination rule; Generate problem description information corresponding to the objects to be analyzed one by one according to the obtained objects to be analyzed and the corresponding problem description templates, and send it to the LLM model; Receive the analysis result output by the LLM model, and the analysis result corresponds to the object to be analyzed one by one.
[0010] As an implementable manner: The object to be analyzed includes node types and attributes; 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; The problem description template includes questions and options, and the query type of the object to be analyzed is classified and judged through the options.
[0011] As an implementable manner: The optimization strategy includes a point-edge conversion strategy: The steps for model optimization based on the point-edge conversion strategy are: 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 problem description information corresponding to each object to be analyzed and input it into the LLM model; Receive each analysis result output by the LLM model; Based on the analysis results, determine the node types that are judged to be only traversed as the target optimization objects; Convert all nodes corresponding to the target optimization objects in the first graph model into edges to obtain a corresponding second graph model.
[0012] As an implementable manner: The optimization strategy includes an attribute migration strategy; The steps for model optimization 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 results are used to indicate the accessed manner corresponding to the attributes of the node type, and the second analysis results are used to indicate the accessed manner corresponding to the corresponding attributes in the node type; When the accessed manners indicated by the corresponding first analysis results and second analysis results are both only traversal, use the attributes corresponding to the second analysis results as the target optimization objects; Convert each target optimization object in the first graph model into edge attributes to obtain a corresponding second graph model.
[0013] As an implementable manner, 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 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 feedback generated by the LLM; Based on the first analysis result, judge whether the corresponding accessed manner is only traversal; 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 the second analysis results feedback by the LLM model; If not, complete the questioning of the current node type.
[0014] As an implementable manner: 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 manner involved in querying the attribute value; The steps for model optimization based on the index optimization strategy are: Use the corresponding problem description template as the problem description information; 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 that can be queried by keyword matching, obtains the attributes corresponding to such attribute values, and generates the corresponding analysis result; Based on the corresponding optimization judgment rule, determine the target optimization object from the attributes indicated by the analysis result; 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.
[0015] The present invention also provides a system for converting a relational model into a graph model based on an LLM model, including: An input module for obtaining the relational model to be converted and various query requirements; A conversion module for converting the relational model to be converted into an initial graph model based on the primary-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 the corresponding candidate optimization objects based on the corresponding first graph model, the query requirements, and the corresponding optimization strategy, based on the queried features corresponding to the optimizable objects, and generating the corresponding analysis result, where the first graph model is the initial graph model or the second graph model obtained from the previous optimization; For determining the 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.
[0016] As an implementable manner, it includes: The optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule, and the problem generation strategy includes the corresponding problem description template; The optimization module includes a decision-making unit and an execution unit; The decision-making unit: For generating the corresponding problem description information based on the problem generation strategy; 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 result feedback by the LLM model; For determining the target optimization object based on the optimization judgment rule and the corresponding analysis result; 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.
[0017] Due to the adoption of the above technical solutions, the present invention has remarkable technical effects: 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] 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, and those of ordinary skill in the art can also obtain other drawings based on these drawings without creative efforts.
[0019] Figure 1 It is a schematic flowchart of model optimization based on a target optimization strategy in an embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0020] 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.
[0021] 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; S100. Obtain the relational model to be converted and various query requirements; It is configured by the user based on the business query scenario corresponding to the relational model to be converted; The user can also convert the corresponding historical query statements into query texts expressed in natural language and filter out the query texts as query requirements.
[0022] S200. Convert the relational model to be converted into an initial graph model based on the main foreign key mapping method; Including: Vertex mapping: Convert the primary key (PK) in the corresponding data table into a "vertex" of the graph model; Edge mapping: Convert the foreign key (FK) relationship in the corresponding data table into an "edge" of the graph model; Attribute mapping: Retain the fields in the table as the attributes of the corresponding vertex.
[0023] S300. Iteratively optimize the initial graph model based on the query requirements and various preset optimization strategies to obtain a target graph model; The optimization strategy is used to indicate the queried features corresponding to the optimizable objects.
[0024] Taking the currently executed optimization strategy as the target optimization strategy, the method for optimizing the model based on the target optimization strategy is as follows: 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; 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.
[0025] Due to the difficulty in characterizing optimizable situations, current graph model optimization often requires human participation, that is, manually indicating the optimization object and the optimization plan.
[0026] In this embodiment, based on the queried feature as the determination feature of the optimizable object, and using the LLM model to analyze the graph paths involved in the various query requirements in the graph model to be optimized (the graph path does not involve specific nodes and reflects the query path based on the node type), 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.
[0027] As an implementable manner, the optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule: The problem generation strategy includes a corresponding problem description template, which is 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 also used to indicate all or part of the queried features corresponding to the optimizable object; The optimization judgment rule is used to determine the target optimization object based on the analysis result output by the LLM model; The execution rule is used to perform an optimization transformation based on the target optimization object.
[0028] The queried features of the optimizable object are indicated based on the problem generation strategy and / or the optimization judgment rule.
[0029] 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.
[0030] As an implementable manner, referring to Figure 1 , the process of optimizing the model based on the target optimization strategy includes: S310. Input the corresponding first graph model and each query requirement into the LLM model; When the first graph model is the same as the previous one, there is no need to output it again, and you can continue to ask questions to the LLM model; In this embodiment, the first graph model is a graph model of json type.
[0031] S320. Obtain the corresponding object to be analyzed from the first graph model based on the object determination rule; In this embodiment, the types of the objects to be analyzed include node type, attribute, and attribute value.
[0032] 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; The problem description information is used to guide the LLM model to analyze the queried type of the corresponding object to be analyzed; When the object to be analyzed is a node type or an attribute: The queried type is used to indicate the access method involved in the corresponding object to be analyzed, and the access methods include traversal and positioning; 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; 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); When the optimization strategy involves 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.
[0033] Although you can 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, structured options are used to guide, and the LLM model is allowed to select the corresponding category, which can ensure the accuracy of the analysis results.
[0034] When the 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; S340. Receive the analysis results output by the LLM model; The analysis results correspond to the objects to be analyzed one by one.
[0035] S350. Determine the target optimization object based on the optimization judgment rule and the analysis results; When there is no target optimization object, it is determined that there is no optimization and the next optimization strategy is executed.
[0036] S360. Optimize and transform the corresponding first graph model based on the execution rule and the target optimization object to obtain the corresponding second graph model.
[0037] In this embodiment, the optimization strategy includes a point-edge conversion strategy, an attribute migration strategy, and an index optimization strategy.
[0038] In the point-edge conversion strategy, the queried feature of the object to be optimized is the node type that is only traversed. The steps for optimizing the model based on the point-edge conversion strategy are as follows: 110. Input the corresponding first graph model and various query requirements into the LLM model. 120. Based on the corresponding object determination rule, extract the node types corresponding to the nodes that are only connected to two neighbor nodes from the first graph model, and use the obtained node types as the objects to be analyzed, where the objects to be analyzed are the candidate optimization objects. 130. Generate the corresponding problem description information based on the object to be analyzed and the corresponding problem description template. In this embodiment, the problem description information is as follows: Question: Determine which of the following types the target node type belongs to in the query: Options: 1. Directly located (i.e., queried by ID or attribute); 2. Only traversed through; 3. Neither; 4. Both. 140. Send the problem description information to the LLM model, and the LLM model generates the corresponding analysis result. 150. Based on the corresponding optimization judgment rule, extract the objects to be analyzed with the access method of only traversed through to obtain the corresponding target optimization objects. That is, the queried feature corresponding to the optimizable object is the access method of only traversed through. 160. Based on the corresponding execution rule, convert all the nodes corresponding to the target optimization object in the first graph model into edges to obtain the corresponding second graph model.
[0039] That is, convert the node type to the edge type, convert the nodes to the corresponding edges, and convert the node attributes to the corresponding edge attributes.
[0040] The graph model obtained by conversion based on the primary-foreign key mapping may have redundant node types. Such nodes are only intermediate nodes connecting other points, and none of the various query requirements will directly locate to this point. Set the corresponding optimization strategy for the structure and queried features of such nodes. In this embodiment, the point-edge conversion strategy can automatically identify such points that only serve as intermediate nodes and convert them into edges, thereby reducing redundancy and improving query performance.
[0041] The attribute migration strategy includes a problem description template for analyzing node types and a problem description template for analyzing attributes. It can optimize the type of the object to an attribute, and the corresponding queried feature is: the access method of the attribute of the node type is only traversal, and it is only traversal visible itself; As an implementable manner, the steps for optimizing the model based on the attribute migration strategy are: 210. Input the corresponding first graph model and various query requirements into the LLM model; 220. Based on the node types in the first graph model, sequentially ask questions to the LLM model to obtain the corresponding first analysis results and several second analysis results for each node type. The first analysis result is used to indicate the access method corresponding to the attribute of the node type, and the second analysis result is used to indicate the access method corresponding to the attribute in the node type; 230. When the access methods indicated by the corresponding first analysis result and second analysis result are both only traversal, use the attribute corresponding to the second analysis result as the target optimization object; 240. Convert each target optimization object in the first graph model into an edge attribute to obtain the corresponding second graph model.
[0042] As another implementable manner, the specific steps for sequentially asking questions to the LLM model based on the node types in the first graph model are: 221. Use the currently extracted node type as the first object to be analyzed, and use each attribute under the node type as the second object to be analyzed; The second analysis object is the corresponding candidate optimization object.
[0043] 222. 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 fed back by the LLM; In this embodiment, the first problem description text is: Question: Determine which of the following types the target node type belongs to in the query: Options: 1. Directly locate the point attribute; 2. Only traverse the point attribute; 3. Do not involve the point attribute; 4. Locate and traverse simultaneously.
[0044] 223. Based on the first analysis result, determine whether the corresponding access method is only traversal; 224. Thus, the second problem description texts corresponding to each second object to be analyzed are generated in sequence and sent to the LLM model, and each second analysis result fed back by the LLM model is received. In this embodiment, the second problem description text is as follows: Question: Determine which of the following types the target attribute belongs to in the query: Options: 1. Direct positioning; 2. Only traverse visible; 3. Not involved; 4. Simultaneously position and traverse.
[0045] 225. If not, complete the questioning of the current node type.
[0046] The graph model converted 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 the actual business query, only the loan disbursement node will be accessed through the loan node to read the amount. If its node attribute is converted into an edge attribute, there is no need to traverse the loan disbursement node during the corresponding query. In this embodiment, through the attribute migration strategy, the attributes that are only traversed and queried and whose nodes will not 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.
[0047] In this embodiment, 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: Use the corresponding problem description template as the problem description information; Based on the corresponding first graph model, query requirements, and the problem description information, the LLM model analyzes the queried types of each attribute value, determines whether there are attribute values queried by keyword matching, and obtains the attributes corresponding to such attribute values, generating the corresponding analysis results; Based on the corresponding optimization judgment rule, 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 are used as the target optimization objects.
[0048] 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.
[0049] Through the index optimization strategy in this embodiment, full-graph scanning for corresponding attribute values can be avoided, the positioning speed can be accelerated, and the performance and maintainability of the overall graph database can be improved.
[0050] Moreover, when a certain 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: An input module, configured to obtain the relational model to be converted and various query requirements; A conversion module, configured to convert the relational model to be converted into an initial graph model based on the mapping of primary and foreign keys; An optimization module, configured to iteratively optimize 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: Is used to interact 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, where the first graph model is the initial graph model or the second graph model obtained from the previous optimization; Is used to determine the target optimization object based on the corresponding optimization strategy and the corresponding analysis result, and perform an optimization transformation on the graph model to be optimized based on the target optimization object.
[0051] As an implementable manner: The optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule, and the problem generation strategy includes a corresponding problem description template; The optimization module includes a decision-making unit and an execution unit; The decision-making unit: Is used to generate corresponding problem description information based on the problem generation strategy; Is used to interact with the LLM model, send the corresponding graph model to be optimized, query requirements, and problem description information to the LLM model, and receive the analysis result feedback by the LLM model; Is used to determine the target optimization object based on the optimization judgment rule and the corresponding analysis result; 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.
[0052] 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.
[0053] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, an apparatus, or a computer program product. 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 storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0054] 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 Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0055] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0056] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, such that a series of operation steps are executed on the computer or other programmable terminal devices to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0057] It should be noted that: 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 phrase "an embodiment" or "embodiments" that appears throughout the specification does not necessarily refer to the same embodiment.
[0058] Although the preferred embodiments of the present invention have been described, additional changes and modifications can be made to these embodiments by those skilled in the art once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the present invention.
[0059] In addition, it should be noted that for the specific embodiments described in this specification, the shapes, names, etc. 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 the present invention are included within the protection scope of the present invention. Those skilled in the technical field to which the present invention pertains can make various modifications or supplements to the described specific embodiments or use similar methods for substitution, as long as they do not deviate from the structure of the present invention or exceed the scope defined by this claims book, they should all fall within the protection scope of the present 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 strategies are 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; 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.
2. The method for converting a relationship model to a graph model based on an LLM model according to claim 1, wherein: The optimization strategies include: A problem generation strategy for generating corresponding problem description information, and the problem generation strategy includes corresponding problem description templates; An optimization judgment rule for determining the target optimization object based on the analysis result output by the LLM model; An execution rule for performing an optimization transformation on the obtained target optimization object.
3. The method for converting a relationship model to a graph model based on an LLM model according to claim 2, wherein: The problem generation strategy includes one or more groups of corresponding object determination rules and problem 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 object to be analyzed from the first graph model based on the object determination rule; 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; Receive the analysis result output by the LLM model, and the analysis result corresponds to the object 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, wherein: The object to be analyzed includes a node type and attributes; When the object to be analyzed is a node type or an attribute, 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; The problem description template includes a problem 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, wherein: The optimization strategy includes a point-edge conversion strategy: The steps for optimizing the model based on the point-edge conversion strategy are: Extract the node type corresponding to the node that is only connected to two neighbor nodes from the corresponding first graph model to obtain the object 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 traversed only; 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 an LLM model according to claim 5, wherein: The optimization strategy includes an attribute migration strategy; The steps for model optimization based on the attribute migration strategy are: 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 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 corresponding attributes in the node type; When the access methods indicated by the corresponding first analysis results and second analysis results are both traversal only, use the attributes corresponding to the second analysis results as the target optimization objects; Convert each target optimization object in the first graph model into edge attributes 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: 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 results generated and fed back by the LLM; Based on the first analysis results, judge whether the corresponding access method is traversal only; 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 an LLM model according to claim 2, wherein: 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; The steps for model optimization based on the index optimization strategy are: Use the corresponding problem description template as the problem description information; Based on the corresponding first graph model, query requirements, and the problem description information, the LLM model analyzes the query types of each attribute value, 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 nodes based on the attribute values corresponding to the target optimization object to obtain the 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 primary-foreign key mapping; 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: Is used to interact with the LLM model, enabling the LLM model to analyze the 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; Is used to determine the target optimization object based on the corresponding optimization strategy and the corresponding analysis result, and perform an optimization transformation on the graph model to be optimized based on the target optimization object.
10. The system for converting a relationship model to a graph model based on the LLM model according to claim 9, wherein: The optimization strategy includes a problem generation strategy, an optimization judgment rule, and an execution rule, and the problem generation strategy includes a corresponding problem description template; The optimization module includes a decision-making unit and an execution unit; The decision-making unit: Is used to generate corresponding problem description information based on the problem generation strategy; Is used to interact with the LLM model, send the corresponding graph model to be optimized, query requirements, and problem description information to the LLM model, and receive the analysis results fed back by the LLM model; Is used to determine the target optimization object based on the optimization judgment rule and the corresponding analysis result; 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.
Citation Information
Patent Citations
Interactive data migration method from relational data to graph data
CN109753537A
User demand decision-making method applying AI and big data analysis and internet system
CN114896502A
Power diagram model generation method and device, computer equipment and medium
CN115374145A
Target object recommendation method and system based on scientific research big data information
CN117114105A
Power distribution network data graph model construction method and device, electronic equipment and storage medium
CN118035502A