-
Notifications
You must be signed in to change notification settings - Fork 32k
[Pipelines] Add revision tag to all default pipelines #17667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d54a4cb
ca6a820
3623fed
38d686d
ab5324e
618aee5
2fcd9b6
24205b8
4e4ff87
f8ef027
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| from ..models.auto.tokenization_auto import TOKENIZER_MAPPING, AutoTokenizer | ||
| from ..tokenization_utils import PreTrainedTokenizer | ||
| from ..tokenization_utils_fast import PreTrainedTokenizerFast | ||
| from ..utils import http_get, is_tf_available, is_torch_available, logging | ||
| from ..utils import HUGGINGFACE_CO_RESOLVE_ENDPOINT, http_get, is_tf_available, is_torch_available, logging | ||
| from .audio_classification import AudioClassificationPipeline | ||
| from .automatic_speech_recognition import AutomaticSpeechRecognitionPipeline | ||
| from .base import ( | ||
|
|
@@ -41,7 +41,7 @@ | |
| Pipeline, | ||
| PipelineDataFormat, | ||
| PipelineException, | ||
| get_default_model, | ||
| get_default_model_and_revision, | ||
| infer_framework_load_model, | ||
| ) | ||
| from .conversational import Conversation, ConversationalPipeline | ||
|
|
@@ -131,21 +131,21 @@ | |
| "impl": AudioClassificationPipeline, | ||
| "tf": (), | ||
| "pt": (AutoModelForAudioClassification,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "superb/wav2vec2-base-superb-ks"}}, | ||
| "default": {"model": {"pt": ("superb/wav2vec2-base-superb-ks", "372e048")}}, | ||
| "type": "audio", | ||
| }, | ||
| "automatic-speech-recognition": { | ||
| "impl": AutomaticSpeechRecognitionPipeline, | ||
| "tf": (), | ||
| "pt": (AutoModelForCTC, AutoModelForSpeechSeq2Seq) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "facebook/wav2vec2-base-960h"}}, | ||
| "default": {"model": {"pt": ("facebook/wav2vec2-base-960h", "55bb623")}}, | ||
| "type": "multimodal", | ||
| }, | ||
| "feature-extraction": { | ||
| "impl": FeatureExtractionPipeline, | ||
| "tf": (TFAutoModel,) if is_tf_available() else (), | ||
| "pt": (AutoModel,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "distilbert-base-cased", "tf": "distilbert-base-cased"}}, | ||
| "default": {"model": {"pt": ("distilbert-base-cased", "935ac13"), "tf": ("distilbert-base-cased", "935ac13")}}, | ||
| "type": "multimodal", | ||
| }, | ||
| "text-classification": { | ||
|
|
@@ -154,8 +154,8 @@ | |
| "pt": (AutoModelForSequenceClassification,) if is_torch_available() else (), | ||
| "default": { | ||
| "model": { | ||
| "pt": "distilbert-base-uncased-finetuned-sst-2-english", | ||
| "tf": "distilbert-base-uncased-finetuned-sst-2-english", | ||
| "pt": ("distilbert-base-uncased-finetuned-sst-2-english", "af0f99b"), | ||
| "tf": ("distilbert-base-uncased-finetuned-sst-2-english", "af0f99b"), | ||
| }, | ||
| }, | ||
| "type": "text", | ||
|
|
@@ -166,8 +166,8 @@ | |
| "pt": (AutoModelForTokenClassification,) if is_torch_available() else (), | ||
| "default": { | ||
| "model": { | ||
| "pt": "dbmdz/bert-large-cased-finetuned-conll03-english", | ||
| "tf": "dbmdz/bert-large-cased-finetuned-conll03-english", | ||
| "pt": ("dbmdz/bert-large-cased-finetuned-conll03-english", "f2482bf"), | ||
| "tf": ("dbmdz/bert-large-cased-finetuned-conll03-english", "f2482bf"), | ||
| }, | ||
| }, | ||
| "type": "text", | ||
|
|
@@ -177,7 +177,10 @@ | |
| "tf": (TFAutoModelForQuestionAnswering,) if is_tf_available() else (), | ||
| "pt": (AutoModelForQuestionAnswering,) if is_torch_available() else (), | ||
| "default": { | ||
| "model": {"pt": "distilbert-base-cased-distilled-squad", "tf": "distilbert-base-cased-distilled-squad"}, | ||
| "model": { | ||
| "pt": ("distilbert-base-cased-distilled-squad", "626af31"), | ||
| "tf": ("distilbert-base-cased-distilled-squad", "626af31"), | ||
| }, | ||
| }, | ||
| "type": "text", | ||
| }, | ||
|
|
@@ -187,9 +190,8 @@ | |
| "tf": (TFAutoModelForTableQuestionAnswering,) if is_tf_available() else (), | ||
| "default": { | ||
| "model": { | ||
| "pt": "google/tapas-base-finetuned-wtq", | ||
| "tokenizer": "google/tapas-base-finetuned-wtq", | ||
| "tf": "google/tapas-base-finetuned-wtq", | ||
| "pt": ("google/tapas-base-finetuned-wtq", "69ceee2"), | ||
| "tf": ("google/tapas-base-finetuned-wtq", "69ceee2"), | ||
| }, | ||
| }, | ||
| "type": "text", | ||
|
|
@@ -199,26 +201,22 @@ | |
| "pt": (AutoModelForVisualQuestionAnswering,) if is_torch_available() else (), | ||
| "tf": (), | ||
| "default": { | ||
| "model": { | ||
| "pt": "dandelin/vilt-b32-finetuned-vqa", | ||
| "tokenizer": "dandelin/vilt-b32-finetuned-vqa", | ||
| "feature_extractor": "dandelin/vilt-b32-finetuned-vqa", | ||
|
Comment on lines
-204
to
-205
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleted tokenizer and feature extractor because of https://github.com/huggingface/transformers/pull/17667/files#r910987282 |
||
| }, | ||
| "model": {"pt": ("dandelin/vilt-b32-finetuned-vqa", "4355f59")}, | ||
| }, | ||
| "type": "multimodal", | ||
| }, | ||
| "fill-mask": { | ||
| "impl": FillMaskPipeline, | ||
| "tf": (TFAutoModelForMaskedLM,) if is_tf_available() else (), | ||
| "pt": (AutoModelForMaskedLM,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "distilroberta-base", "tf": "distilroberta-base"}}, | ||
| "default": {"model": {"pt": ("distilroberta-base", "ec58a5b"), "tf": ("distilroberta-base", "ec58a5b")}}, | ||
| "type": "text", | ||
| }, | ||
| "summarization": { | ||
| "impl": SummarizationPipeline, | ||
| "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (), | ||
| "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "sshleifer/distilbart-cnn-12-6", "tf": "t5-small"}}, | ||
| "default": {"model": {"pt": ("sshleifer/distilbart-cnn-12-6", "a4f8f3e"), "tf": ("t5-small", "d769bba")}}, | ||
| "type": "text", | ||
| }, | ||
| # This task is a special case as it's parametrized by SRC, TGT languages. | ||
|
|
@@ -227,70 +225,76 @@ | |
| "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (), | ||
| "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (), | ||
| "default": { | ||
| ("en", "fr"): {"model": {"pt": "t5-base", "tf": "t5-base"}}, | ||
| ("en", "de"): {"model": {"pt": "t5-base", "tf": "t5-base"}}, | ||
| ("en", "ro"): {"model": {"pt": "t5-base", "tf": "t5-base"}}, | ||
| ("en", "fr"): {"model": {"pt": ("t5-base", "686f1db"), "tf": ("t5-base", "686f1db")}}, | ||
| ("en", "de"): {"model": {"pt": ("t5-base", "686f1db"), "tf": ("t5-base", "686f1db")}}, | ||
| ("en", "ro"): {"model": {"pt": ("t5-base", "686f1db"), "tf": ("t5-base", "686f1db")}}, | ||
| }, | ||
| "type": "text", | ||
| }, | ||
| "text2text-generation": { | ||
| "impl": Text2TextGenerationPipeline, | ||
| "tf": (TFAutoModelForSeq2SeqLM,) if is_tf_available() else (), | ||
| "pt": (AutoModelForSeq2SeqLM,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "t5-base", "tf": "t5-base"}}, | ||
| "default": {"model": {"pt": ("t5-base", "686f1db"), "tf": ("t5-base", "686f1db")}}, | ||
| "type": "text", | ||
| }, | ||
| "text-generation": { | ||
| "impl": TextGenerationPipeline, | ||
| "tf": (TFAutoModelForCausalLM,) if is_tf_available() else (), | ||
| "pt": (AutoModelForCausalLM,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "gpt2", "tf": "gpt2"}}, | ||
| "default": {"model": {"pt": ("gpt2", "6c0e608"), "tf": ("gpt2", "6c0e608")}}, | ||
| "type": "text", | ||
| }, | ||
| "zero-shot-classification": { | ||
| "impl": ZeroShotClassificationPipeline, | ||
| "tf": (TFAutoModelForSequenceClassification,) if is_tf_available() else (), | ||
| "pt": (AutoModelForSequenceClassification,) if is_torch_available() else (), | ||
| "default": { | ||
| "model": {"pt": "facebook/bart-large-mnli", "tf": "roberta-large-mnli"}, | ||
| "config": {"pt": "facebook/bart-large-mnli", "tf": "roberta-large-mnli"}, | ||
| "tokenizer": {"pt": "facebook/bart-large-mnli", "tf": "roberta-large-mnli"}, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Narsil before merging this PR, I'd love to have your opinion here. I've checked a the pipeline function and I don't think a "default" tokenizer is never used. If no |
||
| "model": {"pt": ("facebook/bart-large-mnli", "c626438"), "tf": ("roberta-large-mnli", "130fb28")}, | ||
| "config": {"pt": ("facebook/bart-large-mnli", "c626438"), "tf": ("roberta-large-mnli", "130fb28")}, | ||
| }, | ||
| "type": "text", | ||
| }, | ||
| "zero-shot-image-classification": { | ||
| "impl": ZeroShotImageClassificationPipeline, | ||
| "tf": (TFAutoModel,) if is_tf_available() else (), | ||
| "pt": (AutoModel,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "openai/clip-vit-base-patch32", "tf": "openai/clip-vit-base-patch32"}}, | ||
| "default": { | ||
| "model": { | ||
| "pt": ("openai/clip-vit-base-patch32", "f4881ba"), | ||
| "tf": ("openai/clip-vit-base-patch32", "f4881ba"), | ||
| } | ||
| }, | ||
| "type": "multimodal", | ||
| }, | ||
| "conversational": { | ||
| "impl": ConversationalPipeline, | ||
| "tf": (TFAutoModelForSeq2SeqLM, TFAutoModelForCausalLM) if is_tf_available() else (), | ||
| "pt": (AutoModelForSeq2SeqLM, AutoModelForCausalLM) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "microsoft/DialoGPT-medium", "tf": "microsoft/DialoGPT-medium"}}, | ||
| "default": { | ||
| "model": {"pt": ("microsoft/DialoGPT-medium", "8bada3b"), "tf": ("microsoft/DialoGPT-medium", "8bada3b")} | ||
| }, | ||
| "type": "text", | ||
| }, | ||
| "image-classification": { | ||
| "impl": ImageClassificationPipeline, | ||
| "tf": (), | ||
| "pt": (AutoModelForImageClassification,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "google/vit-base-patch16-224"}}, | ||
| "default": {"model": {"pt": ("google/vit-base-patch16-224", "5dca96d")}}, | ||
| "type": "image", | ||
| }, | ||
| "image-segmentation": { | ||
| "impl": ImageSegmentationPipeline, | ||
| "tf": (), | ||
| "pt": (AutoModelForImageSegmentation, AutoModelForSemanticSegmentation) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "facebook/detr-resnet-50-panoptic"}}, | ||
| "default": {"model": {"pt": ("facebook/detr-resnet-50-panoptic", "fc15262")}}, | ||
| "type": "image", | ||
| }, | ||
| "object-detection": { | ||
| "impl": ObjectDetectionPipeline, | ||
| "tf": (), | ||
| "pt": (AutoModelForObjectDetection,) if is_torch_available() else (), | ||
| "default": {"model": {"pt": "facebook/detr-resnet-50"}}, | ||
| "default": {"model": {"pt": ("facebook/detr-resnet-50", "2729413")}}, | ||
| "type": "image", | ||
| }, | ||
| } | ||
|
|
@@ -545,8 +549,13 @@ def pipeline( | |
| # Use default model/config/tokenizer for the task if no model is provided | ||
| if model is None: | ||
| # At that point framework might still be undetermined | ||
| model = get_default_model(targeted_task, framework, task_options) | ||
| logger.warning(f"No model was supplied, defaulted to {model} (https://huggingface.co/{model})") | ||
| model, default_revision = get_default_model_and_revision(targeted_task, framework, task_options) | ||
| revision = revision if revision is not None else default_revision | ||
| logger.warning( | ||
| f"No model was supplied, defaulted to {model} and revision" | ||
| f" {revision} ({HUGGINGFACE_CO_RESOLVE_ENDPOINT}/{model}).\n" | ||
| "Using a pipeline without specifying a model name and revision in production is not recommended." | ||
| ) | ||
|
|
||
| # Retrieve use_auth_token and add it to model_kwargs to be used in .from_pretrained | ||
| model_kwargs["use_auth_token"] = model_kwargs.get("use_auth_token", use_auth_token) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted tokenizer because of https://github.com/huggingface/transformers/pull/17667/files#r910987282