Skip to content

Commit

Permalink
Make config/class properties on ComposerMPTForCausalLM (#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakinggg authored May 22, 2024
1 parent 8e29698 commit c891bed
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions llmfoundry/models/mpt/modeling_mpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
MutableMapping,
Optional,
Tuple,
Type,
Union,
)

Expand Down Expand Up @@ -1082,9 +1083,7 @@ def __init__(

additional_train_metrics = additional_train_metrics or []

model = MPTForCausalLM(
MPTConfig(use_train_metrics=use_train_metrics, **kwargs),
)
model = self.model_class(self.config_class(**kwargs),)

use_train_metrics = use_train_metrics
train_metric_names = DEFAULT_CAUSAL_LM_TRAIN_METRICS + additional_train_metrics
Expand Down Expand Up @@ -1134,6 +1133,14 @@ def __init__(
f'Specified loss_fn={self.loss_fn} not recognized. `loss_fn` must be one of [`fused_crossentropy`, `torch_crossentropy`].',
)

@property
def model_class(self) -> Type[MPTForCausalLM]:
return MPTForCausalLM

@property
def config_class(self) -> Type[MPTConfig]:
return MPTConfig

def get_targets(self, batch: Mapping) -> torch.Tensor:
targets = torch.roll(batch['labels'], shifts=-1)
targets[:, -1] = -100
Expand Down

0 comments on commit c891bed

Please sign in to comment.