Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to use https://huggingface.co/anas-awadalla/mpt-7b model downloading issue? #294

Open
MRAWAY77 opened this issue Mar 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@MRAWAY77
Copy link

100%|███████████████████████████████████████| 933M/933M [01:59<00:00, 7.79MiB/s]
tokenizer_config.json: 100%
 237/237 [00:00<00:00, 53.8kB/s]
tokenizer.json: 100%
 2.11M/2.11M [00:00<00:00, 4.15MB/s]
special_tokens_map.json: 100%
 99.0/99.0 [00:00<00:00, 24.1kB/s]
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
config.json: 100%
 1.26k/1.26k [00:00<00:00, 321kB/s]
configuration_mpt.py: 100%
 9.20k/9.20k [00:00<00:00, 2.21MB/s]
A new version of the following files was downloaded from https://huggingface.co/anas-awadalla/mpt-7b:

  • configuration_mpt.py
    . Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
    modeling_mpt.py: 100%
     18.4k/18.4k [00:00<00:00, 3.96MB/s]
    A new version of the following files was downloaded from https://huggingface.co/anas-awadalla/mpt-7b:
  • modeling_mpt.py
    . Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.

ImportError Traceback (most recent call last)
Cell In[3], line 2
1 # Foundational Models with 9B parameter with Multimodal Pretraining (MPT) on 7 Billion Tokens
----> 2 model, image_processor, tokenizer = create_model_and_transforms(
3 clip_vision_encoder_path="ViT-L-14",
4 clip_vision_encoder_pretrained="openai",
5 lang_encoder_path="anas-awadalla/mpt-7b",
6 tokenizer_path="anas-awadalla/mpt-7b",
7 cross_attn_every_n_layers=4,
8 cache_dir="/home/mraway/Desktop/src/open_flamingo/open_flamingo" # Defaults to ~/.cache
9 )
11 checkpoint_path = hf_hub_download("openflamingo/OpenFlamingo-9B-vitl-mpt7b", "checkpoint.pt")
12 model.load_state_dict(torch.load(checkpoint_path), strict=False)

File ~/Desktop/src/open_flamingo/open_flamingo/src/factory.py:65, in create_model_and_transforms(clip_vision_encoder_path, clip_vision_encoder_pretrained, lang_encoder_path, tokenizer_path, cross_attn_every_n_layers, use_local_files, decoder_layers_attr_name, freeze_lm_embeddings, cache_dir, **flamingo_kwargs)
60 if text_tokenizer.pad_token is None:
61 # Issue: GPT models don't have a pad token, which we use to
62 # modify labels for the loss.
63 text_tokenizer.add_special_tokens({"pad_token": ""})
---> 65 lang_encoder = AutoModelForCausalLM.from_pretrained(
66 lang_encoder_path,
67 local_files_only=use_local_files,
68 trust_remote_code=True,
69 cache_dir=cache_dir,
70 )
72 # hacks for MPT-1B, which doesn't have a get_input_embeddings method
73 if "mpt-1b-redpajama-200b" in lang_encoder_path:

File ~/anaconda3/envs/flamingo/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:550, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
548 if has_remote_code and trust_remote_code:
549 class_ref = config.auto_map[cls.name]
--> 550 model_class = get_class_from_dynamic_module(
551 class_ref, pretrained_model_name_or_path, code_revision=code_revision, **hub_kwargs, **kwargs
552 )
553 _ = hub_kwargs.pop("code_revision", None)
554 if os.path.isdir(pretrained_model_name_or_path):

File ~/anaconda3/envs/flamingo/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:501, in get_class_from_dynamic_module(class_reference, pretrained_model_name_or_path, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, repo_type, code_revision, **kwargs)
488 # And lastly we get the class inside our newly created module
489 final_module = get_cached_module_file(
490 repo_id,
491 module_file + ".py",
(...)
499 repo_type=repo_type,
500 )
--> 501 return get_class_in_module(class_name, final_module)

File ~/anaconda3/envs/flamingo/lib/python3.12/site-packages/transformers/dynamic_module_utils.py:201, in get_class_in_module(class_name, module_path)
199 name = os.path.normpath(module_path).replace(".py", "").replace(os.path.sep, ".")
200 module_path = str(Path(HF_MODULES_CACHE) / module_path)
--> 201 module = importlib.machinery.SourceFileLoader(name, module_path).load_module()
202 return getattr(module, class_name)

File :649, in _check_name_wrapper(self, name, *args, **kwargs)

File :1176, in load_module(self, fullname)

File :1000, in load_module(self, fullname)

File :537, in _load_module_shim(self, fullname)

File :966, in _load(spec)

File :935, in _load_unlocked(spec)

File :995, in exec_module(self, module)

File :488, in _call_with_frames_removed(f, *args, **kwds)

File ~/.cache/huggingface/modules/transformers_modules/anas-awadalla/mpt-7b/b772e556c8e8a17d087db6935e7cd019e5eefb0f/modeling_mpt.py:18
16 from .configuration_mpt import MPTConfig
17 from .adapt_tokenizer import AutoTokenizerForMOD, adapt_tokenizer_for_denoising
---> 18 from .hf_prefixlm_converter import add_bidirectional_mask_if_missing, convert_hf_causal_lm_to_prefix_lm
19 from .meta_init_context import init_empty_weights
20 from .param_init_fns import MODEL_INIT_REGISTRY, generic_param_init_fn_

File ~/.cache/huggingface/modules/transformers_modules/anas-awadalla/mpt-7b/b772e556c8e8a17d087db6935e7cd019e5eefb0f/hf_prefixlm_converter.py:15
13 import torch
14 from transformers.models.bloom.modeling_bloom import BaseModelOutputWithPastAndCrossAttentions, BloomForCausalLM, BloomModel, CausalLMOutputWithCrossAttentions, CrossEntropyLoss
---> 15 from transformers.models.bloom.modeling_bloom import _expand_mask as _expand_mask_bloom
16 from transformers.models.bloom.modeling_bloom import _make_causal_mask as _make_causal_mask_bloom
17 from transformers.models.bloom.modeling_bloom import logging

ImportError: cannot import name '_expand_mask' from 'transformers.models.bloom.modeling_bloom' (/home/mraway/anaconda3/envs/flamingo/lib/python3.12/site-packages/transformers/models/bloom/modeling_bloom.py)

@MRAWAY77 MRAWAY77 added the bug Something isn't working label Mar 22, 2024
@Wangzi06
Copy link

Wangzi06 commented Aug 2, 2024

Hello were you able to solve this issue? if saw would you share how you got around it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants