Designing LLM-Generated Daily Briefs for Perishable Goods Logistics
Machine LearningModel answerLast updated
Design a pipeline that adds LLM-written narrative insights to existing supply-chain reports while keeping numbers exact, data secure, and outputs verified before delivery.
Scenario
You work as a data analyst for a distributor of fresh, high-quality produce. Each day your team produces supply-chain reports using SQL queries and BI dashboards. Leadership wants to try an LLM that writes short plain-language insights from the structured data so that operations staff can act sooner.
Your task
Describe how you would add an LLM to the reporting process. Cover three areas:
- Fit: Give one supply-chain situation where an LLM is clearly better than a static dashboard, and one where it is worse or risky.
- Architecture: Outline the end-to-end flow that produces a report, and explain how you keep the model anchored to real database records.
- Validation: Propose a way to check the accuracy and truthfulness of generated summaries before stakeholders see them.
Constraints
- The data includes sensitive inventory and pricing information.
- The solution must serve hundreds of operations managers.
- Managers value precision over creativity.
Answer as you would in a technical screen: structured, concrete, and explicit about trade-offs.
Hints
Hint 1
Separate computing facts from describing facts: decide which component is allowed to produce numbers and which is only allowed to write sentences.
Hint 2
Think about how to make a wrong number structurally impossible, for example by having the model reference fact IDs instead of typing values.
Hint 3
For validation, combine cheap deterministic checks on every report (numbers, entities, direction, coverage) with an offline golden set and a shadow-mode rollout.
Hint 4
Do not forget access control: filter data to each manager's scope before it enters the prompt, and plan a safe fallback when checks fail.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Core idea
Treat the LLM as a narration layer on top of deterministic analytics, never as a source of truth. SQL and statistical models compute facts; the LLM only turns pre-computed facts into readable prose. A verification step then proves the prose matches the facts.
1. Clarify requirements
- Users: roughly 300-500 managers (buyers, warehouse leads, logistics), each limited to certain sites, categories and suppliers.
- Outputs: a daily brief per manager, generated in batch before the trading day starts, and optionally ad hoc Q&A.
- Volume: about 500 briefs a day at a few thousand input tokens each is cheap. For Q&A, rate limits and caching matter more than raw throughput.
- Non-functional needs: zero tolerance for wrong numbers, pricing data kept inside a controlled boundary, and auditability (which fact produced which sentence).
- Success metrics: time to decision on exceptions, share of exceptions actioned, numeric error rate of zero.
2. Use-case fit
Where the LLM wins: exception triage that spans several signals. A dashboard might show that a leafy-vegetable fill rate at one distribution centre fell to 72%, but the manager must open several tiles to learn why. The LLM can combine pre-computed facts into one prioritised paragraph: the inbound shipment arrived 18 hours late, demand ran 30% above forecast, and substitutes have only two days of cover. Its value is synthesis, prioritisation and plain language, especially for the long tail of items that no one has a dashboard for. Conversational drill-down is also a good fit.
Where it loses or is risky:
- Exact quantitative decisions such as reorder quantities, price setting, stock reconciliation and shrink accounting.
- Forecasting.
LLMs are weak at arithmetic and are non-deterministic. A confident wrong figure could become a real purchase order. Looking up a single KPI is also faster on a dashboard. These tasks belong to SQL and statistical models; the LLM may only describe their output.
3. Architecture
Principle: the LLM never queries raw tables and never computes a number.
Warehouse
-> Semantic layer (governed metrics: fill rate, days of cover, margin)
-> Deterministic jobs (KPI SQL per manager scope, row-level security,
anomaly/trend detection)
-> Fact sheet (JSON: id, value, unit, trend label, provenance)
-> LLM (low temperature, structured output citing fact IDs)
-> Verifier (numeric, entity, direction, coverage, entailment)
-> pass: renderer injects values -> email / chat / BI
-> fail: regenerate once -> fall back to templated report + alert
Key decisions:
- Grounding over fine-tuning. Stock changes daily; fine-tuning teaches style, not today's data, and bakes in staleness. Put the day's fact sheet in context. Fine-tuning is optional and only for tone.
- Results-to-text for daily briefs. For ad hoc Q&A, allow text-to-SQL only against allowlisted, read-only semantic-layer views, using a service account scoped to the user, with query validation (no DDL, row limits) and the SQL shown to the user.
- Structured output with placeholders. The model emits sentences containing tokens such as
{{f12}}plus the list of fact IDs it relies on. A renderer substitutes the real values. A wrong number then becomes structurally impossible, not merely unlikely. - Security. Enforce access control before data reaches the prompt, so the model cannot leak what it never saw. Use a private or enterprise endpoint with no retention or training on inputs. Redact cost and margin fields for roles that do not need them. Log prompts and outputs in-region for audit.
- Scale. Run briefs as a parallel batch job with retries, cache fact sheets shared by a site, and use a small model for routine briefs and a larger one for complex exception narratives.
4. Validation before delivery
Online checks on every report (deterministic first):
- Numeric fidelity: extract every number from the final text; each must match a fact-sheet value after unit normalisation and an explicit rounding tolerance. An orphan number fails the report.
- Entity validity: every item, supplier and site mentioned must exist in the fact sheet and in the manager's scope.
- Directional consistency: words like "rose", "fell" or "above forecast" must agree with the cited fact's sign and trend label.
- Coverage: the top-k anomalies by severity must appear. Omission is a silent failure.
- Unsupported claims: an NLI model or LLM judge checks that each sentence is entailed by its cited facts, catching invented causes such as "due to weather" when no weather fact exists.
On failure, regenerate once; if it fails again, send the templated non-LLM report and log the incident. Precision beats prose.
Offline evaluation:
- Build a golden set of around 200 historical days across roles, with analyst-written reference briefs.
- Score every prompt or model change on numeric error rate (target 0), faithfulness, coverage recall, and a human rubric (correctness, actionability, clarity).
- Before launch, run in shadow mode for 2-4 weeks with analysts reviewing a 10-20% sample, reducing sampling as confidence grows.
- After launch, monitor fallback rate, verifier failures, and manager feedback (a "this is wrong" button) as drift signals.
5. Trade-offs
| Choice | Benefit | Cost |
|---|---|---|
| Placeholder numbers | Wrong values impossible | Slightly stiffer prose |
| Low temperature + schema | Reproducible, auditable | Less varied language |
| Templated fallback | Always safe output | Occasional plain report |
| Hosted API vs self-hosted | Quality, less ops | Data-governance review needed |
6. Common mistakes
- Letting the model do arithmetic or read raw tables.
- Relying on prompt instructions ("do not make up numbers") instead of structural guarantees.
- Checking only numbers and ignoring omissions, direction words and invented causes.
- Applying permissions after generation instead of before.
- Skipping a fallback path, so a verifier failure means no report at all.
Follow-up: the LLM's trend reading contradicts the statistical model
The deterministic model is the source of truth. The LLM should never infer trends; trend labels and significance come from the model and are passed in as facts. The directional check catches the contradiction, the report is regenerated or falls back, and the case is added to the golden set as a regression test.