What's new#
Page classification results now include the model's reasoning for each classification decision. When pages are classified, you'll receive both the classification labels and a text explanation of why those labels were chosen.
Why it matters#
- Debug classification errors - understand why pages got unexpected labels
- Improve prompt engineering - see how the model interprets your classification prompts
- Build confidence - verify the model's decision-making process
- Iterate faster - refine prompts based on reasoning insights
Highlights#
- Detailed reasoning for each page classification
- Helps identify prompt engineering opportunities
- Useful for complex documents where classification logic isn't obvious
- No performance impact - reasoning is generated alongside classification
How to use#
Reasoning is automatically included in classification results:
1doc_ai = DocumentAI()
2
3result = doc_ai.parse_and_wait(
4 file="complex_document.pdf",
5 page_classification=PageClassificationConfig(
6 page_classes=["Terms", "Transactions", "Account_Info"]
7 )
8)
9
10for page in result.pages:
11 print(f"Page {page.page_number}:")
12 print(f"Classifications: {page.classifications}")
13 print(f"Reasoning: {page.classification_reasoning}")
Example output:
1{
2"page_class": "Terms",
3"page_numbers": [
4 2
5],
6"classification_reasons": {
7 "2": "The page provides instructions on how to balance an account, which involves managing account information and balances. It also details how to track and reconcile deposits and withdrawals, directly relating to transactions. Furthermore, it outlines terms and procedures for resolving errors, understanding billing rights, and calculating finance charges, which fall under terms and conditions."
8}
9},
Use cases#
- Prompt debugging - See why certain pages aren't getting expected classifications
- Model validation - Verify the classification logic makes sense for your use case
- Documentation - Generate explanations for downstream users about document structure
- Quality assurance - Spot-check model reasoning on complex documents
Status#
✅ Live now. Classification reasoning included automatically in all page classification results.