Hi team, I am using a custom model built on top of GLiNER (knowledgator/gliner-relex-large-v1.0) and wanted to ask if there are plans to support dictionary-based labels in the base library.
The Context
The model card for the custom knowledgator model instructs users to pass a dictionary (mapping labels to their descriptions) to the inference() method:
entity_labels = {
"person": "A human individual, including fictional characters",
"organization": "A company, institution, agency, or other group of people",
}
entities, relations = model.inference(
texts=[text],
labels=entity_labels, # Passing a Dict instead of a List
# ...
)
The Issue
Running this code currently crashes the base library with a TypeError: unhashable type: 'dict' (or KeyError: 0).
This happens because BaseEncoderGLiNER.prepare_batch() (around line 2069) assumes labels is a list, and evaluating labels[0] on a dictionary triggers a key lookup error. Furthermore, the base type signature for inference() explicitly only accepts Union[str, List[str], List[List[str]]].
Environment:
- gliner version: 0.2.27
- Python: 3.13
- Branch:
main
Question
Are there any plans for the base GLiNER library to officially support passing label descriptions as a Dict[str, str]? Or is this a custom feature that downstream model creators should be implementing themselves via custom wrappers?
Hi team, I am using a custom model built on top of GLiNER (
knowledgator/gliner-relex-large-v1.0) and wanted to ask if there are plans to support dictionary-based labels in the base library.The Context
The model card for the custom knowledgator model instructs users to pass a dictionary (mapping labels to their descriptions) to the
inference()method:The Issue
Running this code currently crashes the base library with a
TypeError: unhashable type: 'dict'(orKeyError: 0).This happens because
BaseEncoderGLiNER.prepare_batch()(around line 2069) assumeslabelsis a list, and evaluatinglabels[0]on a dictionary triggers a key lookup error. Furthermore, the base type signature forinference()explicitly only acceptsUnion[str, List[str], List[List[str]]].Environment:
mainQuestion
Are there any plans for the base GLiNER library to officially support passing label descriptions as a
Dict[str, str]? Or is this a custom feature that downstream model creators should be implementing themselves via custom wrappers?