A structure-aware large model graph reasoning method and system

By standardizing the graph data and structuring encoding, it is converted into structure-aware sequence data, and inputting it to a large model for graph inference, the problem of low conversion efficiency of graph data in the existing methods is solved, and the efficiency and reliability of graph inference are significantly improved.

CN119150996BActive Publication Date: 2025-03-18ZHEJIANG LAB
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411624995.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-18
Estimated Expiration
2044-11-14

AI Technical Summary

Technical Problem

When existing methods use large models for graph inference, it is difficult to effectively convert graph data into sequence data, resulting in low inference efficiency and reliability.

Method used

By standardizing the graph data and structured encoding, it is converted into structure-aware sequence data, using code language or graph query language, inputting a large model for graph reasoning, and parsing the results into structured data or natural language descriptions.

Benefits of technology

It significantly improves the efficiency and reliability of large models in graph inference, and can more effectively utilize the serialized structure data capabilities of code language and graph query language to ensure the accuracy and credibility of the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150996B_ABST
    Figure CN119150996B_ABST
Patent Text Reader

Abstract

The present invention discloses a structure-aware large model graph reasoning method and system, which can convert graph data into structure-aware sequences, support zero-sample reasoning of large models, and thus efficiently and accurately complete graph reasoning tasks. The method includes: first, preparing graph data and graph reasoning tasks, the graph data includes nodes, edges and their features, then standardizing the graph data and performing structured coding on the graph data; then, converting the structured coded graph data into structure-aware sequences, which can be code languages ​​or standard graph query languages; then, inputting the serialized graph data into the large model, and designing a specific input format and task description, so that the large model can understand and execute graph reasoning tasks; then, parsing the reasoning results from the output of the large model, converting them into structured data or natural language descriptions for use by users or other systems; finally, verifying and evaluating the reasoning results to ensure the reliability of the results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graph reasoning, and specifically to a structure-aware large-model graph reasoning method and system. Background Art

[0002] Graph reasoning is of great significance in many applications, such as social network analysis and traffic network optimization. In recent years, large models based on pre-trained language models have demonstrated excellent processing capabilities in many tasks with their powerful task understanding and generation capabilities. How to use large models for effective graph reasoning has become one of the hot research directions. Existing methods are mainly divided into rule-based methods and graph neural network (GNN)-based methods when converting graph data into sequence data and inputting them into large models for reasoning. The former uses natural language to describe graph data, and the latter requires training a GNN to encode graph data. Therefore, a more reasonable method is to use structured language to convert graph data into structure-aware sequences, and then input them into large models for graph reasoning. Summary of the invention

[0003] In view of the graph reasoning problem, in order to effectively implement graph reasoning based on large models, the present invention proposes a structure-aware large model graph reasoning method and system.

[0004] The objective of the present invention is achieved through the following technical solutions:

[0005] The present invention provides a structure-aware large model graph reasoning method, comprising the following steps:

[0006] Step 1: Prepare graph data and graph reasoning tasks, where the graph data includes nodes, edges and their features; standardize the graph data and perform structured encoding on the processed graph data;

[0007] Step 2: Convert the structured encoded graph data into a structure-aware sequence, where the sequence is a code language or a graph query language;

[0008] Step 3: Input the serialized graph data into the large model and design the input format and task description so that the large model can understand and perform graph reasoning tasks;

[0009] Step 4: Analyze the inference results from the output of the large model and convert them into structured data or natural language descriptions;

[0010] Step 5: Verify and evaluate the inference results to ensure the reliability of the results.

[0011] Furthermore, the step 1 comprises:

[0012] The format of the collected graph data is uniformly converted into adjacency list, adjacency matrix, edge list or attribute graph.

[0013] Furthermore, in step 2, the code language includes Python's NetworkX library code; the graph query language includes Cypher and Gremlin.

[0014] Furthermore, the step 3 comprises:

[0015] Based on the serialized graph data obtained in step 2, the input prompt is constructed together with the associated task description: "You are an expert in graph reasoning, please analyze the given graph: G; And answer the question: Q" is input to the big model, where, represents a line break, G represents the serialized graph data, and Q represents the graph reasoning task;

