AWS ML ★ 86 5 min

Build self-improving document processing using Amazon Bedrock AgentCore

Amazon Bedrock AgentCoreExpert (400)Technical How-to

🔗 https://aws.amazon.com/blogs/machine-learning/build-self-improving-document-processing-using-amazon-bedrock-agentcore/

📌 發票格式年年變?AgentCore 做自學習文件處理

TL;DR:AWS 示範用 8 個協作 agent 打造能自動學習新發票/採購單格式的文件處理系統。

IDC 研究指出,文件相關問題每年讓每位資訊工作者多花 19,732 美元成本,生產力下降 21.3%——問題往往不是文件難懂,而是每換一個供應商的版面,整套樣板就要重新設定一次。

🤔 樣板一改版面就壞,發票越多維護越痛

企業同時收來自數百家供應商的發票時,版面會依發行者而異,而且常常毫無預警地更動。傳統的智慧文件處理(IDP)系統需要替每一種文件格式預先設定樣板、擷取規則與驗證邏輯,一旦版面跑掉就會整套失效。素材指出,員工最多可花 30% 的工時處理文件相關工作,而人工輸入的錯誤率落在 1–4%。

🧩 8 個 agent 分兩條流程線,從分類到學習

這套方案用 Strands Agents(一套開源 agent SDK)建構多 agent workflow graph,跑在 Amazon Bedrock AgentCore 之上,由 8 個專責 agent 分別負責分類、擷取、驗證與學習。部署會建立六個 CloudFormation stack:Core(S3、Cognito、DynamoDB)、Gateway(Lambda 工具、AgentCore Gateway)、Aurora(Amazon Aurora DSQL)、Agent(AgentCore runtime、容器)、UI Orchestrator(API 端點),以及 Modern UI(跑在 CloudFront 上的 React 應用),整個部署約需 15–20 分鐘。

文件素材給出一個具體案例:新供應商 Two Wheel Store 寄來第一張採購單時,流程是這樣走的:

  • Step 1:Matcher agent 在向量庫中搜尋,找不到相似文件,於是把工作導向訓練流程。
  • Step 2:Analyzer agent 用 Amazon Textract 擷取文件的原始文字。
  • Step 3:Instructions agent 依 schema 產生擷取用的 prompt,Extractor agent 據此產出結構化 JSON。
  • Step 4:Validator agent 比對 schema 後驗證失敗——供應商的 SKU 格式(SB-004)和內部格式(AB-SB-004)不一致。
  • Step 5:Instructions Fixer agent 診斷出問題,在擷取 prompt 中加入明確規則:把供應商 SKU 加上 AB- 前綴。
  • Step 6:第二次嘗試,七筆品項全數通過驗證,Save Instructions agent 把修正後的 prompt 存回向量庫。

第一次處理這張單子,從頭到尾耗時 3 分 49 秒。等 Two Wheel Store 的第二張採購單進來,Matcher agent 以 confidence score 3.946(門檻為 3.7)直接比對到先前存下的擷取指令,這次就改走自動化流程,不需要再重新訓練。

📊 一個月處理 1000 份文件,成本估算約 58 美元

以每月 10 份訓練文件、1,000 份處理文件計算(美國東部維吉尼亞區域),估計月成本約 58 美元,其中基礎模型推論約佔整體成本的 85%,平均每份文件約 0.055 美元。各 agent 使用的模型集中設定在設定檔中,可以針對簡單任務選用較便宜的模型。更換模型後,可用 AgentCore Evaluations 確認擷取品質是否仍維持在可接受水準。

⚠️ 範例資料是假的,schema 與規則要自己換

範例使用的是合成的腳踏車公司資料集與模擬 ERP 資料庫,要套用到自己的文件類型,必須自行建立 JSON schema(定義欄位名稱、資料型別,以及每個欄位是文件上明寫還是需要從上下文推斷),也要替換驗證邏輯——寫一個接受擷取 JSON、回傳通過/失敗與錯誤訊息的 Lambda function,再註冊成 AgentCore Gateway 的工具。此外,Orchestrator、Validator、Instructions 等 agent 的 prompt 都寫死了採購單相關用語,換文件類型也要一併調整。

🎯 自動化的是學習迴圈,不是免設定

這套系統真正的價值在於把「遇到新格式 → 驗證失敗 → 修正擷取規則 → 記住」這個迴圈自動化,而不是讓你完全不用設定。對想導入的團隊來說,schema、驗證規則與 prompt 仍需要工程師依據自己的業務邏輯重新打造。

🔗 來源

#AWS #AmazonBedrock #AgentCore #IDP #DocumentProcessing #AIAgents #StrandsAgents #Automation #MachineLearning #CloudComputing

原始資料 AWS ML · 收集於 2026-10-14
來源原標題
Build self-improving document processing using Amazon Bedrock AgentCore
作者
Erik Cordsen
原始標籤
Amazon Bedrock AgentCore · Expert (400) · Technical How-to
原始連結
https://aws.amazon.com/blogs/machine-learning/build-self-improving-document-processing-using-amazon-bedrock-agentcore/

摘要原文

