Skip to content

Loading the model from huggingface is broken. #308

@tuv-benedikt-mayer

Description

@tuv-benedikt-mayer

When executing the basic:

from gliner import GLiNER

model = GLiNER.from_pretrained("urchade/gliner_medium-v2.1")

only with the latest version v0.2.23, not with v0.2.22, it throws this error:

Traceback (most recent call last):
  File "/home/my-username/workspace/IDAS/backend/analytics/services/gliner_endpoint/download_gliner_model.py", line 9, in <module>
    model = GLiNER.from_pretrained("urchade/gliner_medium-v2.1")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my-username/.cache/uv/environments-v2/download-gliner-model-c0b76d7f0d4a21f1/lib/python3.11/site-packages/gliner/model.py", line 2800, in from_pretrained
    return gliner_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my-username/.cache/uv/environments-v2/download-gliner-model-c0b76d7f0d4a21f1/lib/python3.11/site-packages/gliner/model.py", line 629, in from_pretrained
    state_dict = cls._load_state_dict(model_file, map_location)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my-username/.cache/uv/environments-v2/download-gliner-model-c0b76d7f0d4a21f1/lib/python3.11/site-packages/gliner/model.py", line 359, in _load_state_dict
    for key in f:
TypeError: 'builtins.safe_open' object is not iterable

This seems to be related to:
huggingface/transformers#40318

Are there ways to use GLiNER via torch as mentioned in that issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions