Confidence Scores
Extend uses machine learning models to extract information from documents. A confidence score tells you how ‘confident’ the model is about the accuracy of an extracted value. The score is presented as a number between 0 and 1, with values closer to 1 indicating higher confidence.
Below, you can see an example of an extraction with high confidence, and that all of the extracted values are correct.
Overview
The format and availability of confidence scores depends on your processor configuration type:
- JSON Schema Processors: Provide detailed confidence scores in a
metadata
object withlogprobsConfidence
andocrConfidence
values - Fields Array Processors: Include confidence scores directly within each field’s result object (legacy configuration)
Common Usage Patterns
The following usage patterns apply to both JSON Schema and Fields Array processors:
Using Confidence Scores in Conditional Steps
Using conditional steps, you can handle a document differently depending on whether its extraction confidence score is above or below a certain ‘confidence threshold’. For instance, if you’re extracting important financial data, you might set a high threshold, accepting only data with confidence scores above 0.95. For less critical data, a lower threshold might be acceptable.
Review and Verification
Use confidence scores to prioritize data for review. Data points with low confidence scores might need manual verification or further investigation.
Data Filtering
In large datasets, you may want to filter out data below a certain confidence level to ensure the quality and reliability of your analysis.
JSON Schema Processors
This section applies to processors using the JSON Schema config type. If you’re using the Fields Array config type, see the Fields Array Processors section below.
JSON Schema processors provide two types of confidence scores in the metadata
object of processor run outputs:
logprobsConfidence
- Confidence from the language model based on token probabilities during generationocrConfidence
- Confidence from the OCR (Optical Character Recognition) system about text extraction accuracy
Both scores range from 0 to 1, with values closer to 1 indicating higher confidence.
Accessing Confidence Scores
Confidence scores are stored in the metadata
object using path-like keys that correspond to your extracted data structure:
Using Confidence in Conditional Steps
JSON Schema processors provide several ways to access confidence scores in conditional steps:
Aggregate Confidence Access:
{{extractionStepName.avgConfidence}}
- Average confidence across all extracted fields{{extractionStepName.minConfidence}}
- Minimum confidence across all extracted fields
Specific Field Confidence Access:
{{extractionStepName.output.metadata.field_name.logprobsConfidence}}
- Language model confidence for a specific field{{extractionStepName.output.metadata.field_name.ocrConfidence}}
- OCR confidence for a specific field
Array and nested object confidence access (e.g., line_items[0].description
) is not currently supported in conditional steps.
Example Conditional Logic:
Working with Arrays
For JSON Schema processors, confidence scores are provided for arrays at multiple levels:
- Array-level confidence: Overall confidence for the entire array using the array field name
- Item-level confidence: Confidence for each object in the array using
arrayName[index]
notation - Property-level confidence: Confidence for individual properties within array items using
arrayName[index].propertyName
notation
Programmatic Access
To access confidence scores programmatically in JSON Schema processors:
Fields Array Processors
This section applies to processors using the legacy Fields Array config type. If you’re using JSON Schema processors, see the JSON Schema Processors section above.
Fields Array processors include confidence scores directly within each field’s result object. The specific format and availability may vary based on your processor configuration.
Using Confidence in Conditional Steps
Fields Array processors can use confidence scores in conditional steps for routing decisions:
Working with Arrays
For Fields Array processors, confidence scores are included within the array field result structure. To view these confidences in the UI, hover over the cell the value is contained in.
Low confidence values are highlighted yellow. When reviewing an array with highlighted low confidence values:
It is important to check the values around the low confidence value to make sure they are correct in addition to the flagged value.
Low confidence values in arrays might indicate that the model doesn’t have enough context to extract the value correctly or that the model is confused by the format of the document. In these cases, it may be helpful to add more context to your extraction field descriptions. If this does not remedy the issue, reach out to the Extend team.
Programmatic Access
Fields Array processors include confidence scores directly within each field’s result object. The specific format and availability may vary based on your processor configuration.
Limitations and Best Practices
While confidence scores are a valuable tool in assessing the reliability of extracted data, it’s important to recognize their limitations to use them effectively. These considerations apply to both JSON Schema and Fields Array processors.
Not a Guarantee of Accuracy
A high confidence score indicates a high probability of correctness, but it doesn’t guarantee accuracy. Even with a high score, there’s always a chance of errors, so critical data should always be cross-verified.
Context Matters
Confidence scores are calculated using models and their understanding of the data. They may not account for nuances or context that a human reviewer who understands your business would recognize. Because of this, it’s imperative to supply sufficient context on the value you want extracted so the AI can determine whether it is confident or not.
For example, if you name a field “company_name” on an extractor designed for invoices, the model may not be confident on which name you are asking for as there are a couple different company names on invoices.
Best Practices
- Provide clear field descriptions: Ambiguous field names can lead to lower confidence scores
- Test and iterate: Monitor confidence patterns in your specific use case and adjust thresholds accordingly