Skip to content

fix(privacy-filter)!: resolve labels from modelName, fix fromCustomModel identity collapse#1198

Merged
msluszniak merged 2 commits into
mainfrom
@ms/privacy-filter-identity-collapse
May 29, 2026
Merged

fix(privacy-filter)!: resolve labels from modelName, fix fromCustomModel identity collapse#1198
msluszniak merged 2 commits into
mainfrom
@ms/privacy-filter-identity-collapse

Conversation

@msluszniak
Copy link
Copy Markdown
Member

Description

PrivacyFilterModelSources carried labelNames / viterbiBiases on it but usePrivacyFilter's deps only watched modelName / modelSource / tokenizerSource, so two custom loads with the same sources but different labels collapsed to the same identity and the runner kept the old config silently. fromCustomModel made it worse by hardcoding modelName: 'custom'.

Followed @chmjkb's suggestion on #1116: match the ObjectDetection / Segmentation shape — drop labelNames / viterbiBiases from PrivacyFilterModelSources, resolve them from modelName via an internal lookup, and keep custom-label support only on fromCustomModel (unreachable from the hook). The hook's existing deps now fully cover the prop surface, so the collapse is gone.

Introduces a breaking change?

  • Yes
  • No

(labelNames / viterbiBiases are no longer accepted as fields on PrivacyFilterModelSources or on the PRIVACY_FILTER_* constants. Custom label spaces and Viterbi tuning move to PrivacyFilterModule.fromCustomModel.)

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

  1. Run `apps/llm` and open the Privacy Filter screen.
  2. Switch between the OpenAI and Nemotron presets — both should load and produce the expected entity spans.
  3. Re-trigger the hook with the same preset — should not reload.

Related issues

Closes #1116

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings

…Model identity collapse

PrivacyFilterModelSources had labelNames/viterbiBiases on it but the
usePrivacyFilter hook deps only watched modelName/modelSource/tokenizerSource,
so swapping labels with the same sources collapsed to the same identity and
the runner kept the old config silently. fromCustomModel hardcoded
modelName: 'custom' which made the collapse the default for any custom load.

Match the ObjectDetection/Segmentation shape: drop labelNames/viterbiBiases
from PrivacyFilterModelSources, resolve labels from modelName via an internal
lookup, and keep custom-label support only on fromCustomModel (unreachable
from the hook). The hook's existing deps now fully cover the prop surface.

Closes #1116
@msluszniak msluszniak self-assigned this May 28, 2026
@msluszniak msluszniak added the bug fix PRs that are fixing bugs label May 28, 2026
@msluszniak msluszniak requested a review from chmjkb May 28, 2026 11:38
…iases/

PrivacyFilterModelSources is now a type alias (union of preset variants),
so typedoc generates it under 06-api-reference/type-aliases/, not under
interfaces/. Fix the doc link to avoid Docusaurus broken-link failure.
@msluszniak msluszniak changed the title fix(privacy-filter): resolve labels from modelName, fix fromCustomModel identity collapse fix(privacy-filter)!: resolve labels from modelName, fix fromCustomModel identity collapse May 29, 2026
@msluszniak msluszniak merged commit d488d1b into main May 29, 2026
5 checks passed
@msluszniak msluszniak deleted the @ms/privacy-filter-identity-collapse branch May 29, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix PRs that are fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fromCustomModel: hardcoded modelName: 'custom' causes identity collapse across loads

2 participants