Amazon Augmented AI (A2I)
Amazon Augmented AI (A2I) คือบริการที่ช่วยเพิ่ม human review เข้าไปใน ML prediction workflows เมื่อระบบ AI มีความมั่นใจต่ำ หรือเมื่อมีความจำเป็นตามกฎหมายหรือนโยบายที่ต้องมีมนุษย์ตรวจสอบ A2I ช่วยให้องค์กรสร้าง Human-in-the-Loop workflows ที่ combine AI automation กับ human judgment อย่างลงตัว
บริการนี้ integrate กับ Amazon Textract (อ่านเอกสาร), Amazon Rekognition (วิเคราะห์ภาพ), Amazon SageMaker (custom ML models) และ Amazon Bedrock (generative AI) ได้โดยตรง ทำให้เพิ่ม human review เข้าไปใน AI pipeline ได้อย่างง่ายดาย รองรับ workforce 3 ประเภทคือ private workforce (พนักงานของคุณ), Amazon Mechanical Turk (crowd workers) และ AWS Marketplace vendors
AWS Docs: https://docs.aws.amazon.com/augmented-ai/2019-11-07/APIReference/Welcome.html
สถาปัตยกรรม
ฟีเจอร์หลัก
Built-In Task Types (Textract Forms, Rekognition Moderation)
มี task types สำเร็จรูปสำหรับ:
- Amazon Textract: ตรวจสอบผลการสกัดข้อมูลจากฟอร์มและเอกสาร เมื่อ confidence score ต่ำกว่า threshold
- Amazon Rekognition Content Moderation: ตรวจสอบภาพที่ AI ไม่แน่ใจว่าเหมาะสมหรือไม่
- รองรับ custom task types สำหรับทุก ML use case ที่ต้องการ human review
Custom Task Types for Any ML Use Case
สร้าง custom Human Review workflow สำหรับ ML predictions ใดๆ ก็ได้ ไม่ว่าจะเป็น NLP classification, sentiment analysis, entity extraction, image classification หรือ decision recommendations จาก custom models
Human Review Workflows
กำหนด workflow logic ว่า predictions ไหนควรส่งให้ human review โดยอัตโนมัติ เช่น ทุก prediction ที่ confidence < threshold, random sampling เพื่อ quality check, หรือ predictions ที่ fall ใน specific categories
Worker Task Templates (UI)
สร้าง custom UI templates ด้วย Liquid template language หรือ HTML สำหรับแสดงงานให้ human workers ทำ แสดงข้อมูล original input, AI prediction และ interface สำหรับให้ human ตัดสินใจ
Private Workforce (Your Employees)
ใช้พนักงานภายในองค์กรเป็น reviewers โดยสร้าง user pool ผ่าน Amazon Cognito หรือ OIDC เหมาะสำหรับข้อมูล sensitive ที่ไม่สามารถส่งออกนอกองค์กรได้ ไม่มีค่าใช้จ่ายเพิ่มเติมสำหรับ A2I (จ่ายเฉพาะ SageMaker Ground Truth)
Amazon Mechanical Turk
ใช้ crowd workforce ของ Amazon Mechanical Turk สำหรับงาน annotation ขนาดใหญ่ที่ข้อมูลไม่ sensitive เหมาะสำหรับ scale ออกได้รวดเร็วโดยไม่ต้องจ้างพนักงานเพิ่ม
Third-Party Vendor Workforce
ใช้ vendor บุคคลที่สามใน AWS Marketplace ที่มี domain expertise เช่น medical annotation, legal document review หรือ multilingual content moderation เหมาะสำหรับงานที่ต้องการความเชี่ยวชาญเฉพาะทาง
Confidence Threshold Routing (Review Low-Confidence Only)
ตั้ง confidence threshold เพื่อส่งเฉพาะ predictions ที่ไม่มั่นใจไปให้ human review ทำให้ลดภาระงานของ reviewers โดยให้ AI จัดการ cases ที่ชัดเจน และ human จัดการเฉพาะ edge cases
Audit Review
ส่ง predictions ที่ AI มั่นใจแล้วไปให้ human review แบบ random sampling เพื่อ audit quality ของ ML model ตรวจสอบว่า model ยังทำงานได้ถูกต้องและไม่ได้ bias โดยไม่ต้องรอ complaints จากลูกค้า
Integration with Textract, Rekognition, SageMaker, Bedrock
เชื่อมต่อกับ AWS AI services หลักได้โดยตรงผ่าน built-in integrations ลด development time ในการ implement human review loop
การติดตั้งและการตั้งค่า
เปิดใช้งานผ่าน Console
- เข้า AWS Console > Amazon A2I
- สร้าง Human Review Workflow (Human Task UI + Workforce + Conditions)
- สร้าง Worker Task Template (UI สำหรับ reviewers)
- กำหนด Workforce (Private, Mechanical Turk, หรือ Vendor)
- Integrate กับ ML pipeline ผ่าน SDK
- Monitor review results และ download labeled data
ติดตั้ง SDK
pip install boto3
IAM Permissions ที่จำเป็น
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateFlowDefinition",
"sagemaker:DescribeFlowDefinition",
"sagemaker:StartHumanLoop",
"sagemaker:DescribeHumanLoop",
"sagemaker:ListHumanLoops",
"s3:GetObject",
"s3:PutObject"
],
"Resource": "*"
}
]
}
Worker Task Template (HTML Liquid)
<!-- Template สำหรับ document review -->
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
<crowd-form>
<crowd-classifier
name="document_type"
categories='["Invoice", "Contract", "Receipt", "Other"]'
header="Please review this document extraction"
>
<classification-target>
<h3>Original Document</h3>
<img src="{{ task.input.document_url }}" style="max-width: 600px;">
<h3>AI Extracted Fields</h3>
<table border="1">
<tr>
<th>Field</th>
<th>AI Value</th>
<th>Confidence</th>
</tr>
{% for field in task.input.extracted_fields %}
<tr>
<td>{{ field.name }}</td>
<td>{{ field.value }}</td>
<td style="color: {% if field.confidence < 0.8 %}red{% else %}green{% endif %}">
{{ field.confidence | times: 100 | round }}%
</td>
</tr>
{% endfor %}
</table>
<h3>Please verify the extracted information and correct if needed:</h3>
</classification-target>
<full-instructions header="Review Instructions">
<p>1. ตรวจสอบว่าข้อมูลที่ AI สกัดออกมาถูกต้องหรือไม่</p>
<p>2. แก้ไขข้อมูลที่ผิด</p>
<p>3. เลือกประเภทเอกสาร</p>
</full-instructions>
<short-instructions>
ตรวจสอบและแก้ไขข้อมูลที่ AI สกัดออกมา
</short-instructions>
</crowd-classifier>
</crowd-form>
วิธีใช้งาน
สร้าง Human Review Workflow
import boto3
import json
sagemaker = boto3.client('sagemaker', region_name='ap-southeast-1')
a2i_runtime = boto3.client('sagemaker-a2i-runtime', region_name='ap-southeast-1')
# สร้าง flow definition (human review workflow)
flow_response = sagemaker.create_flow_definition(
FlowDefinitionName='document-review-workflow',
HumanLoopConfig={
'WorkteamArn': 'arn:aws:sagemaker:ap-southeast-1:123456789:workteam/private-crowd/my-reviewers',
'HumanTaskUiArn': 'arn:aws:sagemaker:ap-southeast-1:123456789:human-task-ui/document-review',
'TaskTitle': 'ตรวจสอบการสกัดข้อมูลจากเอกสาร',
'TaskDescription': 'กรุณาตรวจสอบและแก้ไขข้อมูลที่ AI สกัดออกมาจากเอกสาร',
'TaskCount': 1, # จำนวน reviewers ต่อ task
'TaskAvailabilityLifetimeInSeconds': 3600, # 1 ชั่วโมง
'TaskTimeLimitInSeconds': 600 # 10 นาทีต่อ task
},
OutputConfig={
'S3OutputPath': 's3://my-bucket/a2i-outputs/'
},
RoleArn='arn:aws:iam::123456789:role/A2IRole'
)
flow_definition_arn = flow_response['FlowDefinitionArn']
Integrate กับ Amazon Textract
import boto3
import json
import uuid
textract = boto3.client('textract', region_name='ap-southeast-1')
a2i_runtime = boto3.client('sagemaker-a2i-runtime', region_name='ap-southeast-1')
def process_document_with_human_review(document_s3_key, confidence_threshold=0.85):
"""สกัดข้อมูลจากเอกสาร ถ้า confidence ต่ำส่งให้ human review"""
# สกัดข้อมูลด้วย Textract
textract_response = textract.analyze_document(
Document={
'S3Object': {
'Bucket': 'my-documents-bucket',
'Name': document_s3_key
}
},
FeatureTypes=['FORMS']
)
# ตรวจสอบ confidence ของแต่ละ field
extracted_fields = []
needs_review = False
for block in textract_response['Blocks']:
if block['BlockType'] == 'KEY_VALUE_SET' and block.get('EntityTypes', []) == ['KEY']:
confidence = block.get('Confidence', 100) / 100
field_name = block.get('Text', '')
# ดึง value
for relationship in block.get('Relationships', []):
if relationship['Type'] == 'VALUE':
for value_id in relationship['Ids']:
for value_block in textract_response['Blocks']:
if value_block['Id'] == value_id:
field_value = value_block.get('Text', '')
extracted_fields.append({
'name': field_name,
'value': field_value,
'confidence': confidence
})
if confidence < confidence_threshold:
needs_review = True
if needs_review:
# ส่งให้ human review
human_loop_input = {
'document_url': f'https://s3.amazonaws.com/my-documents-bucket/{document_s3_key}',
'extracted_fields': extracted_fields,
'original_textract_response': textract_response
}
human_loop_response = a2i_runtime.start_human_loop(
HumanLoopName=f'doc-review-{str(uuid.uuid4())[:8]}',
FlowDefinitionArn='arn:aws:sagemaker:ap-southeast-1:123456789:flow-definition/document-review-workflow',
HumanLoopInput={
'InputContent': json.dumps(human_loop_input)
}
)
return {
'status': 'PENDING_HUMAN_REVIEW',
'human_loop_arn': human_loop_response['HumanLoopArn'],
'extracted_fields': extracted_fields
}
else:
return {
'status': 'AUTO_APPROVED',
'extracted_fields': extracted_fields
}
ดึงผลลัพธ์จาก Human Review
def get_human_review_result(human_loop_arn):
"""ดูผลลัพธ์ของ human review"""
response = a2i_runtime.describe_human_loop(
HumanLoopName=human_loop_arn.split('/')[-1]
)
status = response['HumanLoopStatus']
print(f"Human Loop Status: {status}")
if status == 'Completed':
# ดึงผลลัพธ์จาก S3
output_uri = response['HumanLoopOutput']['OutputS3Uri']
s3 = boto3.client('s3')
bucket = output_uri.split('/')[2]
key = '/'.join(output_uri.split('/')[3:])
output_obj = s3.get_object(Bucket=bucket, Key=key)
output_data = json.loads(output_obj['Body'].read())
print("Human Review Result:")
print(json.dumps(output_data, indent=2))
return output_data
return {'status': status}
# ตรวจสอบ loops ที่รออยู่
loops = a2i_runtime.list_human_loops(
FlowDefinitionArn='arn:aws:sagemaker:ap-southeast-1:123456789:flow-definition/document-review-workflow',
SortBy='CreationTime',
SortOrder='Descending',
MaxResults=10
)
for loop in loops['HumanLoopSummaries']:
print(f"Loop: {loop['HumanLoopName']}, Status: {loop['HumanLoopStatus']}")
ราคา (ประมาณการในบาท)
| รายการ | ราคา USD | ราคา THB (1 USD = 35 บาท) |
|---|---|---|
| Private Workforce | ไม่มีค่าบริการ A2I (จ่ายค่าแรงพนักงาน) | - |
| Amazon Mechanical Turk | ตามความซับซ้อน task (~$0.01-0.10/task) | ~0.35-3.50 บาท/task |
| AWS Marketplace Vendors | ตกลงกับ vendor | แตกต่างกัน |
| SageMaker Ground Truth สำหรับ Private Workforce | $0.08/label | ~2.80 บาท/label |
หมายเหตุ: ค่าใช้จ่ายหลักของ A2I คือค่า workforce ไม่ใช่ค่า AWS service โดยตรง
ตัวอย่างค่าใช้จ่าย: ตรวจสอบ invoice 1,000 ใบ/วัน โดยส่ง 10% ไปให้ review
- 100 tasks/วัน x $0.05/task = $5/วัน (~175 บาท/วัน)
- รวม ~5,250 บาท/เดือน (สำหรับ Mechanical Turk)
เหมาะสำหรับ
- องค์กรที่ต้องมี human oversight สำหรับการตัดสินใจสำคัญตามกฎหมายหรือ compliance
- งาน document processing ที่ต้องการ accuracy สูงมาก เช่น เอกสารกฎหมาย, ทางการแพทย์, ภาษี
- บริษัทที่ process ข้อมูล sensitive และต้องมี audit trail ที่มนุษย์ตรวจสอบแล้ว
- Platform ที่ต้องการ content moderation แต่ edge cases ต้องผ่านตา human
- ทีมที่ต้องการ continuous quality monitoring ของ ML model ใน production
- สถาบันการเงินที่ต้องการ human sign-off สำหรับ high-value transactions
ใช้ร่วมกับ AWS Services
- Amazon Textract - OCR และ form extraction พร้อม built-in A2I integration
- Amazon Rekognition - image/video analysis พร้อม content moderation review
- Amazon SageMaker - custom ML models ที่ต้องการ human review loop
- Amazon Bedrock - GenAI outputs ที่ต้องการ human verification
- Amazon S3 - เก็บ task inputs และ review outputs
- Amazon Cognito - manage private workforce user accounts
- AWS Step Functions - orchestrate complex review workflows
- Amazon DynamoDB - track review status และ audit logs
Use Case ตัวอย่าง
1. บริษัทประกันภัยตรวจสอบใบเรียกร้องสินไหม
บริษัทประกันภัยใช้ Amazon Textract สกัดข้อมูลจากใบเรียกร้องสินไหมและเอกสารประกอบ แล้วใช้ A2I ส่งเฉพาะกรณีที่ confidence ต่ำกว่า 85% หรือมูลค่าเกิน 50,000 บาทไปให้ claims specialists ตรวจสอบ จากเดิมที่ต้องตรวจสอบทุกใบ (1,500 ใบ/วัน) เหลือเพียง 150 ใบที่ต้องผ่าน human review ลดภาระทีม 90% ขณะเดียวกันยังคง accuracy และ compliance ตามที่ กลต. กำหนด
2. Platform Content Moderation สำหรับ Social Media
แพลตฟอร์ม social media ไทยใช้ Amazon Rekognition ตรวจสอบภาพที่ upload และส่งภาพที่ได้ moderation label "unsafe" ด้วย confidence 50-90% ไปให้ human review team ด้วย A2I สร้าง private workforce จากทีม trust & safety ภายใน ระบบแสดงภาพพร้อม AI prediction และให้ reviewer confirm หรือ override ภายใน 30 วินาที จัดการ cases ที่ต้องการความเข้าใจ cultural context และ Thai language ได้ดีกว่า AI เพียงอย่างเดียว
3. ธนาคาร KYC Document Verification
ธนาคารดิจิทัลใช้ Amazon Textract สกัดข้อมูลจาก ID cards, passports และ utility bills เพื่อ KYC verification แล้วใช้ A2I ส่งเอกสารที่ภาพไม่ชัด, ข้อมูลไม่ครบ หรือมี discrepancy ระหว่าง documents ไปให้ KYC team review ทำให้ process เวลา KYC ลดจากเฉลี่ย 2 วันเหลือ 4 ชั่วโมง โดยยังผ่าน Bank of Thailand compliance requirements สำหรับ electronic KYC