Documents and vision: PDFs, scans and receipts
Notebook· 13.01· 2–3 h· Lesson 110 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Build LangChain standard content blocks for images, PDFs, audio and video, and send the same message to Groq and Gemini.
- Check a multimodal request against provider limits (images per request, size, pages, token cost) before it fails with a 400.
- Route each PDF page: read the text layer when there is one, use a vision model only for scans and pictures.
- Extract typed fields (an invoice, a receipt) from a scan with structured output, on Groq vision and on Gemini's native PDF input.
- Score extractions field by field against ground truth, and compare methods on accuracy, tokens and latency.
- Close the loop in a real workflow: match a photographed receipt to the expense ledger and send mismatches to a human.
Before you start
Lesson 01.02 (images in messages), Lesson 02.03 (structured output) and Module 06 (document loading). Read the module README first.
Python in this lesson
Python guideNew herecsv
