Error while loading the model
Getting an error when loading the model. Gliner version used: '0.2.13' which seems to be the latest released
KeyError Traceback (most recent call last)
Cell In[2], line 2
1 device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
----> 2 model = GLiNER.from_pretrained("knowledgator/modern-gliner-bi-large-v1.0")
File /opt/conda/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, **kwargs)
111 if check_use_auth_token:
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs)
--> 114 return fn(*args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py:550, in ModelHubMixin.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only, revision, **model_kwargs)
547 if cls._hub_mixin_inject_config and "config" not in model_kwargs:
548 model_kwargs["config"] = config
--> 550 instance = cls._from_pretrained(
551 model_id=str(model_id),
552 revision=revision,
553 cache_dir=cache_dir,
554 force_download=force_download,
555 proxies=proxies,
556 resume_download=resume_download,
557 local_files_only=local_files_only,
558 token=token,
559 **model_kwargs,
560 )
562 # Implicitly set the config as instance attribute if not already set by the class
563 # This way config
will be available when calling save_pretrained
or push_to_hub
.
564 if config is not None and (getattr(instance, "_hub_mixin_config", None) in (None, {})):
File /opt/conda/lib/python3.10/site-packages/gliner/model.py:784, in GLiNER.from_pretrained(cls, model_id, revision, cache_dir, force_download, proxies, resume_download, local_files_only, token, map_location, strict, load_tokenizer, resize_token_embeddings, load_onnx_model, onnx_model_file, compile_torch_model, session_options, attn_implementation, max_length, max_width, post_fusion_schema, **model_kwargs)
782 tokenizer = None
783 config = json.load(open(config_file))
--> 784 config = GLiNERConfig(**config)
786 if _attn_implementation is not None:
787 config.encoder_config._attn_implementation = _attn_implementation
File /opt/conda/lib/python3.10/site-packages/gliner/config.py:39, in GLiNERConfig.init(self, model_name, labels_encoder, name, max_width, hidden_size, dropout, fine_tune, subtoken_pooling, span_mode, post_fusion_schema, num_post_fusion_layers, vocab_size, max_neg_type_ratio, max_types, max_len, words_splitter_type, has_rnn, fuse_layers, embed_ent_token, class_token_index, encoder_config, labels_encoder_config, ent_token, sep_token, **kwargs)
35 if isinstance(encoder_config, dict):
36 encoder_config["model_type"] = (encoder_config["model_type"]
37 if "model_type" in encoder_config
38 else "deberta-v2")
---> 39 encoder_config = CONFIG_MAPPINGencoder_config["model_type"]
40 self.encoder_config = encoder_config
42 if isinstance(labels_encoder_config, dict):
File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py:740, in _LazyConfigMapping.getitem(self, key)
738 return self._extra_content[key]
739 if key not in self._mapping:
--> 740 raise KeyError(key)
741 value = self._mapping[key]
742 module_name = model_type_to_module_name(key)
KeyError: 'modernbert'
just restart the session after u run this line
pip install gliner -U
pip install git+https://github.com/huggingface/transformers.git