Skip to content
Selected work

Applied AI · LLM Systems · Edge Inference

AI Operations Assistant

Business answers powered by AI. Numbers calculated by code.

A self-hosted AI assistant that operations staff use every day to ask about inventory, sales, restocking, purchasing and profit. A local language model reads each question; deterministic Python and SQL calculate the answer.

Illustrative interface recreation using synthetic operational data. Not a production conversation.

On this page
  1. 01Overview
  2. 02The problem
  3. 03Try the assistant
  4. 04How it works
  5. 05Behind the engineering
  6. 06Impact and reflection
01

Overview

An AI assistant built for everyday operational decisions.

I independently built a self-hosted AI assistant that helps retail operators ask questions about inventory, sales and profitability in natural language. A local language model interprets each request, while deterministic Python handles the calculations behind the answer.

Developed at Unistop Tech in collaboration with the Intel team.

  • The problem

    Staff need quick, trustworthy answers about stock, sales and profit, without digging through databases or reports.

  • What I built

    The whole assistant, on my own: question understanding, guardrails, calculations, evaluation and on-device model serving.

  • Where it stands

    Deployed on local hardware and used by operations staff for their daily questions.

What I built

I was the sole developer: I designed, built, deployed and debugged the assistant end to end. Its restocking, purchasing and profit calculations reuse business logic from the Inventory & Retail Operations Platform, which I also worked on extensively. For this project I ported those engines to Python; the AI system around them is new.

  1. Question understanding

    The routing pipeline: structured intent classification, entity extraction and validation.

  2. Guardrails

    Python checks and routing overrides that correct the model's reading before anything runs.

  3. Conversation

    Multi-turn follow-ups and clarifying questions.

  4. Answers

    Predefined SQL reports, deterministic calculation, Python-written answers and optional model narration.

  5. Evaluation

    A labelled routing test set, an evaluation harness and a regression-testing workflow.

  6. Integrations

    The company database, Python ports of the inventory, purchasing and financial engines, and Open WebUI.

  7. Inference

    Local Qwen3-30B-A3B INT4 deployment on OpenVINO, Intel GPU and NPU integration, and latency optimisation.

  8. Operations

    Deployment as services, monitoring through a turn log, and debugging in production.

02

The problem

Business questions shouldn't require navigating databases.

Operations staff regularly need to know what's in stock, what to restock, how sales are going, what to order and what each store earns. The answers live in the company database and in several reports.

Understanding a question is only half the job. The answer also has to be numerically right, because staff act on it.

Without it

  1. Operator
  2. Several dashboards and reports
  3. Manual filtering
  4. Interpretation

With it

  1. Operator
  2. A question in plain words
  3. Checked report selection
  4. Calculated answer

A language model can interpret a question, but that doesn't make it a reliable accounting or inventory calculator.

03

Try the assistant

Ask it something.

Pick a question to see the kind of answer staff get, then try a follow-up. The answers come from a small made-up dataset; the assistant's real answers follow the same pattern.

Operations Assistant

Pick a question below to see how the assistant answers. Then try the follow-up.

Example questions

Interactive recreation using fictional stores, products and operational data. No company systems are connected.

04

How it works

The model understands the question. Code produces the answer.

Rather than letting the model do everything, the assistant gives it two narrow jobs: reading the question and, for a few answer types, writing up figures that were already calculated. Step through one question to see where the model stops and code takes over.

Guided walkthrough of the real pipeline's stages, with made-up data.

Step 1 of 5 · Operator

Ask a question

The operator asks in everyday words instead of finding the right report.

How much did Store A sell last week?

Explore the engineering
  1. Structured output parsing

    The router returns JSON. Thinking blocks and code fences are stripped, the JSON span is extracted, defaults are filled in, and any failure becomes “unknown” rather than an error.

  2. Validation

    Placeholder values the model invents (“unknown”, “product”) are cleared, and store names are checked against a directory built from the database.

  3. Routing overrides

    Phrase overrides and report rules in Python can take precedence over the model's choice, and structural rewrites fix known mix-ups such as a profit question with no product.

  4. Entity resolution

    Stores are matched by full name, number or unique first word, typos are fuzzy-matched, and shared names trigger a “which one?” question.

  5. Second-chance routing

    If nothing else matches, a second model call picks from a catalogue of about 30 reports, or says none fits. The answer is labelled with how it was read.

  6. Multi-turn state

    The model only flags a follow-up. Python fills in everything the follow-up didn't change from the previous turn.

  7. Deterministic rendering

    More than 20 answer types are written by Python, so figures never pass through the model.

  8. Narrator payload limits

    Where the model does write up results, its input is capped at 6,000 characters and trimmed with an honest count of what was left out.

05

Behind the engineering

Reliability, speed and evidence.

Reliability

Designing guardrails around imperfect language-model outputs.

A local model will sometimes misread a store name, leave out a detail or file a question under the wrong type. Instead of trusting its reading, the assistant checks it in several layers of ordinary code, and asks the operator when it can't be sure.

  • Ambiguous location

    “Show the stock for Harbour.”

    Model's reading

    Store: “Harbour”

    After the checks

    Two stores share the word “Harbour”, so the assistant asks: Harbour East or Harbour West?

  • A store the model made up

    “Which products sell best?”

    Model's reading

    Store: “Store Z”

    After the checks

    The question named no store and “Store Z” doesn't exist, so the invented store is removed and the report covers every store.

  • A short follow-up

    “How did Store A do last week? … And Store B?”

    Model's reading

    Follow-up, store: Store B (question type and period missing)

    After the checks

    Python fills in what wasn't repeated from the previous question: Sales summary · Store B · last week.

Every layer of checks
  1. Store names

    Aliases built from the database; typos fuzzy-matched; unknown places refused with an explicit “I don't know that store”.

  2. Low confidence

    When the model isn't confident, the assistant asks “Did you mean…?” before running anything.

  3. Rule-based overrides

    Python rules route known phrasings directly, so new question types don't need prompt edits.

  4. Second-chance routing

    Unmatched questions get one more, catalogue-based attempt before the assistant says it can't help.

  5. Follow-ups

    A short follow-up reuses the previous question's details, and a long, self-contained question is never mistaken for one.

Speed

Optimising inference without relying on a cloud API.

The model runs on the company's own machine, on an Intel processor's built-in GPU and NPU, so questions are answered without sending anything to a cloud API. Getting answers back in seconds rather than a minute took several changes: keeping the model loaded, caching the fixed part of the prompt, streaming answers, and calling the model less often.

Chat

Open WebUI

Staff ask in a browser

Assistant

Python pipeline

One conversation per chat; reports read the database through a read-only account

Local model service

Qwen3-30B-A3B INT4 · OpenVINO GenAI

Preferred

Intel Arc GPU

Takes each request first

Overflow

Intel NPU

Used when the GPU is busy

A copy of the model stays loaded on each device. The long, fixed start of the routing prompt is cached, and answers stream back as they are written.

Simplified, with generic names. Everything runs on one local machine; no cloud API is involved.
Mean time to answer one question, historical benchmark
Before · CPU · Ollama · Aug 202656.7s
After · Intel Arc GPU · OpenVINO GenAI · Oct 202610.7s
Benchmark detail
MeasureBeforeAfter
Median per question52.0s9.8s
Slowest 5% (p95)81.0s25.2s
Understanding step (mean)24.9s3.75s
Model write-ups per question1.000.58

Read this carefully

The two runs used different hardware and software, so this is not a hardware-only comparison. The gain combines keeping the model loaded instead of reloading it, faster inference on the GPU, and fewer model calls because Python now writes most answers. The sample is small: 12 benchmark questions (12 runs before, 36 after). The October run used the earlier Qwen3-8B model; the current Qwen3-30B-A3B setup has not been benchmarked the same way.

Inference engineering detail
  1. Persistent pipelines

    One copy of the model per device stays loaded. The earlier setup reloaded the model per call, which the August benchmark identified as the main cost.

  2. GPU first, NPU overflow

    Each request takes the first idle device, preferring the GPU. In a device comparison on the Qwen3-8B setup, routing took 2.6s on the GPU and 6.6s on the NPU.

  3. Prefix caching

    The roughly 3,200-token router prompt is processed once and reused; time to first token was about 130ms on the Qwen3-8B setup.

  4. Streaming

    Answers stream as server-sent events, and generation stops if the client disconnects.

  5. Fewer model calls

    Python-written answers cut model write-ups from 1.00 to 0.58 per question in the benchmark.

  6. Not yet measured

    Behaviour under several simultaneous users hasn't been benchmarked.

Evidence

Treating AI behaviour as something to test, not assume.

Changing a prompt to fix one question can quietly break others. So routing is measured against 133 hand-labelled questions, comparing what the system actually did with what it should have done, and failed or unclear questions from real use are reviewed and turned into fixes and new test cases.

  1. 1Test question
  2. 2Expected answer type
  3. 3What the system chose
  4. 4Compare
  5. 5Review misses

One fictional test case

“What sold best at Store B yesterday?”

Expected
Product sales · Store B · yesterday
Model alone
Sales summary · Store B · yesterday
After the checks
Product sales · Store B · yesterday

The evaluation scores both: what the model chose on its own, and what the system finally did after its checks. The second is the number to protect.

The test case is invented for illustration; the evaluation set itself stays private.
Evaluation and testing detail
  1. Golden routing set

    133 hand-labelled questions across 35 intent labels, scored on the final routed intent and its fields.

  2. Raw vs effective

    The harness scores the model's own choice and the system's final choice after the Python checks separately.

  3. Consistency

    Repeated runs check that the same question is routed the same way; this is reported as consistency, never as accuracy.

  4. Unit tests

    190 offline tests run with the model mocked; 189 passed in the audit run, and the remaining one needs a database connection.

  5. Miss review

    A turn log records each question and how it was routed, never the answer, and a script groups the unanswered and uncertain ones for review.

  6. Prompt discipline

    After few-shot prompt edits regressed other questions, new question types are added as Python rules and the prompt is left alone.

