Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ def pipeline(

# Config is the primordial information item.
# Instantiate config if needed
adapter_path = None
if isinstance(config, str):
config = AutoConfig.from_pretrained(
config, _from_pipeline=task, code_revision=code_revision, **hub_kwargs, **model_kwargs
Expand All @@ -844,6 +845,7 @@ def pipeline(
if maybe_adapter_path is not None:
with open(maybe_adapter_path, "r", encoding="utf-8") as f:
adapter_config = json.load(f)
adapter_path = model
model = adapter_config["base_model_name_or_path"]

config = AutoConfig.from_pretrained(
Expand Down Expand Up @@ -938,7 +940,7 @@ def pipeline(
if isinstance(model, str) or framework is None:
model_classes = {"tf": targeted_task["tf"], "pt": targeted_task["pt"]}
framework, model = infer_framework_load_model(
model,
adapter_path if adapter_path is not None else model,
model_classes=model_classes,
config=config,
framework=framework,
Expand Down
10 changes: 7 additions & 3 deletions tests/peft_integration/test_peft_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,13 @@ def test_peft_pipeline(self):
"""
from transformers import pipeline

for model_id in self.peft_test_model_ids:
pipe = pipeline("text-generation", model_id)
_ = pipe("Hello")
for adapter_id, base_model_id in zip(self.peft_test_model_ids, self.transformers_test_model_ids):
peft_pipe = pipeline("text-generation", adapter_id)
base_pipe = pipeline("text-generation", base_model_id)
peft_params = list(peft_pipe.model.parameters())
base_params = list(base_pipe.model.parameters())
self.assertNotEqual(len(peft_params), len(base_params)) # Assert we actually loaded the adapter too
_ = peft_pipe("Hello")

def test_peft_add_adapter_with_state_dict(self):
"""
Expand Down