{
  "generated_at": "2026-09-10T20:01:43+08:00",
  "models": [
    "qwen/qwen2.5-vl-72b-instruct"
  ],
  "usage": {
    "prompt_tokens": 10049,
    "completion_tokens": 1986,
    "cost_usd": 0.009718
  },
  "per_document": {
    "work_order": {
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "usage": {
        "prompt_tokens": 3335,
        "completion_tokens": 390,
        "cost_usd": 0.0029556
      },
      "seconds": 15.9
    },
    "customs": {
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "usage": {
        "prompt_tokens": 3338,
        "completion_tokens": 419,
        "cost_usd": 0.002987
      },
      "seconds": 10.7
    },
    "coa": {
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "usage": {
        "prompt_tokens": 3376,
        "completion_tokens": 1177,
        "cost_usd": 0.0037754
      },
      "seconds": 24.9
    }
  },
  "field_count": 50,
  "summary": {
    "error": 3,
    "warn": 1,
    "review": 1
  },
  "findings": [
    {
      "severity": "error",
      "rule": "lot_consistency",
      "title": "批號不一致",
      "fields": [
        "work_order.lot_no",
        "customs.lot_no"
      ],
      "values": {
        "work_order.lot_no": "LT-2603-0472",
        "customs.lot_no": "LT-2603-0478"
      },
      "message": "生產製令 Work Order為「LT-2603-0472」，進口報關單為「LT-2603-0478」，兩者不一致。"
    },
    {
      "severity": "error",
      "rule": "quantity_match",
      "title": "製令實際產量與報關數量不符",
      "fields": [
        "work_order.actual_qty",
        "customs.quantity"
      ],
      "values": {
        "work_order.actual_qty": "4850",
        "customs.quantity": "5000"
      },
      "message": "製令實際產量 4850 kg，報關單申報數量 5000，差 +150。"
    },
    {
      "severity": "error",
      "rule": "coa_spec",
      "title": "COA 燒失量 實測值超出規格",
      "fields": [
        "coa.items[3].spec",
        "coa.items[3].measured",
        "coa.items[3].judgement"
      ],
      "values": {
        "coa.items[3].spec": "≤ 1.0",
        "coa.items[3].measured": "1.24",
        "coa.items[3].judgement": "PASS"
      },
      "message": "實測 1.24 超出規格 ≤ 1.0，但判定欄寫 PASS，判定欄與實測值矛盾。"
    },
    {
      "severity": "warn",
      "rule": "coa_overall",
      "title": "COA 總判定與檢驗項目矛盾",
      "fields": [
        "coa.overall"
      ],
      "values": {
        "coa.overall": "合格"
      },
      "message": "至少一項檢驗超出規格，但總判定為「合格」。"
    },
    {
      "severity": "review",
      "rule": "low_confidence",
      "title": "生產製令 Work Order / 工時 (h) 需人工確認",
      "fields": [
        "work_order.work_hours"
      ],
      "values": {
        "work_order.work_hours": "7.5"
      },
      "message": "手寫欄位辨識為「7.5」，辨識備註提到字跡模糊或不確定。 模型備註：手寫數字略顯模糊，但可辨認為7.5"
    }
  ],
  "accuracy": {
    "printed": {
      "correct": 48,
      "total": 48,
      "rate": 1.0
    },
    "handwritten": {
      "correct": 2,
      "total": 2,
      "rate": 1.0
    },
    "overall": {
      "correct": 50,
      "total": 50,
      "rate": 1.0
    },
    "mismatches": []
  },
  "planted": {
    "planted": [
      {
        "id": "qty_mismatch",
        "description": "製令實際產量 4850 kg 與報關單數量 5000 KGM 不符",
        "caught": true,
        "findings": [
          "製令實際產量與報關數量不符"
        ]
      },
      {
        "id": "coa_out_of_spec",
        "description": "COA 燒失量實測 1.24 % 超出規格 ≤ 1.0 %，判定欄卻寫 PASS",
        "caught": true,
        "findings": [
          "COA 燒失量 實測值超出規格"
        ]
      },
      {
        "id": "lot_mismatch",
        "description": "報關單批號 LT-2603-0478 與製令／COA 的 LT-2603-0472 差一字",
        "caught": true,
        "findings": [
          "批號不一致"
        ]
      }
    ],
    "blurry": {
      "id": "blurry_hours",
      "description": "製令工時欄手寫筆跡淡且筆畫重疊，應標記需人工確認",
      "caught": true,
      "findings": [
        "生產製令 Work Order / 工時 (h) 需人工確認"
      ]
    }
  },
  "documents": {
    "work_order": {
      "file": "/Users/crow/ootobai/code/doc-check-poc/samples/work_order.png",
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "structured_output": true,
      "seconds": 15.9,
      "usage": {
        "prompt_tokens": 3335,
        "completion_tokens": 390,
        "cost_usd": 0.0029556
      },
      "attempts": [],
      "fields": {
        "wo_no": {
          "value": "WO-260305-017",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "issue_date": {
          "value": "2026-03-05",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "line": {
          "value": "B2",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "product_name": {
          "value": "二氧化矽微粉 SF-800",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "lot_no": {
          "value": "LT-2603-0472",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "spec": {
          "value": "25 kg/袋",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "planned_qty": {
          "value": "5000",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "actual_qty": {
          "value": "4850",
          "confidence": 0.9,
          "source": "handwritten",
          "note": ""
        },
        "work_hours": {
          "value": "7.5",
          "confidence": 0.8,
          "source": "handwritten",
          "note": "手寫數字略顯模糊，但可辨認為7.5"
        }
      }
    },
    "customs": {
      "file": "/Users/crow/ootobai/code/doc-check-poc/samples/customs.png",
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "structured_output": true,
      "seconds": 10.7,
      "usage": {
        "prompt_tokens": 3338,
        "completion_tokens": 419,
        "cost_usd": 0.002987
      },
      "attempts": [],
      "fields": {
        "decl_no": {
          "value": "AW/26/0305/1187",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "decl_date": {
          "value": "2026-03-12",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "importer": {
          "value": "宏鼎化工股份有限公司",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "product_name": {
          "value": "二氧化矽微粉 SF-800",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "lot_no": {
          "value": "LT-2603-0478",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "hs_code": {
          "value": "2811.22.00",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "quantity": {
          "value": "5000",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "unit_price": {
          "value": "2.35",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "amount": {
          "value": "11750.00",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "port_of_loading": {
          "value": "NINGBO, CN",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        }
      }
    },
    "coa": {
      "file": "/Users/crow/ootobai/code/doc-check-poc/samples/coa.png",
      "model": "qwen/qwen2.5-vl-72b-instruct",
      "structured_output": true,
      "seconds": 24.9,
      "usage": {
        "prompt_tokens": 3376,
        "completion_tokens": 1177,
        "cost_usd": 0.0037754
      },
      "attempts": [],
      "fields": {
        "supplier": {
          "value": "東晟材料股份有限公司",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "product_name": {
          "value": "二氧化矽微粉 SF-800",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "lot_no": {
          "value": "LT-2603-0472",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "mfg_date": {
          "value": "2026-03-05",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "test_date": {
          "value": "2026-03-06",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        },
        "overall": {
          "value": "合格",
          "confidence": 1.0,
          "source": "printed",
          "note": ""
        }
      },
      "items": [
        {
          "item": {
            "value": "SiO2 含量",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "unit": {
            "value": "%",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "spec": {
            "value": "≥ 99.5",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "measured": {
            "value": "99.7",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "judgement": {
            "value": "PASS",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          }
        },
        {
          "item": {
            "value": "水分",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "unit": {
            "value": "%",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "spec": {
            "value": "≤ 0.5",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "measured": {
            "value": "0.32",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "judgement": {
            "value": "PASS",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          }
        },
        {
          "item": {
            "value": "粒徑 D50",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "unit": {
            "value": "μm",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "spec": {
            "value": "0.8 ~ 1.2",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "measured": {
            "value": "1.05",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "judgement": {
            "value": "PASS",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          }
        },
        {
          "item": {
            "value": "燒失量",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "unit": {
            "value": "%",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "spec": {
            "value": "≤ 1.0",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "measured": {
            "value": "1.24",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "judgement": {
            "value": "PASS",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          }
        },
        {
          "item": {
            "value": "pH 值 (10% 水溶液)",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "unit": {
            "value": "-",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "spec": {
            "value": "6.0 ~ 8.0",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "measured": {
            "value": "7.1",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          },
          "judgement": {
            "value": "PASS",
            "confidence": 1.0,
            "source": "printed",
            "note": ""
          }
        }
      ]
    }
  },
  "doc_labels": {
    "work_order": "生產製令 Work Order",
    "customs": "進口報關單",
    "coa": "檢驗報告 COA"
  },
  "labels": {
    "work_order": {
      "wo_no": "製令號",
      "issue_date": "製令日期",
      "line": "生產線",
      "product_name": "品名",
      "lot_no": "批號",
      "spec": "包裝規格",
      "planned_qty": "計畫數量 (kg)",
      "actual_qty": "實際產量 (kg)",
      "work_hours": "工時 (h)"
    },
    "customs": {
      "decl_no": "報單號碼",
      "decl_date": "報關日期",
      "importer": "納稅義務人",
      "product_name": "品名",
      "lot_no": "批號",
      "hs_code": "稅則號別",
      "quantity": "數量 (KGM)",
      "unit_price": "單價 (USD)",
      "amount": "金額 (USD)",
      "port_of_loading": "起運口岸"
    },
    "coa": {
      "supplier": "供應商",
      "product_name": "品名",
      "lot_no": "批號",
      "mfg_date": "製造日期",
      "test_date": "檢驗日期",
      "overall": "總判定"
    }
  },
  "item_labels": {
    "item": "檢驗項目",
    "unit": "單位",
    "spec": "規格",
    "measured": "實測值",
    "judgement": "判定"
  },
  "field_labels": {
    "work_order.wo_no": "生產製令 Work Order / 製令號",
    "work_order.issue_date": "生產製令 Work Order / 製令日期",
    "work_order.line": "生產製令 Work Order / 生產線",
    "work_order.product_name": "生產製令 Work Order / 品名",
    "work_order.lot_no": "生產製令 Work Order / 批號",
    "work_order.spec": "生產製令 Work Order / 包裝規格",
    "work_order.planned_qty": "生產製令 Work Order / 計畫數量 (kg)",
    "work_order.actual_qty": "生產製令 Work Order / 實際產量 (kg)",
    "work_order.work_hours": "生產製令 Work Order / 工時 (h)",
    "customs.decl_no": "進口報關單 / 報單號碼",
    "customs.decl_date": "進口報關單 / 報關日期",
    "customs.importer": "進口報關單 / 納稅義務人",
    "customs.product_name": "進口報關單 / 品名",
    "customs.lot_no": "進口報關單 / 批號",
    "customs.hs_code": "進口報關單 / 稅則號別",
    "customs.quantity": "進口報關單 / 數量 (KGM)",
    "customs.unit_price": "進口報關單 / 單價 (USD)",
    "customs.amount": "進口報關單 / 金額 (USD)",
    "customs.port_of_loading": "進口報關單 / 起運口岸",
    "coa.supplier": "檢驗報告 COA / 供應商",
    "coa.product_name": "檢驗報告 COA / 品名",
    "coa.lot_no": "檢驗報告 COA / 批號",
    "coa.mfg_date": "檢驗報告 COA / 製造日期",
    "coa.test_date": "檢驗報告 COA / 檢驗日期",
    "coa.overall": "檢驗報告 COA / 總判定",
    "coa.items[0].item": "檢驗報告 COA / 第 1 項 檢驗項目",
    "coa.items[0].unit": "檢驗報告 COA / 第 1 項 單位",
    "coa.items[0].spec": "檢驗報告 COA / 第 1 項 規格",
    "coa.items[0].measured": "檢驗報告 COA / 第 1 項 實測值",
    "coa.items[0].judgement": "檢驗報告 COA / 第 1 項 判定",
    "coa.items[1].item": "檢驗報告 COA / 第 2 項 檢驗項目",
    "coa.items[1].unit": "檢驗報告 COA / 第 2 項 單位",
    "coa.items[1].spec": "檢驗報告 COA / 第 2 項 規格",
    "coa.items[1].measured": "檢驗報告 COA / 第 2 項 實測值",
    "coa.items[1].judgement": "檢驗報告 COA / 第 2 項 判定",
    "coa.items[2].item": "檢驗報告 COA / 第 3 項 檢驗項目",
    "coa.items[2].unit": "檢驗報告 COA / 第 3 項 單位",
    "coa.items[2].spec": "檢驗報告 COA / 第 3 項 規格",
    "coa.items[2].measured": "檢驗報告 COA / 第 3 項 實測值",
    "coa.items[2].judgement": "檢驗報告 COA / 第 3 項 判定",
    "coa.items[3].item": "檢驗報告 COA / 第 4 項 檢驗項目",
    "coa.items[3].unit": "檢驗報告 COA / 第 4 項 單位",
    "coa.items[3].spec": "檢驗報告 COA / 第 4 項 規格",
    "coa.items[3].measured": "檢驗報告 COA / 第 4 項 實測值",
    "coa.items[3].judgement": "檢驗報告 COA / 第 4 項 判定",
    "coa.items[4].item": "檢驗報告 COA / 第 5 項 檢驗項目",
    "coa.items[4].unit": "檢驗報告 COA / 第 5 項 單位",
    "coa.items[4].spec": "檢驗報告 COA / 第 5 項 規格",
    "coa.items[4].measured": "檢驗報告 COA / 第 5 項 實測值",
    "coa.items[4].judgement": "檢驗報告 COA / 第 5 項 判定"
  },
  "implementation_notes": [
    "<strong>辨識</strong>：每份單據一次視覺語言模型呼叫（OpenRouter，模型 <code>qwen/qwen2.5-vl-72b-instruct</code>），以嚴格 JSON schema 回傳每個欄位的值、信心 0–1、印刷／手寫來源與備註。本頁三份文件共 12035 tokens、US$0.0097，平均每份 US$0.0032；換成 PaddleOCR 等本地 OCR 做第一層、只把低信心欄位送模型，成本可再降。",
    "<strong>勾稽</strong>：規則引擎是純函式，不靠模型：批號與品名跨單一致、製令實際產量對報關數量、COA 實測值對規格上下限並與判定欄交叉比對、報關金額＝數量×單價、任一欄位信心低於 0.7 或模型自陳模糊即列為需人工確認。規則可依客戶表單增刪，每條規則都有單元測試。",
    "<strong>準確率評估</strong>：合成單據附有標準答案，印刷體與手寫體分開統計命中率；正式導入時以客戶提供的歷史單據＋人工標註建立同樣的對照集，持續量測。低信心欄位一律送人工，校對介面即本頁的原圖對照，人工修正後回寫，作為後續調整 prompt 與規則的樣本。",
    "<strong>輸出</strong>：report.json（API 回傳格式）、report.xlsx（擷取值＋差異報告兩個工作表）、本靜態頁。正式版本可改成每批上傳後自動產生 PDF 差異報告並經 API 推回 ERP。"
  ]
}
