Textract Confidence for Query Results

1

Hi,

when I use queries in textract I get the confidence score back. I wonder what this confidence implies. Is it the confidence that the question is answered correctly? Is it a mix between the confidence of the line, word and question?

Thanks and kind regards,

Oaul

asked 2 years ago796 views
2 Answers
1

Confidence that the answer is correct for the given query. Includes confidence of this being a match for the query and confidence in the value.

AWS
answered 2 years ago
0

Hi, I´m back and my research don't support that the query confidence takes into the confidence of the value. As an example I have a png that I analyse.

When I analyse it via the following:

response = textract.analyze_document(
	Document={
		'S3Object': {
            'Bucket': S3Bucket,
            'Name': S3key,
            }
            },
         HumanLoopConfig={
            "FlowDefinitionArn":"arn:aws:sagemaker:eu-central-1:392047662260:flow-definition/onekey",
            "HumanLoopName":"onekey2",
            "DataAttributes" : {
                "ContentClassifiers":["FreeOfPersonallyIdentifiableInformation","FreeOfAdultContent"]
            }
         },
    FeatureTypes=["QUERIES"],
    QueriesConfig={
        "Queries": [{
            "Text": "Blub",
            "Alias": "Blub"
        }]
    })

I get the following response:

{'DocumentMetadata': {'Pages': 1},
 'Blocks': [{'BlockType': 'PAGE',
   'Geometry': {'BoundingBox': {'Width': 1.0,
     'Height': 1.0,
     'Left': 0.0,
     'Top': 0.0},
    'Polygon': [{'X': 9.166517763292134e-17, 'Y': 0.0},
     {'X': 1.0, 'Y': 1.6361280468230185e-16},
     {'X': 1.0, 'Y': 1.0},
     {'X': 0.0, 'Y': 1.0}]},
   'Id': '23dddda1-597b-4f50-a3b7-8f694a68bc25',
   'Relationships': [{'Type': 'CHILD',
     'Ids': ['8007bbfe-e149-46a8-983f-a1d851819349',
      'caa128eb-48d9-47fd-911c-fe8bfcd11bce',
      '90694f79-c3ea-49c5-a008-a16b3ee107f3',
      'c894d2b7-cb06-49eb-8b26-a5188236107b',
      'fcea87fe-9be9-4f1d-a56b-a2536c61c855']}]},
  {'BlockType': 'LINE',
   'Confidence': 99.37574005126953,
   'Text': 'Name: Paul Spöring',
   'Geometry': {'BoundingBox': {'Width': 0.5787070989608765,
     'Height': 0.0934426411986351,
     'Left': 0.09132613986730576,
     'Top': 0.22022898495197296},
    'Polygon': [{'X': 0.09132613986730576, 'Y': 0.22022898495197296},
     {'X': 0.6700332760810852, 'Y': 0.22022898495197296},
     {'X': 0.6700332760810852, 'Y': 0.31367161870002747},
     {'X': 0.09132613986730576, 'Y': 0.31367161870002747}]},
   'Id': '8007bbfe-e149-46a8-983f-a1d851819349',
   'Relationships': [{'Type': 'CHILD',
     'Ids': ['b585bb68-2ee8-4f14-a3b7-b8255b57272a',
      '8aab4266-4eaa-4dba-b8bb-7624cb02e3ed',
      'ff606403-3987-4b8b-8a5b-16c1d40adb09']}]},
  {'BlockType': 'LINE',
   'Confidence': 99.62093353271484,
   'Text': 'Alter: 20',
   'Geometry': {'BoundingBox': {'Width': 0.2573024034500122,
     'Height': 0.07728662341833115,
     'Left': 0.08906695991754532,
     'Top': 0.3895558714866638},
    'Polygon': [{'X': 0.08906695991754532, 'Y': 0.3895558714866638},
     {'X': 0.3463693857192993, 'Y': 0.3895558714866638},
     {'X': 0.3463693857192993, 'Y': 0.46684250235557556},
     {'X': 0.08906695991754532, 'Y': 0.46684250235557556}]},
   'Id': 'caa128eb-48d9-47fd-911c-fe8bfcd11bce',
   'Relationships': [{'Type': 'CHILD',
     'Ids': ['26853a02-3da9-4c13-ae60-f583c9d4cfb4',
      'd8bfac6e-17ad-44fc-a7ca-1982b29943b4']}]},
  {'BlockType': 'LINE',
   'Confidence': 82.59257507324219,
   'Text': 'Blub: you',
   'Geometry': {'BoundingBox': {'Width': 0.43706580996513367,
     'Height': 0.11816448718309402,
     'Left': 0.09128420799970627,
     'Top': 0.560679018497467},
    'Polygon': [{'X': 0.09128420799970627, 'Y': 0.560679018497467},
     {'X': 0.5283499956130981, 'Y': 0.560679018497467},
     {'X': 0.5283499956130981, 'Y': 0.6788434982299805},
     {'X': 0.09128420799970627, 'Y': 0.6788434982299805}]},
   'Id': '90694f79-c3ea-49c5-a008-a16b3ee107f3',
   'Relationships': [{'Type': 'CHILD',
     'Ids': ['ccb5d25f-dbf6-47b4-a0e4-29f4c90fe5e1',
      '71e21630-0ca9-400f-a050-e3c5168c5174']}]},
  {'BlockType': 'WORD',
   'Confidence': 99.62495422363281,
   'Text': 'Name:',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.19461767375469208,
     'Height': 0.07422882318496704,
     'Left': 0.09132613986730576,
     'Top': 0.2239169031381607},
    'Polygon': [{'X': 0.09132613986730576, 'Y': 0.2239169031381607},
     {'X': 0.28594380617141724, 'Y': 0.2239169031381607},
     {'X': 0.28594380617141724, 'Y': 0.29814571142196655},
     {'X': 0.09132613986730576, 'Y': 0.29814571142196655}]},
   'Id': 'b585bb68-2ee8-4f14-a3b7-b8255b57272a'},
  {'BlockType': 'WORD',
   'Confidence': 98.95515441894531,
   'Text': 'Paul',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.12700314819812775,
     'Height': 0.07847694307565689,
     'Left': 0.30101263523101807,
     'Top': 0.22022898495197296},
    'Polygon': [{'X': 0.30101263523101807, 'Y': 0.22022898495197296},
     {'X': 0.428015798330307, 'Y': 0.22022898495197296},
     {'X': 0.428015798330307, 'Y': 0.29870593547821045},
     {'X': 0.30101263523101807, 'Y': 0.29870593547821045}]},
   'Id': '8aab4266-4eaa-4dba-b8bb-7624cb02e3ed'},
  {'BlockType': 'WORD',
   'Confidence': 99.54711151123047,
   'Text': 'Spöring',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.23034201562404633,
     'Height': 0.09066428989171982,
     'Left': 0.4396912455558777,
     'Top': 0.22300733625888824},
    'Polygon': [{'X': 0.4396912455558777, 'Y': 0.22300733625888824},
     {'X': 0.6700332760810852, 'Y': 0.22300733625888824},
     {'X': 0.6700332760810852, 'Y': 0.31367161870002747},
     {'X': 0.4396912455558777, 'Y': 0.31367161870002747}]},
   'Id': 'ff606403-3987-4b8b-8a5b-16c1d40adb09'},
  {'BlockType': 'WORD',
   'Confidence': 99.47355651855469,
   'Text': 'Alter:',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.16495245695114136,
     'Height': 0.07728662341833115,
     'Left': 0.08906695991754532,
     'Top': 0.3895558714866638},
    'Polygon': [{'X': 0.08906695991754532, 'Y': 0.3895558714866638},
     {'X': 0.2540194094181061, 'Y': 0.3895558714866638},
     {'X': 0.2540194094181061, 'Y': 0.46684250235557556},
     {'X': 0.08906695991754532, 'Y': 0.46684250235557556}]},
   'Id': '26853a02-3da9-4c13-ae60-f583c9d4cfb4'},
  {'BlockType': 'WORD',
   'Confidence': 99.76831817626953,
   'Text': '20',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.07841669768095016,
     'Height': 0.07549438625574112,
     'Left': 0.26795268058776855,
     'Top': 0.3907521665096283},
    'Polygon': [{'X': 0.26795268058776855, 'Y': 0.3907521665096283},
     {'X': 0.3463693857192993, 'Y': 0.3907521665096283},
     {'X': 0.3463693857192993, 'Y': 0.4662465453147888},
     {'X': 0.26795268058776855, 'Y': 0.4662465453147888}]},
   'Id': 'd8bfac6e-17ad-44fc-a7ca-1982b29943b4'},
  {'BlockType': 'WORD',
   'Confidence': 99.90613555908203,
   'Text': 'Blub:',
   'TextType': 'PRINTED',
   'Geometry': {'BoundingBox': {'Width': 0.15235087275505066,
     'Height': 0.07806506007909775,
     'Left': 0.09128420799970627,
     'Top': 0.560679018497467},
    'Polygon': [{'X': 0.09128420799970627, 'Y': 0.560679018497467},
     {'X': 0.24363507330417633, 'Y': 0.560679018497467},
     {'X': 0.24363507330417633, 'Y': 0.638744056224823},
     {'X': 0.09128420799970627, 'Y': 0.638744056224823}]},
   'Id': 'ccb5d25f-dbf6-47b4-a0e4-29f4c90fe5e1'},
  {'BlockType': 'WORD',
   'Confidence': 65.27902221679688,
   'Text': 'you',
   'TextType': 'HANDWRITING',
   'Geometry': {'BoundingBox': {'Width': 0.2605644464492798,
     'Height': 0.10577575862407684,
     'Left': 0.26778554916381836,
     'Top': 0.5730677247047424},
    'Polygon': [{'X': 0.26778554916381836, 'Y': 0.5730677247047424},
     {'X': 0.5283499956130981, 'Y': 0.5730677247047424},
     {'X': 0.5283499956130981, 'Y': 0.6788434982299805},
     {'X': 0.26778554916381836, 'Y': 0.6788434982299805}]},
   'Id': '71e21630-0ca9-400f-a050-e3c5168c5174'},
  {'BlockType': 'QUERY',
   'Id': 'c894d2b7-cb06-49eb-8b26-a5188236107b',
   'Relationships': [{'Type': 'ANSWER',
     'Ids': ['fcea87fe-9be9-4f1d-a56b-a2536c61c855']}],
   'Query': {'Text': 'Blub', 'Alias': 'Blub'}},
  {'BlockType': 'QUERY_RESULT',
   'Confidence': 98.0,
   'Text': 'you',
   'Geometry': {'BoundingBox': {'Width': 0.26047903299331665,
     'Height': 0.10400000214576721,
     'Left': 0.26646706461906433,
     'Top': 0.5720000267028809},
    'Polygon': [{'X': 0.26646706461906433, 'Y': 0.5720000267028809},
     {'X': 0.5269461274147034, 'Y': 0.5720000267028809},
     {'X': 0.5269461274147034, 'Y': 0.6759999990463257},
     {'X': 0.26646706461906433, 'Y': 0.6759999990463257}]},
   'Id': 'fcea87fe-9be9-4f1d-a56b-a2536c61c855'}],
 'HumanLoopActivationOutput': {'HumanLoopArn': 'arn:aws:sagemaker:eu-central-1:392047662260:human-loop/onekey2',
  'HumanLoopActivationReasons': ['ConditionsEvaluation'],
  'HumanLoopActivationConditionsEvaluationResults': '{"Conditions":[{"Or":[{"And":[{"ConditionType":"ImportantFormKeyConfidenceCheck","ConditionParameters":{"ImportantFormKey":"Blub","ImportantFormKeyAliases":[],"KeyValueBlockConfidenceLessThan":70.0,"WordBlockConfidenceLessThan":70.0},"EvaluationResult":false},{"ConditionType":"ImportantFormKeyConfidenceCheck","ConditionParameters":{"ImportantFormKey":"Blub","ImportantFormKeyAliases":[],"KeyValueBlockConfidenceGreaterThan":0.0,"WordBlockConfidenceGreaterThan":0.0},"EvaluationResult":false}],"EvaluationResult":false},{"ConditionType":"MissingImportantFormKey","ConditionParameters":{"ImportantFormKey":"Blub","ImportantFormKeyAliases":null},"EvaluationResult":true}],"EvaluationResult":true}]}'},
 'AnalyzeDocumentModelVersion': '1.0',
 'ResponseMetadata': {'RequestId': 'bc5b9bac-9e6b-4b4b-8686-127526be99e8',
  'HTTPStatusCode': 200,
  'HTTPHeaders': {'x-amzn-requestid': 'bc5b9bac-9e6b-4b4b-8686-127526be99e8',
   'content-type': 'application/x-amz-json-1.1',
   'content-length': '7318',
   'date': 'Fri, 16 Sep 2022 11:26:37 GMT'},
  'RetryAttempts': 0}}

As you can see, the confidence of the query is 98%, but the confidence of the value is just 65%.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions