Skip to content

fix(analyzer): allow GLiNER labels to be scoped per recognizer#2154

Open
ultramancode wants to merge 1 commit into
data-privacy-stack:mainfrom
ultramancode:fix/gliner-requested-labels
Open

fix(analyzer): allow GLiNER labels to be scoped per recognizer#2154
ultramancode wants to merge 1 commit into
data-privacy-stack:mainfrom
ultramancode:fix/gliner-requested-labels

Conversation

@ultramancode

Copy link
Copy Markdown
Contributor

Change Description

When multiple GLiNERRecognizer instances use different entity_mapping values and thresholds, entities from an analyze request are currently added as ad-hoc labels to every selected GLiNER recognizer.

As a result, an entity can pass the threshold of a recognizer that was not configured to handle it.

This change adds an include_requested_entities_as_labels option to GLiNERRecognizer and its YAML configuration.
The option defaults to true to preserve the existing behavior. When set to false, only the recognizer's configured GLiNER labels are sent to the model.

Issue reference

Related to #1760, specifically the runtime threshold edge case and backward-compatible opt-out proposed by @hexsm
in this comment.

Checklist

  • I have reviewed the contribution guidelines
  • I agree to follow this project's Code of Conduct
  • I confirm that I have the right to submit this contribution and that it does not knowingly contain proprietary or confidential code.
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

kalra-mohit pushed a commit to kalra-mohit/presidio that referenced this pull request Jul 21, 2026
…e GLiNER example

The worked example configures instances with different entity_mapping
values, which is exactly the scenario reported in data-privacy-stack#1760's later
comment thread as leaking entity types across instances due to
threshold semantics. Link to the repro and the pending fix (data-privacy-stack#2154)
so readers aren't misled into thinking the pattern is fully isolated
today.
kalra-mohit added a commit to kalra-mohit/presidio that referenced this pull request Jul 21, 2026
…e GLiNER example

The worked example configures instances with different entity_mapping
values, which is exactly the scenario reported in data-privacy-stack#1760's later
comment thread as leaking entity types across instances due to
threshold semantics. Link to the repro and the pending fix (data-privacy-stack#2154)
so readers aren't misled into thinking the pattern is fully isolated
today.
kalra-mohit added a commit to kalra-mohit/presidio that referenced this pull request Jul 21, 2026
…config (data-privacy-stack#1760)

Consolidates and builds on two other open PRs against this issue, crediting
both explicitly:

- Auto-derives a unique recognizer name from class_name + model_name when
  name is omitted on a class_name: GLiNERRecognizer YAML entry, so multiple
  instances no longer each require an explicit unique name. Approach
  credited to data-privacy-stack#2018 (ynachiket).
- Adds an include_requested_entities_as_labels option (default true) to
  GLiNERRecognizer. When multiple instances are configured with different
  entity_mapping/threshold values, GLiNER's ad-hoc-label support previously
  let a requested entity type "leak" into an instance that wasn't
  configured for it, evaluated against the wrong threshold. Setting this to
  false per-instance closes the leak by restricting that instance to only
  ever request labels it's configured for. Design credited to data-privacy-stack#2154
  (ultramancode), reproducing hexsm's original report.
- Updates the GLiNER sample docs and recognizer_registry_provider.md to
  document both, replacing the earlier docs-only PR's caveat about the
  leakage bug with the actual fix.

Closes data-privacy-stack#1760

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant