我用 readme 的示例代码尝试加载模型时出现:
KeyError Traceback (most recent call last)
/tmp/ipython-input-769196332.py in <cell line: 0>()
284
285 model_path = "Dream-org/Dream-v0-Instruct-7B"
--> 286 model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
287 tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
288 model = model.to("cuda").eval()
7 frames
/usr/local/lib/python3.12/dist-packages/transformers/models/auto/auto_factory.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
363 model_class.register_for_auto_class(auto_class=cls)
364 model_class = add_generation_mixin_to_remote_model(model_class)
--> 365 return model_class.from_pretrained(
366 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
367 )
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
563 **kwargs,
564 ):
--> 565 _model = super().from_pretrained(
566 pretrained_model_name_or_path,
567 *model_args,
/usr/local/lib/python3.12/dist-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
4070 with ContextManagers(model_init_context):
4071 # Let's make sure we don't run the init function of buffer modules
-> 4072 model = cls(config, *model_args, **model_kwargs)
4073
4074 if hf_quantizer is not None: # replace module with quantized modules (does not touch weights)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config)
739 def init(self, config):
740 super().init(config)
--> 741 self.model = DreamBaseModel(config)
742 self.vocab_size = config.vocab_size
743 self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config)
615 self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
616 self.layers = nn.ModuleList(
--> 617 [DreamDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
618 )
619 self._attn_implementation = config._attn_implementation
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config, layer_idx)
451
452 # self.self_attn = Dream_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx)
--> 453 self.self_attn = DreamSdpaAttention(config, layer_idx)
454
455 self.mlp = DreamMLP(config)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config, layer_idx)
273 self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
274
--> 275 self.rotary_emb = DreamRotaryEmbedding(config=self.config)
276
277 def forward(
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, dim, max_position_embeddings, base, device, scaling_factor, rope_type, config)
118
119 self.config = config
--> 120 self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
121
122 inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device, **self.rope_kwargs)
KeyError: 'default'
但是一个月前可以正常加载
我用 readme 的示例代码尝试加载模型时出现:
KeyError Traceback (most recent call last)
/tmp/ipython-input-769196332.py in <cell line: 0>()
284
285 model_path = "Dream-org/Dream-v0-Instruct-7B"
--> 286 model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
287 tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
288 model = model.to("cuda").eval()
7 frames
/usr/local/lib/python3.12/dist-packages/transformers/models/auto/auto_factory.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
363 model_class.register_for_auto_class(auto_class=cls)
364 model_class = add_generation_mixin_to_remote_model(model_class)
--> 365 return model_class.from_pretrained(
366 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
367 )
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
563 **kwargs,
564 ):
--> 565 _model = super().from_pretrained(
566 pretrained_model_name_or_path,
567 *model_args,
/usr/local/lib/python3.12/dist-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
4070 with ContextManagers(model_init_context):
4071 # Let's make sure we don't run the init function of buffer modules
-> 4072 model = cls(config, *model_args, **model_kwargs)
4073
4074 if hf_quantizer is not None: # replace module with quantized modules (does not touch weights)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config)
739 def init(self, config):
740 super().init(config)
--> 741 self.model = DreamBaseModel(config)
742 self.vocab_size = config.vocab_size
743 self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config)
615 self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
616 self.layers = nn.ModuleList(
--> 617 [DreamDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
618 )
619 self._attn_implementation = config._attn_implementation
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config, layer_idx)
451
452 # self.self_attn = Dream_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx)
--> 453 self.self_attn = DreamSdpaAttention(config, layer_idx)
454
455 self.mlp = DreamMLP(config)
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, config, layer_idx)
273 self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
274
--> 275 self.rotary_emb = DreamRotaryEmbedding(config=self.config)
276
277 def forward(
~/.cache/huggingface/modules/transformers_modules/Dream_hyphen_org/Dream_hyphen_v0_hyphen_Instruct_hyphen_7B/05334cb9faaf763692dcf9d8737c642be2b2a6ae/modeling_dream.py in init(self, dim, max_position_embeddings, base, device, scaling_factor, rope_type, config)
118
119 self.config = config
--> 120 self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
121
122 inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device, **self.rope_kwargs)
KeyError: 'default'
但是一个月前可以正常加载