More engineering detail

Predefined operational reports
  1. Stock

    Store and warehouse stock, expiry, overstock and velocity bands.

  2. Sales

    Summaries against the previous period, trends, sales by hour and weekday, product sales and transaction lookups.

  3. Restocking and slots

    Restocking list previews and product slot recommendations.

  4. Purchasing

    Purchase-order recommendations from a nightly report.

  5. Profit

    Store profit and loss, and product and category profit rankings.

  6. Pricing and products

    Prices including promotions, promotion and add-on performance, products bought together, store comparisons and vendor lookups.

Integration with the inventory platform's engines
  1. Ported, not reinvented

    The restocking forecast, the profit-and-loss logic and the purchase-order safety stock are Python ports of the Inventory & Retail Operations Platform's business logic, so the assistant's figures match the platform's. That case study explains the forecasting and costing in depth.

  2. One shared module

    The assistant and the nightly purchasing job import the same forecasting code, so their numbers can't drift apart.

Nightly purchase recommendations
  1. Precomputed overnight

    A scheduled job calculates purchase recommendations each night and caches the report; the assistant reads that report, so answers can be up to a day old.

  2. Not automated

    Creating purchase orders in the database automatically is built but kept in dry-run mode.

Architectural trade-offs
The model reads and narrates; Python calculates and writes answersDocumented
Reason
A local model is unreliable at arithmetic and at carrying state across turns. Keeping it out of the calculations makes every figure exact and auditable.
Trade-off
Every new type of question needs code; the assistant can't answer something no report covers.
New question types as Python rules, not prompt editsDocumented
Reason
Editing the router prompt to fix one question regressed others.
Trade-off
Routing stays stable, but the rule list grows and its order matters.
A second-chance report catalogue instead of model-written SQLDocumented
Reason
Every answer then comes from a tested report. Model-written SQL is parked behind a written safety specification until missed questions justify it.
Trade-off
Questions no report covers still get “I can't answer that”.
A separate model service with one pipeline per deviceDocumented
Reason
Several processes need the model, and it must not load per process. GPU-first scheduling with NPU overflow lets two conversations run at once.
Trade-off
A simple lock-based scheduler, without batching requests on the same device.
Port the inventory engines instead of calling the platformDocumented
Reason
The assistant's figures need to match the platform's dashboards.
Trade-off
Two implementations of the same logic that could drift, and no automated cross-check between them yet.
Deterministic follow-ups, where “not mentioned” means “keep”Documented
Reason
The model re-reads each turn from scratch and drops details; Python merging them back is predictable.
Trade-off
A follow-up can't express “go back to the default”.
Known limitations and next steps
  1. Conversation memory

    State is kept in memory, covers the last two turns and is lost on restart.

  2. Code structure

    The core module is large, about 5,700 lines, and the routing rules are a long, order-dependent chain.

  3. Engine cross-checks

    The ported engines aren't yet tested against the original platform's results, and some have no direct unit tests.

  4. Benchmarks

    The latency benchmark is small and single-user; the current Qwen3-30B-A3B setup and multi-user load still need measuring.

  5. Channels and automation

    A WhatsApp channel is built but not deployed, and automatic purchase-order creation remains in dry-run.

  6. Model-written SQL

    A validated SQL fallback is specified but parked until missed questions justify it.

06

Impact and reflection

From an AI prototype to a tool used in daily operations.

The assistant is deployed on local hardware and used by Unistop's operations staff for daily questions about inventory, sales, profitability and purchasing.

  • Capability

    Deployed and self-hosted; no cloud model API

  • Capability

    Used by operations staff for daily operational questions

  • Capability

    About 30 types of operational question and report

  • Capability

    Figures calculated by code, never by the model

Mean response time
57s → 11s
Historical benchmark across two different hardware and software setups. See the caveats in Behind the engineering.
Labelled routing cases
133
Hand-labelled questions used to check routing after every change. No accuracy figure is quoted until it is re-run.
Offline unit tests
189 of 190
Passing in the audit run; the remaining test needs a database connection.

Reflection

Building this assistant taught me that reliable AI systems depend as much on the deterministic software surrounding a model as on the model itself.

The most important decision was where the model should stop: it reads the question, and code does everything that has to be right. Measuring routing against labelled questions, rather than trusting a few good-looking answers, is what made it safe to keep changing the system.

Real data and real questions were messier than any prompt anticipated: ambiguous store names, short follow-ups and stores that hadn't synced. Handling those cases explicitly, and making the assistant ask when it isn't sure, mattered more than the model's size.