sidewalk-fm / SYSTEM_DESIGN.md
Joshua-Abok's picture
P1: Fix extraction (regex-first), rebuild Modal (vLLM 0.19 + L4 + nemotron-mini-4b), delete orphan, cleanup
ccf7eb1
|
Raw
History Blame Contribute Delete
5.53 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade

SYSTEM DESIGN β€” Sidewalk FM

A voice/text bookkeeping ledger + advisor for one named informal street trader. Build Small Hackathon 2026 Β· Backyard AI track. Design principle (from the winning-pattern research): the demo must never break β€” deterministic core, models enhance.


1. The user (named, specific)

Mama Aisha β€” a morning-market produce trader. Low-literacy-friendly, speaks in plain language ("bought 50 mangoes at 200 shillings each"), often offline / limited connectivity, needs to know am I making a profit? β€” not formal accounting.

2. High-level flow

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   text/voice    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Trader     β”‚ ──────────────► β”‚  EXTRACTION          β”‚
  β”‚ (Gradio UI) β”‚                 β”‚  1) deterministic     β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚     regex/rules (1st) β”‚
        β–²                         β”‚  2) Nemotron LLM      β”‚
        β”‚ advice + ledger         β”‚     backup (messy in) β”‚
        β”‚                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                    β”‚ structured txn {action,item,qty,price,ccy}
        β”‚                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                         β”‚  LEDGER STORE         β”‚  JSON/SQLite (local, private)
        β”‚                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                         β”‚  MATH ENGINE (Python) β”‚  revenue/cost/profit/margin
        β”‚                         β”‚  β€” never the LLM      β”‚  (deterministic, exact)
        β”‚                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        └─────────────  ADVISORY                          β”‚
                     β”‚  Nemotron-Mini-4B on MODAL (vLLM)  β”‚
                     β”‚  fallback: deterministic canned    β”‚
                     β”‚  advice from the numbers           β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

3. Components

  • Input (Gradio): text box now; voice (Nemotron 3 ASR) + TTS (Kokoro 82M) in Phase 2.
  • Extraction: deterministic parser first (regex for buy/sell/return qty item at price ccy), grounded β€” every field traceable to the input. Small Nemotron LLM only as a backup when regex fails. (NOT nemotron-parse β€” that's image/OCR and 400s on text.)
  • Ledger store: append-only transactions, local (privacy β€” "a trader's books are private"). JSON file or SQLite.
  • Math engine: pure Python β€” totals, per-item margin, daily profit. Deterministic so numbers are always correct and the demo never breaks.
  • Advisory: nvidia/Nemotron-Mini-4B-Instruct on Modal (vLLM 0.19.0, L4) produces short, actionable advice from the computed numbers. If the endpoint is unavailable, a rule-based advisor returns canned guidance from the same numbers.

4. Transaction schema

{ "action": "buy|sell|return|refund", "item": "string", "quantity": number,
  "unit_price": number, "currency": "string", "vendor": "string|null",
  "notes": "string|null", "ts": "ISO-8601" }

5. Model stack (all ≀4B β†’ Tiny Titan; all NVIDIA β†’ Nemotron prize)

Component Model Params Provider Status
Extraction backup Nemotron (small instruct) ≀4B NIM/Modal optional
Advisory nvidia/Nemotron-Mini-4B-Instruct 4B Modal (L4, vLLM 0.19.0) core
(opt) ASR Nemotron 3 ASR 0.6B β€” Phase 2
(opt) TTS Kokoro 82M β€” Phase 2
(opt) Receipt OCR MiniCPM-V 4.6 ~1.3B OpenBMB Phase 2 (OpenBMB prize)

6. Serving (Modal β€” also the 10k-credit prize)

  • App sidewalk-fm-advisor; endpoint https://joshua-abok--sidewalk-fm-advisor-serve.modal.run/v1.
  • vLLM 0.19.0 OpenAI-compatible, L4 single GPU, min_containers=1 (stays warm for the demo), max-model-len 8192.
  • README must note Modal-at-runtime to qualify for the Modal prize.

7. Reliability / graceful degradation (the differentiator)

Every model call has a deterministic fallback:

  • Extraction: regex first β†’ LLM only if regex fails β†’ if LLM down, ask the user to rephrase.
  • Math: always Python (no dependency).
  • Advisory: Modal LLM β†’ if down, rule-based advice from the numbers. Result: the core ledger + math + basic advice work with zero external calls β†’ "Off the Grid"-leaning, demo-safe.

8. Prize β†’ feature mapping

Backyard AI (named trader) Β· Modal (advisory runtime) Β· NVIDIA (Nemotron) Β· Tiny Titan (≀4B) Β· Best Agent (parseβ†’ledgerβ†’analyzeβ†’advise) Β· Off Brand (custom UI, P2) Β· Best Demo (video+social, P2) Β· Bonus Quest Champion (stack) Β· OpenBMB (MiniCPM receipt, P2) Β· OpenAI Codex (Codex commits, P2).

9. Out of scope (post-hackathon)

Fine-tuned classifier, published vendor-dialogue dataset, revenue "garden" visualization, multi-agent "market council", Android/GGUF edge build.