stanfordnlp / pyreft

ReFT: Representation Finetuning for Language Models
https://arxiv.org/abs/2404.03592
Apache License 2.0
1.06k stars 90 forks source link

RuntimeError: Failed to import transformers.models.blip.modeling_blip due to missing split_torch_state_dict_into_shards from huggingface_hub #120

Closed Akhorramrouz closed 2 months ago

Akhorramrouz commented 2 months ago

I encountered an issue when trying to install the dependencies from requirements.txt and subsequently importing pyreft. The following error is raised:

javascript Copy code RuntimeError: Failed to import transformers.models.blip.modeling_blip because of the following error (look up to see its traceback): Failed to import transformers.generation.utils because of the following error (look up to see its traceback): cannot import name 'split_torch_state_dict_into_shards' from 'huggingface_hub' (/usr/local/lib/python3.10/dist-packages/huggingface_hub/init.py)

PinetreePantry commented 2 months ago

I believe updating huggingface-hub to 0.23.0 and restart the kernel should work - in my environment python == 3.8 works with huggingface-hub 0.23.0 let me know if you met any further issues

Akhorramrouz commented 2 months ago

thanks for your response the requirements.txt that I am using. However the conflict is explained below:

INFO: pip is looking at multiple versions of pyvene to determine which version is compatible with other requirements. This could take a while. ERROR: Cannot install -r requirements.txt (line 4) and huggingface-hub==0.23.0 because these package versions have conflicting dependencies.

The conflict is caused by: The user requested huggingface-hub==0.23.0 pyvene 0.1.2 depends on huggingface-hub==0.20.3

By the way, since I am using google colab, it is not a possibility to use Python3.8 and I should use Python3.10. Is this the reason of this conflict in the dependencies?

can you please help me what should i do?

Thanks a lot for your time and consideration

PinetreePantry commented 1 month ago

If you are using colab, maybe you can try %pip install huggingface-hub=0.23.0. I will consider updating huggingface-hub on pyvene too

Akhorramrouz commented 1 month ago

Thanks a lot for your time and response,

I am looking forward to that.

mlabonne commented 1 month ago

Hello, I still run into this error on Colab, even when downgrading huggingface-hub. Unfortunately, the main demo (https://colab.research.google.com/github/stanfordnlp/pyreft/blob/main/main_demo.ipynb) doesn't work because of this issue. Have you found a fix?

RuntimeError: Failed to import transformers.models.blip.modeling_blip because of the following error (look up to see its traceback): Failed to import transformers.generation.utils because of the following error (look up to see its traceback): cannot import name 'split_torch_state_dict_into_shards' from 'huggingface_hub' (/usr/local/lib/python3.10/dist-packages/huggingface_hub/__init__.py)