AI-Powered Identity Verification and Fraud Detection for Online Lending

sun_finance · Finance · 2026 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Online lending identity verification and fraud detection

Sun Finance needed to reduce manual review in a high-volume microloan identity-verification pipeline where OCR errors, multilingual documents, fraud rings, cost, and processing latency blocked expansion into lower-value lending markets.

Constraints:

Architecture

Sun Finance and the AWS Generative AI Innovation Center built a serverless AWS pipeline with two API routes. The /extract-id route sends ID images through Amazon Textract for primary OCR, falls back to Amazon Rekognition when confidence is low, then sends extracted text to Claude Sonnet 4 on Amazon Bedrock to structure seven standardized fields and applies validation rules. The /detect-fraud route triggers AWS Step Functions to run visual fraud detection and background similarity in parallel. Claude analyzes selfie images for screen-photo and manipulation artifacts, while Rekognition masks faces, Titan Multimodal Embeddings vectorizes backgrounds, S3 Vectors searches known fraud patterns, and a Lambda risk function combines both scores. A separate ingestion path adds confirmed fraud backgrounds to the vector reference set.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  api-gateway["api-gateway"] --> id-extraction-lambda["id-extraction-lambda"]
  api-gateway --> fraud-detection-lambda["fraud-detection-lambda"]
  cognito-auth["cognito-auth"] --> api-gateway
  aws-waf["aws-waf"] --> api-gateway
  application-s3-storage["application-s3-storage"] --> id-extraction-lambda
  application-s3-storage --> fraud-detection-lambda
  id-extraction-lambda --> textract-ocr["textract-ocr"]
  textract-ocr --> rekognition-fallback-ocr["rekognition-fallback-ocr"]
  rekognition-fallback-ocr --> claude-structurer["claude-structurer"]
  textract-ocr --> claude-structurer
  claude-structurer --> validation-rules["validation-rules"]
  validation-rules --> id-extraction-lambda
  fraud-detection-lambda --> fraud-step-functions["fraud-step-functions"]
  fraud-step-functions --> visual-pattern-detector["visual-pattern-detector"]
  fraud-step-functions --> background-similarity-pipeline["background-similarity-pipeline"]
  background-similarity-pipeline --> face-masking-rekognition["face-masking-rekognition"]
  face-masking-rekognition --> titan-background-embeddings["titan-background-embeddings"]
  titan-background-embeddings --> s3-vectors-index["s3-vectors-index"]
  visual-pattern-detector --> risk-assessment-lambda["risk-assessment-lambda"]
  background-similarity-pipeline --> risk-assessment-lambda
  application-s3-storage --> fraud-ingestion-lambda["fraud-ingestion-lambda"]
  fraud-ingestion-lambda --> face-masking-rekognition
  fraud-ingestion-lambda --> titan-background-embeddings
  fraud-ingestion-lambda --> s3-vectors-index
  terraform-cicd["terraform-cicd"] --> id-extraction-lambda
  terraform-cicd --> fraud-step-functions
  terraform-cicd --> api-gateway
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
api-gateway Exposes /extract-id and /detect-fraud routes for the lending workflow. id-extraction-lambda, fraud-detection-lambda, cognito-auth, aws-waf
application-s3-storage Stores loan application data, identity images, selfie images, and confirmed fraud images. id-extraction-lambda, fraud-detection-lambda, fraud-ingestion-lambda
id-extraction-lambda Coordinates OCR, LLM structuring, and validation for identity documents. api-gateway, application-s3-storage, textract-ocr, rekognition-fallback-ocr, claude-structurer, validation-rules
textract-ocr Primary OCR extraction from identity document images. id-extraction-lambda, rekognition-fallback-ocr, claude-structurer
rekognition-fallback-ocr Backup extraction path for low-quality, angled, unusual, or damaged ID images. textract-ocr, id-extraction-lambda, claude-structurer
claude-structurer Claude Sonnet 4 on Amazon Bedrock structures extracted OCR text into standardized ID fields. id-extraction-lambda, validation-rules
validation-rules Normalizes ID number lengths, date formats, document types, and other field-level constraints. claude-structurer, id-extraction-lambda
fraud-detection-lambda Starts fraud detection workflow for selfie images. api-gateway, application-s3-storage, fraud-step-functions
fraud-step-functions Runs visual pattern detection and background similarity checks in parallel. fraud-detection-lambda, visual-pattern-detector, background-similarity-pipeline, risk-assessment-lambda
visual-pattern-detector Claude Sonnet 4 analyzes selfie images for screen photos, glare, reflections, and manipulation artifacts. fraud-step-functions, risk-assessment-lambda
background-similarity-pipeline Masks faces, embeds backgrounds, and searches known fraud backgrounds. fraud-step-functions, face-masking-rekognition, titan-background-embeddings, s3-vectors-index, risk-assessment-lambda
face-masking-rekognition Masks faces so similarity search focuses on background fraud-ring patterns. background-similarity-pipeline, titan-background-embeddings
titan-background-embeddings Amazon Titan Multimodal Embeddings creates 1024-dimensional background vectors. face-masking-rekognition, s3-vectors-index
s3-vectors-index Serverless vector index of known fraud backgrounds. titan-background-embeddings, background-similarity-pipeline, fraud-ingestion-lambda
risk-assessment-lambda Combines visual and background-similarity scores into high/medium/legitimate fraud classification. visual-pattern-detector, background-similarity-pipeline
fraud-ingestion-lambda Ingests confirmed fraud images, masks faces, generates vectors, and stores them in S3 Vectors for future matching. application-s3-storage, face-masking-rekognition, titan-background-embeddings, s3-vectors-index
cognito-auth Authentication with SigV4 request signing. api-gateway
aws-waf Web security protection for the API layer. api-gateway
terraform-cicd Infrastructure-as-code and CI/CD path for redeploying configuration, prompts, validation rules, and Lambda changes. id-extraction-lambda, fraud-step-functions, api-gateway

