Scoring
Heuristic (keyword-based) scoring engine for clinical summaries.
This module provides a fast, deterministic baseline scorer that requires no API key. Each of the 8 rubric dimensions has its own scoring function that inspects the summary text for keyword hits, structural markers, sentence statistics, and word count.
Scoring flow for one role
- Run all 8 dimension scorers independently.
- Apply role-specific adjustments (
_apply_role_adjustments). - Clamp all scores to [1, 5].
- Compute a weighted overall using the role's
w_priorweights.
Score scale: 1 (worst) to 5 (best) per dimension.
AgentScore
dataclass
Container for a single role's scoring output.
Attributes:
| Name | Type | Description |
|---|---|---|
role_id |
str
|
Which clinical role produced this score. |
scores |
Dict[str, int]
|
Mapping of dimension_id → integer score (1-5). |
rationales |
Dict[str, str] | None
|
Optional per-dimension textual justification. |
evidence |
Dict[str, List[str]] | None
|
Optional per-dimension list of matched keywords/evidence. |
overall_notes |
str
|
Free-text note about the role's perspective. |
warnings |
List[str] | None
|
Any warnings generated during scoring (e.g. empty input). |
overall_score |
float | None
|
Weighted average across dimensions (computed post-scoring). |
Source code in src/grading_pipeline/scoring.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
compute_overall_score(scores, weights, dimension_ids)
Compute a weighted average score across dimensions.
If total weight is zero (or all weights missing), falls back to a simple unweighted mean. Result is rounded to 2 decimal places.
Source code in src/grading_pipeline/scoring.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
score_summary_heuristic(summary, role, rubric)
Score a clinical summary using the keyword-based heuristic engine.
Runs all 8 dimension scorers, applies role-specific adjustments, clamps to [1, 5], and computes the weighted overall score.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary
|
str
|
The clinical summary text to evaluate. |
required |
role
|
RoleProfile
|
The clinical role whose perspective to apply. |
required |
rubric
|
Rubric
|
The evaluation rubric (defines which dimensions to score). |
required |
Returns:
| Type | Description |
|---|---|
AgentScore
|
An |
AgentScore
|
and a weighted overall score. |
Source code in src/grading_pipeline/scoring.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |