GenAI that earns its keep: receipt OCR, text-to-SQL and PII scanning
Three GenAI builds tracked by unit cost: receipt OCR at 40% lower cost, text-to-SQL for $700, and an LLM PII scanner at $0.0002 per column.
Data engineer, designer and builder
- GPT-4o
- LLM APIs
- Dify
- AWS Lambda
- API Gateway
- Python
- Redshift
Context
Three different problems with the same shape: a manual or rule-based step that an LLM could replace, if the cost per call stayed small. I treated unit cost as a design requirement from the first prototype.
Role
I designed and built all three, as the data engineer on each.
Approach
- Receipt OCR. Version 1 chained classic OCR with hand-written post-processing to correct dates, merchants, items and prices. Version 2 replaced it with GPT-4o plus named-entity recognition, which also reads cut-off text and classifies icons.
- Text-to-SQL audience sizing. A conversational app on Dify with chain-of-thought SQL generation over a survey datamart. Dify had no database connector, so I wrote a small middleware on Lambda and API Gateway.
- LLM PII scanner. Scans a data lake’s metadata and data samples through an LLM classification service, with pruning that skips columns unlikely to hold personal data.
Result
Receipt OCR: accuracy up 2–10% and cost per receipt down 40%. The text-to-SQL proof of concept was delivered in 3 months for $700. The PII scanner costs about $0.0002 and 2 seconds per column; scanning an entire 85,000-table lake would cost roughly $269, and pruning halved the columns to scan.
What I’d do differently
Version 1 of the OCR spent most of its code on correcting what the OCR got wrong. I would test an LLM-based extractor first, before writing that post-processing at all.