Data flow

A loan application stores ID and selfie images in S3 and calls API Gateway. For ID extraction, Lambda sends the ID image to Textract, uses Rekognition as fallback OCR when Textract confidence is low, passes extracted text to Claude Sonnet 4 for JSON structuring, and validates field formats such as ID number length and date standardization. For fraud detection, Lambda starts a Step Functions workflow that runs two branches in parallel: Claude visual analysis for screen-photo/digital-manipulation artifacts and background similarity that masks faces, creates a Titan 1024-dimensional background vector, and searches S3 Vectors. Lambda combines visual and similarity scores into fraud risk. Confirmed fraud images later flow through a Lambda/Rekognition/Titan/S3 Vectors ingestion pipeline to grow the fraud reference database.

5 supporting quotes
“An AWS Lambda function receives the ID image and sends it to Amazon Textract for primary OCR. If Amazon Textract returns low-confidence results, the system falls back to Amazon Rekognition for OCR.”article, stated
“The extracted text is then passed to Amazon Bedrock (Claude Sonnet 4), which structures it into standardized JSON fields.”article, stated
“An AWS Lambda function triggers an AWS Step Functions workflow that runs two checks in parallel”article, stated
“Both results feed into a Lambda-based risk assessment function that produces a combined fraud score as JSON.”article, stated
“Confirmed fraud images are ingested from Amazon S3 through a Lambda function.”article, stated

Why this architecture

The architecture separates precise OCR, LLM structuring, validation, fraud vision, vector similarity, and risk scoring because each task fails differently. Claude alone triggered PII safeguards and underperformed on character-level ID extraction; Textract and Rekognition handle OCR better, Claude structures and analyzes context, validation catches formatting issues, Step Functions reduce latency through parallel checks, and confirmed fraud ingestion turns fraud review into a growing reference database.

3 supporting quotes
“separating concerns allowed each tool to operate within its design parameters: Amazon Textract for reliable OCR and Claude for intelligent structuring.”article, stated
“combining specialized OCR tools (Amazon Textract + Amazon Rekognition) with LLM structuring (Claude) and validation rules beats using a single tool alone”article, stated
“The fraud detection system uses AWS Step Functions to run two detection methods in parallel, then combines their scores into a final risk assessment.”article, implied

Prerequisites

To implement a similar solution, you need the following:

— article, implied

Models used: Anthropic Claude Sonnet 4 · Amazon Titan Multimodal Embeddings · Amazon Textract · Amazon Rekognition

Scale

Alternatives considered (roads not taken)

Claude Sonnet 4 directly extracting fields from ID images

Rejected because: Direct extraction triggered PII safeguards and achieved only 61.8% overall accuracy, with ID number accuracy at 43%.

“Approach 1: Claude Sonnet 4 alone (61.8% accuracy). The team’s first attempt sent ID images directly to Anthropic’s Claude Sonnet 4 via Amazon Bedrock and asked it to extract fields as JSON.”article, stated
“The results were disappointing: 61.8% overall accuracy, with ID number extraction at only 43%.”article, stated

Single OCR or model path for document extraction

Rejected because: No one service handled every edge case, so the final design cascaded Textract primary OCR, Rekognition fallback, Claude structuring, and validation rules.

“No single OCR service handled every edge case, but the combination added minimal cost while helping avoid complete failures on challenging images.”article, stated
“Amazon Rekognition provides backup extraction when Amazon Textract confidence is low. Claude structures the combined output, and validation rules catch formatting errors”article, stated

Text embeddings for background fraud similarity

Rejected because: Text embeddings had poor precision and recall compared with visual embeddings.

