moment-timeseries-foundation-model / moment

MOMENT: A Family of Open Time-series Foundation Models
https://moment-timeseries-foundation-model.github.io/
MIT License
319 stars 51 forks source link

RuntimeError: Failed to import transformers.models.t5.modeling_t5 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' (/hy-tmp/sz-moment/lib/python3.11/site-packages/huggingface_hub/__init__.py) #38

Closed shaozheliu closed 1 month ago

shaozheliu commented 2 months ago

First of all, thank you very much for your open-source work on Moment.

Environment

Python== 3.11
torch==2.3.1
huggingface-hub==0.19.4
transformers==4.33.3

My code

model = MOMENTPipeline.from_pretrained("/hy-tmp/better464/MOMENT-1-large",  
                                           model_kwargs={
                                               'task_name': 'forecasting',
                                               'forecast_horizon': 192,
                                               'head_dropout': 0.1,
                                               'weight_decay': 0,
                                               'freeze_encoder': True,  # Freeze the patch embedding layer
                                               'freeze_embedder': True,  # Freeze the transformer encoder
                                               'freeze_head': False,  # The linear forecasting head must be trained
                                           },
                                           )
model.init()

Complete traceback

Traceback (most recent call last):
  File "/hy-tmp/moment/huggingface_download.py", line 6, in <module>
    from momentfm import MOMENTPipeline
  File "/hy-tmp/moment/momentfm/__init__.py", line 1, in <module>
    from .models.moment import MOMENT, MOMENTPipeline
  File "/hy-tmp/moment/momentfm/models/moment.py", line 10, in <module>
    from transformers import T5Config, T5EncoderModel, T5Model
  File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
  File "/hy-tmp/sz-moment/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1175, in __getattr__
    value = getattr(module, name)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/hy-tmp/sz-moment/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1174, in __getattr__
    module = self._get_module(self._class_to_module[name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/hy-tmp/sz-moment/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 1186, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.models.t5.modeling_t5 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' (/hy-tmp/sz-moment/lib/python3.11/site-packages/huggingface_hub/__init__.py)
julian-fong commented 1 month ago

I think it is due to the huggingface-hub version. See https://github.com/run-llama/llama_index/discussions/14605

mononitogoswami commented 1 month ago

Hi Shaozhe, Thanks for your interest in MOMENT. We released a few changes to MOMENT, and hope it works for you now. I'll close this issue, but please don't hesitate to open another one should you face any problems.

Best, Mononito