fix: Psl entity score#619
Merged
Merged
Conversation
…ores Root cause: When the evaluate step couldn't compute any per-field confidence (e.g. logprobs unavailable on reasoning models like gpt-5/o1/o3, or image-only flow with no Content Understanding signal), save_handler emitted entity_score=0.0, schema_score=0.0. These `0.0`s flowed through Cosmos -> API -> UI and rendered as `0%` (red), indistinguishable from a genuine zero confidence. Fix: Treat `total_evaluated_fields_count == 0` (or no comparison items) as *unavailable* and propagate `None` through the ContentProcessor, ContentProcessorAPI and ContentProcessorWorkflow models. The frontend percentage cell renderer now shows `N/A` for null/undefined and `0%` only for a genuine numeric zero. Files changed: - ContentProcessor: save_handler.py (extracted _derive_aggregate_scores helper) - ContentProcessor: content_process.py default scores -> None - ContentProcessorAPI: ContentProcess + Content_Process default scores -> None - ContentProcessorWorkflow: ContentProcessRecord + Content_Process default scores -> None - ContentProcessorWorkflow: document_process_executor preserves None instead of coercing to 0.0 - ContentProcessorWeb: ProcessQueueGridTypes types scores nullable; ProcessQueueGrid passes undefined for null/undefined; CustomCellRender renders `N/A` when valueText is null/undefined and only `...` while still processing Tests: - New: ContentProcessor/tests/unit/pipeline/test_save_handler_scores.py (5 cases: valid scores, missing per-field signal, no comparison items, genuine zero, all-fields-above-threshold) - Updated existing default-value tests in Workflow + src/tests to assert None - Added tests for explicit zero preservation and Failed status -> None
Per feedback: Completed runs must always show a meaningful number; Failed runs and genuine zeros stay at 0%. - save_handler._derive_aggregate_scores picks the best available signal: (1) probabilistic confidence when logprobs available; (2) structural completeness (filled fields / total) when no logprobs (reasoning models, image-only flow); (3) 0.0 when no extraction data at all. - _is_filled_value heuristic: None/empty/whitespace count as not filled; descends into nested dicts/lists. - Reverted models from Optional[float]=None back to default 0.0. - Reverted frontend: no N/A path; renders 0% for null/missing scores. - 15 new tests covering all 3 paths + _is_filled_value heuristic.
…ation - F401: drop unused sync DefaultAzureCredential import in 3 credential util files (sync flow now raises RuntimeError; AsyncDefaultAzureCredential is still used). - W293/E122: fix blank-line whitespace and continuation-line indentation in ContentProcessorWorkflow/src/utils/credential_util.py.
Coverage Report •
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates how extraction quality scores (entity_score / schema_score) are computed and propagated across the pipeline, API models, and UI so that completed runs consistently yield numeric scores (with structural fallback when probabilistic confidence is unavailable) and failures/empty results stay at 0.0.
Changes:
- Refactors
SaveHandlerscoring to derive aggregate scores via probabilistic confidence when available, otherwise structural completeness. - Hardens workflow/UI score handling to avoid missing/invalid score payloads (defaulting to
0.0/"0"). - Adds/updates unit tests to cover default score behavior and the new scoring paths.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ContentProcessor/src/libs/pipeline/handlers/save_handler.py | Introduces _derive_aggregate_scores and _is_filled_value and wires derived scores into persisted ContentProcess. |
| src/ContentProcessor/tests/unit/pipeline/test_save_handler_scores.py | Adds unit tests covering probabilistic scoring, structural fallback, and “real zero” behavior. |
| src/ContentProcessorAPI/app/routers/models/contentprocessor/claim_process.py | Updates API model field descriptions to clarify score semantics and fallback behavior. |
| src/ContentProcessorWorkflow/src/repositories/model/claim_process.py | Updates workflow-side model documentation for entity_score / schema_score. |
| src/ContentProcessorWorkflow/src/steps/document_process/executor/document_process_executor.py | Coerces score payloads robustly to floats, defaulting to 0.0 on missing/invalid values. |
| src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGrid.tsx | Updates UI rendering to handle missing scores (fallback display to 0). |
| src/ContentProcessorWeb/src/Pages/DefaultPage/Components/ProcessQueueGrid/ProcessQueueGridTypes.ts | Tweaks UI type documentation wording for entity_score. |
| src/ContentProcessorWorkflow/src/utils/credential_util.py | Minor formatting change and error/log messaging near credential selection failure. |
| src/ContentProcessor/src/libs/utils/credential_util.py | Removes unused DefaultAzureCredential import (sync path). |
| src/ContentProcessor/src/libs/utils/azure_credential_utils.py | Removes unused DefaultAzureCredential import (sync path). |
| src/tests/ContentProcessorWorkflow/services/test_content_process_models.py | Adds assertions/comments reinforcing default scores remain 0.0. |
| src/tests/ContentProcessorWorkflow/repositories/test_claim_process_model.py | Adds assertions/comments reinforcing default scores remain 0.0. |
| src/ContentProcessorWorkflow/tests/unit/services/test_content_process_models.py | Adds unit test ensuring explicit 0.0 scores are preserved. |
| src/ContentProcessorWorkflow/tests/unit/repositories/test_claim_process_model.py | Adds tests ensuring explicit 0.0 scores are preserved and failed runs keep defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avijit-Microsoft
approved these changes
Jun 16, 2026
|
🎉 This PR is included in version 2.1.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request overhauls the way extraction quality scores (
entity_scoreandschema_score) are derived, stored, and displayed throughout the content processing pipeline. The main improvement is a new, robust scoring logic that ensures all completed runs yield meaningful numeric scores: using probabilistic confidence when available, and falling back to a structural completeness ratio otherwise. Failed or empty extractions consistently yield0.0. The changes also update API and UI code to clarify score semantics and handle edge cases gracefully. Comprehensive unit tests are included for the new logic.Scoring logic improvements:
SaveHandlerto always emit numeric scores for completed runs: uses probabilistic confidence if available, otherwise falls back to a structural completeness ratio; failed/empty runs yield0.0. Added_derive_aggregate_scoresand_is_filled_valuehelpers for robust computation. [1] [2]find_process_resultto use the new aggregate scoring logic.test_save_handler_scores.py.API and model documentation:
entity_scoreandschema_scorein API models (claim_process.pyin both API and workflow repositories). [1] [2]UI and workflow robustness:
ProcessQueueGrid.tsx) to handlenullorundefinedscores gracefully, always displaying0if the score is missing. [1] [2]document_process_executor.py) to robustly coerce score payloads to floats, defaulting to0.0on errors or missing values. [1] [2]Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information