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

By constructing a spatial graph structure and a graph neural network model, optimizing the loss function, and combining a vector database and a large language model, the problem of low efficiency in processing high-resolution DEMs and vector data was solved, achieving efficient and accurate spatial data analysis and understanding.

CN120409591BActive Publication Date: 2026-03-27青海省水文水资源测报中心
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently process and analyze the complex spatial relationships between high-resolution DEMs and vector data, resulting in low computational efficiency and excessive resource consumption, which limits the real-time performance and scalability of spatial data in water conservancy projects.

Method used

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

Benefits of technology

It significantly improves data processing speed and accuracy, reduces computing costs, enhances spatial data understanding and intelligent reasoning capabilities, and achieves real-time performance and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409591B_ABST
    Figure CN120409591B_ABST
Patent Text Reader

Abstract

The application 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, multiple layers of message passing layers and an output layer, the input layer receives node features and edge features, the multiple layers of message passing layers aggregate feature information of node neighborhoods layer by layer, and the output layer generates spatial embedding vectors reflecting node spatial features and neighborhood topological relations; a loss function is defined, and the graph neural network model is trained by using the loss function. The problems of large data scale, low processing efficiency, insufficient spatial relation modeling precision and difficulty in fusion with intelligent analysis tools are solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of geographic information systems and artificial intelligence, and more particularly to a loss function optimization method based on a graph neural network in spatial data processing. BACKGROUND

[0002] With the rapid development of big data, artificial intelligence (AI) and large language models (LLMs), the trend of intelligent processing of spatial data is increasingly prominent. Geographic information systems (GIS) as an important tool for spatial data processing and analysis are widely used in water conservancy construction, hydrological forecasting, water resources management and environmental monitoring. However, traditional water conservancy GIS application methods mostly rely on two-dimensional or three-dimensional basic spatial analysis techniques, which are difficult to efficiently process and analyze data with complex spatial relationships and high-dimensional characteristics, resulting in limited application in large, complex and dynamic scenarios.

[0003] Digital elevation model (DEM) as an important spatial data describing the change of ground elevation is widely used in flood risk analysis, water system perception and watershed terrain analysis in the water conservancy industry. However, in the existing technology, when high-resolution DEM data and vector geographic data are fused for spatial analysis, there are often problems such as large data size, low computational efficiency, excessive resource consumption, which restrict its real-time, scalability and wide applicability in practical scenarios.

[0004] Graph neural networks (GNN) as a deep learning model for processing graph-structured data have significant advantages, especially suitable for capturing complex spatial relationships and high-dimensional spatial features. GNN can efficiently learn the feature representation of nodes, edges or entire graphs through relationship propagation and information aggregation between nodes, and has great potential to be applied to modeling and analysis of complex spatial relationships. However, when existing GNN methods are directly applied to the scene of high-resolution DEM and vector data fusion, they often exceed the carrying capacity of ordinary computing resources due to the huge amount of data, thereby limiting the promotion and application of GNN in spatial data analysis.

[0005] Meanwhile, vector database technology has outstanding advantages in the storage, retrieval and similarity search of high-dimensional vectors. With efficient index structure and advanced search algorithm, vector database can quickly and accurately process large-scale spatial embedding vector data. However, the current technology still lacks an effective comprehensive method of integrating spatial embedding vectors generated by GNN, vector database and large language model, thereby limiting the further improvement of spatial data intelligent analysis and understanding ability. SUMMARY

[0006] Therefore, the present application provides a loss function optimization method based on graph neural network in spatial data processing.

[0007] In order to achieve the above purpose, the present application adopts the following technical solutions:

[0008] A loss function optimization method based on 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 geographic entities, and the edges represent spatial topological relationships, 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 layers of message passing layers and an output layer, the input layer receives node features and edge features, the multiple layers of message passing layers aggregate feature information of node neighborhood layer by layer, and the output layer generates spatial embedding vectors reflecting spatial features of nodes 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 the spatial topological relationships and node elevation change characteristics.

[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] Wherein, L recon is the node auto-encoding loss function, L edgeFor the graph edge prediction loss function, lambda and gamma are regularization coefficients, W is a set of all learnable weight matrices of graph neural network (GNN) graph convolution layers, and the regularization term For controlling model complexity, preventing overfitting, and improving generalization performance.

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

[0017]

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

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

[0020]

[0021] Where sigma (·) is the Sigmoid function, E is the real existing edge, E - is the negative sampling edge, Z u and 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 convolution 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 index structure to support fast similarity retrieval.

[0024] Optionally, it further comprises 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 comprises:

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

[0027] The retrieved spatial embedding vector is input into the large language model as context auxiliary information, so that the large language model combines spatial features to generate reasoning and answers.

[0028] According to the above technical solution, compared with the prior art, the present application provides a loss function optimization method based on graph neural network in spatial data processing, which has the following advantages:

[0029] 1. The traditional spatial data processing method usually processes the whole map or global data. In actual water conservancy construction and hydrological forecasting application, when facing high-resolution DEM data (such as spatial resolution less than 5 meters), the data processing time is usually counted in hours or even days. Through the key node optimization extraction strategy proposed in the application, only the core spatial nodes such as water system nodes, lake boundary points and reservoir key nodes and elevation data are processed, and the data compression rate can reach more than 85%. According to actual test, compared with the traditional method, the data processing speed is theoretically increased by about 3-5 times when processing the same size of regional spatial data, which effectively reduces the data calculation cost and hardware demand.

[0030] 2. The spatial relationship accurate modeling scheme based on graph neural network can effectively capture the complex spatial topological relationship and elevation change characteristics among water system network, water conservancy facility node, lake and river key node. Compared with the traditional two-dimensional GIS analysis method, the accuracy of river network identification and water system flow direction analysis is increased by about 15%. The deep fusion of elevation data and spatial relationship will effectively improve the decision accuracy of hydrological forecasting and water resources management.

[0031] 3. The vector database is used to store spatial embedding vectors, so that the efficiency and retrieval performance of high-dimensional spatial feature vector management are greatly improved. It is expected that in the actual test of million node scale spatial data, the similarity retrieval response time of spatial embedding vector is controlled below millisecond level (<100ms), which is more than 10 times higher than the second level response time of traditional database query, and improves the real-time performance in actual decision support application.

[0032] 4. By deeply fusing the spatial embedding vector with the large language model (such as DeepSeek, Qwen, GPT series), the method of the application significantly improves the understanding ability and intelligent reasoning level of LLM to spatial data. In the actual test scene, the accurate answer rate of large language model to spatial related problems is increased from about 60% when not fusing spatial embedding information to more than 90%, which effectively solves the problem of insufficient spatial reasoning accuracy of traditional LLM. BRIEF DESCRIPTION OF DRAWINGS

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiment or prior art description. Obviously, the drawings in the following description only the embodiments of the application, and for those skilled in the art, without creative labor, other drawings can also be obtained according to the provided drawings.

[0034] Figure 1 The overall technical flowchart of the application;

[0035] Figure 2A key node-based water conservancy space graph structure schematic diagram;

[0036] Figure 3 A GNN model space information fusion processing schematic diagram;

[0037] Figure 4 A vector database and LLM fusion reasoning detailed schematic diagram;

[0038] Figure 5 A vector database and large language model (LLM) fusion process schematic diagram;

[0039] Figure 6 A core advantage diagram of the technical scheme of the present application;

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

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

[0042] Figure 9 A GNN-LLM fusion flowchart in water resource supply optimization. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0044] Embodiment 1

[0045] This embodiment discloses a loss function optimization method based on a graph neural network in spatial data processing, referring to Figures 1-6 , comprising the following steps:

[0046] Construct a spatial graph structure, the spatial graph structure comprising nodes and edges, the nodes representing geographic entities, and the edges representing spatial topological relationships, the node features comprising spatial coordinate information and digital elevation model elevation values;

[0047] Design a graph neural network model, the graph neural network model comprising an input layer, multiple layers of message passing layers, and an output layer, the input layer receiving node features and edge features, the multiple layers of message passing layers aggregating feature information of node neighborhoods layer by layer, and the output layer generating spatial embedding vectors reflecting node spatial features and neighborhood topological relationships;

[0048] A loss function is defined, and the graph neural network model is trained using the loss function to optimize the spatial embedding vectors so that the spatial embedding vectors can accurately reflect the spatial topological relationship and node elevation change characteristics.

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

[0050] Further, in step one, in order to effectively reduce the computational complexity in the process of spatial data processing, the application designs a key node selection strategy, which clearly selects the key spatial nodes with the most representative and practical significance in the spatial data in the field of water conservancy and hydrology, including but not limited to: river key nodes (such as river confluence nodes, bifurcation nodes, cross-section control points); lake boundary key nodes (such as lake water inlet and outlet, water level monitoring points); reservoir and dam facility key nodes (such as reservoir inlet and outlet, dam flood discharge point); pump station, gate and other water conservancy engineering facility key nodes.

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

[0052] Based on the above-mentioned selected key nodes and elevation data, a graph structure model is constructed, which takes water conservancy spatial entities as nodes and spatial topological relationships (adjacency, intersection, inclusion, connection) as edges, and each node feature includes spatial coordinate information and DEM elevation value. The graph structure designed in this way can accurately express the spatial relationship and elevation change between river network, lake, reservoir and water conservancy facilities, and provide structured data support for subsequent GNN analysis.

[0053] The application designs a graph convolutional network (GCN) or graph attention network (GAT) model structure suitable for spatial data analysis according to the characteristics of the water conservancy and hydrology spatial analysis task, and the specific process is as follows:

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

[0055] Multi-layer message passing layer: aggregate the feature information (elevation and topological structure) of node neighborhood layer by layer, realize the deep fusion of spatial relationship and terrain information;

[0056] Model output layer: obtain spatial embedding vectors (Embedding Vectors) reflecting the spatial characteristics of nodes and the topological relationship of neighborhood.

[0057] The present application is aimed at the characteristics of water conservancy and hydrology spatial analysis tasks, in the model training process, the unsupervised node feature reconstruction loss function is used for optimization, so that the generated embedding vector accurately reflects the spatial topological relationship and node elevation change characteristics.

[0058] GNN training loss function definition:

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

[0060]

[0061] Edge prediction loss (adjacency matrix prediction loss):

[0062]

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

[0064]

[0065] Wherein: X: node original feature matrix; Reconstructed node feature matrix; Z u ,Z v Node embedding vector; E: real existing edge, E - : negative sampling edge; σ (·): Sigmoid function; λ, γ: regularization coefficient;

[0066] The GNN training strategy is as follows:

[0067] Adam optimizer is used for training;

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

[0069] Maximum training rounds: 200 epochs, early stopping mechanism (early stopping) to prevent overfitting.

[0070] Integration technology of spatial embedding vectors and vector databases: In order to effectively manage large-scale spatial feature vectors, the invention uniformly stores the high-dimensional spatial embedding vectors output by the GNN in a general vector database (such as Qdrant, Milvus, etc.). The vector database quickly locates spatial vectors similar or related to the target spatial features through efficient index structures (such as IVF, HNSW, etc.) and similarity search algorithms, greatly improving the storage management and retrieval efficiency of 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 the efficient index type are as follows:

[0072] HNSW (Hierarchical Navigable Small World):

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

[0074] Suitable for high-dimensional data (embedding vectors 32-128 dimensions);

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

[0076] IVF (Inverted File System):

[0077] Efficiently handle node scales of millions or more;

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

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

[0080] Seamless integration technology of spatial embedding vectors and large language models (LLM)

[0081] In order to improve the performance of large language models (such as DeepSeek, Qwen, GPT series, LLaMA) in the field of spatial data intelligent reasoning, the invention proposes the following integration technology route with LLM:

[0082] Fast retrieval of spatial embedding vectors: when the large language model receives a user query related to water conservancy spatial reasoning, the similarity retrieval capability of the vector database is used to retrieve spatial embedding vectors highly relevant to the query task in real time and quickly;

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

[0084] Enhanced spatial reasoning capability: After the above fusion process, the large language model can efficiently realize the reasoning and natural language answer generation task in the complex spatial scene, greatly enhancing the application performance of LLM in the field of spatial perception and intelligent decision support.

[0085] Multi-level deep fusion technology of elevation data and spatial relationship: The present application also proposes a multi-level information fusion technology suitable for spatial data analysis, that is, by using multi-layer graph convolution or graph attention layer in GNN, the elevation data and spatial topological relationship of the nodes are deeply fused layer by layer, realizing more accurate and comprehensive spatial data expression in tasks such as flood inundation range prediction, water system confluence identification, water conservancy facility influence range analysis, etc.

