This project was developed in collaboration with Repsol and is currently being evaluated for application within their industrial systems.
Industrial processes generate massive streams of sensor data, but the knowledge to detect safety anomalies often remains locked in unstructured technical documentation. Traditional anomaly detection methods rely on historical patterns, failing to capture safety definitions described in manuals that have never occurred in operation.
This thesis addresses that gap by introducing a semantic compilation framework that transforms human-authored safety specifications into executable rules. Rather than using Large Language Models (LLMs) as oracles, we treat them as compilers for engineering constraints, producing deterministic rule logic deployed on a lightweight streaming engine for industrial monitoring.
Repsol was highly impressed with the results and is actively evaluating the technology for integration into its operational systems — a strong validation of both the technical approach and industrial relevance.
Problem & Motivation
The process industry suffers from:
- Data abundance but knowledge scarcity
- Manual dependency on domain engineers to interpret safety specifications
- Traditional anomaly detection tools unable to detect defined but unobserved failure conditions
Objective: Build an automated pipeline that:
- Reads natural-language safety specs
- Compiles them into executable rule logic
- Deploys them efficiently in streaming runtimes
What I Built
- A multi-stage semantic compilation framework treating natural language specifications as source code
- A Program-of-Thoughts paradigm coupled with layout-aware Retrieval-Augmented Generation (RAG)
- Deterministic Python rule generation using state-of-the-art LLM libraries (many not available when the research began)
- A clear separation between probabilistic extraction and deterministic execution
- A lightweight stream processing runtime capable of incremental evaluation of rules
All components were built to meet industry-grade LLMops standards with robust reproducibility, constrained decoding for validity, and separation of concerns for data sovereignty and runtime determinism.
Technical Highlights
- Natural language → code compilation using LLMs as compilers, not oracles
- Layout-aware RAG / SAG pipelines to extract structured rule logic
- Constrained decoding for near-perfect validity in generated rules
- Deterministic execution layer separate from model inference
- Efficient incremental stream processing suitable for edge/industrial IoT
Results & Industrial Relevance
- Near-perfect validity of extracted rules on synthetic benchmarks
- Significant improvements in semantic recall for complex temporal constraints compared to standard baselines
- Efficient execution in a lightweight streaming engine, demonstrating proof-of-concept for real-time industrial edge deployment
- Repsol has expressed strong interest and is working on applying the technology in their systems, confirming both business impact and technical maturity
Impact
This work demonstrates an alternative to purely data-driven detection, enabling rule-driven anomaly definitions that can be:
- expressed directly from domain knowledge
- executed deterministically in production
- maintained and audited as code
It represents a foundational advance for specification-driven monitoring systems in industrial environments.
Keywords
Anomaly Definition • LLMs as compilers • Retrieval-Augmented Generation • RAG • Program-of-Thoughts • Industrial IoT • Stream Processing • Knowledge Extraction • Edge Computing • LLMops