[0016] In the input prompt, inform the big model of the code or graph query language used to serialize the graph data; inform the big model of the algorithm called when performing graph reasoning tasks.

[0017] Furthermore, the step 3 also includes:

[0018] The large model is a large language model pre-trained based on code data or a pre-trained large language model fine-tuned based on code data; the graph reasoning tasks include connectivity, shortest path, loop detection, subgraph matching, node prediction, and edge classification.

[0019] Furthermore, the step 4 comprises:

[0020] Specify the output format of the inference results in the input prompt, or convert the code or graph query language results generated by the large model into structured data or natural language descriptions through parsing.

[0021] Furthermore, the step 5 comprises:

[0022] Use a test graph dataset with known results for validation; compare the large model inference results with those of traditional graph algorithms; perform multiple rounds of inference to evaluate the consistency and stability of the results.

[0023] The present invention also provides a structure-aware large model graph reasoning system for implementing the above method, comprising:

[0024] A graph data encoding module, which is used to standardize graph data and perform structured encoding on it;

[0025] The serialization module is used to convert structured encoded graph data into structure-aware sequences;

[0026] The large model reasoning module is used to input serialized graph data into the large model and perform graph reasoning tasks;

[0027] The result parsing module is used to parse the inference results from the output of the large model and convert them into structured data or natural language descriptions;

[0028] The result verification module is used to verify and evaluate the reasoning results to ensure the reliability of the results.

[0029] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the above-mentioned structure-aware large model graph reasoning method.

[0030] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned structure-aware large model graph reasoning method.

[0031] The beneficial effects of the present invention are as follows: the present invention provides a structure-aware large model graph reasoning method, which provides an effective solution for achieving efficient and accurate graph reasoning. The present invention can effectively utilize the powerful serialization structure data capabilities of code language and graph query language, and convert the graph data into structure-aware sequence data before inputting it into the large model, which is more conducive to graph reasoning of the large model. When the present invention is applied to large model graph reasoning, the efficiency and reliability of graph reasoning are significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is a flow chart of the structure-aware large model graph reasoning method proposed by the present invention;

[0033] Figure 2 It is a schematic diagram of the structure of the structure-aware large model graph reasoning system provided by the present invention;

[0034] Figure 3 It is a schematic diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0035] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of systems and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0036] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0037] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0038] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in combination with specific implementation cases and with reference to the accompanying drawings.

[0039] See also Figure 1 The present invention proposes a structure-aware large model graph reasoning method, the main steps of which include:

[0040] Step 1: Prepare graph data and graph reasoning tasks. Graph data includes nodes, edges and their features. Then, the graph data is standardized and structured encoded.

[0041] Specifically, the collected graph data is converted into a unified format to facilitate subsequent processing. The formats of graph data include adjacency list, adjacency matrix, edge list, attribute graph, etc.

[0042] Step 2: Convert the structured encoded graph data into a structure-aware sequence, which can be a code language or a standard graph query language.

[0043] Specifically, based on the structured graph data obtained in step 1, it is converted into a structure-aware serialized form. The sequence can be in code form, including Python's NetworkX library code, or in a graph query language, including Cypher and Gremlin.

[0044] Step 3: Input the serialized graph data into the big model and design a specific input format and task description so that the big model can understand and execute graph reasoning tasks.

[0045] Specifically, based on the serialized graph data obtained in step 2, it is combined with the associated task description to construct the input prompt word "You are an expert in graph reasoning, please analyze the given graph: G; And answer the question: Q" is input to the big model, where, represents a line break, G represents the serialized graph data, and Q represents the graph reasoning task.

[0046] The large model is preferably a large language model pre-trained based on code data or a pre-trained large language model fine-tuned based on code data; the graph reasoning tasks include connectivity, shortest path, loop detection, subgraph matching, node prediction, edge classification, etc.

[0047] In the input prompt, you can clearly tell the big model which code or graph query language is used to implement the serialized graph data; when performing graph reasoning tasks, you can clearly tell the big model which algorithm should be called to help obtain the graph reasoning results.

