A physical constraint watershed hydrology real-time prediction method based on semantic causal reasoning

By constructing a watershed knowledge graph and a large language model for causal reasoning, and combining graph attention and physically constrained neural networks, the problems of multimodal data fusion and physical constraints were solved, achieving high-precision and robust real-time hydrological forecasting to meet flood control needs.

CN122175011APending Publication Date: 2026-06-09SICHUAN FUZE TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SICHUAN FUZE TECHNOLOGY CO LTD
Filing Date
2026-04-28
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing hydrological forecasting methods are difficult to effectively integrate multimodal data, and the lack of physical constraints leads to weak generalization ability. In particular, the forecast results are inaccurate in extreme weather or data shortage situations, making it difficult to meet flood control needs.

Method used

We construct a watershed knowledge graph, combine it with a large language model for causal reasoning and feature optimization, design a neural network that integrates graph attention mechanism and physical constraints, supplement the data with the knowledge graph and introduce hydrological and physical laws to form a semantically constrained prediction network.

Benefits of technology

It significantly improves the utilization rate and forecast accuracy of multimodal data, enhances the robustness and interpretability of the model under extreme conditions, ensures that the prediction results conform to hydrophysical laws, and provides high-precision and reliable flash flood early warning support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122175011A_ABST
    Figure CN122175011A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of hydrological forecasting, and in particular to a physical constraint basin hydrological real-time forecasting method based on semantic causal reasoning. In view of the semantic gap of multi-source heterogeneous data and the missing problem of physical mechanism existing in the prior art, the following scheme is proposed: first, a knowledge graph within a basin is constructed based on water conservancy text data; second, a semantic causal reasoning is performed by using a large language model combined with the knowledge graph to dynamically identify key disaster-causing factors and generate an input feature set; then, a semantic constraint prediction network is constructed, which realizes the spatio-temporal aggregation of upstream station features through a knowledge graph attention mechanism, and modifies the forget gate by introducing a rainfall attenuation coefficient and adds a water balance constraint term in the loss function to explicitly inject the hydrological physical law into the neural network; finally, the model is trained by using historical data and features are completed and dynamically optimized in the real-time data stream combined with the knowledge graph to output the water level prediction value at the future time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of hydrological forecasting technology, specifically to a real-time hydrological forecasting method for watersheds based on semantic causal reasoning and physical constraints. Background Technology

[0002] Watershed hydrological forecasting is a crucial foundation for flood control, drought relief, and water resource allocation. Especially in scenarios involving flash flood warnings in small watersheds, the accuracy and timeliness of forecasts directly impact the safety of people's lives and property. Current mainstream hydrological forecasting methods fall into two main categories: one is based on physical mechanisms and distributed hydrological models, such as SWAT and TOP models, which simulate runoff generation and confluence processes by solving the Saint-Venant equations or water balance equations; the other is based on data-driven machine learning methods, such as support vector machines and long short-term memory networks (LSTM), which learn the mapping relationship between inputs and outputs using historical data. In recent years, with the development of artificial intelligence technology, more and more research has attempted to apply deep learning to the field of hydrological forecasting, improving forecast accuracy by incorporating multi-source time-series data such as rainfall, water level, and flow. Some studies have also begun to explore combining graph neural networks or attention mechanisms to model the spatial correlations between stations within a watershed.

[0003] The aforementioned existing technologies still have the following shortcomings in practical applications: First, there is the semantic gap problem of multi-source heterogeneous data. Watershed data naturally contains multimodal information such as numerical (rainfall, water level), textual (weather forecast text, dispatch instructions), and topological (river network structure). Existing deep learning methods are difficult to effectively integrate unstructured textual data, resulting in the waste of a large amount of valuable information (such as upstream reservoir dispatch instructions). Feature selection often relies on human experience and is difficult to dynamically capture nonlinear causal relationships in complex watersheds. Second, there is the problem of weak generalization ability due to the lack of physical mechanisms. Pure data-driven models lack physical constraints and are essentially "black box" mappings. They are prone to learning spurious correlations. Under extreme weather, sensor failure, or data missing conditions, the prediction results may violate the water balance principle (such as rising water levels without rain), resulting in poor robustness and difficulty in meeting the physical credibility requirements of forecast results in actual flood control scenarios. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a real-time watershed hydrological forecasting method based on semantic causal reasoning and physical constraints, which solves the problem of weak generalization ability caused by the lack of physical mechanisms in current methods.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a real-time watershed hydrological forecasting method based on semantic causal reasoning, comprising the following steps: Step S1: Construct a knowledge graph within the watershed Based on water conservancy text data, a large language model is used to extract hydrological entities and their semantic relationships, and a watershed knowledge graph containing node attributes and topological connections is constructed. Step S2: Multi-source data integration and preprocessing By accessing multimodal data sources, missing data is filled in and time series are aligned based on the knowledge graph to generate standardized input data; Step S3: Causal Inference and Feature Optimization Based on Large Language Model Construct structured prompt words for water conservancy scenarios, drive a large language model to perform causal reasoning in conjunction with the knowledge graph, dynamically identify key disaster-causing factors under the current forecast target, and generate an input feature index set; Step S4: Construct a semantic constraint prediction network Design a neural network architecture that integrates graph attention mechanism and physical constraints, including: Knowledge graph-based graph topology input layer; An attention aggregation module based on upstream and downstream relationships and flow path distance; Gated units with embedded hydrophysical laws; A loss function incorporating water balance constraints; Step S5: Model Training and Real-time Rolling Forecasts The semantic constraint prediction network is trained using historical data, and feature completion and dynamic optimization are performed by combining knowledge graphs in real-time data streams to output the water level forecast value for future time.

