Skip to content

feat: showcase typed spans in Streamlit demo#72

Merged
adaamko merged 1 commit into
KRLabsOrg:mainfrom
w3lld1:feat/typed-span-streamlit-demo
Jul 15, 2026
Merged

feat: showcase typed spans in Streamlit demo#72
adaamko merged 1 commit into
KRLabsOrg:mainfrom
w3lld1:feat/typed-span-streamlit-demo

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the demo's developer-local checkpoint with a fresh-clone-compatible v2 encoder cascade
  • add a cached sidebar selector for typed and binary models
  • color typed spans by taxonomy category and show category, subcategory, and confidence in tooltips
  • add a category legend, per-span table, and focused renderer tests for typed, untyped, and multiple spans

Related issue

Fixes #57

Type of change

  • Bug fix
  • Feature
  • Documentation
  • Tests
  • Refactor or maintenance

Testing

  • python3 -m ruff format --check demo/streamlit_demo.py tests/test_demo_pytest.py
  • python3 -m ruff check demo/streamlit_demo.py tests/test_demo_pytest.py
  • python3 -m pytest tests/test_demo_pytest.py -v (3 passed)
  • python3 -m py_compile demo/streamlit_demo.py tests/test_demo_pytest.py
  • git diff --check
  • pytest tests/test_inference_pytest.py -v -k "not TestAnswerStartToken" — collection was attempted but this runner does not have torch installed
  • Interactive model-download smoke test — not run locally because the runner lacks Streamlit/model dependencies and has insufficient disk for the model stack

Checklist

  • I kept the PR focused on one change.
  • I added or updated tests/docs when needed.
  • I checked that no secrets, API keys, or credentials are included.

Rights & sign-off (required)

  • I certify that I have the right to submit this code and that it may be
    distributed under the repository's MIT license
    (see CONTRIBUTING).

@adaamko adaamko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — this is a careful implementation and it hits every item in #57: the fresh-clone fix, the cache-keyed model selector, per-category colors with subcategory and confidence tooltips, the legend, the per-span table, and a pure renderer with focused tests (including the right-to-left insertion-order check). I verified the full suite passes merged with current main (88 passed via both python -m pytest and python tests/run_pytest.py) and ruff is clean.

One fix needed before merge, and it's on us, not you — the issue text gave you a wrong model id: the binary v1 model on the Hub is KRLabsOrg/lettucedect-base-modernbert-en-v1 (the same lettucedect slug spelling as the v2 repos; the lettucedetect- form 404s). As written, picking "Binary spans (ModernBERT)" in the sidebar crashes on download. Please swap that one string in MODEL_OPTIONS — the issue text and docs are being fixed separately (#82).

Also please update the branch (or rebase on main): CI was recently switched to run the full test suite, and your green run predates that, so tests/test_demo_pytest.py hasn't actually been exercised by CI yet. It passes locally against current main, so this should be a formality.

Non-blocking nit: use_container_width=True on st.dataframe is deprecated in recent Streamlit (width="stretch" is the replacement); fine to leave.

Signed-off-by: w3lld1 <42353747+w3lld1@users.noreply.github.com>
@w3lld1
w3lld1 force-pushed the feat/typed-span-streamlit-demo branch from c7dff4b to 95616f8 Compare July 14, 2026 14:33
@w3lld1

w3lld1 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — fixed the binary v1 model ID to KRLabsOrg/lettucedect-base-modernbert-en-v1 and rebased the branch onto current main.

Fresh validation on 95616f8:

  • python -m pytest — 142 passed
  • python tests/run_pytest.py — 142 passed
  • ruff format --check demo/streamlit_demo.py tests/test_demo_pytest.py
  • ruff check demo/streamlit_demo.py tests/test_demo_pytest.py
  • git diff --check

@adaamko adaamko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model id fixed and the rebase means CI now runs the demo tests under the full-suite workflow — all green. Merging; thanks for the quick turnaround and for a genuinely well-built demo upgrade.

@adaamko
adaamko merged commit 007bc5c into KRLabsOrg:main Jul 15, 2026
4 checks passed
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.

Showcase typed spans in the Streamlit demo

2 participants