[0048] Step 4: parse the inference results from the output of the large model and convert them into structured data or natural language descriptions for use by users or other systems.

[0049] Specifically, the output format of the inference result can be specified in the input prompt, or the code or graph query language result generated by the large model can be converted into structured data or natural language description through parsing. For example, the result of community division is expressed as: [

[0051] {"node": "Node1", "community": 1},

[0052] {"node": "Node2", "community": 1},

[0053] {"node": "Node3", "community": 2},

[0054] {"node": "Node4", "community": 2},

[0055] {"node": "Node5", "community": 3} ]

[0057] By parsing the above structured data, a natural language description can be generated: "In the analyzed social network, nodes 1 and 2 are classified into community 1, showing a close connection between them; nodes 3 and 4 belong to community 2, indicating that they have similar roles or characteristics in the network; node 5 alone constitutes community 3 and may represent an independent group or role."

[0058] Structured data can include:

[0059] (1) Node attribute table: Each node is a row, and the columns include the node ID and its calculated attributes or features, such as classification label, embedding vector, degree, centrality index, etc.;

[0060] (2) Edge attribute table: Each edge is a row, and the columns include the starting node, the ending node, and its calculated attributes or features, such as edge weight, predicted relationship type, connection strength, etc.

[0061] (3) Adjacency matrix: used to represent the connectivity of a graph. Rows and columns correspond to nodes, and the values ​​in the matrix represent the connectivity between nodes (such as 0 or 1, or specific edge weights).

[0062] (4) Feature matrix: Each row corresponds to a node, each column corresponds to a feature, and the value in the matrix is ​​the feature value or embedded representation of the node;

[0063] (5) Community partition list: in list or dictionary form, indicating the community to which the node belongs; each community contains a set of node IDs.

[0064] Step 5: Verify and evaluate the inference results to ensure the reliability of the results.

[0065] Specifically, the reliability of the reasoning results is verified by the following methods: using a test graph dataset with known results for verification; comparing the reasoning results of the large model with the results of the traditional graph algorithm. For example, when the graph reasoning task is to find the shortest path, the corresponding traditional graph algorithm is the shortest path algorithm; when the graph reasoning task is to discover communities, the corresponding traditional graph algorithm is the community discovery algorithm; performing multiple rounds of reasoning (the number of rounds is set artificially) to evaluate the consistency and stability of the results.

[0066] The structure-aware big model graph reasoning system provided by the present invention is described below. The structure-aware big model graph reasoning system described below and the structure-aware big model graph reasoning method described above can refer to each other.

[0067] Figure 2 The schematic diagram of the structure of the structure-aware large model graph reasoning system provided by the present invention is as follows: Figure 2 As shown, the present invention provides a set of structure-aware large model graph reasoning system, the system includes:

[0068] A graph data encoding module, which is used to standardize graph data and perform structured encoding on it;

[0069] The serialization module is used to convert structured encoded graph data into structure-aware sequences;

[0070] The large model reasoning module is used to input serialized graph data into the large model and perform graph reasoning tasks;

[0071] The result parsing module is used to parse the inference results from the output of the large model and convert them into structured data or natural language descriptions for use by users or other systems;

[0072] The result verification module is used to verify and evaluate the inference results to ensure the reliability and accuracy of the results.

[0073] This embodiment utilizes the powerful serialization structured data capabilities of the code language and graph query language to convert the graph data into structure-aware sequence data before inputting it into the large model, thereby improving the efficiency and reliability of large model graph reasoning.

[0074] Corresponding to the embodiment of the structure-aware large model graph reasoning method described above, the embodiment of the present application further provides an electronic device, including: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the structure-aware large model graph reasoning method described above. Figure 3 As shown, it is a hardware structure diagram of any device with data processing capability where the structure-aware large model graph reasoning method provided by the embodiment of the present application is located, except Figure 3 In addition to the processor, memory, DMA controller, disk, and non-volatile memory shown, any device with data processing capabilities in which the apparatus in the embodiment is located may also include other hardware, which will not be described in detail, generally based on the actual functions of the device with data processing capabilities.

