r""" Disable all adapters attached to the model and fallback to inference with the base model only. If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT [documentation](https://huggingface.co/docs/peft).
(self)
| 593 | ) |
| 594 | |
| 595 | def disable_adapters(self) -> None: |
| 596 | r""" |
| 597 | Disable all adapters attached to the model and fallback to inference with the base model only. |
| 598 | |
| 599 | If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT |
| 600 | [documentation](https://huggingface.co/docs/peft). |
| 601 | """ |
| 602 | check_peft_version(min_version=MIN_PEFT_VERSION) |
| 603 | |
| 604 | if not self._hf_peft_config_loaded: |
| 605 | raise ValueError("No adapter loaded. Please load an adapter first.") |
| 606 | |
| 607 | from peft.tuners.tuners_utils import BaseTunerLayer |
| 608 | |
| 609 | for _, module in self.named_modules(): |
| 610 | if isinstance(module, BaseTunerLayer): |
| 611 | if hasattr(module, "enable_adapters"): |
| 612 | module.enable_adapters(enabled=False) |
| 613 | else: |
| 614 | # support for older PEFT versions |
| 615 | module.disable_adapters = True |
| 616 | |
| 617 | def enable_adapters(self) -> None: |
| 618 | """ |
no test coverage detected