Azure Document Intelligence 모델 사용
API 사용
사용자 지정 모델을 사용하여 양식 데이터를 추출하려면 모델 ID(모델 학습 중에 생성됨)를 제공하면서 지원되는 SDK 또는 REST API의 문서 함수를 분석합니다. 이 함수는 양식 분석을 시작합니다. 그런 다음 결과를 요청하여 분석을 가져올 수 있습니다.
모델을 호출하는 예제 코드:
C#
string endpoint = "<endpoint>";
string apiKey = "<apiKey>";
AzureKeyCredential credential = new AzureKeyCredential(apiKey);
DocumentAnalysisClient client = new DocumentAnalysisClient(new Uri(endpoint), credential);
string modelId = "<modelId>";
Uri fileUri = new Uri("<fileUri>");
AnalyzeDocumentOperation operation = await client.AnalyzeDocumentFromUriAsync(WaitUntil.Completed, modelId, fileUri);
AnalyzeResult result = operation.Value;
파이썬
endpoint = "YOUR_DOC_INTELLIGENCE_ENDPOINT"
key = "YOUR_DOC_INTELLIGENCE_KEY"
model_id = "YOUR_CUSTOM_BUILT_MODEL_ID"
formUrl = "YOUR_DOCUMENT"
document_analysis_client = DocumentAnalysisClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
# Make sure your document's type is included in the list of document types the custom model can analyze
task = document_analysis_client.begin_analyze_document_from_url(model_id, formUrl)
result = task.result()
성공적인 JSON 응답에는 추출된 콘텐츠와 문서 콘텐츠에 대한 정보가 포함된 페이지 배열이 포함된 analyzeResult 포함됩니다.
문서 JSON 응답을 분석하는 예제:
{
"status": "succeeded",
"createdDateTime": "2023-10-18T23:39:50Z",
"lastUpdatedDateTime": "2023-10-18T23:39:54Z",
"analyzeResult": {
"apiVersion": "2022-08-31",
"modelId": "DocIntelModel",
"stringIndexType": "utf16CodeUnit",
"content": "Purchase Order\nHero Limited\nCompany Phone: 555-348-6512 Website: www.herolimited.com Email: accounts@herolimited.com\nPurchase Order\nDated As: 12/20/2020 Purchase Order #: 948284\nShipped To Vendor Name: Balozi Khamisi Company Name: Higgly Wiggly Books Address: 938 NE Burner Road Boulder City, CO 92848 Phone: 938-294-2949\nShipped From Name: Kidane Tsehaye Company Name: Jupiter Book Supply Address: 383 N Kinnick Road Seattle, WA 38383\nPhone: 932-299-0292\nDetails\nQuantity\nUnit Price\nTotal\nBindings\n20\n1.00\n20.00\nCovers Small\n20\n1.00\n20.00\nFeather Bookmark\n20\n5.00\n100.00\nCopper Swirl Marker\n20\n5.00\n100.00\nSUBTOTAL\n$140.00\nTAX\n$4.00\nTOTAL\n$144.00\nKidane Tsehaye\nManager\nKidane Tsehaye\nAdditional Notes: Do not Jostle Box. Unpack carefully. Enjoy. Jupiter Book Supply will refund you 50% per book if returned within 60 days of reading and offer you 25% off you next total purchase.",
"pages": [
{
"pageNumber": 1,
"angle": 0,
"width": 1159,
"height": 1486,
"unit": "pixel",
"words": [
{
"content": "Purchase",
"polygon": [
89,
90,
174,
91,
174,
112,
88,
112
],
"confidence": 0.996,
"span": {
"offset": 0,
"length": 8
}
},
{
"content": "Order",
"polygon": [
178,
91,
237,
91,
236,
113,
178,
112
],
"confidence": 0.997,
"span": {
"offset": 9,
"length": 5
}
},
...
신뢰도 점수 이해
analyzeResult 신뢰도 값이 낮으면 입력 문서의 품질을 향상시킵니다.
신뢰도 값이 낮은 경우 분석하는 양식이 학습 집합의 양식과 유사한 모양인지 확인하려고 합니다. 양식 모양이 다른 경우 각 모델이 하나의 양식 형식에 초점을 맞춘 두 개 이상의 모델을 학습하는 것이 좋습니다.
사용 사례에 따라 위험 수준이 낮은 애플리케이션에 대해 신뢰도 점수가 80% 이상일 수 있습니다. 의료 기록 또는 청구 명세서를 읽는 것과 같은 더 민감한 경우 100% 점수가 권장됩니다.