[0006] In some embodiments, the step S1 of constructing the intra-basin knowledge graph includes: By leveraging the named entity recognition capabilities of large language models, hydrological station, reservoir, and river entities can be automatically extracted from water conservancy documents. The large language model is guided by prompt words to establish "upstream-downstream" and "tributary-mainstream" topological relationships between entities; Static attributes and real-time data interfaces are attached to graph nodes to form a dynamically updatable knowledge graph structure.

[0007] In some embodiments, the causal inference based on the large language model in step S3 includes: Construct water conservancy scene prompts that include watershed topology and meteorological text; Drive the large language model to execute the causal inference chain and determine the causal influence strength of each upstream node on the target station's water level; Output a set of input feature indices with strong causal relationships to guide the construction of subsequent model inputs.

[0008] In some embodiments, the graph topology input layer in step S4 is constructed as follows: Map each hydrological station within the basin to a graph network node; Construct a directed adjacency matrix based on the "upstream" and "tributary" relationships in the knowledge graph; The causal reasoning results output by the large language model are used as semantic embeddings and injected into the node feature representation.

[0009] In some embodiments, the attention aggregation module in step S4 is calculated as follows: For the target site, determine its set of upstream neighbor nodes based on the adjacency matrix; By combining features such as flow path distance and historical state, the attention weight of each neighbor node to the input at the current moment is calculated; The features of upstream nodes are weighted and aggregated using attention weights to generate an input vector that incorporates spatial topological information.

[0010] In some embodiments, the gating unit embedding physical laws in step S4 includes: A rainfall attenuation coefficient determined by watershed soil type is introduced to correct the output of the traditional forgetting gate; The model is forced to follow the physical decay law during rainless periods to prevent prediction results from violating the principle of water balance.

[0011] In some embodiments, the loss function introduced in step S4 includes: Data-driven terms: measure the error between predicted and actual values; Physical constraint: Penalizes outputs that violate the monotonicity of the "water level-rainfall" relationship in the prediction results; The two weighted sums are used to form the total loss function for model training.

[0012] In some embodiments, the real-time rolling forecast in step S5 includes: Real-time access to hydrological and meteorological data streams; When missing data is detected, the knowledge graph is triggered to retrieve data from neighboring nodes for reasoning and completion. The processed data is input into the trained semantic constraint prediction network, which outputs the water level forecast value for future time. It supports hourly rolling updates to meet real-time early warning needs.

[0013] In some embodiments, the semantic constraint prediction network employs an early stopping mechanism during training to monitor changes in validation set loss and prevent overfitting.

[0014] In some embodiments, the method is applicable to flash flood warning scenarios in small watersheds, supporting the maintenance of physical consistency and robustness of forecasts under conditions such as extreme weather and data loss.

[0015] Compared with existing technologies, this invention provides a real-time hydrological forecasting method for physically constrained watersheds based on semantic causal reasoning, which has the following beneficial effects: 1. By introducing a semantic causal reasoning mechanism based on a large language model and knowledge graph, the semantic barriers between multi-source heterogeneous data are effectively overcome. Unlike traditional methods that rely on manual experience for feature selection, this invention utilizes a large language model to automatically parse unstructured data such as meteorological texts and dispatch instructions. Combined with the watershed topological relationships stored in the knowledge graph, it dynamically derives combinations of key disaster-causing factors with strong causal relationships, achieving a precise mapping from the semantic space to the numerical feature space. This mechanism not only significantly improves the utilization rate of multimodal data, enabling previously ignored textual information (such as upstream reservoir dispatch instructions) to effectively participate in the forecasting process, but also simulates the spatial lag in the flood confluence process through knowledge graph-driven spatial attention aggregation, significantly improving forecast accuracy and interpretability. 2. By embedding hydrophysical laws into the neural network, the robustness and generalization ability of the model under extreme conditions are significantly enhanced. Traditional data-driven models are prone to producing prediction results that violate the principle of water balance under conditions of missing data or extreme weather. However, this invention modifies the LSTM unit physically, introduces a rainfall attenuation coefficient determined by soil properties to correct the forgetting gate, and adds a water balance constraint term to the loss function, forcing the model's prediction results to conform to basic hydrophysical laws. Experiments show that when some sensor data is missing, this invention can not only complete the data by retrieving neighboring data through a knowledge graph, but also prevent the prediction results from diverging by relying on the embedded physical conservation laws. It outperforms existing methods in key indicators such as Nash efficiency coefficient and flood peak fitting degree, providing technical support for flash flood early warning in small watersheds with both accuracy and reliability. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the overall system process of the present invention; Figure 2 This is a schematic diagram of the semantic constraint prediction grid of the present invention; Figure 3 This is a schematic diagram comparing different prediction methods of the present invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] In the description of this invention, it should be noted that the terms "upper," "lower," "inner," "outer," "front end," "rear end," "both ends," "one end," and "the other end," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0019] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installed," "equipped with," "connected," etc., should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0020] Please see Figure 1-3 In this implementation plan: a real-time watershed hydrological forecasting method based on semantic causal reasoning and physical constraints includes the following steps: Step S1: Construct a knowledge graph within the watershed; Based on water conservancy text data, a large language model is used to extract hydrological entities and their semantic relationships, and a watershed knowledge graph containing node attributes and topological connections is constructed. Step S2: Multi-source data integration and preprocessing; By accessing multimodal data sources, missing data is filled in and time series are aligned based on the knowledge graph to generate standardized input data; Step S3: Causal reasoning and feature optimization based on a large language model; Construct structured prompt words for water conservancy scenarios, drive a large language model to perform causal reasoning in conjunction with the knowledge graph, dynamically identify key disaster-causing factors under the current forecast target, and generate an input feature index set; Step S4: Construct a semantic constraint prediction network; Design a neural network architecture that integrates graph attention mechanism and physical constraints, including: Knowledge graph-based graph topology input layer; An attention aggregation module based on upstream and downstream relationships and flow path distance; Gated units with embedded hydrophysical laws; A loss function incorporating water balance constraints; Step S5: Model training and real-time rolling forecasts; The semantic constraint prediction network is trained using historical data, and feature completion and dynamic optimization are performed by combining knowledge graphs in real-time data streams to output the water level forecast value for future time.

[0021] Step 1: Construct a knowledge graph within the watershed; This step utilizes natural language processing technology to automatically extract entities, relationships, and attributes from water resources texts, constructing a structured watershed knowledge graph. The specific implementation method is as follows: 1. Entity Definition and Intelligent Extraction: Employing the named entity recognition capabilities of large language models (LLMs, such as the GPT series or domestic open-source models), the system automatically identifies core entities such as hydrological stations, reservoirs, rivers, and rain gauges from documents such as water conservancy census reports, reservoir operation regulations, and historical meteorological texts. For example, the LLM is guided to complete the extraction process by prompting the text "Please extract the names and types of all hydrological stations, reservoirs, and rivers from the following text."

[0022] 2. Relational reasoning: LLM analysis is used to analyze the semantic descriptions between entities and establish topological relationships. Structured prompts are designed, such as "Based on the text description, determine whether hydrological station A is located downstream of reservoir B, or whether river C is a tributary of river D." Through multiple rounds of prompts, relationships such as "upstream-downstream," "tributary-mainstream," and "belong to" are automatically generated to form a directed graph structure.

[0023] 3. Attribute mounting: The static attributes of entities (such as name, latitude and longitude, address, soil type, and reservoir capacity) and dynamic attribute interfaces (such as APIs for acquiring real-time water level, rainfall, and wind speed) are mapped to nodes in the knowledge graph. Dynamic attributes support subsequent real-time data updates.

[0024] The knowledge graph constructed in this step provides a priori knowledge foundation for subsequent spatial modeling and causal reasoning.

[0025] Step 2: Multi-source data integration and preprocessing; This step involves accessing multiple data sources and cleaning, aligning, and completing them to generate standardized time-series data.

[0026] 1. Data Acquisition: It receives real-time data on water level and flow from hydrological stations, rainfall and wind speed from meteorological stations, geographic information data (elevation, land use), and human activity data (reservoir outflow and gate opening instructions). Data sources include automatic monitoring and reporting systems, meteorological forecast numerical products, and text documents issued by dispatching departments.

[0027] 2. Frequency unification and missing information completion: All data are standardized to hourly time steps. For missing data, a knowledge graph is used to retrieve neighboring nodes with the closest spatial location and similar attributes to the missing node, and linear interpolation or reference completion methods based on similar days are used to fill the gaps. For example, if data from an upstream rain gauge station is missing, the knowledge graph can be used to find similar stations downstream or in adjacent watersheds, and their rainfall data can be interpolated using distance weighting.

[0028] 3. Normalization process: To eliminate the influence of different units on neural network training, each variable is mapped to the [0,1] interval using min-max normalization. The normalization formula is: ; in and These are the minimum and maximum values ​​from historical data.

[0029] Step 3: Reasoning and Feature Generation Based on Large Language Models; This step utilizes a large language model combined with a knowledge graph to perform causal reasoning, dynamically selecting the key factors that have the greatest influence on the target forecasting site, and generating an input feature index set.

[0030] 1. Cue word engineering and inference rule construction: Design structured prompts for water conservancy scenarios, injecting the current watershed topology (in the form of triples in a knowledge graph) and the latest weather forecast text into the LLM. For example, a prompt might include: "The following is a knowledge graph description of a watershed: Station A is located 5 km upstream of Station B; Station C is the confluence point of a tributary. Current weather forecast text: 'Heavy rain is expected in the upstream area in the next 3 hours.' Please deduce which stations' rainfall data are most critical to the water level change at Station B, and provide the reasoning." This is achieved by constructing the following reasoning chain rules: Rule 1: If (river, subordinate to, reservoir) and (hydrological station, belonging to, reservoir) → we can deduce (hydrological station, located on, river).

[0031] Rule 2: If (Station A, upstream, Station B) → the rainfall at Station A is the key lag factor for the water level at Station B.

[0032] LLM outputs a list of factors with strong causal relationships based on these rules, such as [rainfall at station A (2-hour lag), rainfall at station C (1-hour lag), and historical water level at station B].

[0033] Feature optimization: Retrieve and output a set of indexes for the optimal input variables from the knowledge graph. Based on this set, the system loads the corresponding numerical sequence xt from the database, including historical data of the target station and rainfall and water level data of key upstream stations confirmed through reasoning.

[0034] Step 4: Construct a semantic constraint prediction network; This step aims to design a semantically constrained prediction network architecture specifically for watershed topology. This model can explicitly utilize the topological relationships of the knowledge graph constructed in step one and the factor importance weights output by the large language model in step three to achieve feature aggregation in the spatial dimension and memory modeling in the temporal dimension.

[0035] 4.1 Construction of the dynamic graph topology input layer: Unlike traditional long short-term memory networks that concatenate all features into a one-dimensional vector, this model preserves the graph structure features of the data.

[0036] 4.1.1 Node Definition: Mapping hydrological stations and rainfall stations within the watershed to nodes in a graph network. .

[0037] 4.1.2 Adjacency Matrix Construction (A): A directed adjacency matrix A is constructed based on the upstream and branch relationships in the knowledge graph. If node j is a direct upstream of node i, then Otherwise, it is 0.

[0038] 4.1.3 Semantic Enhancement Embedding: This transforms the inference results of the large language model for each node (i.e., the discriminative information regarding whether it is a key disaster-causing factor) into... , as a prior knowledge embedding model. 4.2 Introducing the "Knowledge Graph Attention Mechanism" (KG-Attention Mechanism); A spatial attention layer is added before the signal input to the long short-term memory network unit to simulate the spatial weight allocation during the flood confluence process.

[0039] 4.2.1 Calculating the Attention Coefficient: For the target forecasting station i, its current input is not only its own data, but also a weighted aggregation of all upstream associated nodes j. Attention Coefficient The calculation is as follows: ; ; in, The set of upstream neighbor nodes defined in the knowledge graph; The path distance attribute stored in the knowledge graph; This indicates vector concatenation.

