[core] remove GenerationMixin inheritance by default in PreTrainedModel (#37173)

This commit is contained in:
Joao Gante
2025-04-08 16:42:05 +01:00
committed by GitHub
parent aab0878327
commit 4321b0648c
10 changed files with 54 additions and 83 deletions

View File

@@ -1720,8 +1720,8 @@ class ModelUtilsTest(TestCasePlus):
self.assertTrue("" == cl.out)
self.assertTrue(can_generate)
# 4 - BC: models with a custom `prepare_inputs_for_generation` can generate (it was assumed they inherited
# `GenerationMixin`)
# 4 - Legacy: models with a custom `prepare_inputs_for_generation` can generate (it was assumed
# they inherited `GenerationMixin`). Deprecated in v4.45 and removed in v4.51.
class DummyBertWithPrepareInputs(BertModel):
def prepare_inputs_for_generation(self):
pass
@@ -1729,7 +1729,7 @@ class ModelUtilsTest(TestCasePlus):
with CaptureLogger(logger) as cl:
can_generate = DummyBertWithPrepareInputs.can_generate()
self.assertTrue("it doesn't directly inherit from `GenerationMixin`" in cl.out)
self.assertTrue(can_generate)
self.assertFalse(can_generate)
def test_save_and_load_config_with_custom_generation(self):
"""