SENTINEL: Schema-Anchored Prompt Compilation for NL-to-SQL over Industrial Digital Twins on Edge Hardware
Abstract
Industrial Digital Twins (DTs) embed rich sensor telemetry in databases that factory operators cannot query without SQL expertise — a barrier amplified in the Global South by unreliable connectivity, scarce training, and limited hardware budgets. We present SENTINEL, an agentic NL-to-SQL pipeline centred on a Schema-Anchored Prompt Compiler (SAPC) that injects live database statistics into every prompt, grounding small language models against the actual schema. SAPC is complemented by a Reflexion-inspired SQL retry loop and a confidence-gated alert system. We evaluate SENTINEL across three model families (Phi-3.5 Mini 3.8B, Qwen-2.5 7B, Llama-3.1 8B), all 4-bit quantised, on three Industry 4.0 benchmarks (AI4I, Hydraulic System, NASA C-MAPSS) using a 49-query benchmark. SAPC is model-agnostic: every model moves from 0% baseline to 43–88% accuracy with schema grounding alone. Scaling from 3.8B to 7B doubles filtering accuracy (21%→50%), though further scaling to 8B yields no additional gain. The confidence gate achieves AUC-ROC of 0.989–1.000 (validated via 5-fold CV), though its fixed decision threshold requires per-dataset calibration. The full pipeline runs offline on consumer hardware (~5 GB, no GPU required for the smallest model) with zero cloud dependency.