A highway tunnel traffic event intelligent question and answer system and method
By combining knowledge graphs and large language models, an intelligent question-answering system has solved the problems of unstructured fusion of multi-source data and lack of professional constraints in models in tunnels. It has achieved accurate conversion from natural language to executable emergency response instructions, thereby improving the level of intelligence in tunnel operation and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TECH TRAFFIC ENG GRP CO LTD
- Filing Date
- 2025-12-05
- Publication Date
- 2026-07-24
Smart Images

Figure CN121636540B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of interdisciplinary technology of intelligent transportation systems and artificial intelligence, and particularly relates to an intelligent question-and-answer system and method for traffic incidents in highway tunnels. Background Technology
[0002] As a crucial node in the modern integrated transportation system, highway tunnels are characterized by their strong enclosure, limited space, difficult evacuation, and complex rescue operations. Once an emergency occurs, it can easily trigger secondary disasters, causing significant casualties and economic losses. With the continuous expansion of my country's highway network, my country currently ranks first in the world in both the total number and length of highway tunnels, leading to increasingly severe pressure on tunnel safety operations. Traditional tunnel monitoring and emergency response mainly rely on manual experience and pre-set rule systems, resulting in problems such as delayed response, information silos, and crude decision-making, making it difficult to meet the reliable, timely, and intelligent requirements of modern tunnel operation and maintenance.
[0003] In recent years, with the rapid development of IoT, edge computing, big data, and AI technologies, smart tunnel construction has gradually evolved from "passive response" to "proactive early warning and intelligent decision-making." Various sensing devices (such as high-definition video cameras, millimeter-wave radar, distributed fiber optic temperature measurement systems, multi-parameter gas monitoring stations, and acoustic sensors) are widely deployed within tunnels, enabling real-time collection of multi-dimensional data on traffic flow, environmental parameters, and structural safety. However, while this multi-source data is massive in volume, it lacks effective semantic association and knowledge integration mechanisms, leading to a "rich in data, poor in knowledge" dilemma, making it difficult to directly support accurate event identification and collaborative handling. Against this backdrop, Large Language Models (LLMs), due to their powerful natural language understanding and generation capabilities, are being explored for intelligent question answering and decision support in the transportation field. However, general-purpose large models have revealed significant shortcomings in professional applications: on the one hand, their training data mostly comes from the open internet, lacking in-depth coverage of vertical domain knowledge such as tunnel engineering specifications, equipment interface protocols, and emergency response procedures; on the other hand, the models are prone to generating "illusions" in the absence of factual constraints, that is, generating information that seems reasonable but is inconsistent with reality or even completely wrong, which is unacceptable in tunnel emergency scenarios involving public safety. In addition, the "black box" nature of large models also leads to a lack of interpretability and traceability in their output, making it difficult for operation and maintenance personnel to trust and adopt them.
[0004] To alleviate these problems, the Retrieval-Augmented Generation (RAG) framework has been proposed, which improves the factual accuracy of answers by combining external knowledge base retrieval with language model generation. However, most existing RAG systems use unstructured text (such as PDF documents and web pages) as knowledge sources, and their retrieval accuracy is limited by keyword matching or vector similarity, making it difficult to accurately extract structured operational knowledge such as event triggering conditions and equipment control logic. Furthermore, text knowledge bases are difficult to update, semantically ambiguous, and lack entity relationship representation, failing to support complex reasoning (such as "Which sensor combinations can identify abnormal parking?"). Knowledge graphs (KG), as a structured semantic knowledge representation method, can display concepts and their logical relationships in the modeling domain through "entity-relationship-entity" triples, demonstrating powerful knowledge organization and reasoning capabilities in fields such as medicine, finance, and energy. In the transportation field, although some studies have attempted to construct accident or road network knowledge graphs, few researchers have built dedicated knowledge graphs for the high-risk, highly enclosed scenario of highway tunnels.
[0005] In summary, the existing technologies for responding to highway tunnel incidents have the following problems and shortcomings: (1) Multi-source sensing data and emergency knowledge have not been structurally integrated, making it difficult to support accurate incident judgment; (2) General-purpose large language models are prone to illusion and lack effective constraints on professional facts; (3) Question-answering systems lack interpretability and operability, and cannot generate execution instructions that can be directly used for equipment linkage or personnel dispatch. Therefore, there is an urgent need for a new type of intelligent question-answering system that integrates domain knowledge graphs and retrieval enhancement generation mechanisms, which can understand the intent of natural language queries and generate accurate, reliable, and executable response solutions based on structured knowledge, providing intelligent and practical technical support for tunnel safety operation and maintenance. Summary of the Invention
[0006] To overcome the problems existing in related technologies, this invention discloses an intelligent question-answering system and method for highway tunnel traffic incidents, specifically involving an intelligent question-answering system and method for highway tunnel traffic incidents based on the collaborative driving of knowledge graphs and retrieval-enhanced generation (RAG). It is applicable to structured knowledge services in tunnel operation and maintenance management, emergency response decision-making, and digital twin platforms.
[0007] The technical solution is as follows: A smart question-and-answer method for highway tunnel traffic incidents, comprising the following steps:
[0008] S1 receives natural language queries input by the user;
[0009] S2, using a large language model to perform contextual understanding on the input natural language query, and using prompting engineering to guide the contextual understanding to output a standardized event label from one of five preset event categories;
[0010] S3, based on the standardized event tag, calls the pre-set Cypher template, dynamically fills in the event name, generates a structured query statement, and executes a query on the pre-built tunnel control knowledge graph Neo4j to obtain a structured subgraph containing triggering conditions, affected areas, and responding devices;
[0011] S4. Process the query results and extract key fields including sensor type, threshold, device ID, and control command to construct a structured knowledge dictionary.
[0012] S5: Input the natural language query into the large language model, and guide the large language model to generate a natural language answer through strong constraint prompts;
[0013] S6. If the identification result in step S2 is not one of the five categories of events, then skip steps S3–S5 and directly execute the rejection response.
[0014] Step S2 specifically includes: using a large language model to perform deep semantic parsing and contextual understanding on the input natural language query; mapping the natural language query to one of five predefined tunnel events through a designed structured prompt template; dynamically constructing a decision boundary based on its parameterized knowledge, outputting standardized event labels following the JSON format, and generating a classification confidence score; triggering a rejection mechanism when the confidence score is lower than the threshold or the query exceeds the domain scope; the five defined event categories are: fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion.
[0015] Step S3 specifically includes: retrieving and obtaining a structured event knowledge subgraph based on the identified standardized event tags; calling a pre-set parameterized Cypher query template, filling the template with standardized event names as dynamic parameters, and automatically generating a structured query statement that conforms to the syntax of the Neo4j graph database; the query starts from a specific event node and traverses along a predefined semantic relationship path, including triggering conditions, affected areas, and core relationships of responding devices, thereby retrieving a complete knowledge subgraph related to the event;
[0016] The generated Cypher statement sends a request to the Neo4j database via an HTTP node to execute a query; upon successful query, Neo4j returns a knowledge subgraph organized in JSON format, which contains structured data of triggering conditions, affected areas, and responding device elements.
[0017] In step S3, the pre-constructed tunnel control knowledge graph Neo4j specifically includes:
[0018] The first step is to define four types of core entities at the ontology layer. These four types of core entities include data acquisition devices, sensed data, diagnostic events, and control devices.
[0019] The second step is to construct a multidimensional semantic relationship network;
[0020] The third step is to assign a globally unique identifier to each entity and establish an interface mapping with the physical system. The perceived data is injected into the knowledge graph in real time via MQTT or HTTP protocol. By parsing the response strategy generated by the knowledge graph, key elements such as device identifiers, action types and control parameters are extracted and converted into standard instruction formats that conform to the device communication protocol, thus realizing a closed loop of semantic reasoning and physical action.
[0021] The fourth step involves using a multi-source heterogeneous data fusion determination mechanism to determine the triggering conditions.
[0022] The second step, constructing a multidimensional semantic relationship network, includes:
[0023] Step 1: Spatial topology relationship. Based on the geographic information system standard, this step extends the system by establishing a mapping between equipment deployment coordinates and tunnel stationing system. Following spatial positioning principles, it clearly defines the monitoring coverage relationship between equipment and lanes, the structural connectivity relationship between cross passages and main tunnels, and the responsibility scope relationship between sensors and monitoring sections, forming a standardized spatial reference system.
[0024] Step 2: Logical Relationships. A rule base is built based on historical handling cases and expert experience. When multi-source sensing data meets a specific threshold combination, the corresponding event node is automatically triggered. Through semantic matching of the contingency plan knowledge base, the event node is associated with the preset handling strategy. Finally, the strategy is transformed into specific equipment instructions through the equipment control interface.
[0025] Step 3, temporal relationships: By defining temporal rule templates and establishing an event state machine model, the dependencies and state transition conditions of each node on the time axis are described, enabling dynamic deduction and prediction of event evolution.
[0026] The fourth step involves using a multi-source heterogeneous data fusion determination mechanism to determine the triggering conditions, including:
[0027] A multi-source heterogeneous data fusion judgment mechanism based on weighted confidence is adopted. By establishing a multi-dimensional data association matrix, spatiotemporal alignment and confidence assessment are performed on data from different sensing devices. Specifically, the following are weighted values: the fiber optic temperature measurement system detects a temperature rise rate ≥3℃ / min, with a weight of 0.7; the multi-parameter gas station detects a CO concentration >100ppm and VOCs >200ppb, with a weight of 0.7; the thermal imaging system identifies a high-temperature area >150℃ showing a diffusion trend, with a weight of 0.1. When the weighted combination meets the preset logic, the fire event node is activated and associated with the corresponding response device.
[0028] Step S4 specifically includes: First, parsing the JSON-formatted HTTP response to extract key fields such as sensor type, judgment threshold, device ID, control instructions, and affected area; then, constructing a structured knowledge dictionary containing three core fields: triggering conditions, affected area, and responding device. The triggering conditions explicitly record the data source, numerical threshold, and judgment weight; the affected area includes the area identifier and spatial location description; and the responding device encapsulates the device identifier, control parameters, and response delay time. The entire process incorporates data verification and anomaly handling mechanisms to ensure the construction of a complete knowledge context even when some data is missing.
[0029] In step S4, key fields are extracted, and the structured knowledge dictionary is further constructed including:
[0030] Deploy the Dify open-source intelligent agent orchestration platform and use a six-node workflow to achieve end-to-end processing;
[0031] The user inputs node 1, which receives the original query;
[0032] LLM category node 2, outputs event tags in JSON format;
[0033] Code parsing node 3 securely extracts the event string;
[0034] HTTP query node 4 sends a POST request to the Neo4j REST API, with the body containing parameterized Cypher statements;
[0035] Knowledge parsing node 5 extracts rows data from the HTTP response and constructs a dictionary containing fields of trigger_data, affected_zone, and response_devices;
[0036] LLM generates node 6, which combines the original query with structured knowledge to generate the final answer;
[0037] Data is passed between nodes through variables, forming a deterministic mapping function.
[0038] Step S5 specifically includes: employing a constraint decoding mechanism based on retrieval knowledge to restrict the large language model to only using entities, attributes, and relationships explicitly contained in the knowledge dictionary for content organization; the large language model first parses the trigger condition field in the knowledge dictionary, extracting the trigger conditions and their thresholds; then integrates the spatial location information in the influence region field; finally, it converts the device control parameters in the response device field into specific operation instructions; during the generation process, when the large language model is detected attempting to generate content outside the knowledge scope, the output is automatically suppressed, ensuring that every factual element of the final answer originates from the knowledge graph;
[0039] Step S6 includes: in the event intent identification stage, the domain boundary of the query semantics is determined. First, the semantic boundaries of five types of events and related terms are established. A domain classifier is used to calculate the semantic relevance between the query statement and each event category. When the highest relevance is lower than a set threshold, it is determined to be an out-of-domain query. At the same time, a query intent analysis module is introduced to identify the actions and objects in the query through syntactic analysis and semantic role labeling. The actions are matched with the preset categories of diagnosis, treatment, and impact actions. Queries that are outside the categories are filtered. For questions that deviate from the five types of events, they are not entered into the knowledge retrieval process and are directly returned as rejected.
[0040] In step S5, a constraint decoding mechanism based on retrieval knowledge is adopted to restrict the large language model to only using entities, attributes, and relationships explicitly contained in the knowledge dictionary for content organization, including:
[0041] S501, Knowledge Retrieval and Injection;
[0042] Retrieval Phase: Based on user input or generated task requirements, retrieve relevant entities, attributes, and relation triples from the knowledge graph (KG) and external knowledge sources such as the database;
[0043] Knowledge representation: Converting retrieval results into a structured format that large language models can understand, serving as contextual input to LLMs;
[0044] S502, Decoding Constraint Design;
[0045] Dynamic mask generation: Based on the retrieved knowledge, the logits mask of the token is dynamically constructed at each step of decoding, and only entities or relations that conform to the knowledge constraints are allowed to be generated;
[0046] Algorithm optimization: The Earley algorithm dynamic pruning strategy ZapFormat is adopted to identify invalid decoding paths in real time;
[0047] Multi-modal fusion: Combining a copying mechanism, a retrieval mechanism that extracts relationships from knowledge sources, and a prediction mechanism that generates connecting words, the source of output vocabulary is made controllable;
[0048] S503, Compliance Verification and Remediation;
[0049] Real-time verification: During the decoding process, the generated content is checked word by word to see if it conforms to the entity boundaries, attribute types and relational logic of the retrieved knowledge;
[0050] Error rollback: If invalid output is detected, a rollback and resampling are triggered;
[0051] S504, optimization strategy;
[0052] State caching: Caching the knowledge constraint states that are frequently queried accelerates the structured generation of similar tasks;
[0053] Hybrid decoding engine: It adopts an integrated dynamic pruning ZapFormat and Formatron engine to improve inference speed while ensuring compliance;
[0054] Dynamic trimming of ZapFormat includes:
[0055] (1) Invalid state elimination rules;
[0056] Rule 1: Remove states that exceed the knowledge fragment length threshold, such as automatically pruning when the generated sequence length exceeds twice the length of the knowledge fragment;
[0057] Rule 2: Delete states that conflict with entities / relationships in the retrieved knowledge;
[0058] Rule 3: Merge duplicate states, and retain the state with the highest probability for states with the same prediction prefix;
[0059] (2) Calculation of state transition probability;
[0060] The probability of generating a token is dynamically adjusted based on retrieval knowledge constraints, using the following formula:
[0061] ;
[0062] In the formula, Validity of knowledge retrieval The set, including specific entity names and relationship types, is amplified by this formula to meet the constraints. probability; For the mask, For dynamically adjusted masks, For marking, Tagging for dynamically adjusted retrieval knowledge;
[0063] (3) Retrieve knowledge-driven dynamic masks; generate real-time masks based on retrieved knowledge fragments to prevent large language models from generating conflicting content.
[0064] Another objective of this invention is to provide an intelligent question-and-answer system for highway tunnel traffic incidents, which implements the intelligent question-and-answer method for highway tunnel traffic incidents. The system includes:
[0065] The user input module is used to receive query requests from users in natural language regarding traffic incidents in highway tunnels. The query requests include the triggering conditions, scope of impact, response equipment, control strategies, and handling procedures of the incident.
[0066] The event intent recognition module, integrated into the large language model, is used to perform semantic parsing on the query request and classify it into one of the five predefined typical tunnel traffic events;
[0067] The knowledge graph query module is used to dynamically generate structured query statements that conform to Cypher syntax based on the identified event categories and the ontology structure of the pre-built tunnel control knowledge graph. The query is then submitted to the Neo4j graph database via an HTTP interface to retrieve the complete knowledge subgraph related to the event.
[0068] The fact constraint generation module, integrated into the large language model, transforms the structured triple information in the knowledge subgraph into natural language answers through constraint prompts.
[0069] The rejection judgment module is used to determine whether the user's query falls within the five preset event categories mentioned above during the event intent recognition stage. If it does not, a standardized rejection statement is returned directly.
[0070] Combining all the above technical solutions, the beneficial effects of this invention are as follows: This invention effectively constrains the large language model generation process through knowledge graphs, which not only solves the problem of model illusion in professional fields, but also realizes the accurate conversion from fuzzy natural language to quantitative and executable emergency commands, providing an interpretable, verifiable and implementable technical path for intelligent operation and maintenance of highway tunnels, and has important engineering application value and promotion prospects. Attached Figure Description
[0071] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure;
[0072] Figure 1 This is a flowchart of the intelligent question-and-answer method for highway tunnel traffic incidents provided in an embodiment of the present invention;
[0073] Figure 2 This is a hierarchical architecture diagram of the tunnel control knowledge graph technology system in this invention;
[0074] Figure 3 This is a schematic diagram of the entity classification system of the tunnel knowledge graph in this invention;
[0075] Figure 4 This is a flowchart illustrating the operation of the intelligent agent based on the Dify platform in this invention.
[0076] Figure 5 This is a screenshot of the interface comparing the answer results in this invention. Detailed Implementation
[0077] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0078] Example 1, as Figure 1 As shown, an intelligent question-answering method for highway tunnel traffic incidents includes:
[0079] S1 receives natural language queries input by the user;
[0080] For example, "What are the core data that trigger 'fire' diagnosis? What are their respective thresholds?"
[0081] S2, using a large language model to perform contextual understanding on the input natural language query, and using prompting engineering to guide the contextual understanding to output a standardized event label from one of five preset event categories;
[0082] For example, specifically including:
[0083] The system leverages a large language model to perform deep semantic parsing and contextual understanding of input natural language queries. Through a designed structured prompt template, the large language model accurately maps natural language queries to one of five predefined tunnel event categories. For example, it identifies "a car is parked in a tunnel" as an "abnormal parking" event. The large language model dynamically constructs decision boundaries based on its parameterized knowledge, outputting standardized event labels that strictly adhere to JSON format, while also generating classification confidence scores. When the confidence score falls below a threshold or the query exceeds the domain scope, the system triggers a rejection mechanism to ensure that subsequent processes only handle valid event queries.
[0084] S3, based on the standardized event tag, calls the pre-set Cypher template, dynamically fills in the event name, generates a structured query statement, and executes a query on the pre-built tunnel control knowledge graph Neo4j to obtain a structured subgraph containing triggering conditions, affected areas, and responding devices;
[0085] For example, this specifically includes: retrieving and obtaining a structured event knowledge subgraph based on identified standardized event tags. The system calls a pre-defined parameterized Cypher query template, dynamically populating the template with standardized event names as parameters, and automatically generating a structured query statement conforming to the Neo4j graph database syntax. This query starts with a specific event node and traverses along a predefined semantic relationship path, including core relationships such as triggering conditions, affected areas, and responding devices, thereby retrieving a complete knowledge subgraph related to the event.
[0086] For example, a query for a "fire" event will specifically match nodes labeled "Fire," retrieving trigger data and thresholds connected by triggering conditions, spatial location information connected by affected area relationships, and control equipment and its specific control parameters connected by responding equipment relationships. The generated Cypher statement sends a request to the Neo4j database via an HTTP node to execute the query. Upon successful query execution, Neo4j returns a knowledge subgraph organized in JSON format, containing structured data that precisely includes key elements such as triggering conditions, affected areas, and responding equipment, providing a unique and reliable knowledge basis for subsequent fact generation.
[0087] S4. Process the query results and extract key fields including sensor type, threshold, device ID, and control command to construct a structured knowledge dictionary.
[0088] For example, specifically including:
[0089] The query results returned by the Neo4j knowledge graph are structured and knowledge extracted through code nodes. This includes: first, parsing the JSON-formatted HTTP response to accurately extract key fields such as sensor type, judgment threshold, device ID, control commands, and affected area; then, constructing a structured knowledge dictionary containing three core fields: triggering conditions, affected area, and responding device. The triggering conditions explicitly record the data source, numerical threshold, and judgment weight; the affected area includes the region identifier and spatial location description; and the responding device encapsulates the device identifier, control parameters, and response latency. The entire process incorporates data verification and anomaly handling mechanisms to ensure that a complete and reliable knowledge context can still be stably constructed even when some data is missing, providing machine-readable and accurate factual evidence for subsequent generation stages.
[0090] S5: Input the natural language query into the large language model, and guide the large language model to generate a natural language answer through strong constraint prompts;
[0091] For example, “Fire diagnosis is triggered by the following core data: 1) Fiber optic thermography shows a temperature rise rate ≥3℃ / min; 2) CO concentration >100ppm and VOCs >200ppb; 3) Thermal imaging shows that the area with temperature >150℃ continues to spread”;
[0092] For example, specifically including:
[0093] The natural language query input by the original user in step S1 and the structured knowledge dictionary constructed in step S4 are jointly input into the large language model. Strongly constrained prompts guide the model to generate concise, accurate, and executable natural language answers. This process employs a constraint decoding mechanism based on retrieved knowledge, strictly limiting the model to using only entities, attributes, and relationships explicitly included in the knowledge dictionary for content organization. The model first parses the trigger condition field in the knowledge dictionary, extracting the trigger conditions and their thresholds; then it integrates the spatial location information in the influence area field; finally, it converts the equipment control parameters in the response device field into specific operation instructions. During the generation process, when the model is detected attempting to generate content outside its knowledge scope, the output is automatically suppressed, ensuring that every factual element of the final answer originates from the knowledge graph. For example, fire diagnosis is triggered by the following core data: 1) Fiber optic thermography shows a temperature rise rate ≥3℃ / min; 2) CO concentration >100ppm and VOCs >200ppb; 3) Thermal imaging shows continuous diffusion in areas with temperatures >150℃.
[0094] For example, in step S5, a constraint decoding mechanism based on retrieval knowledge is used to restrict the large language model to only using entities, attributes, and relationships explicitly included in the knowledge dictionary for content organization, including:
[0095] S501, Knowledge Retrieval and Injection;
[0096] Retrieval Phase: Based on user input or generated task requirements, retrieve relevant entities, attributes, and relation triples from the knowledge graph (KG) and external knowledge sources such as the database;
[0097] Knowledge representation: Converting retrieval results into a structured format that large language models can understand (such as text prompt templates, graph structure serialization) as contextual input to LLMs;
[0098] S502, Decoding Constraint Design;
[0099] Dynamic mask generation: Based on the retrieved knowledge, the logits mask of the token is dynamically constructed at each step of decoding, and only entities or relations that conform to the knowledge constraints are allowed to be generated;
[0100] Algorithm optimization: Employ dynamic pruning strategies (such as ZapFormat) such as the Earley algorithm to identify invalid decoding paths in real time, reducing computational overhead and accelerating structure generation;
[0101] Multi-modal fusion: Combining a copying mechanism (copying entities from the input), a retrieval mechanism (extracting relationships from knowledge sources), and a prediction mechanism (generating conjunctions) ensures that the source of the output vocabulary is controllable;
[0102] S503, Compliance Verification and Remediation;
[0103] Real-time verification: During the decoding process, the generated content is checked word by word to see if it conforms to the entity boundaries, attribute types and relational logic of the retrieved knowledge;
[0104] Error rollback: If invalid output is detected (such as an unregistered entity), a rollback and resampling are triggered;
[0105] S504, optimization strategy;
[0106] State caching: Caching the knowledge constraint states that are frequently queried accelerates the structured generation of similar tasks;
[0107] Hybrid decoding engine: Integrates dynamic pruning ZapFormat with the existing optimization technology Formatron engine to improve inference speed while ensuring compliance.
[0108] The dynamic pruning ZapFormat optimizes the state management of the Earley algorithm to reduce unnecessary calculations during decoding, and consists of three parts:
[0109] (1) Invalid state elimination rules;
[0110] Rule 1: Remove states that exceed the knowledge fragment length threshold, such as automatically pruning when the generated sequence length exceeds twice the length of the knowledge fragment;
[0111] Rule 2: Delete states that conflict with entities / relationships in the retrieved knowledge, such as entity type mismatch (e.g., predicting "location" as "person").
[0112] Rule 3: Merge duplicate states, and retain the state with the highest probability for states with the same prediction prefix to reduce redundant calculations;
[0113] (2) Calculation of state transition probability;
[0114] The probability of generating a token is dynamically adjusted based on retrieval knowledge constraints, using the following formula:
[0115] ;
[0116] In the formula, Validity of knowledge retrieval The set, including specific entity names and relationship types, is amplified by this formula to meet the constraints. probability; For the mask, For dynamically adjusted masks, For marking, Tagging for dynamically adjusted retrieval knowledge;
[0117] (3) Retrieve knowledge-driven dynamic masks;
[0118] A real-time mask is generated based on retrieved knowledge fragments (such as documents and triples) to prevent the model from generating conflicting content. The mask is implemented using a binary matrix, where 1 indicates that generation is allowed and 0 indicates that generation is prohibited.
[0119] S6. If the identification result in step S2 is not one of the five categories of events, then skip steps S3–S5 and directly execute the rejection response.
[0120] For example, in step S3, the pre-built tunnel control knowledge graph Neo4j specifically includes:
[0121] The first step is to define four types of core entities and their attributes at the ontology layer, based on industry standards (such as the "Design Code for Highway Tunnels" and the "Design Rules for Traffic Engineering and Ancillary Facilities of Highway Tunnels") and actual tunnel operation and maintenance experience;
[0122] like Figure 2 This is a layered architecture diagram of the tunnel control knowledge graph technology system (the ontology structure of the tunnel control knowledge graph) in this invention. It shows a three-layer collaborative structure from the bottom-level data collection to the upper-level intelligent services, including the data layer, ontology layer and service layer, reflecting the complete technical chain of multi-source heterogeneous data fusion, semantic standardization modeling and intelligent decision reasoning.
[0123] like Figure 3 This is a schematic diagram of the entity classification system of the tunnel knowledge graph in this invention. It specifically shows the four major categories of core entities covered by the knowledge graph: data acquisition equipment, sensing data, diagnostic events, and control equipment. Typical examples of each type of entity are listed, such as fiber optic temperature measurement system, CO concentration, fire event, and longitudinal ventilation fan.
[0124] The second step is to construct a multidimensional semantic relationship network: (1) Spatial topological relationship, based on the extension of geographic information standards, describes the adjacency, inclusion or connectivity relationship between equipment and lanes, cross passages and main tunnels, and sensors and sections; (2) Logical relationship, establishes the causal or mapping relationship between sensing data and events, events and contingency plans, and contingency plans and equipment, such as "abnormal parking → triggers the information board to display 'vehicle malfunction ahead, please slow down'"; (3) Temporal relationship, depicts the event evolution chain, such as "traffic accident → traffic flow speed decrease → congestion → activation of speed limit signs and broadcast prompts";
[0125] A network of knowledge structures built between entities through spatial topological relationships, logical connections, and temporal evolutionary relationships, such as the adjacency relationship between cameras and lanes, the causal relationship between abnormal parking events and the content displayed on information boards, and the temporal dependency from traffic accidents to traffic congestion.
[0126] Another example involves constructing a multidimensional semantic relationship network, specifically including: Step 1, spatial topological relationships. Based on Geographic Information System (GIS) standards, this involves extending the network by establishing a precise mapping between equipment deployment coordinates and tunnel stationing systems. Strictly adhering to the spatial positioning principles in the "Highway Tunnel Design Specifications," the system clearly defines the monitoring coverage relationship between equipment and lanes, the structural connectivity between cross passages and the main tunnel, and the responsibility scope relationship between sensors and monitoring sections, forming a standardized spatial reference system. Step 2, logical association relationships. A rule base is constructed based on historical handling cases and expert experience. When multi-source sensing data meets specific threshold combinations, corresponding event nodes are automatically triggered. Then, through semantic matching in the pre-plan knowledge base, event nodes are associated with preset handling strategies. Finally, the strategy is transformed into specific equipment instructions through the equipment control interface, such as "abnormal parking → triggering the information board to display 'Vehicle malfunction ahead, please slow down'". Step 3, temporal relationships. Complex event processing technology is used for characterization. The system defines temporal rule templates and establishes an event state machine model to accurately describe the dependencies and state transition conditions of each node on the time axis, thereby achieving dynamic deduction and prediction of event evolution.
[0127] The third step is to assign a globally unique identifier to each entity (such as device code "CAM-023" or event ID "EV-FIRE-001") and establish an interface mapping with the physical system: the perception data is injected into the graph in real time through the MQTT or HTTP protocol, and the control commands are converted into device executable commands through the API, realizing a closed loop of "semantic reasoning → physical action".
[0128] Specifically, this includes the following: assigning a globally unique identifier to each entity (such as device code "CAM-023" or event ID "EV-FIRE-001") and establishing an interface mapping with the physical system; injecting perception data into the knowledge graph in real time via MQTT or HTTP protocol; extracting key elements such as device identifiers, action types, and control parameters by parsing the response strategy generated by the knowledge graph; converting these elements into a standard instruction format that conforms to the device communication protocol; and realizing a closed loop of "semantic reasoning → physical action".
[0129] The fourth step involves a multi-source heterogeneous data fusion judgment mechanism for triggering conditions. Taking a fire event as an example, the judgment logic is a weighted combination judgment: 1) The fiber optic temperature measurement system detects a temperature rise rate ≥3℃ / min, with a weight of 0.7; 2) The multi-parameter gas station detects a CO concentration >100ppm and VOCs >200ppb, with a weight of 0.7; 3) The thermal imaging system identifies a high-temperature area >150℃ showing a diffusion trend, with a weight of 0.1. Only when the weighted combination meets the preset logic is the "fire" event node activated and associated with the corresponding response equipment.
[0130] For example, the multi-dimensional data judgment logic for fire events in this invention specifically illustrates that fire diagnosis is triggered by three types of core sensing data: fiber optic temperature measurement showing a temperature rise rate ≥3℃ / min (weight 0.7), CO concentration >100ppm and VOCs >200ppb (weight 0.7), and thermal imaging showing diffusion in areas >150℃ (weight 0.1), reflecting an event adjudication mechanism based on the fusion of multi-source heterogeneous data.
[0131] The fire incident handling scheme based on knowledge graph in this invention demonstrates that starting from the fire incident node, it is linked to specific tunnel sections (such as the K12+350 main tunnel) and control equipment to be activated (such as fans, information boards, and fireproof rolling doors) through the relationship chain of "affected area" and "response equipment", and the corresponding control parameters are marked, reflecting the direct support capability of knowledge graph for emergency operation.
[0132] Another example is that the fourth step specifically includes: adopting a multi-source heterogeneous data fusion judgment mechanism based on weighted confidence, establishing a multi-dimensional data association matrix, and performing spatiotemporal alignment and confidence assessment on data from different sensing devices. Taking a fire event as an example, its judgment logic is a weighted combination judgment: (1) the fiber optic temperature measurement system detects a temperature rise rate ≥3℃ / min, with a weight of 0.7; (2) the multi-parameter gas station detects a CO concentration >100ppm and VOCs >200ppb, with a weight of 0.7; (3) the thermal imaging system identifies a high-temperature area >150℃ with a diffusion trend, with a weight of 0.1; when the weighted combination meets the preset logic, the "fire" event node is activated and associated with the corresponding response device.
[0133] For example, step S4 extracts key fields to construct a structured knowledge dictionary, including:
[0134] The system deploys the Dify open-source intelligent agent orchestration platform, employing a six-node workflow to achieve end-to-end processing. The specific functions of each node are as follows:
[0135] Node 1 (User Input): Receives the original query;
[0136] Node 2 (LLM category): Outputs event labels in JSON format;
[0137] Node 3 (Code Analysis): Safely extract event strings and standardize them to "fire", "abnormal parking", etc.;
[0138] Node 4 (HTTP Query): Sends a POST request to the Neo4j REST API, with the body containing parameterized Cypher statements;
[0139] Node 5 (Knowledge Analysis): Extract rows data from the HTTP response and construct a dictionary containing fields of trigger_data, affected_zone, and response_devices;
[0140] Node 6 (LLM Generation): Combines the original query with structured knowledge to generate the final answer; data is passed between nodes through variables (such as {{detected_event}}, {{final_knowledge}}) to form a deterministic mapping function, ensuring that the process is reproducible and the results are auditable.
[0141] For example, such as Figure 4 This is a flowchart of the intelligent agent operation based on the Dify platform in this invention. It shows the six-node workflow of the system, starting from receiving the user's natural language query, through event intent recognition, Cypher query generation, knowledge graph retrieval and fact constraint generation, clearly presenting the collaborative interaction mechanism between the large language model and the knowledge graph.
[0142] For example, in step S6, the system has a highly robust ability to filter irrelevant questions: the system performs domain boundary judgment on the query semantics during the event intent recognition stage. For questions that clearly deviate from the five types of events (such as "tunnel toll standards" or "how to get a driver's license"), the system does not enter the knowledge retrieval process and directly returns a rejection answer. After verification on a test set containing 30 irrelevant questions, the rejection answer accuracy rate reached 96.00%, effectively preventing the model from outputting misleading information in critical infrastructure scenarios.
[0143] Another example is that step S6 specifically includes: the system possesses a highly robust ability to filter irrelevant questions: during the event intent recognition stage, the system performs domain boundary judgment on the query semantics, first establishing the semantic boundaries of five types of events and related terms; it uses a domain classifier to calculate the semantic relevance between the query statement and each event category, and when the highest relevance is lower than a set threshold, it is determined to be an out-of-domain query; at the same time, a query intent analysis module is introduced, which identifies the core actions and objects in the query through syntactic analysis and semantic role labeling, and matches them with the preset core action categories in the fields of "diagnosis," "treatment," and "impact," filtering out queries that exceed the categories. For questions that clearly deviate from the five types of events (such as "tunnel toll standards" or "how to get a driver's license"), they do not enter the knowledge retrieval process and directly return a rejection; after verification on a test set containing 30 irrelevant questions, the rejection accuracy rate reached 96.00%, effectively preventing the model from outputting misleading information in critical infrastructure scenarios.
[0144] As can be seen from the above embodiments, the system can serve as an intelligent operation and maintenance knowledge hub, providing real-time, accurate, and interpretable event response decision support for monitoring personnel, inspection robots, or upper-level management and control platforms, significantly improving the efficiency and safety of handling tunnel emergencies.
[0145] To address the technical challenges in existing highway tunnel traffic incident response systems, such as the susceptibility of large language models to illusions, lack of interpretability, and difficulty in structurally integrating multi-source sensory data with emergency knowledge, this invention proposes an intelligent question-answering system and method for highway tunnel traffic incidents based on the collaborative drive of knowledge graphs and retrieval-enhanced generation (RAG). This system deeply integrates domain ontology modeling, graph database retrieval, and the semantic understanding capabilities of large language models, constructing a three-stage closed-loop reasoning framework of "intent recognition—knowledge retrieval—fact generation," achieving end-to-end mapping from user natural language queries to executable emergency response instructions.
[0146] The core of this invention lies in constructing a dedicated domain knowledge graph for tunnel operation and maintenance scenarios, and using it as the source of factual constraints for the generation process of large language models. The knowledge graph is constructed based on ontology methodology and defines four categories of core entities: (1) Data acquisition equipment, including intelligent multispectral cameras, millimeter-wave radar systems, distributed fiber optic temperature measurement devices, acoustic sensor arrays, laser scanners (LiDAR), multi-parameter gas monitoring stations, and vibration monitoring systems; (2) Perception data, covering thermal imaging temperature matrix, CO concentration, total VOCs concentration, temperature rise rate, vehicle spacing matrix, abnormal acoustic signature features, three-dimensional point cloud data, and structural displacement; (3) Diagnostic events, limited to five types of typical tunnel traffic events: fire, abnormal parking, traffic congestion, spilled materials, and pedestrian intrusion; (4) Control equipment, including longitudinal ventilation fans, variable message signs, fireproof roller shutters, variable speed limit signs, lane indicator lights, inspection robots, broadcasting systems, emergency lighting systems, and directional sound wave devices. Entities are linked through multidimensional semantic relationships: in the spatial dimension, the topology of equipment deployment, the connectivity of structures and the distribution of environmental elements are extended based on the ISO 19107 standard; in the logical dimension, causal or mapping chains are established between perceived data and events, events and contingency plans, and contingency plans and equipment; in the temporal dimension, the dynamic dependency relationship between event evolution and equipment state changes is depicted.
[0147] Based on this knowledge graph, this invention designs a two-stage collaborative workflow for a large language model. First, the natural language query input by the user (such as "What is the threshold for the rate of temperature rise in a fire?") is fed into the first round of the large language model for reasoning. Through prompting engineering, it is guided to identify intent only from five preset event categories and forces the output of standardized JSON format tags (such as {"event":"fire"}) to ensure that the classification results are structured and unambiguous. Subsequently, the system dynamically generates Cypher query statements that conform to the syntax of Neo4j graph database based on the identified event type, and automatically retrieves the complete knowledge subgraph related to the event. The subgraph precisely contains three key elements: (1) Triggering conditions, namely the combination of multi-source sensing data and its threshold required to determine the establishment of the event (for example, a fire event must simultaneously meet the core conditions such as "temperature rise rate ≥ 3℃ / min" and "CO concentration > 100ppm and VOCs > 200ppb"); (2) Affected area, namely the tunnel section or structural unit affected after the event occurs (such as "K12+350 main tunnel eastbound lane"); (3) Response equipment, namely the control equipment that should be activated and its specific control parameters (such as "start 2#~5# longitudinal fans, speed 1800rpm" and "information board displays 'fire ahead, do not approach'").
[0148] Finally, the retrieved structured knowledge subgraph serves as a strongly constrained context, inputting into the second-round large language model for natural language generation. This stage explicitly limits responses to "answers based solely on retrieved knowledge, and the creation of unmentioned content is prohibited," thus achieving generation under factual constraints. If no corresponding information is found in the knowledge graph, or if the user's question does not fall under one of the five preset event categories (such as asking "how to apply for ETC"), the system will automatically return a standardized rejection statement, effectively suppressing illusions and improving security.
[0149] This invention is implemented on the Dify intelligent agent orchestration platform, employing a six-node workflow: user input → LLM event classification → JSON parsing → HTTP graph query → knowledge structure parsing → LLM fact generation. Deterministic mapping is achieved between nodes through variable passing. Validated on a self-built tunnel event question-answering dataset (PTE-QA), the system achieves a precise matching accuracy of 90.53% across five event categories, a key information recall rate of 90.13%, and an illusion rate below 2.93%. It also achieves a 96.00% rejection rate for irrelevant questions, significantly outperforming traditional rule-based systems.
[0150] Example 2: An intelligent question-and-answer system for traffic incidents in highway tunnels, comprising the following modules working collaboratively:
[0151] The user input module is used to receive query requests from users in natural language regarding traffic incidents in highway tunnels. The query requests may involve the triggering conditions, scope of impact, response equipment, control strategies, and handling procedures of the incident.
[0152] The event intent recognition module, integrated into the large language model, is used to perform semantic parsing on the query request and accurately classify it into one of the five predefined typical tunnel traffic events. The five defined events are: fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion. The classification result provides support for subsequent knowledge retrieval.
[0153] The knowledge graph query module is used to dynamically generate a structured query statement that conforms to Cypher syntax by a large language model based on the identified event category and the ontology structure of the pre-built tunnel control knowledge graph. The query is submitted to the Neo4j graph database through the HTTP interface to retrieve the complete knowledge subgraph related to the event. The knowledge subgraph contains at least the following three types of key information: (1) the multi-source sensing data and its threshold conditions required to trigger the event, (2) the tunnel area or structural unit affected after the event occurs, and (3) the activated control equipment and its control parameters.
[0154] The fact constraint generation module, also integrated into the large language model, has constraint prompts (such as "answer only based on retrieved knowledge, do not fabricate unmentioned content"), which is used to convert the structured triple information in the knowledge subgraph into natural language answers, ensuring that the output content is strictly consistent with the knowledge graph at the fact level, and has operability and interpretability.
[0155] The rejection judgment module is used to determine whether the user query falls into the above five preset event categories during the event intent recognition stage. If it does not, a standardized rejection statement is returned directly to avoid the model from generating irrelevant questions arbitrarily.
[0156] For example, in the knowledge graph query module, the tunnel management knowledge graph is constructed based on ontology modeling, and its core entities are divided into four categories: 1) Data acquisition equipment, including intelligent multispectral cameras, millimeter-wave radar, distributed fiber optic temperature measurement systems, multi-parameter gas monitoring stations, acoustic sensor arrays, and laser scanners; 2) Sensing data, including thermal imaging temperature matrix, CO concentration, total VOCs concentration, temperature rise rate, vehicle spacing matrix, and abnormal voiceprint features; 3) Diagnostic events: fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion; 4) Control equipment, including longitudinal ventilation fans, variable message signs, fireproof roller shutters, lane indicator lights, broadcasting systems, emergency lighting systems, and intelligent traffic cone robots.
[0157] For example, the Cypher statement generated by the knowledge graph query module is a parameterized dynamic statement whose structure automatically adapts to the event type. For instance, when the event is "fire", the query statement includes a joint match of the relations TRIGGERED_BY (triggered by ...), AFFECTS (affected area), and RESPONDS_TO (responded by ... equipment), and limits the node label to Fire. The subgraph returned by the query results includes specific numerical thresholds (such as "temperature rise rate ≥ 3℃ / min"), spatial locations (such as "K12+350 main tunnel eastbound lane"), and equipment instructions (such as "start longitudinal fans 2#~5#, set the speed to 1800rpm").
[0158] For example, the event labels output by the event intent recognition module are presented in a strict JSON format, such as {"event":"fire"}, and are securely parsed through subsequent code nodes: This code node uses Python's json.loads() function to perform structured parsing of the output of the large language model, and has a built-in exception handling mechanism. If the output format does not meet expectations (such as containing redundant fields, non-standard event names, or syntax errors), it is automatically classified as an "unknown event" and a rejection process is triggered, thereby ensuring the robustness of the system operation.
[0159] For example, when generating natural language answers, the fact constraint generation module strictly follows the constraint decoding mechanism of "Retrieval Enhanced Generation (RAG)": output is only allowed if the probability distribution of the generated words supports entities, attributes, or relations from the retrieval knowledge subgraph; if the user's question involves content not modeled in the knowledge graph (such as "how to repair a wind turbine" or "ETC application process"), the system automatically returns standardized rejection statements such as "this question does not fall under the scope of tunnel traffic incident response and cannot provide a valid answer"; experimental verification shows that this mechanism can control the illusion rate to below 3% and achieve an exact matching accuracy of 90.53%.
[0160] To further illustrate the effects of the embodiments of the present invention, the following experiments were conducted. The present invention proposes an intelligent question-answering system for responding to emergencies in highway tunnels. Through a combination of Large Language Model (LLM), Retrieval Enhanced Generation (RAG) framework, and knowledge graph, it achieves accurate identification and rapid response to five typical events within tunnels—fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion. The specific implementation steps of the system are as follows:
[0161] User Input Node: First, the system receives the user's natural language query through the user input node. This stage does not require specific technology; the focus is on ensuring that the user can easily input their question.
[0162] Intent Recognition: Upon receiving a user's question, the system uses the first LLM node to perform event intent recognition. Through a deep understanding of the contextual semantics, the model can categorize the user's question into one of five predefined typical tunneling events. To improve classification accuracy, cue engineering is used to guide the model to output structured event labels.
[0163] Event Category Determination: Once events are categorized, the system enters the knowledge acquisition phase. During this process, the second LLM node automatically generates a grammatically correct Cypher query based on the identified event type. This step relies on an understanding of the knowledge graph's schema structure to accurately express the structured semantics behind the user's question.
[0164] Knowledge Retrieval: The generated Cypher query is then submitted to the Neo4j graph database for structured search, extracting complete subgraph information related to the event from the knowledge graph. This information includes key elements such as triggering conditions, scope of impact, responding devices, and their control logic.
[0165] Fact Generation: Finally, the system uses the retrieved structured knowledge as contextual input, feeding it into the second LLM node for fine-grained information integration and natural language reconstruction, thereby generating accurate, professional, and actionable answers. To avoid illusions, the generation process is strictly based on factual information within a subset of knowledge.
[0166] Applications of multi-layered reasoning frameworks:
[0167] Intent recognition phase: Predict the tunnel event category corresponding to the user query by maximizing conditional probability.
[0168] Knowledge retrieval phase: Cypher query language is used to extract related entities and relationships from the knowledge graph and construct subgraphs related to events.
[0169] Fact generation stage: Based on the search results, the system only generates answers that are included in the knowledge support set, ensuring the consistency and reliability of the information.
[0170] Workflow Node Configuration: To implement the theoretical framework described above, a six-node workflow was built in the Dify intelligent agent orchestration platform, including a user input node, two LLM nodes, one Python code node, and an HTTP node. Each node is responsible for different functions, such as event category recognition, data parsing, knowledge retrieval, and final answer generation.
[0171] Experimental Verification: To evaluate the system's performance, a private Tunneling Event Question Answering (PTE-QA) dataset was constructed, containing 150 questions covering various types such as threshold queries, impact range queries, and response action queries. Experimental results show that the system's overall fact accuracy reached 90.53%, and the illusion rate was controlled below 3%, demonstrating the effective constraint of the knowledge graph on the generation process. For detailed experimental comparisons, see [link to relevant documentation]. Figure 5 The comparison chart of the response results shows that, for the question "What are the core data that trigger 'fire' diagnosis?", the left side shows the response from a traditional large language model; the right side shows a schematic diagram of the intelligent agent question-answering effect of this invention. The system returned a structured, quantitative, and concise natural language response, verifying the system's ability to transform fuzzy queries into accurate facts. The comparison reveals significant advantages of this invention in terms of factual accuracy and semantic interpretability.
[0172] Demonstration of Results: Through a series of test cases, it is demonstrated how an agent can efficiently and accurately retrieve information from a knowledge graph and transform originally qualitative and vague descriptions into quantitative, accurate, and concise answers, demonstrating the significant improvement of graph retrieval-enhanced generation on the interpretability and reproducibility of LLM answers.
[0173] In summary, this invention provides a complete solution for improving the speed and accuracy of response to emergencies in highway tunnels. By integrating advanced AI technology and domain expertise, it enables effective management of complex traffic problems.
[0174] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention and within the spirit and principles of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A smart question-and-answer method for traffic incidents in highway tunnels, characterized in that, The method includes the following steps: S1 receives natural language queries input by the user; S2, using a large language model to perform contextual understanding on the input natural language query, and using prompting engineering to guide the contextual understanding to output a standardized event label from one of five preset event categories; S3, based on the standardized event tag, calls the pre-built Cypher template, dynamically fills in the event name, generates a structured query statement, and executes the query on the pre-built tunnel control knowledge graph Neo4j to obtain a structured subgraph containing triggering conditions, affected areas, and responding devices; the triggering conditions clearly record the data source, numerical threshold and its judgment weight, the affected area includes the area identifier and spatial location description, and the responding device encapsulates the device identifier, control parameters and response delay time; S4. Process the query results and extract key fields including sensor type, threshold, device ID, and control command to construct a structured knowledge dictionary. S5: Input the natural language query into the large language model, and guide the large language model to generate a natural language answer through strong constraint prompts; S6. If the identification result in step S2 is not one of the five types of events, then skip steps S3–S5 and directly execute the rejection response. The five types of events are defined as: fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion.
2. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 1, characterized in that, Step S2 specifically includes: using a large language model to perform deep semantic parsing and contextual understanding on the input natural language query; mapping the natural language query to one of five predefined tunneling events through a designed structured prompt template; dynamically constructing a decision boundary based on its parameterized knowledge, outputting standardized event labels following the JSON format, and generating a classification confidence score; triggering a rejection mechanism when the confidence score is lower than the threshold or the query exceeds the domain scope.
3. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 1, characterized in that, Step S3 specifically includes: retrieving and obtaining a structured event knowledge subgraph based on the identified standardized event tags; calling a pre-set parameterized Cypher query template, filling the template with standardized event names as dynamic parameters, and automatically generating a structured query statement that conforms to the syntax of the Neo4j graph database; the query starts from a specific event node and traverses along a predefined semantic relationship path, including triggering conditions, affected areas, and core relationships of responding devices, thereby retrieving a complete knowledge subgraph related to the event; The generated Cypher statement sends a request to the Neo4j database via an HTTP node to execute a query; upon successful query, Neo4j returns a knowledge subgraph organized in JSON format, which contains structured data of triggering conditions, affected areas, and responding device elements.
4. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 1, characterized in that, In step S3, the pre-constructed tunnel control knowledge graph Neo4j specifically includes: The first step is to define four types of core entities at the ontology layer. These four types of core entities include data acquisition devices, sensed data, diagnostic events, and control devices. The second step is to construct a multidimensional semantic relationship network; The third step is to assign a globally unique identifier to each entity and establish an interface mapping with the physical system. The perceived data is injected into the knowledge graph in real time via MQTT or HTTP protocol. By parsing the response strategy generated by the knowledge graph, key elements such as device identifiers, action types and control parameters are extracted and converted into standard instruction formats that conform to the device communication protocol, thus realizing a closed loop of semantic reasoning and physical action. The fourth step involves using a multi-source heterogeneous data fusion determination mechanism to determine the triggering conditions.
5. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 4, characterized in that, The second step, constructing a multidimensional semantic relationship network, includes: Step 1: Spatial topology relationship. Based on the geographic information system standard, this step extends the system by establishing a mapping between equipment deployment coordinates and tunnel stationing system. Following spatial positioning principles, it clearly defines the monitoring coverage relationship between equipment and lanes, the structural connectivity relationship between cross passages and main tunnels, and the responsibility scope relationship between sensors and monitoring sections, forming a standardized spatial reference system. Step 2: Logical Relationships. A rule base is built based on historical handling cases and expert experience. When multi-source sensing data meets a specific threshold combination, the corresponding event node is automatically triggered. Through semantic matching of the contingency plan knowledge base, the event node is associated with the preset handling strategy. Finally, the strategy is transformed into specific equipment instructions through the equipment control interface. Step 3, temporal relationships: By defining temporal rule templates and establishing an event state machine model, the dependencies and state transition conditions of each node on the time axis are described, enabling dynamic deduction and prediction of event evolution.
6. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 4, characterized in that, The fourth step involves using a multi-source heterogeneous data fusion determination mechanism to determine the triggering conditions, including: A multi-source heterogeneous data fusion judgment mechanism based on weighted confidence is adopted. By establishing a multi-dimensional data association matrix, spatiotemporal alignment and confidence assessment are performed on data from different sensing devices. Specifically, the following are weighted values: the fiber optic temperature measurement system detects a temperature rise rate ≥3℃ / min, with a weight of 0.7; the multi-parameter gas station detects a CO concentration >100ppm and VOCs >200ppb, with a weight of 0.7; the thermal imaging system identifies a high-temperature area >150℃ showing a diffusion trend, with a weight of 0.
1. When the weighted combination meets the preset logic, the fire event node is activated and associated with the corresponding response device.
7. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 1, characterized in that, Step S4 specifically includes: first, parsing the HTTP response in JSON format to extract key fields such as sensor type, judgment threshold, device ID, control command, and affected area; then, constructing a structured knowledge dictionary containing three core fields: triggering condition, affected area, and responding device; the entire process incorporates data verification and anomaly handling mechanisms to enable the construction of a complete knowledge context even when some data is missing. In step S4, key fields are extracted, and the structured knowledge dictionary is further constructed including: Deploy the Dify open-source intelligent agent orchestration platform and use a six-node workflow to achieve end-to-end processing; The user inputs node 1, which receives the original query; LLM category node 2, outputs event tags in JSON format; Code parsing node 3 securely extracts the event string; HTTP query node 4 sends a POST request to the Neo4j REST API, with the body containing parameterized Cypher statements; Knowledge parsing node 5 extracts rows data from the HTTP response and constructs a dictionary containing fields of trigger_data, affected_zone, and response_devices; LLM generates node 6, which combines the original query with structured knowledge to generate the final answer; Data is passed between nodes through variables, forming a deterministic mapping function.
8. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 1, characterized in that, Step S5 specifically includes: employing a constraint decoding mechanism based on retrieval knowledge to restrict the large language model to only using entities, attributes, and relationships explicitly contained in the knowledge dictionary for content organization; the large language model first parses the trigger condition field in the knowledge dictionary, extracting the trigger conditions and their thresholds; then integrates the spatial location information in the influence region field; finally, it converts the device control parameters in the response device field into specific operation instructions; during the generation process, when the large language model is detected attempting to generate content outside the knowledge scope, the output is automatically suppressed, ensuring that every factual element of the final answer originates from the knowledge graph; Step S6 includes: in the event intent identification stage, the domain boundary of the query semantics is determined. First, the semantic boundaries of five types of events and related terms are established. A domain classifier is used to calculate the semantic relevance between the query statement and each event category. When the highest relevance is lower than a set threshold, it is determined to be an out-of-domain query. At the same time, a query intent analysis module is introduced to identify the actions and objects in the query through syntactic analysis and semantic role labeling. The actions are matched with the preset categories of diagnosis, treatment, and impact actions. Queries that are outside the categories are filtered. For questions that deviate from the five types of events, they are not entered into the knowledge retrieval process and are directly returned as rejected.
9. The intelligent question-and-answer method for highway tunnel traffic incidents according to claim 8, characterized in that, In step S5, a constraint decoding mechanism based on retrieval knowledge is adopted to restrict the large language model to only using entities, attributes, and relationships explicitly contained in the knowledge dictionary for content organization, including: S501, Knowledge Retrieval and Injection; Retrieval Phase: Based on user input or generated task requirements, retrieve relevant entities, attributes, and relation triples from the knowledge graph (KG) and external knowledge sources such as the database; Knowledge representation: Converting retrieval results into a structured format that large language models can understand, serving as contextual input to LLMs; S502, Decoding Constraint Design; Dynamic mask generation: Based on the retrieved knowledge, the logits mask of the token is dynamically constructed at each step of decoding, and only entities or relations that conform to the knowledge constraints are allowed to be generated; Algorithm optimization: The Earley algorithm dynamic pruning strategy ZapFormat is adopted to identify invalid decoding paths in real time; Multi-modal fusion: Combining a copying mechanism, a retrieval mechanism that extracts relationships from knowledge sources, and a prediction mechanism that generates connecting words, the source of output vocabulary is made controllable; S503, Compliance Verification and Remediation; Real-time verification: During the decoding process, the generated content is checked word by word to see if it conforms to the entity boundaries, attribute types and relational logic of the retrieved knowledge; Error rollback: If invalid output is detected, a rollback and resampling are triggered; S504, optimization strategy; State caching: Caching the knowledge constraint states that are frequently queried accelerates the structured generation of similar tasks; Hybrid decoding engine: It adopts an integrated dynamic pruning ZapFormat and Formatron engine to improve inference speed while ensuring compliance; Dynamic trimming of ZapFormat includes: (1) Invalid state elimination rules; Rule 1: Remove states that exceed the threshold for the length of the retrieved knowledge fragment; Rule 2: Delete states that conflict with entities / relationships in the retrieved knowledge; Rule 3: Merge duplicate states, and retain the state with the highest probability for states with the same prediction prefix; (2) Calculation of state transition probability; The probability of generating a token is dynamically adjusted based on retrieval knowledge constraints, using the following formula: ; In the formula, Validity of knowledge retrieval The set, including specific entity names and relationship types, is amplified by this formula to meet the constraints. probability; For the mask, For dynamically adjusted masks, For marking, Tagging for dynamically adjusted retrieval knowledge; (3) Retrieve knowledge-driven dynamic masks; generate real-time masks based on retrieved knowledge fragments to prevent large language models from generating conflicting content.
10. A smart question-and-answer system for traffic incidents in highway tunnels, characterized in that, The system implements the intelligent question-and-answer method for highway tunnel traffic incidents as described in any one of claims 1-9, and the system includes: The user input module is used to receive query requests from users in natural language regarding traffic incidents in highway tunnels. The query requests include the triggering conditions, scope of impact, response equipment, control strategies, and handling procedures of the incident. The event intent recognition module, integrated into the large language model, is used to perform semantic parsing on the query request and classify it into one of the five predefined typical tunnel traffic events; The knowledge graph query module is used to dynamically generate structured query statements conforming to Cypher syntax based on the identified event categories and the ontology structure of the pre-built tunnel control knowledge graph. The query is then submitted to the Neo4j graph database via an HTTP interface to retrieve the complete knowledge subgraph related to the event. The triggering conditions explicitly record the data source, numerical threshold and judgment weight, the affected area includes the area identifier and spatial location description, and the responding device encapsulates the device identifier, control parameters and response delay time. The fact constraint generation module, integrated into the large language model, transforms the structured triple information in the knowledge subgraph into natural language answers through constraint prompts. The rejection judgment module is used to determine whether the user query falls under the above five typical tunnel traffic events during the event intent recognition stage. If it does not, a standardized rejection statement is returned directly. The five defined events are: fire, abnormal parking, traffic congestion, littering, and pedestrian intrusion.
Citation Information
Patent Citations
CN116644158A
CN119515640A