[0086] The method of the present application is particularly aimed at practical application scenarios such as water conservancy construction, hydrological forecasting, and water resources optimization management, and clearly designs to include: flood inundation analysis and risk assessment; river system perception and confluence path analysis; water conservancy facility spatial influence range analysis; water resources dispatching optimization and environmental monitoring evaluation.

[0087] In practical application, the present application can directly provide spatial intelligent analysis, prediction results and decision suggestions, realizing accurate, efficient and practical water conservancy and hydrological decision support.

[0088] Embodiment 2

[0089] As shown in Figure 7 , this embodiment shows the specific application process of the present application in the water conservancy construction scene, and explains how to realize intelligent understanding and reasoning of the complex spatial relationship between water conservancy facilities by key node extraction, graph neural network modeling, vector database construction and large language model integration, and provide efficient and accurate technical support for water conservancy engineering 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 certain typical area, including vector information such as reservoirs, main rivers, tributaries, pumping stations, water intakes, and sluices, containing spatial coordinates, attribute fields such as reservoir capacity, pumping station type, etc.

[0093] Terrain elevation data acquisition:

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

[0095] II. Data preprocessing and graph structure construction

[0096] Graph structure construction:

[0097] Vector layer data is structured into a graph form using GIS tools, where:

[0098] Nodes: Represent key water conservancy facilities such as reservoirs, river junctions, pumping stations, and sluices.

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

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

[0101] Elevation feature extraction and fusion:

[0102] Elevation values corresponding to key water conservancy nodes are extracted from DEM data as elevation features in node attributes, and spatial features such as geometric center points and planar facility barycenters are fused as part of the input node features for graph neural networks.

[0103] Graph neural network modeling and training

[0104] Graph structure input:

[0105] A spatial graph structure is constructed containing nodes and edges, with node feature dimensions including:

[0106] Coordinate information (X, Y)

[0107] Elevation value (Z)

[0108] Water conservancy facility function attributes (such as "reservoir access points" and "control hubs")

[0109] Water body capacity, water flow connection series, and other auxiliary features.

[0110] III. GNN model design:

[0111] A two-layer graph convolutional network (GCN) structure is adopted with ReLU activation function, and the feature dimension settings are as follows:

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

[0113] Hidden layer dimension: d_hidden = 32

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

[0115] Model training:

[0116] Using unsupervised learning methods, node auto-encoding loss (such as reconstruction loss + similarity constraints) is used to optimize parameters, and the training goal is to obtain high 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] The trained embedding vector representation of each node (such as a 16-dimensional vector) is exported, along with the original node ID and attribute label.

[0120] Vector database construction:

[0121] Using high-performance vector databases (such as Qdrant or Milvus), create vector indexes (such as HNSW, IVF Flat, etc. structure) to support fast retrieval of spatial semantic similarity.

[0122] Integrate with large language models to realize intelligent question answering

[0123] Interface design:

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

[0125] Query process:

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

[0127] Retrieve the most semantically similar spatial node embedding vector in the vector database;

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

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

[0130] The name and distance of the nearest pump station

[0131] Whether there is a connected path with the pump station, direction, and cascade relationship, 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 connection path between all reservoirs in the current area and their downstream pumping stations?

[0136] Q2: If the water level of the upstream reservoir rises, which pumping stations are affected?

[0137] Q3: Which areas have the most densely packed nodes within the 50-meter submerged water level line?

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

[0139] Performance evaluation indicators:

[0140] Accuracy improvement: Improve the accuracy of traditional LLM without spatial embedding state to more than 80%;

[0141] Average search time: <80ms (million-level node scale);

[0142] Semantic connectivity reasoning accuracy: about 30% improvement;

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

[0144] Example 3

[0145] As shown in Figure 8 , this example demonstrates the specific application process of the invention in the water conservancy construction scene, explaining how to extract key nodes, model with graph neural networks, build vector databases, and integrate large language models to intelligently understand and reason about complex spatial relationships between water conservancy facilities, providing efficient and accurate technical support for water conservancy engineering design, operation and dispatch, and disaster prevention decision-making.

