Documentation Index
Fetch the complete documentation index at: https://docs.qwedai.com/llms.txt
Use this file to discover all available pages before exploring further.
Deterministic verification for financial AI (v2.1.0).
When an LLM told a customer his Chase card had “$12,889” in rewards, QWED-Finance would have caught the hallucination before it caused a lawsuit.
QWED Finance is a specialized guardrail library designed to prevent financial hallucinations in Large Language Models (LLMs). It uses neurosymbolic AI — combining the flexibility of GenAI with the mathematical certainty of symbolic solvers (SymPy, Z3, mpmath) and standard financial algorithms.
New in v2.1.0: Security audit hardening — fail-closed enforcement across OpenResponsesIntegration, unified AML high-risk country list, BondGuard._parse_rate() returns Decimal, and full Decimal/mpmath migration for BondGuard, DerivativesGuard, and RiskGuard. Greeks are now Decimal-quantized strings.
Why QWED Finance?
LLMs struggle with basic math and strict logic. In finance, close enough is not good enough.
- Problem: LLM says “IRR is 12%” (when it’s actually 11.8%)
- Solution: QWED calculates the exact IRR symbolically and either validates or corrects the LLM.
Key features
- 10 specialized guards: Compliance, Calendar, Derivatives, Messages, Query, Cross, Bond, FX, Risk, ISO.
- GitHub Action v2.0: Integrated CI/CD verifier with SARIF support for security dashboards.
- Audit trails: Cryptographic attestation of verification results.
- Deterministic verification: When deterministic engines apply, results are exact rather than probabilistic.
The 4 pillars of banking verification
| Pillar | Guard | Engine | Use case |
|---|
| Calculation | Finance + Calendar + Derivatives | SymPy | NPV, IRR, options pricing |
| Regulation | Compliance | Z3 | KYC/AML, OFAC sanctions |
| Interoperability | Message | XML Schema | ISO 20022, SWIFT MT |
| Data safety | Query | SQLGlot | SQL injection prevention |
Quick example
from qwed_finance import ComplianceGuard
guard = ComplianceGuard()
# Verify AML flagging decision
result = guard.verify_aml_flag(
amount=15000, # Over $10k threshold
country_code="US",
llm_flagged=True # LLM flagged it
)
print(result.compliant) # True ✅
print(result.proof) # "amount >= 10000 → flag required"
Architecture
High-level flow
Guard selection flow
Verification engine stack
Payment verification sequence
Why not just trust the LLM?
LLMs are probabilistic. They can:
- Hallucinate numbers (12,889insteadof2.88)
- Miss compliance thresholds (CTR at $10,000.01)
- Generate malformed XML (rejected by SWIFT)
- Create dangerous SQL (DROP TABLE)
QWED-Finance uses deterministic verification:
| LLM output | QWED verification | Engine |
|---|
| ”NPV is $180.42” | SymPy recalculates | Math |
| ”Transaction is compliant” | Z3 checks threshold | Logic |
| ”Payment XML is valid” | Schema validation | Structure |
| ”SELECT * FROM users” | AST analysis | SQL |
Regulatory alignment
QWED-Finance aligns with:
- RBI FREE-AI Framework (India 2025)
- BSA/FinCEN (AML/CTR thresholds)
- OFAC (Sanctions screening)
- ISO 20022 (Payment messaging)
“Accuracy alone is not sufficient - transparency, auditability, and defensible decision logic are required.” — India AI Governance Guidelines
FinanceVerifier rejects ambiguous or unknown inputs instead of silently falling back to a default. In finance, a wrong answer with no error signal is worse than a loud failure.
verify_compound_interest — accepted compounding frequencies
Since N-04 fix: verify_compound_interest() raises ValueError for unknown compounding frequencies. Previously, unknown values (for example "weekly" or "continuous") silently defaulted to annual compounding, producing wrong results with no indication of failure.
Accepted values for the compounding argument:
| Value | Periods per year |
|---|
annual | 1 |
semi-annual | 2 |
quarterly | 4 |
monthly | 12 |
daily | 365 |
from qwed_finance import FinanceVerifier
verifier = FinanceVerifier()
# ✅ Valid frequency
result = verifier.verify_compound_interest(
principal=10000,
rate=0.05,
periods=10,
compounding="monthly",
llm_amount="$16,470.09",
)
# ❌ Unknown frequency — fail-closed
verifier.verify_compound_interest(
principal=10000,
rate=0.05,
periods=10,
compounding="weekly", # not supported
llm_amount="$16,470.09",
)
# raises ValueError:
# Unknown compounding frequency: 'weekly'.
# Accepted values: annual, daily, monthly, quarterly, semi-annual
If you need a frequency outside this list, compute the equivalent rate yourself and pass one of the supported values, or use a guard that explicitly models continuous compounding.
Next steps