LA24AI

Courses / Learn from zero

Extract document fields with AI and audit every value

Goal: feed a made-up invoice to a text AI assistant, request structured fields, and verify every number and omission. Do not upload real receipts, customer addresses or sensitive documents in this exercise. The JSON shown below is a reference example, not a claimed live run.

Five connected lessons with worked examples and exercises

Teaching examples are not claimed live model runs; review each lesson’s limits.

Download practice worksheet ↓
Start at lesson one ↗
Lesson 1 / 5

Lesson 1: Define the field list and the original text

If you ask someone to sort receipts without specifying the fields, “amount” might mean a unit price or a total. Give AI this fictional source: Practice invoice INV-001. Item: notebook. Quantity: 2. Unit price: 3 units. Total tax: 1 unit. Invoice total: 7 units. Request: Extract only invoice_id,item,quantity,unit_price,tax,total. Do not invent a seller, currency, or date. Use null for fields absent from the source.
The expected values are INV-001, notebook, two, three, one and seven. Practice: remove the tax line. A careful response must mark it missing rather than insert zero. Good extraction starts with an exact source and a precise task.

Review question: Why specify fields and source text for the model?

To prevent guessing missing seller, currency or invoice structure.

Next lesson ↗
Lesson 2 / 5

Lesson 2: Ask for valid JSON, not persuasive prose

“This looks like a normal invoice” is not a format a spreadsheet can validate. Prompt: Return one valid JSON object with exactly these six keys. Preserve string IDs, use numbers for quantity and amounts, and null for missing values. No commentary inside JSON.
Reference output: {"invoice_id":"INV-001","item":"notebook","quantity":2,"unit_price":3,"tax":1,"total":7}. Practice: paste the response into the site's JSON validator. A trailing comma or unquoted key invalidates JSON. However, even perfectly formatted JSON can contain false values; formatting is just the first check.

Review question: Does syntactically valid JSON mean the values are true?

No; source comparison and arithmetic checks are still required.

Next lesson ↗
Lesson 3 / 5

Lesson 3: Independently verify extracted numbers

Calculate 2 × 3 = 6, then 6 + 1 = 7. Ask the assistant: Compare the JSON numbers with the original text and arithmetic. Report mismatches; never silently overwrite the original document.
An invented failure might be total=8 while the original says seven. This must be flagged even if AI produces a convincing explanation. Exercise: alter the quantity to three while leaving the source's total as seven. Now source and arithmetic conflict. Do not decide the “true” figure from inference alone; record the discrepancy for a human to resolve. AI is a checker, not a replacement receipt.

Review question: What is the sample invoice calculation?

Two notebooks times three plus one in total tax equals seven.

Next lesson ↗
Lesson 4 / 5

Lesson 4: Keep unreadable data distinct from zero

Suppose a scanned tax field is illegible. A model may be tempted to guess. Change the practice source to say Tax: unreadable and request: Return tax=null and needs_review=["tax"]. Never convert uncertainty to zero.
Expected fragment: {"tax":null,"needs_review":["tax"]}. Zero is a definite number; null represents absence of reliable information. Practice: explain why a missing tax is not necessarily zero tax. If you later use a genuine OCR engine, compare the extracted value with the document image. OCR and AI can misread a digit, and repeated checking is worth more than confidence in the generated wording.

Review question: How should an unreadable tax field be represented?

As null and a review flag, not as a guessed zero.

Next lesson ↗
Lesson 5 / 5

Lesson 5: Deliver an auditable extraction sheet

Your finished table should show each field, source text, AI suggestion, comparison result, and review status. Label the source fictional and the JSON reference educational. The deliverable is a set of values with visible evidence and flags, not a generic “conversion successful” claim.
Ask AI: List differences between the quoted invoice and this extracted object. Only label a field verified if directly supported or calculated correctly from known figures. Then audit its answer yourself. Outcome: you can use AI for structured extraction without treating a tidy answer as proof of correctness.

Review question: What makes an AI extraction auditable?

Showing the input source, each extracted value, a comparison and a review status.

What did you accomplish?

Finish only when you can complete the final exercise and explain each step’s outcome or limits.

Topic-specific worked final project

Practice input

Fictional INV-001: two notebooks at three units each, one unit total tax and invoice total seven.

Reference deliverable

AI prompt: “Extract invoice_id,item,quantity,unit_price,tax,total as valid JSON with no invented fields.”
{"invoice_id":"INV-001","item":"notebook","quantity":2,"unit_price":3,"tax":1,"total":7}
Independent check: 2×3+1=7.
If tax is unreadable, use null and a review flag rather than inventing zero.

How do we judge success?

Six grounded fields, valid JSON, separate arithmetic review, explicit unknowns, fictional data only.