[0040] 4.2.2 Spatial Feature Aggregation: Utilizing the calculated... The features of upstream stations (such as rainfall) are weighted and summed to generate a comprehensive input vector that incorporates spatial information. : ; Here The initial weights are determined by the reasoning results of the large language model in step three (i.e., the upstream sites that the large language model considers more critical have higher initial weights), thus realizing the guidance of "knowledge-driven" to "data-driven".

[0041] 4.3 Improved Physically Constrained LSTM Cells The internal structure of standard long short-term memory network units is modified to conform to the physical laws of hydrology.

[0042] 4.3.1 Mass Conservation Forgetting Gate: Traditional Forgetting Gate This model is derived solely from data training. It incorporates a rainfall attenuation coefficient. (Determined by watershed soil type attributes and stored as static attributes in the knowledge graph) Correction of forgetting gates: ; This forces the model to follow the laws of physics during rainless periods. ( Water level, to prevent the model from making predictions that violate common sense physics.

[0043] 4.3.2 State Update Equation: Maintain the standard Long Short-Term Memory (LSTM) network's cell state update logic, but change the input to a graph-attention aggregated input. rather than original .

[0044] 4.4 Physical Constraint Loss Function To further improve generalization ability, physical constraints are introduced during the model training phase. This replaces the simple MSE loss.

[0045] 4.4.1 Physical Constraints ( Define the monotonicity constraint of "water level-rainfall". That is, at each moment, the increment of water level... It should not exceed the product of the total upstream rainfall and the maximum runoff capacity: ; Where C is the comprehensive runoff parameter of the watershed, which includes the combined effects of unit conversion, watershed area, and runoff generation characteristics. This constraint forces the model prediction results to conform to the basic principle of watershed water balance.

[0046] Step 5: Training, evaluating, and real-time rolling forecasting of the semantically constrained prediction network model This step describes how to optimize a semantically constrained prediction network model using historical data, and how to achieve efficient and robust real-time rolling forecasts in practical flood control scenarios. The data flow of the semantically constrained prediction network is as follows: Figure 2 As shown.

[0047] 5.1 Loss Function and Optimization Strategy 5.1.1 Definition of Total Loss Function: A mixed loss function is used, which combines the standard mean squared error (MSE) with the total loss function. The physical constraint loss introduced in step four () This is combined to balance prediction accuracy and physical plausibility.

[0048] ; in, Mean square error; The weighting factors for the physical constraint terms are determined through cross-validation. This is a penalty term for the conservation of mass.

[0049] 5.1.2 Optimizer and Hyperparameters: The Adam optimizer is used for gradient descent, with the initial learning rate set to 0.0001.

[0050] 5.1.3 Training and Validation Strategy: Divide the historical dataset into training set, validation set and test set in chronological order, with a ratio of 70%:15%:15%.

[0051] 5.1.4 Employs an Early Stopping mechanism to monitor the validation set. Loss. Training is stopped when the validation set loss does not decrease for N consecutive epochs (e.g., N=20) to prevent the model from overfitting on the training set. The maximum number of training iterations (Epochs) is set to 500.

[0052] 5.2 Model Performance Evaluation and Validation After the model is trained, it is evaluated on an independent test set, with a focus on the root mean square error (RMSE): an accuracy metric that is sensitive to large errors (peaks).

[0053] 5.3 Real-time rolling forecasts and robustness assurance This step involves deploying the trained model into a real-time forecasting system and utilizing knowledge graphs to ensure the robustness of the forecasts.

[0054] 5.3.1 Real-time data stream: The system collects the latest hydrological and meteorological data in real time at every forecast interval (e.g., every hour).

[0055] 5.3.2 Knowledge-driven feature preprocessing: When data gaps occur in the real-time data stream due to sensor malfunctions, the system immediately triggers a knowledge graph retrieval of neighboring node data for inference and completion. This mechanism improves the model's robustness under extreme weather conditions. The large language model then dynamically verifies the effectiveness of key input factors based on the forecast requirements of the current time period, eliminating irrelevant noise.

[0056] 5.3.3 Rolling Forecast Output: Processed data The data is input into a semantically constrained prediction network model for inference. The model outputs a normalized prediction value for the future time T. Finally, through inverse normalization, the actual water level value is obtained. It achieves real-time rolling release with inference speed at the second level, meeting the requirement of real-time rolling forecast once per hour.

[0057] 5.4 Comparison of Model Prediction Performance We compared the real-time water level forecasting performance of the standard data-driven model (LSTM), the knowledge graph augmentation model (KG-LSTM), and the semantic constraint prediction network proposed in this invention on existing datasets. Experimental results are as follows: Figure 3 The results show that the semantic constraint prediction network of this invention (the green line and the orange dashed line almost overlap) has the curve that best matches the actual water level (the green solid line), demonstrating the highest fit, especially in capturing the trend of flood peaks and troughs.

[0058] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A real-time watershed hydrological forecasting method based on semantic causal reasoning and physical constraints, characterized in that, Includes the following steps: Step S1: Construct a knowledge graph within the watershed Based on water conservancy text data, a large language model is used to extract hydrological entities and their semantic relationships, and a watershed knowledge graph containing node attributes and topological connections is constructed. Step S2: Multi-source data integration and preprocessing By accessing multimodal data sources, missing data is filled in and time series are aligned based on the knowledge graph to generate standardized input data; Step S3: Causal Inference and Feature Optimization Based on Large Language Model Construct structured prompt words for water conservancy scenarios, drive a large language model to perform causal reasoning in conjunction with the knowledge graph, dynamically identify key disaster-causing factors under the current forecast target, and generate an input feature index set; Step S4: Construct a semantic constraint prediction network Design a neural network architecture that integrates graph attention mechanism and physical constraints, including: Knowledge graph-based graph topology input layer; An attention aggregation module based on upstream and downstream relationships and flow path distance; Gated units with embedded hydrophysical laws; A loss function incorporating water balance constraints; Step S5: Model Training and Real-time Rolling Forecasts The semantic constraint prediction network is trained using historical data, and feature completion and dynamic optimization are performed by combining knowledge graphs in real-time data streams to output the water level forecast value for future time.

2. The real-time hydrological forecasting method for physically constrained watersheds based on semantic causal reasoning according to claim 1, characterized in that: The construction of the watershed knowledge graph in step S1 includes: By leveraging the named entity recognition capabilities of large language models, hydrological station, reservoir, and river entities can be automatically extracted from water conservancy documents. The system uses prompts to guide the large language model in establishing "upstream-downstream" and "tributary-mainstream" topological relationships between entities. Static attributes and real-time data interfaces are attached to graph nodes to form a dynamically updatable knowledge graph structure.

3. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The causal reasoning based on the large language model in step S3 includes: Construct water conservancy scene prompts that include watershed topology and meteorological text; Drive the large language model to execute the causal inference chain and determine the causal influence strength of each upstream node on the target station's water level; Output a set of input feature indices with strong causal relationships to guide the construction of subsequent model inputs.

4. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The graph topology input layer in step S4 is constructed as follows: Map each hydrological station within the basin to a graph network node; Construct a directed adjacency matrix based on the "upstream" and "tributary" relationships in the knowledge graph; The causal reasoning results output by the large language model are used as semantic embeddings and injected into the node feature representation.

5. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The calculation method of the attention aggregation module in step S4 is as follows: For the target site, determine its set of upstream neighbor nodes based on the adjacency matrix; By combining features such as flow path distance and historical state, the attention weight of each neighbor node to the input at the current moment is calculated; The features of upstream nodes are weighted and aggregated using attention weights to generate an input vector that incorporates spatial topological information.

6. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The gating unit with embedded physical laws in step S4 includes: A rainfall attenuation coefficient determined by watershed soil type is introduced to correct the output of the traditional forgetting gate; The model is forced to follow the physical decay law during rainless periods to prevent prediction results from violating the principle of water balance.

7. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The loss function introduced in step S4 includes: Data-driven terms: measure the error between predicted and actual values; Physical constraint: Penalizes outputs that violate the monotonicity of the "water level-rainfall" relationship in the prediction results; The two weighted sums are used to form the total loss function for model training.

8. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The real-time rolling forecast in step S5 includes: Real-time access to hydrological and meteorological data streams; When missing data is detected, the knowledge graph is triggered to retrieve data from neighboring nodes for reasoning and completion. The processed data is input into the trained semantic constraint prediction network, which outputs the water level forecast value for future time. It supports hourly rolling updates to meet real-time early warning needs.

9. The real-time hydrological forecasting method for physically constrained watersheds based on semantic causal reasoning according to claim 1, characterized in that: The semantic constraint prediction network employs an early stopping mechanism during training to monitor changes in validation set loss and prevent overfitting.

10. The real-time watershed hydrological forecasting method based on semantic causal reasoning according to claim 1, characterized in that: The proposed method is applicable to flash flood warning scenarios in small watersheds and supports maintaining the physical consistency and robustness of forecasts under conditions such as extreme weather and data gaps.