Table of Contents
Fetching ...

GraphRAG for Engineering Diagrams: ChatP&ID Enables LLM Interaction with P&IDs

Achmad Anggawirya Alimin, Artur M. Schweidtmann

Abstract

Large Language Models (LLMs) combined with Retrieval-Augmented Generation (RAG) and knowledge graphs offer new opportunities for interacting with engineering diagrams such as Piping and Instrumentation Diagrams (P&IDs). However, directly processing raw images or smart P&ID files with LLMs is often costly, inefficient, and prone to hallucinations. This work introduces ChatP&ID, an agentic framework that enables grounded and cost-effective natural-language interaction with P&IDs using Graph Retrieval-Augmented Generation (GraphRAG), a paradigm we refer to as GraphRAG for engineering diagrams. Smart P&IDs encoded in the DEXPI standard are transformed into structured knowledge graphs, which serve as the basis for graph-based retrieval and reasoning by LLM agents. This approach enables reliable querying of engineering diagrams while significantly reducing computational cost. Benchmarking across commercial LLM APIs (OpenAI, Anthropic) demonstrates that graph-based representations improve accuracy by 18% over raw image inputs and reduce token costs by 85% compared to directly ingesting smart P&ID files. While small open-source models still struggle to interpret knowledge graph formats and structured engineering data, integrating them with VectorRAG and PathRAG improves response accuracy by up to 40%. Notably, GPT-5-mini combined with ContextRAG achieves 91% accuracy at a cost of only $0.004 per task. The resulting ChatP&ID interface enables intuitive natural-language interaction with complex engineering diagrams and lays the groundwork for AI-assisted process engineering tasks such as Hazard and Operability Studies (HAZOP) and multi-agent analysis.

GraphRAG for Engineering Diagrams: ChatP&ID Enables LLM Interaction with P&IDs

Abstract

Large Language Models (LLMs) combined with Retrieval-Augmented Generation (RAG) and knowledge graphs offer new opportunities for interacting with engineering diagrams such as Piping and Instrumentation Diagrams (P&IDs). However, directly processing raw images or smart P&ID files with LLMs is often costly, inefficient, and prone to hallucinations. This work introduces ChatP&ID, an agentic framework that enables grounded and cost-effective natural-language interaction with P&IDs using Graph Retrieval-Augmented Generation (GraphRAG), a paradigm we refer to as GraphRAG for engineering diagrams. Smart P&IDs encoded in the DEXPI standard are transformed into structured knowledge graphs, which serve as the basis for graph-based retrieval and reasoning by LLM agents. This approach enables reliable querying of engineering diagrams while significantly reducing computational cost. Benchmarking across commercial LLM APIs (OpenAI, Anthropic) demonstrates that graph-based representations improve accuracy by 18% over raw image inputs and reduce token costs by 85% compared to directly ingesting smart P&ID files. While small open-source models still struggle to interpret knowledge graph formats and structured engineering data, integrating them with VectorRAG and PathRAG improves response accuracy by up to 40%. Notably, GPT-5-mini combined with ContextRAG achieves 91% accuracy at a cost of only $0.004 per task. The resulting ChatP&ID interface enables intuitive natural-language interaction with complex engineering diagrams and lays the groundwork for AI-assisted process engineering tasks such as Hazard and Operability Studies (HAZOP) and multi-agent analysis.
Paper Structure (39 sections, 2 equations, 8 figures, 4 tables, 4 algorithms)

This paper contains 39 sections, 2 equations, 8 figures, 4 tables, 4 algorithms.

Figures (8)

  • Figure 1: Agentic workflow illustrating how LLMs interact with external tools. The input prompt (2) provides intent, context, and structured information to the model (1). When needed, the model invokes tools (2a) to obtain additional information or perform tasks, and the tool's output serves as context that improves the final response.
  • Figure 2: ChatP&ID Workflow. The ChatP&ID takes a flowsheet knowledge graph as its input. The knowledge graph can be generated by digitizing a PDF or image theisen2023digitization and exporting it to a DEXPI-conformant smart P&ID. The DEXPI P&ID then transformed into a knowledge graph using pyDEXPI Goldstein2025. Using the pyDEXPI object, each flowsheet element is mapped one-to-one to a node in the knowledge graph. From this knowledge graph, multiple abstraction layers are created, from a complete graph to process-level and conceptual-level. GraphRAG methods: ContextRAG, VectorRAG, PathRAG, or CypherRAG, are implemented as tools to retrieve relevant information from a knowledge graph. The LLMs are integrated into the workflow as an agent that determines the appropriate retrieval method to invoke. Finally, a context-aware response is generated to answer user queries.
  • Figure 3: ChatP&ID agentic workflow integrating graph database and graph-based retrieval method.
  • Figure 4: Illustration of the path exploration algorithm. To answer the query “how to control process stream temperature,” VectorRAG is first applied to the global embedding space to identify a suitable starting node. The Heat Exchanger (HE) is selected as the starting point, as it is the semantically closest node to the query. From this node, two candidate paths exist: (i) a direct connection to the Globe Valve, or (ii) a path through the Temperature Indicating Controller (TIC). VectorRAG is then applied to the local embedding of neighboring nodes to resolve this choice, selecting the TIC. The exploration proceeds through the Actuator and Globe Valve, and terminates at the Off-Page Connector (OPC) for Cooling Water Return (CWR). The resulting path is returned to the LLM to support the generation of the final answer.
  • Figure 5: Sample of DEXPI P&ID used in this case study Theissen2021.
  • ...and 3 more figures