Unverified Commit a3ded170 authored by Nicolas Patry's avatar Nicolas Patry Committed by GitHub
Browse files

Fixing mutable default argument in `pipeline`. (#14316)

* Fixing mutable default argument.

* XX.

* Revert "XX."

This reverts commit 61d4bb333f6d39a7fbe31d161b8bd14787ceec2e.
parent 9b78b070
...@@ -308,7 +308,7 @@ def pipeline( ...@@ -308,7 +308,7 @@ def pipeline(
revision: Optional[str] = None, revision: Optional[str] = None,
use_fast: bool = True, use_fast: bool = True,
use_auth_token: Optional[Union[str, bool]] = None, use_auth_token: Optional[Union[str, bool]] = None,
model_kwargs: Dict[str, Any] = {}, model_kwargs: Dict[str, Any] = None,
**kwargs **kwargs
) -> Pipeline: ) -> Pipeline:
""" """
...@@ -420,6 +420,8 @@ def pipeline( ...@@ -420,6 +420,8 @@ def pipeline(
>>> tokenizer = AutoTokenizer.from_pretrained("bert-base-cased") >>> tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
>>> pipeline('ner', model=model, tokenizer=tokenizer) >>> pipeline('ner', model=model, tokenizer=tokenizer)
""" """
if model_kwargs is None:
model_kwargs = {}
if model is None and tokenizer is not None: if model is None and tokenizer is not None:
raise RuntimeError( raise RuntimeError(
"Impossible to instantiate a pipeline with tokenizer specified but not the model " "Impossible to instantiate a pipeline with tokenizer specified but not the model "
......
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