Loss function optimization method based on graph neural network in spatial data processing

By constructing spatial graph structure and optimizing the loss function of graph neural network, combining vector database and large language model, the problem of low efficiency of high-resolution DEM and vector data processing is solved, and efficient spatial data analysis and decision support are achieved.

CN120409591AActive Publication Date: 2025-08-01青海省水文水资源测报中心

Patent Information

Application Number
CN202510597180.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-08-01
Estimated Expiration
2045-05-09

AI Technical Summary

Technical Problem

The existing technology is difficult to efficiently process and analyze the complex spatial relationship between high-resolution DEM and vector data, resulting in low computing efficiency and excessive resource consumption, limiting the real-time and scalability of spatial data in water conservancy engineering construction and hydrological forecasting.

Method used

Build a spatial graph structure, design a graph neural network model and define a loss function, optimize spatial embedding vectors, combine vector databases and large language models to achieve efficient spatial data processing and analysis.

Benefits of technology

It significantly improves the speed and accuracy of data processing, reduces calculation costs, improves spatial data understanding capabilities and intelligent reasoning levels, and achieves more efficient water conservancy engineering construction and hydrological forecast decision-making support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409591A_ABST
    Figure CN120409591A_ABST
Patent Text Reader

Abstract

The invention discloses a loss function optimization method based on a graph neural network in spatial data processing, and relates to the technical field of geographic information system and artificial intelligence cross fusion. A spatial graph structure is constructed, the spatial graph structure comprises nodes and edges, the nodes represent geographic entities, the edges represent spatial topological relations, and node features comprise spatial coordinate information and digital elevation model elevation values; a graph neural network model is designed, the graph neural network model comprises an input layer, a multi-layer message passing layer and an output layer, the input layer receives node features and edge features, and the multi-layer message passing layer aggregates feature information of node neighborhoods layer by layer; the output layer generates a spatial embedding vector reflecting a node spatial feature and a neighborhood topological relation; and defining a loss function, and training the graph neural network model by using the loss function. The problems of huge data scale, low processing efficiency, insufficient spatial relationship modeling precision, difficulty in fusion with an intelligent analysis tool and the like are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of the cross - integration of geographic information systems and artificial intelligence, and more specifically, to an optimization method for the loss function of graph neural networks in spatial data processing. Background Art

[0002] With the rapid development of big data, artificial intelligence (AI) and large language models (LLMs) technologies, the trend of intelligent processing of spatial data has become increasingly prominent. As an important tool for spatial data processing and analysis, Geographic Information Systems (GIS) are widely used in the fields of water conservancy project construction, hydrological forecasting, water resources management, and environmental monitoring. However, most traditional water conservancy GIS application methods rely on two - dimensional or three - dimensional basic spatial analysis techniques and are difficult to efficiently process and analyze data with complex spatial relationships and high - dimensional features, resulting in limited applications in large - scale, complex, and dynamically changing scenarios.

[0003] Digital Elevation Model (DEM), as an important spatial data describing surface elevation changes, is widely used in the water conservancy industry for flood risk analysis, water system perception, and watershed terrain analysis. In the existing technology, when fusing high - resolution DEM data with vector geographic data for spatial analysis, problems such as large data scale, low computing efficiency, and excessive resource consumption are often faced, restricting its real - time performance, scalability, and application universality in actual scenarios.

[0004] Graph Neural Networks (GNN), as a deep learning model for effectively processing graph - structured data, have significant advantages and are particularly suitable for capturing complex spatial relationships and high - dimensional spatial features. Through the relationship propagation and information aggregation between nodes, GNN can efficiently learn the feature representations of nodes, edges, or the entire graph and have great potential for application in the modeling and analysis of complex spatial relationships. However, when existing GNN methods are directly applied to the scenario of fusing high - resolution DEM and vector data, they often exceed the bearing capacity of ordinary computing resources due to the huge amount of data, thus restricting the popularization and application of GNN in spatial data analysis.

[0005] Meanwhile, vector database technology has shown outstanding advantages in aspects such as the storage, retrieval, and similarity search of high-dimensional vectors. With the help of efficient index structures and advanced search algorithms, vector databases can process large-scale spatial embedding vector data quickly and accurately. However, the current technology still lacks an effective comprehensive method to integrate the spatial embedding vectors generated by GNNs, vector databases, and large language models, thus restricting the further improvement of the intelligent analysis and understanding ability of spatial data. Summary of the Invention

[0006] In view of this, the present invention provides a method for optimizing the loss function of a graph neural network in spatial data processing.

[0007] To achieve the above object, the present invention adopts the following technical solutions:

[0008] A method for optimizing the loss function of a graph neural network in spatial data processing, comprising the following steps:

[0009] Construct a spatial graph structure, the spatial graph structure includes nodes and edges, the nodes represent geographical entities, the edges represent spatial topological relationships, and the node features include spatial coordinate information and digital elevation model elevation values;

[0010] Design a graph neural network model, the graph neural network model includes an input layer, multiple message passing layers, and an output layer, the input layer receives node features and edge features, the multiple message passing layers aggregate the feature information of node neighborhoods layer by layer, and the output layer generates spatial embedding vectors reflecting node spatial features and neighborhood topological relationships;

[0011] Define a loss function and use the loss function to train the graph neural network model to optimize the spatial embedding vectors so that the spatial embedding vectors can accurately reflect spatial topological relationships and node elevation change features.

[0012] Optionally, the loss function includes a node auto-encoding loss function and a graph edge prediction loss function, the node auto-encoding loss function is used to measure the difference between the original node features and the reconstructed node features, and the graph edge prediction loss function is used to measure the difference between the actually existing edges and the predicted edges.

[0013] Optionally, the loss function is calculated as follows:

[0014]

[0015] Where L recon is the node auto-encoding loss function, L edgeis the loss function for graph edge prediction. λ and γ are regularization coefficients respectively. W is the set of learnable weight matrices of all graph convolutional layers in the graph neural network (GNN). The regularization term is used to control the model complexity, prevent overfitting, and improve the generalization performance.

[0016] Optionally, the calculation formula of the node auto-encoding loss function is as follows:

[0017]

[0018] where X is the original node feature matrix, is the reconstructed node feature matrix.

[0019] Optionally, the calculation formula of the graph edge prediction loss is as follows:

[0020]

[0021] where σ(·) is the Sigmoid function, E is the actually existing edge, E - is the negative sampled edge, Z u , Z v are the first node embedding vector and the second node embedding vector respectively.

[0022] Optionally, the graph neural network model adopts a graph convolutional network or a graph attention network structure.

[0023] Optionally, the spatial embedding vector is stored in a vector database, and the vector database adopts an efficient indexing structure to support fast similarity retrieval.

[0024] Optionally, it further includes fusing the spatial embedding vector with a large language model to enhance the performance of the large language model in spatial reasoning tasks.

[0025] Optionally, the fusion process includes:

[0026] When the large language model receives a user query involving spatial reasoning, utilize the similarity retrieval ability of the vector database to retrieve the spatial embedding vector related to the query task in real time;

[0027] Input the retrieved spatial embedding vector as context auxiliary information into the large language model, enabling the large language model to perform reasoning and answer generation in combination with spatial features.

[0028] Through the above technical solutions, compared with the prior art, the present invention provides an optimization method for the loss function of a graph neural network in spatial data processing, having the following beneficial effects:

[0029] 1. Traditional spatial data processing methods usually process the entire map or regional data. In the actual construction of water conservancy projects and hydrological forecasting applications, when facing high-resolution DEM data (such as when the spatial resolution is less than 5 meters), the data processing time is usually measured in hours or even days. Through the key node optimization and extraction strategy proposed by the present invention, only the core spatial nodes such as water system nodes, lake boundary points, and key reservoir nodes and elevation data are processed, and the data volume compression rate can reach more than 85%. According to actual tests, when processing spatial data in areas of the same scale, compared with traditional methods, the data processing speed will theoretically increase by about 3 to 5 times, effectively reducing the data calculation cost and hardware requirements.

[0030] 2. The precise spatial relationship modeling solution based on graph neural network of the present invention can effectively capture the complex spatial topological relationships and elevation change characteristics among water system networks, water conservancy facility nodes, and key nodes of lakes and rivers. Compared with traditional two-dimensional GIS analysis methods, the accuracy of river network recognition and water system flow direction analysis is increased by about 15%. The deep integration of elevation data and spatial relationships will effectively promote the improvement of the decision-making accuracy of hydrological forecasting and water resource management.

[0031] 3. Using a vector database to store spatial embedding vectors greatly improves the efficiency and retrieval performance of high-dimensional spatial feature vector management. It is expected that in the actual test of spatial data with a scale of millions of nodes, the similarity retrieval response time of spatial embedding vectors is controlled below the millisecond level (<100ms), which is more than 10 times faster than the second-level response time of traditional database query methods, improving the real-time performance in actual decision-making support applications.