IDC research shows that document-related challenges cost organizations $19,732 for each information worker annually and reduce productivity by 21.3 percent. Organizations receiving invoices from hundreds of suppliers often face layouts that vary by issuer and change without notice. Template-based systems require constant maintenance at this scale. Staff can spend up to 30 percent of their time on document-related tasks, and manual data entry error rates range from 1–4 percent . Conventional intelligent document processing (IDP) solutions address some of this burden, but they require extensive upfront configuration for each document format and break when layouts vary across vendors. In this post, you learn how to build an agentic IDP system using Amazon Bedrock AgentCore that classifies, extracts, validates, and learns from business documents with minimal human intervention. Amazon Bedrock AgentCore is a platform to build, connect, and optimize agents at scale, with any framework or model. Your agents automatically handle new document formats, such as supplier invoices, purchase orders, insurance claims, and loan applications. By the end of this post, you can: Many IDP pipelines require you to define templates, extraction rules, and validation logic for every document format upfront. When a new vendor sends a purchase order with a different layout, the pipeline breaks. This creates three core challenges: An agentic approach addresses these challenges. Instead of static templates, AI agents analyze each document, generate extraction instructions, validate results, and learn from corrections automatically. Over time, your system builds a knowledge base of document formats, so you process similar documents with minimal additional configuration. In this solution, eight specialized agents collaborate across two graph-based workflows running on Amazon Bedrock AgentCore. The following diagram shows the multi-agent workflow graph built using Strands Agents , an open source SDK for building AI agents. Figure 1: Multi-agent orchestration workflow graph The following diagram shows the infrastructure architecture for the solution. Figure 2: Agentic IDP infrastructure architecture on AWS Follow these steps to deploy the solution infrastructure and web UI to your AWS account. To deploy this solution, you must have: This deploys six AWS CloudFormation stacks: Core (S3, Cognito, DynamoDB), Gateway (Lambda tools, AgentCore Gateway), Aurora (Amazon Aurora DSQL), Agent (AgentCore runtime, containers), UI Orchestrator (API endpoints), and Modern UI (React app on Amazon CloudFront ). Deployment takes approximately 15–20 minutes. After deployment, you receive an email with the CloudFront URL, username, and temporary password. Suppose you upload the first purchase order from a new retailer, Two Wheel Store. The Matcher agent searches the vector store, finds no similar document, and routes the job through the training workflow. The Analyzer agent uses Amazon Textract to extract the raw document text: The Instructions agent generates extraction prompts from the schema, and the Extractor agent produces structured JSON: The Validator agent checks the result against the schema and fails : The vendor’s SKU format ( SB-004 ) doesn’t match Acme Bikes’ internal format ( AB-SB-004 ). The Instructions Fixer agent diagnoses the mismatch and adds an explicit SKU transformation rule to the extraction prompt: prefix vendor SKUs with AB- . On the second pass, the seven line items validate successfully, and the Save Instructions agent persists the refined prompt to the vector store. End-to-end time for this first run: 3 minutes 49 seconds. When a second purchase order from Two Wheel Store arrives, the Matcher agent finds the stored instructions from the first run with a confidence score of 3.946 (threshold: 3.7) and routes the job through the automation workflow: The dashboard includes a chat interface for troubleshooting: The system improves over time through two feedback loops: When changing models, use AgentCore Evaluations , a capability of Amazon Bedrock AgentCore, to confirm that extraction quality remains acceptable. The solution already uses AgentCore Observability, so it has the required instrumentation. You pay only for what you use, because the solution runs on serverless and on-demand resources with no idle costs. For a workload of 10 training documents and 1,000 processed documents each month in US East (N. Virginia), the estimated cost is approximately $58 per month. Foundation model (FM) inference through Amazon Bedrock represents approximately 85 percent of the total cost, at roughly $0.055 per document. Actual cost depends largely on the models assigned to each agent. Model choices are centralized in agents/orchestratorgraph/utils/config.py , so you can use lower-cost models for simpler tasks and stronger models where needed. For detailed pricing, refer to the Amazon Bedrock pricing page. You get a purchase order processing use case with a synthetic bike company dataset, a pre-built JSON schema, and a validation Lambda function that checks extracted data against product and vendor records in a mock ERP database. To process your own documents, you must replace the included schemas and validation logic with your own. Create a JSON schema that defines the fields you want to extract for each document type. The sample purchase order schema in agents/orchestratorgraph/doc_schema/purchase_order_schema.json provides a reference. Your schema should specify field names, data types, and whether each field is explicitly stated in the document or inferred from context. The included validator checks purchase order data against synthetic vendor and product tables in Aurora DSQL. Your production implementation requires a validation process tailored to your business rules. For example: To add a new validator, create a Lambda function that accepts extracted JSON and returns a pass/fail result with detailed error messages, then register it as a tool in AgentCore Gateway. Refer to gateway/tools/po_validator_tool/ for the implementation pattern. The agent prompts in agents/orchestratorgraph/prompts/ reference purchase order terminology. Update these prompts to reflect your document types and extraction requirements. The Orchestrator agent, Validator agent, and Instructions agent each contain document-type-specific language that you should adapt. Keep these recommendations in mind as you train and operate your agentic IDP system. Important: Before running cleanup, export the data you want to retain. The destroy.py script permanently deletes processed documents (S3), job history (DynamoDB), validation data (Aurora DSQL), and learned extraction instructions (vector store). To avoid ongoing charges, remove the deployed resources: Verify that the six CloudFormation stacks are deleted on the console: AgenticIDP-Core-Dev, AgenticIDP-Gateway-Dev, AgenticIDP-Aurora-Dev, AgenticIDP-Agent-Dev, AgenticIDP-UIOrchestr-Dev, and AgenticIDP-ModernUI-Dev. In this post, you learned how to build a self-improving document processing system using Amazon Bedrock AgentCore, where specialized AI agents collaborate to classify, extract, validate, and learn from business documents. This agentic approach adapts to new document formats automatically and improves accuracy over time through feedback loops, replacing manual template configuration with autonomous learning. To learn more about the services and patterns used in this post, refer to the following resources: For expert guidance on building document processing solutions, AWS Professional Services and AWS Partners can help.

由 claude-code/sonnet 自動生成