Skip to content

Commit

Permalink
Fix backward compatibility caused by missing eval metrics class (#3385)
Browse files Browse the repository at this point in the history
* a

* a'

* a

* a

* a

* a

* a

* a

* a

* Apply suggestions from code review

Co-authored-by: Mihir Patel <[email protected]>

---------

Co-authored-by: Daniel King <[email protected]>
Co-authored-by: Mihir Patel <[email protected]>
  • Loading branch information
3 people committed Jun 8, 2024
1 parent 7a533cb commit 4d0384a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions composer/metrics/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,27 @@ def compute(self) -> Tensor:
"""Returns torch.exp() of the LanguageCrossEntropy."""
avg_loss = super().compute()
return torch.exp(avg_loss)


# For backward compatibility
class InContextLearningMetric:
"""InContextLearningMetric only exists for backwards compatibility of checkpoints that contain pickled metrics."""

def __init__(self):
raise RuntimeError(
f'This class only exists for maintaining backward compatibility for checkpoints that contain pickled metrics. Please instead use https://github.com/mosaicml/llm-foundry/blob/main/scripts/eval/README.md.',
)

def __getstate__(self):
return None

def __setstate__(self, state):
pass


InContextLearningCodeEvalAccuracy = InContextLearningMetric
InContextLearningLMAccuracy = InContextLearningMetric
InContextLearningLMExpectedCalibrationError = InContextLearningMetric
InContextLearningMCExpectedCalibrationError = InContextLearningMetric
InContextLearningQAAccuracy = InContextLearningMetric
InContextLearningMultipleChoiceAccuracy = InContextLearningMetric

0 comments on commit 4d0384a

Please sign in to comment.