Skip to content

docs(analyzer): document and test configuring multiple GLiNERRecognizer instances via YAML#2180

Closed
kalra-mohit wants to merge 2 commits into
data-privacy-stack:mainfrom
kalra-mohit:fix/gliner-multi-instance-yaml
Closed

docs(analyzer): document and test configuring multiple GLiNERRecognizer instances via YAML#2180
kalra-mohit wants to merge 2 commits into
data-privacy-stack:mainfrom
kalra-mohit:fix/gliner-multi-instance-yaml

Conversation

@kalra-mohit

@kalra-mohit kalra-mohit commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Configuring multiple GLiNERRecognizer instances side-by-side via the recognizer registry YAML (e.g. different models/thresholds/entity mappings) already works today by giving each entry a distinct name while pointing class_name at GLiNERRecognizer — the same mechanism used for HuggingFaceNerRecognizer. It just wasn't documented, so users had no way to discover it.

This PR:

  • Adds a "Configuring multiple GLiNER recognizers via YAML" section with a worked example to the GLiNER sample doc
  • Clarifies the class_name field in recognizer_registry_provider.md
  • Adds regression tests (with GLiNER mocked, so no heavy optional dependency required) covering both the registry-provider path and the lower-level loader utils
  • Notes a known related limitation (entity leakage across instances when entity_mappings differ — see Can multiple GLiNERRecognizer instances be configured via YAML? #1760's later comment thread and the pending fix in fix(analyzer): allow GLiNER labels to be scoped per recognizer #2154) so the doc doesn't imply stronger isolation than currently exists

No source code changes — this is docs + tests only.

Closes #1760

Loading flow

flowchart TD
    A["recognizer_registry.yaml"] --> B1["entry: name=GLiNERRecognizerMultiPII<br/>class_name=GLiNERRecognizer<br/>threshold=0.4"]
    A --> B2["entry: name=GLiNERRecognizerSmall<br/>class_name=GLiNERRecognizer<br/>threshold=0.25"]
    B1 --> C1["GLiNERRecognizer instance A<br/>gliner_multi_pii-v1"]
    B2 --> C2["GLiNERRecognizer instance B<br/>gliner_small-v2.5"]
    C1 --> D["RecognizerRegistry"]
    C2 --> D
    D --> E["AnalyzerEngine.analyze"]
    E -. "known gap #1760 / fix pending #2154:<br/>requested entities appended as labels to ALL instances" .-> C1
    E -. same gap .-> C2
Loading

Test plan

  • New regression test in test_recognizer_registry_provider.py
  • New regression test in test_recognizers_loader_utils.py
  • Verified class_name resolution logic predates this change (not new behavior, just newly documented)
  • Verified the entity-leakage caveat against the live issue thread and the open fix PR (fix(analyzer): allow GLiNER labels to be scoped per recognizer #2154) before documenting it

…er instances via YAML

Fixes data-privacy-stack#1760. The recognizer registry YAML loader already supports
multiple predefined recognizer instances of the same class by giving
each entry a distinct `name` while pointing `class_name` at the shared
class (the mechanism used elsewhere for HuggingFaceNerRecognizer), but
this wasn't documented for GLiNERRecognizer and had no regression
coverage, leading users to file this as a missing feature.

- Add a "Configuring multiple GLiNER recognizers via YAML" section to
  docs/samples/python/gliner.md with a two-model example.
- Document the `class_name` field in
  docs/analyzer/recognizer_registry_provider.md and link to the new
  GLiNER section.
- Add regression tests covering multiple GLiNERRecognizer instances
  loaded via class_name/name, both through RecognizerListLoader.get
  directly and through the full RecognizerRegistryProvider (Pydantic
  validation) path. The GLiNER model class is mocked so the tests run
  without the optional `gliner` extra installed.
- Update CHANGELOG.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…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

Copy link
Copy Markdown
Author

Superseded by #2181, which folds this docs-only change together with a fix for the entity-leakage bug (credited to #2154) and the auto-naming ergonomics (credited to #2018) into one consolidated PR, per the coordination note on the issue. Closing this one to avoid leaving redundant/overlapping PRs open.

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.

Can multiple GLiNERRecognizer instances be configured via YAML?

2 participants