Skip to content

feat(clinical): add deterministic summary length budgets - #3173

Open
maziyarpanahi wants to merge 1 commit into
masterfrom
dev/v3-issue-2706
Open

maziyarpanahi wants to merge 1 commit into
masterfrom
dev/v3-issue-2706

Conversation

@maziyarpanahi

Copy link
Copy Markdown
Owner

Pull Request

Description

Adds deterministic, local-only length budgeting for clinical-summary
generation. A closed policy allocates explicit output-token caps across
approved evidence classes and returns value-free truncation metadata naming
classes whose requested evidence was deferred.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition/improvement

Changes Made

  • Added the versioned clinical_summary_v1 policy with safety-first priority,
    minimum/maximum bounds, and deterministic weighted allocation.
  • Added immutable per-class allocations and SummaryTruncationMetadata with
    deferred class identifiers, counts, fixed statuses, and clinician-review
    guardrails.
  • Kept the planner metadata-only: it accepts token counts, never stores source
    values, and performs no model loading or mandatory network call.
  • Added the clinical guide and MkDocs/publication navigation entries.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change with different models/inputs

Exact local validation:

  • .venv/bin/python -m pytest tests/unit/clinical/test_summary_length_budget.py -q — 7 passed
  • .venv/bin/python -m pytest tests/unit/clinical/test_summary_length_budget.py tests/unit/clinical/test_summary_card.py tests/unit/clinical/test_citation_ordering.py -q — 35 passed
  • .venv/bin/python -m mypy openmed/clinical/summary_length_budget.py — passed
  • .venv/bin/python -m py_compile openmed/clinical/summary_length_budget.py tests/unit/clinical/test_summary_length_budget.py — passed
  • make format — passed; 2036 files left unchanged
  • make lint — passed
  • make format-check — passed; 2036 files already formatted
  • make docs-build — passed, including strict MkDocs staging and publication validation
  • git diff --check — passed

Checks intentionally not run: the full repository test suite, model-backed or
benchmark checks, Swift checks (no Swift files changed), and remote CI waiting.

Documentation

  • I have updated the documentation accordingly
  • I have added docstrings to new functions/classes
  • I have updated the CHANGELOG.md

Code Quality

  • I ran make format, make lint, and make format-check
  • For Swift/OpenMedKit changes, I ran make format-swift and make lint-swift
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Dependencies

  • I have not added any new dependencies
  • OR I have added new dependencies and they are justified because: ____

Checklist

Related Issues

Closes #2706

Screenshots/Examples

The synthetic API and truncation examples are covered in
tests/unit/clinical/test_summary_length_budget.py and
docs/clinical/summary-length-budgets.md; no patient or restricted data is
used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add deterministic length budgeting for clinical summaries

1 participant