Skip to content

fix: Preserve GLiNER config fields through Pydantic validation#2007

Open
yuriihavrylko wants to merge 1 commit intomicrosoft:mainfrom
yuriihavrylko:fix/gliner-config-model-name
Open

fix: Preserve GLiNER config fields through Pydantic validation#2007
yuriihavrylko wants to merge 1 commit intomicrosoft:mainfrom
yuriihavrylko:fix/gliner-config-model-name

Conversation

@yuriihavrylko
Copy link
Copy Markdown

@yuriihavrylko yuriihavrylko commented Apr 28, 2026

Change Description

Add GLiNERRecognizerConfig to the YAML recognizer config model and register it in CONFIG_MODEL_MAP, so that model_name and other GLiNER-specific fields (flat_ner, threshold, multi_label, map_location, load_onnx_model, onnx_model_file, entity_mapping) are preserved through Pydantic validation when loading recognizer configuration from YAML.

Root cause: When parsing a GLiNERRecognizer entry from YAML, parse_recognizers looked up "GLiNERRecognizer" in CONFIG_MODEL_MAP and found nothing, falling back to PredefinedRecognizerConfig. Since that class has no model_name field and Pydantic's default is to ignore extra fields, model_name (and all other GLiNER params) were silently dropped. The recognizer would then always load the hardcoded default model (urchade/gliner_multi_pii-v1) regardless of what was specified in config. HuggingFaceNerRecognizer already had this handled correctly via HuggingFaceRecognizerConfig.

Issue reference

Fixes #XX

Checklist

  • I have reviewed the contribution guidelines
  • I have signed the CLA (if required)
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

@yuriihavrylko
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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