Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

PlantGraph — Universal Document Ingestion & Knowledge Graph Agent

Prototype for: AI for Industrial Knowledge Intelligence — Unified Asset & Operations Brain Module built: Universal Document Ingestion & Knowledge Graph Agent (Other modules — Expert Copilot, RCA Agent, Compliance Intelligence — are scoped as Phase 2/3 in the architecture diagram; this prototype proves the foundation layer they'd all sit on top of.)

What it does

Feeds heterogeneous plant documents (PDFs, scanned images, text) into a single pipeline that:

  1. Extracts text from any format — native PDF text layer, OCR fallback for scanned pages/images (Tesseract).
  2. Extracts entities using an industrial-domain rule engine: equipment/ instrument tags (P-101A, PT-101, FCV-102...), document references (WO-2024-8871, PID-2024-0113...), regulatory references (OISD-STD-118, PESO Rule 45...), personnel, dates, and measurements.
  3. Builds a knowledge graph (networkx) linking every entity to the documents it appears in, and linking entities to each other via co-occurrence — so a single equipment tag like P-101A automatically connects its P&ID, its work orders, its inspection reports, and its SOPs, even though a human filed those in four different systems.
  4. Serves a search + graph explorer UI — keyword/semantic search over document chunks with source citations, plus an interactive graph you can click through to trace an equipment tag's entire operational history.

This directly targets the problem statement's core pain point: a large plant running 7–12 disconnected document systems, where nobody has a single view of an asset's full history.

Why rule-based entity extraction (not a generic NER model)

Generic NER models (spaCy, BERT-NER, etc.) are trained on news/Wikipedia text and do not recognize plant tag-numbering conventions (P-101A, FIC-103). A regex/rule engine tuned to real P&ID/work-order conventions is:

  • more accurate for this domain out of the box,
  • fully deterministic and auditable (important for compliance-adjacent data),
  • zero external dependency / no model download needed.

The tradeoff: personnel-name extraction is heuristic and occasionally noisy. Production roadmap: swap personnel/free-text extraction for a small fine-tuned NER model or an LLM extraction call, while keeping the deterministic regex layer for tag/document/regulatory extraction where precision matters most.

Architecture

                    ┌─────────────────────────┐
                    │   Document Sources       │
                    │  PDFs / scans / P&IDs /  │
                    │  work orders / SOPs       │
                    └────────────┬──────────────┘
                                 │ upload
                                 ▼
                    ┌─────────────────────────┐
                    │  Ingestion Layer          │
                    │  pdfplumber + Tesseract   │
                    │  OCR fallback              │
                    └────────────┬──────────────┘
                                 │ raw text + chunks
                                 ▼
                    ┌─────────────────────────┐
                    │  Entity Extraction        │
                    │  regex rule engine:        │
                    │  equipment / doc-ref /     │
                    │  regulatory / person / date│
                    └────────────┬──────────────┘
                                 │ entities
                                 ▼
                    ┌─────────────────────────┐
                    │  Knowledge Graph Store    │
                    │  networkx graph            │
                    │  (co-occurrence +          │
                    │   containment edges)       │
                    │  + TF-IDF chunk index       │
                    └────────────┬──────────────┘
                                 │ REST API (FastAPI)
                                 ▼
                    ┌─────────────────────────┐
                    │  Web UI                    │
                    │  graph explorer + search +  │
                    │  entity drill-down          │
                    └─────────────────────────┘

Phase 2 (not built in this prototype, but this layer feeds them directly):
  → Expert Knowledge Copilot (RAG + citations, mobile-first)
  → Maintenance Intelligence / RCA Agent (walks the graph's work-order chain)
  → Compliance Intelligence (walks the graph's regulatory-reference edges)

Running it

cd knowledge-graph-app
pip install -r requirements.txt --break-system-packages   # if needed
# Tesseract OCR binary must be installed on the system:
#   Ubuntu/Debian: sudo apt-get install tesseract-ocr
#   Mac: brew install tesseract

uvicorn app.main:app --reload --port 8000

Then open http://localhost:8000.

Click "Load sample plant documents" to ingest 4 bundled synthetic documents (a P&ID extract, a maintenance work order, an inspection report, and an SOP — all for the same boiler feed water system, cross-referencing the same equipment) and watch the knowledge graph assemble live.

You can also upload your own PDF/image/text document via the file picker — it will be parsed, entities extracted, and merged into the graph immediately.

API reference

Endpoint Method Purpose
/api/ingest POST (multipart file) Ingest a single uploaded document
/api/ingest_samples POST Load the bundled demo documents
/api/graph GET Full graph as {nodes, edges} JSON (filter by entity_type, search)
/api/entity/{key} GET Single entity detail + its connections
/api/search?q=... GET TF-IDF search over document chunks, with citations
/api/documents GET List ingested documents
/api/documents/{doc_id} GET Full text + extracted entities for one document
/api/stats GET Dashboard counts
/api/reset POST Clear all ingested data

Demo script (for the hackathon judges)

  1. Load sample documents — graph populates in ~1s.
  2. Point at the P-101A node (Boiler Feed Pump). Click it. → Right panel shows it's connected to the P&ID, the work order, the SOP, OISD-STD-118, and colleague equipment (B-201, LT-108, RV-210) — a query that today requires a human to manually cross four separate systems.
  3. Search "bearing failure" — results surface the work order's root-cause section with a similarity score and exact source snippet, even though the word "failure" only appears in this one document.
  4. Upload a new document live — show the graph updating without restart.

Evaluation criteria mapping (per the problem statement)

  • Entity extraction accuracy: deterministic rule engine, 100% precision on plant tag conventions in the demo corpus (see app/entity_extraction.py).
  • Knowledge graph linkage completeness: co-occurrence edges mean any two entities mentioned in the same document are auto-linked; containment edges preserve full document provenance.
  • Time-to-answer vs traditional search: single click from equipment tag to its full document history, vs. manually searching 4 separate systems.
  • Scalability: stateless FastAPI service + swappable graph backend (networkx → Neo4j is a drop-in path for production scale) and swappable chunk index (TF-IDF → real vector DB for production scale).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages