Section 7: Lab: Validation and Business Rules
- Check the 13-digit tax ID format, Buddhist and Gregorian dates and currency
- Check that line items, 7% VAT and the net total add up
- Match against master data such as the vendor list and purchase order numbers
- Lab: write a rule set and an error report for each document
Section 8: Classifying Documents and Extracting Contract Data
- Classify document types automatically before choosing the schema
- Split several documents that were scanned into one file
- Extract parties, dates, value, term and renewal conditions from contracts, with page references
- Lab: classify and extract data from a mixed document set
Section 9: Lab: Human-in-the-Loop Review
- Use confidence and rule results to decide which documents pass automatically and which need a person
- Build a review screen in Streamlit that shows the document image next to the extracted fields
- Record reviewer corrections and use them to improve prompts and rules
- Audit trail: who changed what, when, and why it was approved
Section 10: Measuring Accuracy and Controlling Cost
- Build a ground truth set from documents that people have checked
- Measure field-level accuracy, review rate and time per document
- Cut cost with batching, caching and smaller models for simple documents
- Lab: a report comparing the three approaches on the same document set
Section 11: Automated Pipeline and PDPA
- Receive documents from email, folders or an API and process them through FastAPI
- Connect an n8n workflow that sends results to Google Sheets, a database or a downstream system
- Handle errors, retries and documents that fail processing
- PDPA: mask personal data, control access, set retention periods and run models in-house when needed
Section 12: Workshop: Document AI Capstone
- Choose a brief: vendor invoices, application forms or contracts
- Design the schema, validation rules and the criteria for human review
- Assemble the pipeline from file intake and reading to validation and data export
- Present the accuracy results and a plan for real-world use