Unverified Commit b29c3945 authored by Hwijeen Ahn's avatar Hwijeen Ahn Committed by GitHub
Browse files

raise exception when arguments to pipeline are incomplete (#12548)

* raise exception when arguments are incomplete

* change exception to runtime error
parent 122d7dc3
......@@ -387,6 +387,18 @@ def pipeline(
>>> tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
>>> pipeline('ner', model=model, tokenizer=tokenizer)
"""
if model is None and tokenizer is not None:
raise RuntimeError(
"Impossible to instantiate a pipeline with tokenizer specified but not the model "
"as the provided tokenizer may not be compatible with the default model. "
"Please provide a PreTrainedModel class or a path/identifier to a pretrained model when providing tokenizer."
)
if model is None and feature_extractor is not None:
raise RuntimeError(
"Impossible to instantiate a pipeline with feature_extractor specified but not the model "
"as the provided feature_extractor may not be compatible with the default model. "
"Please provide a PreTrainedModel class or a path/identifier to a pretrained model when providing feature_extractor."
)
# Retrieve the task
targeted_task, task_options = check_task(task)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment