mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
raise exception when arguments to pipeline are incomplete (#12548)
* raise exception when arguments are incomplete * change exception to runtime error
This commit is contained in:
parent
122d7dc34f
commit
b29c394586
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user