Skip to content

Chapter 04 -pin peft version compatible with transformers==4.41.2 ImportError: cannot import name 'EncoderDecoderCache' from 'transformers' (/usr/local/lib/python3.12/dist-packages/transformers/ #117

Description

@seanv507

Problem

The Supervised classification fails because of an implicit install of peft which imports EncoderDecoderCache from transformers.

/usr/local/lib/python3.12/dist-packages/peft/peft_model.py in
37 from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
---> 38 from transformers import Cache, DynamicCache, EncoderDecoderCache, PreTrainedModel
39 from transformers.modeling_outputs import QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput

ImportError: cannot import name 'EncoderDecoderCache' from 'transformers' (/usr/local/lib/python3.12/dist-packages/transformers/init.py)

Solution

pinning peft to 0.11.1 (as in requirements.txt ) solves this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions