Andyson commited on
Commit
b8b69f9
1 Parent(s): 0fc422c
configs/clm_models/agent_7b_sft.yaml CHANGED
@@ -15,4 +15,5 @@ output_resampler:
15
 
16
  lm_loss_scale: 1.0
17
  rec_loss_scale: 1.0
18
- pretrained_model_path: TencentARC/SEED-Story
 
 
15
 
16
  lm_loss_scale: 1.0
17
  rec_loss_scale: 1.0
18
+ pretrained_model_path: TencentARC/SEED-Story
19
+ subfolder: seed_story/george_sft
src/models_clm/models.py CHANGED
@@ -221,23 +221,22 @@ class ContinuousLVLM(nn.Module):
221
  'past_key_values': output_past_key_values
222
  }
223
 
224
-
225
  @classmethod
226
- def from_pretrained(cls, llm, input_resampler, output_resampler, pretrained_model_path=None, **kwargs):
227
  model = cls(llm=llm, input_resampler=input_resampler, output_resampler=output_resampler, **kwargs)
228
 
229
  if pretrained_model_path is not None:
230
- # Check if the path is intended for Hugging Face Hub
231
  if 'TencentARC/SEED-Story' in pretrained_model_path:
232
- # Load from a specific subfolder within the Hugging Face repository
233
- ckpt = AutoModel.from_pretrained(pretrained_model_path, subfolder="seed_story/george_sft")
234
  missing, unexpected = model.load_state_dict(ckpt.state_dict(), strict=False)
235
- print('Agent model, missing keys: ', len(missing), 'unexpected keys:', len(unexpected))
236
  else:
237
  # For local path loading
238
  ckpt = torch.load(pretrained_model_path, map_location='cpu')
239
  missing, unexpected = model.load_state_dict(ckpt, strict=False)
240
- print('Agent model, missing keys: ', len(missing), 'unexpected keys:', len(unexpected))
241
 
242
  return model
243
 
 
221
  'past_key_values': output_past_key_values
222
  }
223
 
 
224
  @classmethod
225
+ def from_pretrained(cls, llm, input_resampler, output_resampler, pretrained_model_path=None, subfolder=None, **kwargs):
226
  model = cls(llm=llm, input_resampler=input_resampler, output_resampler=output_resampler, **kwargs)
227
 
228
  if pretrained_model_path is not None:
229
+ # Load model from Hugging Face Hub with subfolder specification
230
  if 'TencentARC/SEED-Story' in pretrained_model_path:
231
+ # Use `subfolder` to specify the location within the repository
232
+ ckpt = AutoModel.from_pretrained(pretrained_model_path, subfolder=subfolder)
233
  missing, unexpected = model.load_state_dict(ckpt.state_dict(), strict=False)
234
+ print('Detokenizer model, missing keys: ', len(missing), 'unexpected keys:', len(unexpected))
235
  else:
236
  # For local path loading
237
  ckpt = torch.load(pretrained_model_path, map_location='cpu')
238
  missing, unexpected = model.load_state_dict(ckpt, strict=False)
239
+ print('Detokenizer model, missing keys: ', len(missing), 'unexpected keys:', len(unexpected))
240
 
241
  return model
242