Atul Iwale · Project 2 · Generative AI patterns: RAG, text-to-SQL, guardrails

Ask the ERP Copilot

Ask about projects, purchase orders, invoices or contract clauses in plain English. The Copilot finds the exact records, calculates totals with SQL, cites its sources, and declines anything it can't support from the data.

Entity-aware BM25 retrievalIntent router (logistic regression)Text-to-SQLGuardrails + groundedness checkRuns in your browser · synthetic ERP data

← Original Copilot evidence viewer · Notebook · README

Try these

Every answer shows how it was produced: the route, the SQL or retrieved records, and its sources.

How well it works

Measured in the notebook on questions whose wording the router never saw during training.

Retrieval: finding the right record ( questions)

End to end

How it works

  • Knowledge base: plain-language documents, one per project, purchase order, invoice and contract clause, with linked IDs as metadata.
  • Normalisation: spelling fixes and ID formats ("PO 85" → PO000085, "invoice no 45" → INV000045).
  • Router: a logistic-regression classifier decides lookup, one of eight calculations, or out of scope.
  • Lookup: extract entities, filter to linked records, rank with BM25, answer from the top record and cite it.
  • Calculation: fill slots, generate SQL, compute, and cite the rows used.
  • Guardrails: off-topic questions, unknown IDs and questions with no recognisable record are declined.

Honest limits

  • No large language model runs here: answers are composed deterministically from the records, so every figure can be checked. The notebook shows the constrained prompt an LLM would use.
  • Pure vector search performed poorly on this ID-heavy data, which is why retrieval is keyword and entity based.
  • Evaluation questions were generated from templates; real users phrase questions more freely.
  • The data is synthetic. Figures reflect the portfolio snapshot, not live systems.