[0075] Corresponding to the embodiment of the aforementioned structure-aware large model graph reasoning method, an embodiment of the present invention also provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the structure-aware large model graph reasoning method in the above embodiment is implemented.

[0076] The computer-readable storage medium may be an internal storage unit of any device with data processing capability described in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium may also be any device with data processing capability, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. equipped on the device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of any device with data processing capability and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by any device with data processing capability, and may also be used to temporarily store data that has been output or is to be output.

[0077] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

[0078] The above embodiments are only used to illustrate the design ideas and features of the present invention, and their purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly. The protection scope of the present invention is not limited to the above embodiments. Therefore, any equivalent changes or modifications made based on the principles and design ideas disclosed by the present invention are within the protection scope of the present invention.

Claims

1. A structure-aware large model graph reasoning method, characterized in that: The following steps are involved: Step 1: Prepare graph data and graph reasoning tasks, where the graph data includes nodes, edges and their features; standardize the graph data and perform structured encoding on the processed graph data; Step 2: Convert the structured encoded graph data into a structure-aware sequence, where the sequence is a code language or a graph query language; Step 3: Input the serialized graph data into the big model, and design the input format and task description so that the big model can understand and perform the graph reasoning task; specifically: Based on the serialized graph data obtained in step 2, construct the input prompt words "You are an expert in graph reasoning, please analyze the given graph: G" together with the associated task description; And answer the question: Q" is input to the big model, where, represents a line break, G represents serialized graph data, and Q represents a graph reasoning task; in the input prompt, the code or graph query language used by the serialized graph data of the big model is informed; when performing a graph reasoning task, the algorithm called by the big model is informed; the big model is a big language model pre-trained based on code data or a pre-trained big language model fine-tuned based on code data; Step 4: Analyze the inference results from the output of the large model and convert them into structured data or natural language descriptions; Step 5: Verify and evaluate the inference results to ensure the reliability of the results.

2. The structure-aware large model graph reasoning method according to claim 1, characterized in that: The step 1 comprises: The format of the collected graph data is uniformly converted into adjacency list, adjacency matrix, edge list or attribute graph.

3. The structure-aware large model graph reasoning method according to claim 1, characterized in that: In step 2, the code language includes Python's NetworkX library code; the graph query language includes Cypher and Gremlin.

4. The structure-aware large model graph reasoning method according to claim 1, characterized in that: The step 3 comprises: The graph reasoning tasks include connectivity, shortest path, loop detection, subgraph matching, node prediction, and edge classification.

5. The structure-aware large model graph reasoning method according to claim 1, characterized in that: The step 4 comprises: Specify the output format of the inference results in the input prompt, or convert the code or graph query language results generated by the large model into structured data or natural language descriptions through parsing.

6. The structure-aware large model graph reasoning method according to claim 1, characterized in that: The step 5 comprises: Use a test graph dataset with known results for validation; compare the large model inference results with those of traditional graph algorithms; perform multiple rounds of inference to evaluate the consistency and stability of the results.

7. A structure-aware large model graph reasoning system implementing the method of claim 1, characterized in that: include: A graph data encoding module, which is used to standardize graph data and perform structured encoding on it; The serialization module is used to convert structured encoded graph data into structure-aware sequences; The large model reasoning module is used to input serialized graph data into the large model and perform graph reasoning tasks; The result parsing module is used to parse the inference results from the output of the large model and convert them into structured data or natural language descriptions; The result verification module is used to verify and evaluate the reasoning results to ensure the reliability of the results.

8. An electronic device comprising a memory and a processor, characterized in that: The memory is coupled to the processor; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the structure-aware large model graph reasoning method described in any one of claims 1-6 above.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the structure-aware large model graph reasoning method as described in any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Multi-element mixed retrieval method, device and equipment

    CN118260452A

  • Graph-based natural language processing (NLP) for querying, analyzing, and visualizing complex data structures

    US20240362208A1