[0146] I. Data preparation

[0147] Spatial vector data collection:

[0148] Obtain the spatial distribution layers of water conservancy facilities in a typical area (Shapefile format), including vector information such as reservoirs, major rivers, tributaries, pumping stations, water intakes, and water gates, containing spatial coordinates, attribute fields such as reservoir capacity, pumping station type, etc.

[0149] Terrain elevation data acquisition:

[0150] Obtain the corresponding digital elevation model (DEM) data for the area, with a resolution of 10 meters, reflecting the terrain undulations and river elevation differences, providing a basis for hydrological process modeling and flooding analysis.

[0151] Data preprocessing and graph structure construction

[0152] II. Graph structure construction:

[0153] The vector layer data is structured into a graph form using GIS tools, wherein:

[0154] Nodes: Represent key water conservancy facilities such as reservoirs, river junctions, pumping stations, and sluices.

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

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

[0157] Elevation feature extraction and fusion:

[0158] Only the elevation values corresponding to the key water conservancy nodes are extracted from the DEM data as the elevation feature in the node attributes, and the geometric center point, face-shaped facility barycenter, and other spatial features are fused as part of the input node features of the graph neural network.

[0159] Graph neural network modeling and training

[0160] Graph structure input:

[0161] A spatial graph structure is constructed containing nodes and edges, and the node feature dimensions include:

[0162] Coordinate information (X, Y)

[0163] Elevation value (Z)

[0164] Water conservancy facility function attributes (such as "inlet and outlet points" and "control hubs")

[0165] Water body capacity, water flow connection series, and other auxiliary features.

[0166] III. GNN model design:

[0167] A two-layer graph convolutional network (GCN) structure is adopted, with ReLU as the activation function, and the feature dimension settings are 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] Unsupervised learning is used for training, and node auto-encoding loss (such as reconstruction loss + similarity constraint) is used to optimize parameters, with the training goal being to obtain high-expression node embedding vectors that can be used for similarity retrieval and spatial reasoning.

[0173] Embedding vector storage and index management

[0174] Vectorized representation:

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

[0176] Vector database construction:

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

[0178] Integrate with large language models to realize intelligent question answering

[0179] Interface design:

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

[0181] Query process:

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

[0183] Retrieve the most semantically similar spatial node embedding vector in the vector database;

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

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

[0186] The name and distance of the nearest pump station

[0187] Whether there is a connected path with the pump station, direction, and cascading relationship, 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 in the current area and their downstream pump stations?

[0192] Q2: If the water level of the upstream reservoir on the river rises, which pump station nodes are affected?

[0193] Q3: Which nodes in the 50-meter submerged water level line are the most densely populated?

[0194] Q4: Which reservoir has the shortest connection with a river mouth?

[0195] Performance evaluation indicators:

[0196] Accuracy improvement: Improve the accuracy of traditional LLM without spatial embedding state to more than 80%;

[0197] Average search time: <80ms (million-level node scale);

[0198] Semantic connectivity reasoning accuracy: about 30% improvement;

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

[0200] Example 4

[0201] As Figure 9 shown, this embodiment shows the specific application process of the invention in the water conservancy construction scene, and explains how to realize 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, and provide efficient and accurate technical support for water conservancy engineering design, operation scheduling and disaster prevention decision-making.

[0202] I. Data preparation

[0203] Spatial vector data collection:

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

[0205] Terrain elevation data acquisition:

[0206] Obtain the corresponding digital elevation model (DEM) data for the area, with a resolution of 10 meters, reflecting the terrain undulations and river height differences, 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, including:

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

[0211] Edge: represents spatial adjacency relationship (such as river connectivity, facility correlation path, etc.);

[0212] Node attribute: includes spatial location, geometric shape, facility type, water conservancy function (such as "storage", "drainage", etc.).

[0213] Elevation feature extraction and fusion:

[0214] Only the elevation value corresponding to the key water conservancy node is extracted from the DEM data as the elevation feature in the node attribute, and the geometric center point, face-shaped facility gravity center and other spatial features are fused as part of the input node feature of the graph neural network.

[0215] Graph neural network modeling and training

[0216] Graph structure input:

[0217] Build a spatial graph structure containing nodes and edges, and the node feature dimension includes:

[0218] Coordinate information (X, Y)

[0219] Elevation value (Z)

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

[0221] Water body capacity, water flow connection series and other auxiliary features.

[0222] III. GNN model design:

[0223] Two-layer graph convolution network (GCN) structure is adopted, and the activation function is ReLU, and the feature dimension is set as follows:

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

[0225] Hidden layer dimension: d_hidden=32

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

[0227] Model training:

[0228] Unsupervised learning is used for training, node auto-encoding loss (such as reconstruction loss + similarity constraint) is used to optimize parameters, and the training target is to obtain a high-expression node embedding vector that can be used for similarity retrieval and spatial reasoning.

[0229] Embedding vector storage and index management

[0230] Vector representation:

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

[0232] Vector database construction:

[0233] Use high-performance vector databases (such as Qdrant or Milvus) to create vector indexes (such as 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 to and parse natural language questions from users or upper-level systems (such as: "What water stations are there upstream of XX reservoir?" "What is the nearest pump station near a certain reservoir?" "Is XX pump station connected to the upstream reservoir?").

[0237] Query process:

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

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

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

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

[0242] The name and distance of the nearest pump station

[0243] Whether there is a connected path with the pump station, direction, and cascading relationship, 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 pump stations in the current area?

[0248] Q2: If the water level of the upstream reservoir on the river rises, which pump station nodes are affected?

[0249] Q3: Which areas have the most dense nodes within the 50-meter submergence water level line?

[0250] Q4: What is the shortest connected relationship between a certain reservoir and an inlet?

[0251] Performance evaluation index:

[0252] Answer accuracy rate improvement: improve the accuracy of traditional LLM without spatial embedding state to more than 80%;

[0253] Average search time: <80ms (million node scale);

[0254] Semantic connectivity reasoning accuracy: about 30% improvement;

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

[0256] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

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

Claims

1. A loss function optimization method based on graph neural networks in spatial data processing, characterized in that, Includes the following steps: Construct a spatial graph structure, which includes nodes and edges. The nodes represent geographic entities, and the edges represent spatial topological relationships. The node features include spatial coordinate information and digital elevation model elevation values. Design a graph neural network model, which 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 feature information of the node's neighborhood layer by layer. The output layer generates a spatial embedding vector that reflects the spatial features of the node and the topological relationship of its neighborhood. 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 node elevation change characteristics; The loss function includes a node autoencoding loss function and a graph edge prediction loss function. The node autoencoding 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 actual edges and the predicted edges.

2. The loss function optimization method based on graph neural networks in spatial data processing according to claim 1, characterized in that, The loss function is calculated using the following formula: ; in, For node autoencoding loss function, Let the graph edge prediction loss function be... These are the regularization coefficients, This is the set of learnable weight matrices for all graph convolutional layers in a graph neural network.

3. The loss function optimization method based on graph neural networks in spatial data processing according to claim 1, characterized in that, The formula for calculating the node autoencoding loss function is as follows: ; in, This is the original feature matrix of the nodes. To reconstruct the node feature matrix.

4. The loss function optimization method based on graph neural networks in spatial data processing according to claim 1, characterized in that, The formula for calculating the graph edge prediction loss function is as follows: ; in, For the Sigmoid function, For real-existing edges, For negative sampling edges, These are the embedding vectors for the first node and the second node, respectively.

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

6. The loss function optimization method based on graph neural networks in spatial data processing according to claim 1, characterized in that, The spatial embedding vectors are stored in a vector database, which employs an efficient indexing structure to support fast similarity retrieval.

7. The loss function optimization method based on graph neural networks in spatial data processing according to claim 1, characterized in that, It also includes fusing the spatial embedding vectors with a large language model to enhance the performance of the large language model in spatial reasoning tasks.

8. The loss function optimization method based on graph neural networks 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, it uses the similarity retrieval capability of the vector database to retrieve spatial embedding vectors related to the query task in real time. The retrieved spatial embedding vectors are used as contextual auxiliary information and input into the large language model, enabling the large language model to combine spatial features for reasoning and answer generation.

Citation Information

Patent Citations

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

    CN115654381A

  • Network embedding method and system based on graph neural network

    CN117493617A