SAHI is an open-source evaluation benchmark and deterministic safety guard designed to prevent catastrophic monetary transfer errors in Indic voice banking agents.
In conversational voice banking, language models and speech recognizers frequently propose incorrect transaction amounts due to:
- Power-of-ten scale confusion (e.g., dropping or adding a zero, confusing thousand with lakh).
- Phonetic digit swaps (e.g., 15 vs 50, pandrah vs pachas, padihenu vs yabhai).
- Colloquial fractional expressions (e.g., dhai hazar [₹2,500], dedh lakh [₹1,50,000], rendunnara velu [₹2,500]).
- Spoken self-corrections (e.g., "five hundred rupees no wait six hundred rupees").
- Ambiguous or conflicting amounts (e.g., "send 500 or 1000 rupees", "send 500 five thousand rupees").
SAHI establishes the core architectural principle: an LLM-generated amount is an unverified proposal, not the authority to move money. Transactions are never executed merely because an LLM or speech recognizer proposed them.
-
Multilingual Amount Parsing Engine (
AmountEngine):- Parses spoken Hindi (Devanagari & Latin script), Telugu (Telugu script & Latin), Hinglish, and Indian English into exact integer INR values.
- Enforces an absolute maximum transaction ceiling of ₹100,000,000 (₹10 crore).
- Rejects zero and negative amounts at the parser boundary.
- Accurately resolves valid self-corrections to the final intended correction, while flagging conflicting or unsafe corrections as
AMBIGUOUS. - Detects word-plus-digit contradictions and disjunctive expressions (or, ya, athava, leda).
- Correctly handles Indian comma grouping (
1,00,000) and standard international grouping (100,000). - Disambiguates phone numbers, dates, and account numbers from monetary values.
-
Deterministic Safety Guard (
SahiGuard):- Multi-source agreement evaluation across independent transcripts and LLM proposals.
- Detects catastrophic power-of-ten mismatches (10x, 100x, 1000x) and escalates.
- Detects phonetic confusable pairs and prompts for clarification.
- Enforces straight-through execution limits (default ₹50,000) requiring explicit user read-back for high-value amounts.
- Includes confirmation binding verification via
evaluate_confirmationto ensure confirmed amount and recipient payee strictly match the proposal before simulated ledger execution. - Fail-closed security: missing, ambiguous, or unvalidated proposals cannot execute.
-
Atomic Mock Bank Ledger (
MockBankDatabase/ FastAPI Service):- Process-local thread-safe simulated banking ledger using SQLite (
WALmode and a single-processthreading.Lock) with transaction atomicity. Cross-process concurrency is not managed by an external lock manager. - Strict transfer idempotency preventing duplicate debits.
- Boundary validation for strictly positive amounts, account balance sufficiency, and ceiling limits.
- Complete audit logging and ledger history.
- Process-local thread-safe simulated banking ledger using SQLite (
-
Live-Pilot Runner & Preflight (
scripts/run_live_pilot.py):- Safe offline dry-run by default with zero network or external API calls.
- Rigorous budget cap enforcement (default ₹10) prior to any paid API execution.
- Content-addressed caching with automatic credential redaction from cache keys.
Spoken User Utterance / Audio
│
▼
┌──────────────────────────────────────────────────┐
│ Dual-Mode Speech Recognition (Saaras v4) │
│ - Literal Transcript Mode │
│ - Code-mixed Transcript Mode │
└────────────────────────┬─────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ AmountEngine │ │ Sarvam 105B │
│ Deterministic │ │ LLM Agent │
│ Amount Parse │ │ (Proposal Only) │
└────────┬─────────┘ └────────┬─────────┘
│ │
└───────────────┬──────────────┘
│
▼
┌──────────────────────────────────────────────────┐
│ SahiGuard │
│ Deterministic Safety Guard Engine │
│ - Multi-reading consensus verification │
│ - Power-of-ten mismatch detection (10x, 100x) │
│ - Phonetic confusable pair checks │
│ - High-value read-back policy enforcement │
│ - Confirmation & payee binding verification │
└────────────────────────┬─────────────────────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
[EXECUTE] [READ_BACK] [RE_ASK] / [ESCALATE]
│ │ │
▼ │ ▼
┌──────────────────┐ │ Halt Execution &
│ FastAPI / SQLite│ │ Prompt / Escalate
│ Mock Bank │◄────┘
│ Atomic Transfer │ (Upon User Confirmation)
└──────────────────┘
| Language | Example Spoken Input | Parsed INR |
|---|---|---|
| Telugu (Script) | రెండు వేల ఐదు వందల రూపాయలు |
₹2,500 |
| Telugu (Script) | రెండు లక్షల రూపాయలు |
₹2,00,000 |
| Telugu (Script) | రెండు కోట్ల రూపాయలు |
₹20,000,000 |
| Telugu (Latin) | rendu vela aidu vandalu |
₹2,500 |
| Telugu (Latin) | rendunnara velu (colloquial fraction) |
₹2,500 |
| Hindi (Devanagari) | दो हज़ार पाँच सौ रुपये |
₹2,500 |
| Hindi (Devanagari) | ढाई हज़ार रुपये |
₹2,500 |
| Hindi (Devanagari) | डेढ़ लाख रुपये |
₹1,50,000 |
| Hindi (Latin) | dhai hazar rupaye |
₹2,500 |
| Hinglish | send 5k, transfer 5 hazar, pay 2.5 lakh |
₹5,000 / ₹2,50,000 |
| Indian English | twenty five hundred rupees |
₹2,500 |
| Indian English | two and a half lakhs |
₹2,50,000 |
| Indian English | ten thousand rupees actually five thousand rupees |
₹5,000 (Self-corrected) |
| Guard Action | Trigger Condition | Safety Objective |
|---|---|---|
EXECUTE |
All deterministic readings and LLM proposal agree; amount <= straight-through limit (₹50,000). | Safe straight-through processing in mock ledger. |
READ_BACK |
All readings agree, but amount exceeds ₹50,000 straight-through threshold. | Requires explicit conversational confirmation before moving money. |
RE_ASK |
Disagreement between readings, phonetic confusion (e.g. 15k vs 50k), self-correction ambiguity, or missing readings. | Halts execution; re-prompts the customer for clarification. |
ESCALATE |
Critical power-of-ten mismatch (e.g. 5,000 vs 50,000), zero/negative amount, or out-of-bounds ceiling violation. | Immediately halts execution; triggers human-in-the-loop review. |
- Python 3.11, 3.12, or 3.13
- Git
Windows PowerShell:
Set-Location "C:\Users\bokin\Downloads\sahi"
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -e ".[dev]"Linux / macOS:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e ".[dev]"python -c "import sahi; print('SAHI package loaded successfully')"pytest -qTo run with coverage:
pytest --cov=sahi tests/Runs the vertical slice across three standard safety scenarios:
python -m sahi.demoExpected Outcomes:
₹2500 भेजो(Agreement) →EXECUTE(mock ledger debited ₹2,500).₹5000 పంపించుwith simulated 10x LLM proposal₹50000→ESCALATE(POWER_OF_TEN_MISMATCH).send 500 no wait 5000(Self-correction conflict) →RE_ASK(PARSE_AMBIGUOUS_SELF_CORRECTION).
Output is printed as JSON and saved to demo_results.json.
Verifies the pilot manifest, budget calculations, and degradation pipeline offline:
python scripts/run_live_pilot.py --dry-runTo view CLI options:
python scripts/run_live_pilot.py --helpLaunches the browser-based demonstration with microphone push-to-talk, preset scenarios, deterministic guard analysis, and live confirmation against the simulated ledger:
python -m uvicorn sahi.bank.app:app --host 127.0.0.1 --port 8000Open http://127.0.0.1:8000/ in your browser.
- Microphone Push-To-Talk: Record audio in Hindi, Telugu, Hinglish, or English.
- Preset Safety Scenarios: Click preset buttons to test Agreement, 10x Mismatch escalation, or Ambiguous self-correction.
- Confirmation Flow: Safe amounts surface an explicit confirmation button wired to
evaluate_confirmationbefore updating the mock bank ledger. - Interactive OpenAPI Documentation: Visit
http://127.0.0.1:8000/docsto test raw API endpoints.
The mock bank ledger (MockBankDatabase) is an isolated SQLite simulation.
- It never connects to any real bank, payment processor, or UPI switch.
- All account IDs (
ACC_USER_001,ACC_RAMESH_002,ACC_SURESH_003) are synthetic test fixtures. - All debits enforce atomic balance checks and idempotency keys to ensure reproducibility.
- Offline / Deterministic Testing: The complete test suite and demo run 100% offline using deterministic mocks and local fixtures. No API keys or paid accounts are needed.
- Optional Live Testing:
test_sarvam_adapters.py:404contains an opt-in live test that is skipped by default. It only activates whenRUN_LIVE_SARVAM_TESTS=1andSARVAM_API_KEYare explicitly configured in.env. - Live Pilot Runner:
scripts/run_live_pilot.pydefaults strictly to--dry-run. Live execution via--execute-liverequires an activeSARVAM_API_KEYand enforces a hard ₹10 budget cap.
- Dialect and Colloquial Vocabulary: Telugu and Hindi dialects have varied regional colloquialisms. While common forms (dhai, dedh, vandalu, kotlu, lakshalu) are fully supported, localized slang outside these sets defaults to
UNRECOGNIZED. - Sub-Rupee Paise Settlement: Non-integer decimal paise amounts (e.g.
12.75 rupees) or fractional paise expressions are flagged asFRACTION_AMBIGUITYrather than silently rounded, adhering to bank safety principles. - Synthetic Speech Fixtures: The evaluation metrics in
report/index.htmlreflect offline benchmark simulations. Live acoustic validation across physical speakers remains outside the repository's offline verification boundary. - Process-Local Locking:
MockBankDatabaseuses a Pythonthreading.Lockfor thread safety within a single process, plus SQLiteWALmode. It does not implement cross-process application-level locking across separate server processes. - Confirmation Binding Integration:
SahiGuard.evaluate_confirmationis unit-tested and integrated into thePOST /api/voice/confirmendpoint and SAHI Live web interface. The batch evaluation scriptSahiPipeline.process_utteranceexecutes single-turn instructions without multi-turn interactive confirmation.
Distributed under the Apache 2.0 License. See LICENSE for details.