“Text embeddings (having Claude describe the background, then comparing descriptions) achieved 91% accuracy but only 27.8% precision and 21.7% recall.”article, stated
“Visual embeddings performed far better: 96% accuracy, 80% precision, and 52% recall.”article, stated

Sequential fraud detection checks

Rejected because: Step Functions parallel execution reduced fraud-detection latency from 6-8 seconds to 3-5 seconds.

“The parallel execution architecture processes images in 3–5 seconds, down from 6–8 seconds when run sequentially.”article, stated

Retrain specialized models for every new document type or language

Rejected because: The team uses prompt engineering, validation rules, configuration updates, and CI/CD redeployment to expand without model retraining.

“adding a new document type or language requires prompt engineering and validation, not retraining specialized models.”article, stated
“The team updates Claude Sonnet 4 prompts via Amazon Bedrock and defines document-specific validation rules, then tests against a validation dataset.”article, stated

Patterns

tool-use-orchestration (architecture)

The solution coordinates API Gateway, Lambda, Textract, Rekognition, Bedrock Claude, Titan embeddings, S3 Vectors, Step Functions, Cognito, WAF, and Terraform into two production routes.

“The solution uses the following key services:”article, stated
“The architecture exposes two API routes through Amazon API Gateway”article, stated

structured-output-contract (data)

Claude structures OCR output into seven standardized ID fields, followed by validation rules for field formatting and normalization.

“Claude Sonnet 4 then structured the output into 7 standardized fields: document type, date of birth, name, surname, middle name, ID number, and expiry date.”article, stated
“validation rules catch formatting errors that slip through. ID numbers get padded to the correct length based on document type, and dates are standardized to YYYY-MM-DD format.”article, stated

fallback-degradation (resilience)

The ID extraction route uses Rekognition as fallback OCR when Textract confidence is low, avoiding complete failure on difficult ID images.

“If Amazon Textract returns low-confidence results, the system falls back to Amazon Rekognition for OCR.”article, stated
“Amazon Rekognition provides backup extraction when Amazon Textract confidence is low.”article, stated

eval-driven-development (evaluation)

The team iterated through Claude-only, Textract-plus-Claude, and multi-tier OCR designs, using weekly accuracy measurements over 585 images to decide the next architecture.

“The team iterated through three distinct approaches over four weeks, and each failure pointed toward the next improvement.”article, stated
“The following chart shows the weekly accuracy progression across 585 test images.”article, stated

latency-optimization (operations)

Step Functions runs fraud-detection branches in parallel, reducing latency from 6-8 seconds to 3-5 seconds.

“The parallel execution architecture processes images in 3–5 seconds, down from 6–8 seconds when run sequentially.”article, stated
“Serverless enables rapid iteration. The parallel execution in AWS Step Functions cut fraud detection latency by 40% with minimal code changes.”article, stated

cost-aware-routing (operations)

The final design reserves expensive model use for structuring and visual analysis, uses Textract as primary OCR, calls AnalyzeID only when needed, and caches embeddings.

“Start simple, add complexity when metrics demand it. The team achieved a 91% cost reduction by using Amazon Textract as primary OCR instead of Claude for everything.”article, stated
“They called AnalyzeID only when specific fields were missing and cached embeddings for fraud detection.”article, stated

data-quality-loop (data)

Confirmed fraud images are continuously ingested, masked, embedded, and stored to grow the fraud-pattern reference database over time.

“Confirmed fraud images are ingested from Amazon S3 through a Lambda function.”article, stated
“* More training data. Continuous collection of confirmed fraud cases and diverse background patterns will directly improve background similarity recall beyond the current 55% on seen patterns.”article, stated

privacy-preserving-processing (safety)

The production stack uses Cognito/SigV4, WAF, KMS encryption, TLS, and face masking to protect sensitive loan and identity data.

“Authentication uses Amazon Cognito with AWS SigV4 request signing. AWS WAF protects against common web security issues.”article, stated
“Data is encrypted at rest with AWS Key Management Service (AWS KMS) and in transit via TLS 1.2+.”article, stated

Tradeoffs

Separate OCR from LLM structuring

Chose Textract/Rekognition OCR followed by Claude structuring over Claude reading raw ID images directly.

Rationale: OCR services reliably extract sensitive text, while Claude is better used for normalization and structuring after PII-triggering image extraction is avoided.

“The breakthrough came when the team separated OCR from structuring.”article, stated
“This approach worked because Amazon Textract, as a specialized OCR service, doesn’t have the same PII refusal mechanisms as Claude, so it reliably extracted text from every ID image without triggering safety protocols.”article, stated

Use two complementary fraud checks

Chose visual pattern detection plus background similarity over one fraud method.

Rationale: Screen-photo artifacts and fraud-ring background reuse catch different failure modes, and neither method alone is sufficient.

“The fraud detection system uses two complementary methods.”article, stated
“Neither method alone is sufficient, and the system improves as more confirmed fraud cases are added to the database.”article, stated

Weight visual pattern and background similarity equally

Chose 50/50 score weighting over favoring one fraud signal.

Rationale: The article describes equal weighting as the production scoring algorithm for high/medium/legitimate classification.

“The scoring algorithm weighs visual pattern detection (50%) and background similarity (50%) equally.”article, stated
“Scores of 75+ indicate high-confidence fraud, 38–74 indicate medium confidence, and below 38 is classified as legitimate.”article, stated

Use serverless infrastructure for weekly iteration

Chose Lambda, Step Functions, API Gateway, Terraform, and CI/CD over a heavier fixed service architecture.

Rationale: The approach changed weekly during the engagement, so modifying individual functions and deploying without downtime mattered.

“This design lets the team modify individual Lambda functions, test changes immediately, and deploy updates without downtime.”article, stated
“This was critical during a 6-week engagement where the approach changed weekly.”article, stated

Gotchas (what bit them)

The most obvious LLM-only approach failed because the model protected PII.

Root cause: Claude Sonnet 4's built-in privacy safeguards limited extraction from real identity documents, hurting sensitive-field accuracy.

Resolution: The team moved raw OCR to Textract/Rekognition and used Claude only after text extraction for structuring and contextual normalization.

“The core issue was the model’s built-in safety protocols for handling personally identifiable information (PII).”article, stated
“By working with already-extracted text rather than raw ID images, Claude avoided its safety constraints.”article, stated

Traditional OCR struggled with local-language and layout diversity.

Root cause: Documents included English and a local language underrepresented in OCR training data, plus seven ID layouts.

Resolution: The final pipeline combined OCR tools with Claude structuring, document-specific extraction rules, and validation rules.

“Processing documents in both English and a local language proved difficult for traditional OCR systems.”article, stated
“Sun Finance also needed to handle 7 different ID types, each with different layouts and formats.”article, stated

A high fraud-accuracy number hid weak precision/recall for the text-embedding approach.

Root cause: Claude text descriptions of backgrounds preserved enough commonality for accuracy but failed to capture discriminative visual details for fraud-ring matching.

Resolution: The team switched to visual background embeddings, which improved precision and recall substantially.

“Text embeddings (having Claude describe the background, then comparing descriptions) achieved 91% accuracy but only 27.8% precision and 21.7% recall.”article, stated
“Visual embeddings performed far better: 96% accuracy, 80% precision, and 52% recall.”article, stated

Fraud recall remained imperfect by design.

Root cause: Lowering thresholds would catch more fraud but create customer-friction false positives in a lending application.

Resolution: The system uses conservative thresholds, other fraud controls, and a growing confirmed-fraud database to improve recall over time.

“The 59% recall means the system catches about 6 in 10 fraud cases.”article, stated
“The conservative thresholds reflect a business reality: false positives create customer friction, while missed fraud can be caught through other controls.”article, stated

Evaluation

The project used staged experiments for ID extraction, weekly accuracy tracking on 585 ID images, field-level ID metrics, fraud precision/recall/specificity comparisons, text-versus-visual embedding tests, latency measurements, cost comparison, security audit findings, and projected operational impact.

Metrics: overall ID extraction accuracy · field-level name/date/document-type/ID-number accuracy · fraud accuracy · fraud recall · fraud specificity · visual embedding precision and recall · processing latency · cost reduction · manual intervention rate · FTE reduction · security audit findings

4 supporting quotes
“The following chart shows the weekly accuracy progression across 585 test images.”article, implied
“The system was evaluated against 585 ID images:”article, stated
“Visual embeddings performed far better: 96% accuracy, 80% precision, and 52% recall.”article, implied
“The combined end-to-end fraud detection pipeline (visual pattern detection plus background similarity) achieved 81% accuracy with 59% recall and 83% specificity.”article, implied

Outcomes

Sun Finance operates in nine countries, processes one loan request every 0.63 seconds, delivers more than 4 million evaluations monthly, and targeted an 80,000-application-per-month microloan workflow. The project took 107 business days end-to-end and used 585 ID images for evaluation.

4 supporting quotes
“The solution improved extraction accuracy from 79.7% to 90.8%, cut per-document costs by 91%, and reduced processing time from up to 20 hours to under 5 seconds.”article, stated
“The combined end-to-end fraud detection pipeline (visual pattern detection plus background similarity) achieved 81% accuracy with 59% recall and 83% specificity.”article, stated
“* Manual intervention projected to drop from 60% to 30% of applications, cutting the review workload in half.”article, stated
“went live on January 22, 2026.”article, stated