msgpack.exceptions.ExtraData: unpack(b) received extra data

System Info

  • transformers version: 4.9.0
  • Platform: Linux-5.15.0-52-generic-x86_64-with-glibc2.29
  • Python version: 3.8.10
  • PyTorch version (GPU?): 1.9.0+cpu (False)
  • Tensorflow version (GPU?): 2.9.1 (True)
  • Flax version (CPU?/GPU?/TPU?): 0.3.4 (gpu)
  • Jax version: 0.4.8
  • JaxLib version: 0.4.7
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

-Models: FlaxHybridCLIP

I’m trying to load a trained FlaxHybridCLIP model from a folder that contains the following files


I attempted to load it using the below:

 if args.run_from_checkpoint is not None:
        with open(f"{args.run_from_checkpoint}/config.json", "r") as fp:
            config_dict = json.load(fp)
        config_dict["vision_config"]["model_type"] = "clip"
        config = HybridCLIPConfig(**config_dict)
        model = FlaxHybridCLIP.from_pretrained(
            dtype=getattr(jnp, model_args.dtype),

But, I encountered the following error:

text_config_dict is None. Initializing the CLIPTextConfig with default values.
vision_config_dict is None. initializing the CLIPVisionConfig with default values.
loading weights file freeze/flax_model.msgpack
Traceback (most recent call last):
  File "", line 832, in <module>
  File "", line 529, in main
    model = FlaxHybridCLIP.from_pretrained(
  File "/home/ubuntu/.local/lib/python3.8/site-packages/transformers/", line 350, in from_pretrained
    state = from_bytes(cls,
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flax/", line 359, in from_bytes
    state_dict = msgpack_restore(encoded_bytes)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/flax/", line 342, in msgpack_restore
    return msgpack.unpackb(
  File "msgpack/_unpacker.pyx", line 201, in msgpack._cmsgpack.unpackb
msgpack.exceptions.ExtraData: unpack(b) received extra data.

I used the modified Italian hybrid CLIP scripts here

Expected behavior

to load successfully and fine-tune with unfrozen backbone