[0032] 4. By deeply integrating spatial embedding vectors with large language models (such as DeepSeek, Qwen, GPT series), the method of the present invention significantly improves the understanding ability and intelligent reasoning level of LLM for spatial data. In actual test scenarios, the accurate answer rate of large language models for spatial-related questions has increased from about 60% when not integrating spatial embedding information to more than about 90%, effectively solving the problem of insufficient spatial reasoning accuracy of traditional LLMs. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] 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 the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.

[0034] Figure 1 It is the overall technical flow chart of the present invention;

[0035] Figure 2Schematic diagram of the water conservancy spatial graph structure based on key nodes;

[0036] Figure 3 Schematic diagram of the spatial information fusion processing of the GNN model;

[0037] Figure 4 Detailed schematic diagram of the fusion inference of the vector database and the LLM;

[0038] Figure 5 Schematic diagram of the fusion process of the vector database and the large language model (LLM);

[0039] Figure 6 Core advantage diagram of the technical solution of the present invention;

[0040] Figure 7 Schematic diagram of the application of the present invention in the water conservancy environment field;

[0041] Figure 8 System integration flowchart in the hydrological forecasting scenario;

[0042] Figure 9 GNN-LLM fusion flowchart in the optimization of water resources supply; Detailed implementation method

[0043] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0044] Embodiment 1

[0045] This embodiment discloses an optimization method for the loss function of the graph neural network in spatial data processing. Refer to Figures 1-6 , including the following steps:

[0046] Construct a spatial graph structure, where the spatial graph structure includes nodes and edges. The nodes represent geographical entities, the edges represent spatial topological relationships, and the node features include spatial coordinate information and digital elevation model elevation values;

[0047] Design a graph neural network model. The graph neural network model includes an input layer, multiple message passing layers, and an output layer. The input layer receives node features and edge features. The multiple message passing layers gradually aggregate the feature information of the node neighborhoods. The output layer generates a spatial embedding vector reflecting the node spatial features and neighborhood topological relationships;

[0048] Define a loss function and use the loss function to train a graph neural network model to optimize the spatial embedding vector so that the spatial embedding vector can accurately reflect the spatial topological relationship and the node elevation change characteristics.

[0049] Among them, the loss function includes a node auto-encoding loss function and a graph edge prediction loss function. The node auto-encoding loss function is used to measure the difference between the original node features and the reconstructed node features, and the graph edge prediction loss function is used to measure the difference between the actually existing edges and the predicted edges.

[0050] Further, in step one, in order to effectively reduce the computational complexity in the process of spatial data processing, the present invention designs a key node selection strategy to clearly select the key spatial nodes that are the most representative and practically significant in the spatial data in the field of water conservancy and hydrology, including but not limited to: key nodes of river channels (such as river confluence nodes, diversion nodes, cross-section control points); key nodes of lake boundaries (such as lake inlets and outlets, water level monitoring points); key nodes of reservoir and dam facilities (such as reservoir inlet and outlet, dam flood discharge point); key nodes of water conservancy project facilities such as pumping stations and gates.

[0051] The above key nodes are extracted from spatial vector data (such as shapefile vector data files), and the elevation data corresponding to the nodes are selected from high-resolution digital elevation data (Digital Elevation Model, DEM) as node features, thereby greatly reducing the scale of processed data, improving data processing efficiency, and at the same time ensuring the integrity of key terrain information and the accuracy of analysis.

[0052] Based on the above selected key nodes and elevation data, the present invention constructs a graph structure model with water conservancy spatial entities as nodes and spatial topological relationships (adjacency, intersection, inclusion, connection) as edges. Each node feature includes spatial coordinate information and DEM elevation values. The graph structure designed in this way can accurately express the spatial relationship and elevation change between the water system network, lakes, reservoirs and water conservancy facilities, providing structured data support for subsequent GNN analysis.

[0053] In view of the characteristics of the water conservancy and hydrology spatial analysis tasks, the present invention designs a model structure of a graph convolutional network (Graph Convolutional Network, GCN) or a graph attention network (Graph Attention Network, GAT) suitable for spatial data analysis. The specific process is as follows:

[0054] Model input layer: Node features (elevation, location) and edge features (topological relationship) are input into the GNN;

[0055] Multi - layer message passing layer: Aggregate the feature information (elevation and topological structure) of node neighborhoods layer by layer to achieve a deep fusion of spatial relationships and terrain information;

[0056] Model output layer: Obtain spatial embedding vectors (Embedding Vectors) that reflect the spatial characteristics of nodes and the topological relationships of neighborhoods.

[0057] In view of the characteristics of water conservancy and hydrological spatial analysis tasks, during the model training process, an unsupervised node feature reconstruction loss function is used for optimization to ensure that the generated embedding vectors accurately reflect the spatial topological relationships and the characteristics of node elevation changes.

[0058] Definition of GNN training loss function:

[0059] Node auto - encoding loss (feature reconstruction loss):

[0060]

[0061] Graph edge prediction loss (adjacency matrix prediction loss):

[0062]

[0063] Total loss function (comprehensive training objective):

[0064]

[0065] Where: X: Node original feature matrix; Reconstructed node feature matrix; Z u ,Z v : Node embedding vector; E: Real - existing edge, E - : Negative - sampled edge; σ(·): Sigmoid function; λ, γ: Regularization coefficients;

[0066] The GNN training strategy is as follows:

[0067] Use the Adam optimizer for training;

[0068] Learning rate setting: Initial 0.001, gradually decaying (such as Cosine Annealing Scheduler);

[0069] Maximum number of training epochs: 200 epochs, and the early - stopping mechanism is used to prevent overfitting.

[0070] Integration Technology of Spatial Embedding Vectors and Vector Databases: To effectively manage large-scale spatial feature vectors, the present invention uniformly stores the high-dimensional spatial embedding vectors output by the GNN in a general vector database (such as Qdrant, Milvus, etc.). Through efficient indexing structures (such as IVF, HNSW, etc.) and similarity search algorithms, the vector database can quickly locate spatial vectors similar or relevant to the target spatial features, significantly improving the storage management and retrieval efficiency of the embedding vectors. This technology enables the system to exhibit excellent real-time performance and scalability when processing large-scale spatial data, providing efficient data access capabilities for subsequent intelligent applications.

[0071] The characteristics of efficient indexing types are as follows:

[0072] HNSW (Hierarchical Navigable Small World):

[0073] Suitable for real-time and efficient retrieval;

[0074] Applicable to high-dimensional data (embedding vectors of 32 to 128 dimensions);

[0075] Fast retrieval speed (millisecond-level response).

[0076] IVF (Inverted File System):

[0077] Efficiently handle node scales of over one million;

[0078] Establish a fast index based on clustering with low memory occupancy;

[0079] Support fast batch retrieval with high recall rate.

[0080] Seamless Fusion Technology of Spatial Embedding Vectors and Large Language Models (LLMs)

[0081] To improve the performance of large language models (such as DeepSeek, Qwen, GPT series, LLaMA) in the field of intelligent reasoning of spatial data, the present invention proposes the following technical routes for integration with LLMs:

[0082] Fast Retrieval of Spatial Embedding Vectors: When the large language model receives a user query involving water conservancy spatial reasoning, utilize the similarity retrieval ability of the vector database to retrieve spatial embedding vectors highly relevant to the query task in real-time and quickly;

[0083] Context Fusion Technology: Encode the retrieved spatial embedding vectors in a way suitable for the input of the large language model and input them as context auxiliary information into the LLM model, enabling the large language model to fully integrate the high-dimensional spatial feature information from the GNN;

[0084] Enhanced Spatial Reasoning Ability: After the above fusion process, the large language model can efficiently perform reasoning and natural language answer generation tasks in complex spatial scenarios, significantly enhancing the application performance of the LLM in the fields of spatial perception and intelligent decision-making support.

[0085] Multi-level Deep Fusion Technology of Elevation Data and Spatial Relationships: The present invention also proposes a multi-level information fusion technology applicable to spatial data analysis, that is, by using multi-layer graph convolution or graph attention layers in the GNN, the elevation data of nodes and spatial topological relationships are gradually and deeply fused to achieve more accurate and comprehensive spatial data expression in tasks such as flood inundation range prediction, river confluence identification, and impact range analysis of water conservancy facilities.

[0086] The method of the present invention is specifically oriented to practical application scenarios such as water conservancy project construction, hydrological forecasting, and optimal management of water resources, and clearly designs including: flood inundation analysis and risk assessment; river system perception and confluence path analysis; spatial impact range analysis of water conservancy facilities; optimization of water resource scheduling and environmental monitoring and assessment.

[0087] In practical applications, the present invention can directly provide spatial intelligent analysis, prediction results, and decision-making suggestions to achieve accurate, efficient, and practical water conservancy and hydrological decision-making support.

[0088] Example 2

[0089] As Figure 7 shown, this embodiment demonstrates the specific application process of the present invention in the water conservancy construction scenario, and illustrates how to achieve intelligent understanding and reasoning of complex spatial relationships between water conservancy facilities through key node extraction, graph neural network modeling, vector database construction, and large language model integration, providing efficient and accurate technical support for water conservancy project design, operation scheduling, and disaster prevention decision-making.

[0090] I. Data Preparation

[0091] Spatial Vector Data Acquisition:

[0092] Obtain the spatial distribution layer (Shapefile format) of water conservancy facilities in a typical area, and the data content includes: vector information such as reservoirs, main rivers, tributaries, pumping stations, water intake points, and sluice gates, including spatial coordinates and attribute fields such as reservoir capacity and pumping station type.

[0093] Terrain Elevation Data Acquisition:

[0094] Obtain the digital elevation model (DEM) data corresponding to this area, with a resolution of 10 meters, which reflects the terrain undulation and river channel elevation difference, providing a basis for hydrological process modeling and inundation analysis.

[0095] II. Data Preprocessing and Graph Structure Construction [[ID=XXX]]

[0096] Graph Structure Construction:

[0097] Use GIS tools to structure the vector layer data into a graph form, where:

[0098] Nodes: Represent key water conservancy facilities such as reservoirs, river confluence points, pumping stations, and sluice gates;

[0099] Edges: Represent spatial adjacency relationships (such as river connectivity, facility association paths, etc.);

[0100] Node attributes: Include spatial location, geometric shape, facility type, water conservancy functions (such as "regulation" and "drainage"), etc.

[0101] Elevation Feature Extraction and Fusion:

[0102] Only extract the elevation values corresponding to the key water conservancy nodes from the DEM data as the elevation features in the node attributes, and fuse spatial features such as the geometric center point and the centroid of the planar facility as part of the input node features of the graph neural network.

[0103] Graph Neural Network Modeling and Training

[0104] Graph Structure Input:

[0105] Construct a spatial graph structure containing nodes and edges. The node feature dimensions include:

[0106] Coordinate information (X, Y)

[0107] Elevation value (Z)

[0108] Functional attributes of water conservancy facilities (such as "inlet / outlet points" and "control hubs")

[0109] Auxiliary features such as water body capacity and water flow connection levels.

[0110] III. GNN Model Design:

[0111] Adopt a two-layer graph convolutional network (GCN) structure with the activation function ReLU, and set the feature dimensions as follows:

[0112] Input layer dimension: d_in = 6 (spatial + attribute)

[0113] Hidden layer dimension: d_hidden = 32

[0114] Output layer dimension: d_out = 16 (spatial embedding vector)

[0115] Model Training:

[0116] Trained using unsupervised learning, the parameters are optimized with node auto-encoding loss (such as reconstruction loss + similarity constraint), and the training objective is to obtain highly expressive node embedding vectors that can be used for similarity retrieval and spatial reasoning.

[0117] Embedding vector storage and index management

[0118] Vector representation:

[0119] Export the embedding vector representation of each trained node (such as a 16-dimensional vector), along with the original node ID and attribute labels.

[0120] Vector database construction:

[0121] Use a high-performance vector database (such as Qdrant or Milvus) to create a vector index (such as structures like HNSW, IVF Flat, etc.) to support fast retrieval of spatial semantic similarity.

[0122] Integration with large language models to achieve intelligent question answering

[0123] Interface design:

[0124] Build a query interface to listen for and parse natural language questions from users or upper-level systems (such as: "Which hydrological stations are there upstream of XX Reservoir?", "Which is the nearest pumping station near a certain reservoir?", "Is XX Pumping Station connected to the upstream reservoir?").

[0125] Query process:

[0126] Use keyword analysis and spatial feature encoding to vectorize the question;

[0127] Retrieve the spatially closest node embedding vectors in the vector database;

[0128] The retrieval results (including spatial and attribute information) are used as context to input into a large language model (such as Qwen or DeepSeek);

[0129] The LLM generates structured or natural language answers based on the embedded context, such as:

[0130] Name and distance of the nearest pumping station

[0131] Whether there is a connected path, direction, and cascade relationship with the pumping station, etc.

[0132] Whether there is an overflow risk in the river channel, etc.

[0133] System testing and verification

[0134] Test question set:

[0135] Q1: What is the shortest connected path between all reservoirs and the downstream pumping stations in the current area?

[0136] Q2: If the water level of the reservoir upstream of the river rises, which pumping station nodes will be affected?

[0137] Q3: In which areas are the nodes within the 50-meter flood level line the most concentrated?

[0138] Q4: Which reservoir has the shortest connection relationship with a certain river estuary?

[0139] Performance evaluation indicators:

[0140] Improvement in answer accuracy: Improve the accuracy of traditional LLM without spatial embedding to over 80%;

[0141] Average retrieval time: <80ms (scale of millions of nodes);

[0142] Accuracy of semantic connected reasoning: Improve by about 30%;

[0143] Overall system response time is shortened by 40%.

[0144] Example 3

[0145] As Figure 8 shown, this example demonstrates the specific application process of the present invention in the water conservancy construction scenario, and explains how to achieve intelligent understanding and reasoning of the complex spatial relationships between water conservancy facilities through key node extraction, graph neural network modeling, vector database construction, and large language model integration, providing efficient and accurate technical support for water conservancy project design, operation scheduling, and disaster prevention decision-making.

[0146] I. Data preparation

[0147] Spatial vector data collection:

[0148] Obtain the spatial distribution layer (Shapefile format) of water conservancy facilities in a typical area. The data content includes vector information such as reservoirs, main rivers, tributaries, pumping stations, water intake points, and sluice gates, including spatial coordinates and attribute fields such as reservoir capacity and pumping station type.

[0149] Terrain elevation data acquisition:

[0150] Obtain the digital elevation model (DEM) data corresponding to this area with a resolution of 10 meters, which reflects the terrain undulation and river channel elevation difference, providing a basis for hydrological process modeling and inundation analysis.

[0151] Data preprocessing and graph structure construction

[0152] II. Graph structure construction:

[0153] Using GIS tools to structure vector layer data into a graph form, where:

[0154] Nodes: Represent key water conservancy facilities such as reservoirs, river confluence points, pumping stations, and sluice gates;

[0155] Edges: Represent spatial adjacency relationships (such as river connectivity, facility association paths, etc.);

[0156] Node attributes: Include spatial location, geometric shape, facility type, water conservancy function (such as "regulation" and "drainage"), etc.

[0157] Elevation feature extraction and fusion:

[0158] Only extract the elevation values corresponding to key water conservancy nodes from DEM data as the elevation features in the node attributes, and fuse spatial features such as geometric center points and centroids of planar facilities as part of the input node features of the graph neural network.

[0159] Graph neural network modeling and training

[0160] Graph structure input:

[0161] Construct a spatial graph structure containing nodes and edges. The node feature dimensions include:

[0162] Coordinate information (X, Y)

[0163] Elevation value (Z)

[0164] Functional attributes of water conservancy facilities (such as "inlet / outlet points" and "control hubs")

[0165] Auxiliary features such as water body capacity and water flow connection levels.

[0166] III. GNN model design:

[0167] Adopt a two-layer graph convolutional network (GCN) structure with the activation function ReLU, and set the feature dimensions as follows:

[0168] Input layer dimension: d_in = 6 (space + attributes)

[0169] Hidden layer dimension: d_hidden = 32

[0170] Output layer dimension: d_out = 16 (spatial embedding vector)

[0171] Model training:

[0172] Use unsupervised learning to train, optimize the parameters using node auto-encoding loss (such as reconstruction loss + similarity constraint), and the training objective is to obtain highly expressive node embedding vectors that can be used for similarity retrieval and spatial reasoning.

[0173] Embedded Vector Storage and Index Management

[0174] Vector Representation:

[0175] Export the embedded vector representation of each trained node (such as a 16-dimensional vector), along with the original node ID and attribute labels.

[0176] Vector Database Construction:

[0177] Use a high-performance vector database (such as Qdrant or Milvus) to create vector indexes (such as HNSW, IVF Flat, etc.) to support fast retrieval of spatial semantic similarity.

[0178] Integration with Large Language Models for Intelligent Question Answering

[0179] Interface Design:

[0180] Build a query interface to listen for and parse natural language questions from users or upper-level systems (such as: "Which hydrological stations are there upstream of XX Reservoir?", "Which is the nearest pumping station to a certain reservoir?", "Is XX Pumping Station connected to the upstream reservoir?").

[0181] Query Process:

[0182] Use keyword analysis and spatial feature encoding to vectorize the question;

[0183] Retrieve the spatially closest node embedded vector in the vector database;

[0184] Use the retrieval results (including spatial and attribute information) as context to input into a large language model (such as Qwen or DeepSeek);

[0185] The LLM generates structured or natural language answers based on the embedded context, such as:

[0186] Name and distance of the nearest pumping station

[0187] Whether there is a connected path, direction, and cascade relationship with the pumping station, etc.

[0188] Whether there is an overflow risk in the river channel, etc.

[0189] System Testing and Verification

[0190] Test Question Set:

[0191] Q1: What is the shortest connected path between all reservoirs and their downstream pumping stations in the current area?

[0192] Q2: If the water level of the upstream reservoir of the river channel rises, which pumping station nodes will be affected?

[0193] Q3: Which areas have the densest nodes within the 50-meter inundation water level line?

[0194] Q4: Which reservoir has the shortest connectivity relationship with a certain river estuary?

[0195] Performance evaluation metrics:

[0196] Improvement in answer accuracy: Improve the accuracy of traditional LLMs without spatial embedding to over 80%;

[0197] Average retrieval time: <80ms (for a node scale of one million);

[0198] Accuracy of semantic connectivity reasoning: Improve by approximately 30%;

[0199] Overall system response time is shortened by 40%.

[0200] Example 4

[0201] As Figure 9 shown, this example demonstrates the specific application process of the present invention in the water conservancy construction scenario, explaining how to achieve intelligent understanding and reasoning of the complex spatial relationships between water conservancy facilities through key node extraction, graph neural network modeling, vector database construction, and large language model integration, providing efficient and accurate technical support for water conservancy project design, operation scheduling, and disaster prevention decision-making.

[0202] I. Data preparation

[0203] Spatial vector data collection:

[0204] Obtain the spatial distribution layer (Shapefile format) of water conservancy facilities in a certain typical area, and the data content includes: vector information such as reservoirs, main rivers, tributaries, pumping stations, water intakes, and sluices, including spatial coordinates and attribute fields such as reservoir capacity and pumping station type.

[0205] Terrain elevation data acquisition:

[0206] Obtain the digital elevation model (DEM) data corresponding to this area, with a resolution of 10 meters, which reflects the terrain undulation and river channel elevation difference, providing a basis for hydrological process modeling and inundation analysis.

[0207] II. Data preprocessing and graph structure construction

[0208] Graph structure construction:

[0209] Use GIS tools to structure the vector layer data into a graph form, where:

[0210] Nodes: Represent key water conservancy facilities such as reservoirs, river confluences, pumping stations, and sluices;

[0211] Edge: representing spatial adjacency relationships (such as river connectivity, facility connection paths, etc.);

[0212] Node attributes: including spatial location, geometric shape, facility type, water conservancy functions (such as "regulation", "drainage"), etc.

[0213] Elevation feature extraction and fusion:

[0214] Extract only the elevation values corresponding to key water conservancy nodes from the DEM data as the elevation features in the node attributes, and fuse spatial features such as geometric center points and centroids of planar facilities as part of the input node features of the graph neural network.

[0215] Graph neural network modeling and training

[0216] Graph structure input:

[0217] Construct a spatial graph structure containing nodes and edges, and the node feature dimensions include:

[0218] Coordinate information (X, Y)

[0219] Elevation value (Z)

[0220] Water conservancy facility function attributes (such as "inlet / outlet point", "control hub")

[0221] Auxiliary features such as water body capacity and water flow connection level.

[0222] III. GNN model design:

[0223] Adopt a two-layer graph convolutional network (GCN) structure, with the activation function being ReLU, and the feature dimensions are set as follows:

[0224] Input layer dimension: d_in = 6 (spatial + attribute)

[0225] Hidden layer dimension: d_hidden = 32

[0226] Output layer dimension: d_out = 16 (spatial embedding vector)

[0227] Model training:

[0228] Use unsupervised learning to train, and optimize the parameters using node auto-encoding losses (such as reconstruction loss + similarity constraint). The training objective is to obtain highly expressive node embedding vectors that can be used for similarity retrieval and spatial reasoning.

[0229] Embedding vector storage and index management

[0230] Vectorized representation:

[0231] Export the embedding vector representation of each trained node (such as a vector with a dimension of 16), along with the original node ID and attribute labels.

[0232] Vector database construction:

[0233] Use a high-performance vector database (such as Qdrant or Milvus) to create a vector index (such as structures like HNSW, IVF Flat, etc.) to support fast retrieval of spatial semantic similarity.

[0234] Integrate with large language models to achieve intelligent question answering

[0235] Interface design:

[0236] Build a query interface to listen for and parse natural language questions from users or upper-level systems (such as: "Which hydrological stations are there upstream of XX Reservoir?", "Which is the nearest pumping station near a certain reservoir?", "Is XX Pumping Station connected to the upstream reservoir?").

[0237] Query process:

[0238] Use keyword analysis and spatial feature encoding to vectorize the question;

[0239] Retrieve the spatial node embedding vector with the most similar semantics in the vector database;

[0240] The retrieval results (including spatial and attribute information) are used as context to input into a large language model (such as Qwen or DeepSeek);

[0241] The LLM generates structured or natural language answers based on the embedded context, such as:

[0242] Name and distance of the nearest pumping station

[0243] Whether there is a connected path, direction, and cascade relationship with the pumping station, etc.

[0244] Whether there is an overflow risk in the river channel, etc.

[0245] System testing and verification

[0246] Test question set:

[0247] Q1: What is the shortest connected path between all reservoirs and their downstream pumping stations in the current area?

[0248] Q2: If the water level of the upstream reservoir of the river channel rises, which pumping station nodes will be affected?

[0249] Q3: In which areas are the nodes most concentrated within the 50-meter flood inundation line?

[0250] Q4: Which reservoir has the shortest connection relationship with a certain river estuary?

[0251] Performance evaluation metrics:

[0252] Improvement in answer accuracy: Improve the accuracy of traditional LLMs without spatial embedding to over 80%;

[0253] Average retrieval time: <80ms (scale of millions of nodes);

[0254] Accuracy of semantic connected reasoning: Improve by approximately 30%;

[0255] The overall system response time is shortened by 40%.

[0256] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For related parts, reference can be made to the description in the method section.

[0257] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for optimizing a loss function of a graph neural network in spatial data processing, characterized in that, Including the following steps: Construct a spatial graph structure, where the spatial graph structure includes nodes and edges. The nodes represent geographical entities, the edges represent spatial topological relationships, and the node features include spatial coordinate information and digital elevation model elevation values; Design a graph neural network model. The graph neural network model includes an input layer, multiple message passing layers, and an output layer. The input layer receives node features and edge features. The multiple message passing layers gradually aggregate the feature information of node neighborhoods. The output layer generates a spatial embedding vector that reflects the spatial features of nodes and the topological relationships of neighborhoods; Define a loss function and use the loss function to train the graph neural network model to optimize the spatial embedding vector so that the spatial embedding vector can accurately reflect the spatial topological relationship and the node elevation change characteristics.

2. The loss function optimization method based on graph neural network in spatial data processing according to claim 1, wherein, The loss function includes a node auto-encoding loss function and a graph edge prediction loss function. The node auto-encoding loss function is used to measure the difference between the original node features and the reconstructed node features. The graph edge prediction loss function is used to measure the difference between the actually existing edges and the predicted edges.

3. The loss function optimization method based on graph neural network in spatial data processing according to claim 2, characterized in that, The loss function is calculated as follows: Among them, L recon is the node auto-encoding loss function, and L edge is the graph edge prediction loss function. λ and γ are regularization coefficients respectively, and W is the set of learnable weight matrices of all graph convolutional layers in the graph neural network.

4. The loss function optimization method based on the graph neural network in spatial data processing according to claim 2, wherein The calculation formula of the node auto-encoding loss function is as follows: Among them, X is the original feature matrix of nodes, is the reconstructed node feature matrix.

5. The loss function optimization method based on the graph neural network in spatial data processing according to claim 1, wherein The calculation formula of the graph edge prediction loss function is as follows: Among them, σ(·) is the Sigmoid function, E is the actually existing edge, and E - is the negative sampling edge, and Z u , Z v are the first node embedding vector and the second node embedding vector respectively.

6. The loss function optimization method based on graph neural network in spatial data processing according to claim 1, characterized in that The graph neural network model adopts a graph convolutional network or a graph attention network structure.

7. The loss function optimization method based on graph neural network in spatial data processing according to claim 1, characterized in that, The spatial embedding vector is stored in a vector database, and the vector database adopts an efficient indexing structure to support fast similarity retrieval.

8. A method for optimizing a loss function of a graph neural network in spatial data processing according to claim 1, characterized in that, It also includes fusing the spatial embedding vector with a large language model to enhance the performance of the large language model in spatial reasoning tasks.

9. A method for optimizing the loss function of a graph neural network in spatial data processing according to claim 1, characterized in that The fusion process includes: When the large language model receives a user query involving spatial reasoning, utilize the similarity retrieval ability of the vector database to retrieve in real time the spatial embedding vectors relevant to the query task; Input the retrieved spatial embedding vectors as context auxiliary information into the large language model, enabling the large language model to perform reasoning and answer generation in combination with spatial features.

Citation Information

Patent Citations

  • Network embedding pre-training method based on hierarchical loss function of graph neural network

    CN114596473A

  • Water supply pipeline leakage detection method based on graph neural network

    CN115654381A

  • High-resolution remote sensing image semantic segmentation method based on graph convolutional neural network

    CN116597143A

  • Network embedding method and system based on graph neural network

    CN117493617A

  • Interactive evolution graph intelligent design method based on GNN and LLM

    CN119337928A

Cited By

  • Seabed data organization method and system based on space entity object

    CN121456034A