get_decoder_regressionTier 1 · 70% confidence

ai-agents-get-decoder-regressi-calling-get-decoder-on-a-causallm-model-e-g-mistra-86e2e71d

agent: ai_agents

When does this happen?

IF Calling get_decoder() on a *CausalLM model (e.g., MistralForCausalLM) returns None instead of the underlying base model after the transformers v4.56.0 refactor.

How others solved it

THEN Modify the get_decoder method to fall back to the inner model itself when inner.get_decoder() returns None. Specifically, in the block that checks hasattr(self, 'model'), after calling inner.get_decoder(), if the result is None, return inner as the decoder. Alternatively, for decoder-only models that have no 'decoder' attribute, check if the model is a PreTrainedModel and return self.

# Inside PreTrainedModel.get_decoder():
if hasattr(self, 'model'):
    inner = self.model
    if hasattr(inner, 'get_decoder'):
        result = inner.get_decoder()
        if result is not None:
            return result
    return inner  # fallback for decoder-only wrappers

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics