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

fix: checkpoint conversion to HF #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/modalities/models/huggingface_adapters/hf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HFModelAdapterConfig(PretrainedConfig):

model_type = "modalities"

def __init__(self, **kwargs):
def __init__(self, config={}, **kwargs):
"""
Initializes an HFModelAdapterConfig object.

Expand All @@ -28,6 +28,7 @@ def __init__(self, **kwargs):
ConfigError: If the config is not passed in HFModelAdapterConfig.
"""
super().__init__(**kwargs)
self.config = config
# self.config is added by the super class via kwargs
if self.config is None:
raise ConfigError("Config is not passed in HFModelAdapterConfig.")
Expand Down Expand Up @@ -115,7 +116,7 @@ def forward(
raise NotImplementedError
model_input = {"input_ids": input_ids, "attention_mask": attention_mask}
model_forward_output: dict[str, torch.Tensor] = self.model.forward(model_input)
if return_dict:
if not return_dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I executed the checkpoint conversion. Everything works perfectly.

I ran eval harness with these changes (since the HFModelAdapterConfig and HFModelAdapter are required while evaluating modalities using eval harness as well). This change seems to have affected the eval run. On reverting this change back, it seems to run.

return ModalitiesModelOutput(**model_forward_output)
else:
return model_forward_output[self.prediction_key]
Expand Down
Loading