Skip to main content

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

PillarGuardEngineUse case
CalculationFinance + Calendar + DerivativesSymPyNPV, IRR, options pricing
RegulationComplianceZ3KYC/AML, OFAC sanctions
InteroperabilityMessageXML SchemaISO 20022, SWIFT MT
Data safetyQuerySQLGlotSQL 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,889insteadof12,889 instead of 2.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 outputQWED verificationEngine
”NPV is $180.42”SymPy recalculatesMath
”Transaction is compliant”Z3 checks thresholdLogic
”Payment XML is valid”Schema validationStructure
”SELECT * FROM users”AST analysisSQL

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: fail-closed inputs

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:
ValuePeriods per year
annual1
semi-annual2
quarterly4
monthly12
daily365
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