Three-way matching compares a purchase order, a goods-received note and an invoice. Detecting a mismatch is routine; resolving it is where the manual work piles up. Clarivo targets mid-market Indian manufacturers and the accounting firms that serve them: it ingests documents from email, finds discrepancies with cited evidence, and closes the explainable ones without a human.
Architecture
external
compute
store
llm
check
ui
Ingest
01
Gmail mailbox watch
OAuth 2.0
02
Pub/Sub push
triggers a Django webhook
Extract & store
03
S3
attachments land here
04
Lambda (container on ECR)
native PDF parse, or Tesseract OCR for scans
embed
05
DynamoDB
extracted text and fields
Index & retrieve
06
Weaviate
chunks and embeddings
07
Hybrid search
BM25 + dense, token-budgeted
Reason & verify
08
LLM verdict
structured JSON with cited evidence
09
Grounding check
every cited figure verified against source
10
Case state
clean · flagged · auto-resolved · needs info
↺ new PO or delivery re-opens closed invoices
Serve
11
Django REST API
audit trail
12
Dashboard + RAG copilot
Architecture as built. Dashed lines are feedback paths.
Key decisions
01
Reasoning over field matching
Field-by-field matching broke on informal and inconsistent documents. Each invoice is now judged by one LLM call over the related purchase orders, delivery notes and earlier invoices, returning a verdict with cited evidence.
02
Grounding stays in code
The model never grades itself. A deterministic check confirms each cited figure actually appears in the retrieved source; anything unverified is flagged for review instead of silently trusted.
03
Re-evaluate when evidence changes
Early on, an invoice that had been checked once was never looked at again. Now a new order or delivery from the same supplier re-opens matching invoices, so split-shipment overbills resolve themselves when the missing delivery arrives.
04
Containers for OCR
Tesseract's binaries do not fit in a Lambda zip package, so extraction ships as a container image on ECR. PDFs with a text layer skip OCR entirely.
05
Test data I had to author
I could not find a public dataset that links purchase orders, delivery notes, invoices and payments with planted discrepancies, so I wrote one by hand covering six error classes.
Where it falls short
Grounding verifies that cited figures exist in the source; it does not verify the model's conclusion. A wrong inference from correct figures still needs human review.
The evaluation set is hand-authored, so it checks for regressions rather than claiming real-world accuracy.