Skip to content

Commit 5e961fe

Browse files
committed
Fix imports
1 parent 9365bd6 commit 5e961fe

File tree

3 files changed

+2
-60
lines changed

3 files changed

+2
-60
lines changed

src/huggingface_hub/inference/_client.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,6 @@ def fill_mask(
10831083
When passed, the model will limit the scores to the passed targets instead of looking up in the whole
10841084
vocabulary. If the provided targets are not in the model vocab, they will be tokenized and the first
10851085
resulting token will be used (with a warning, and that might be slower).
1086-
in the whole vocabulary. If the provided targets are not in the model vocab, they will be
1087-
tokenized and the first resulting token will be used (with a warning, and that might be
1088-
slower).
10891086
top_k (`int`, *optional*):
10901087
When passed, overrides the number of predictions to return.
10911088
Returns:
@@ -2381,11 +2378,9 @@ def text_to_image(
23812378
num_inference_steps (`int`, *optional*):
23822379
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
23832380
expense of slower inference.
2384-
expense of slower inference.
23852381
guidance_scale (`float`, *optional*):
23862382
A higher guidance scale value encourages the model to generate images closely linked to the text
23872383
prompt, but values too high may cause saturation and other artifacts.
2388-
usually at the expense of lower image quality.
23892384
model (`str`, *optional*):
23902385
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
23912386
Inference Endpoint. If not provided, the default recommended text-to-image model will be used.
@@ -2479,9 +2474,6 @@ def text_to_speech(
24792474
epsilon_cutoff will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on
24802475
the size of the model. See [Truncation Sampling as Language Model
24812476
Desmoothing](https://hf.co/papers/2210.15191) for more details.
2482-
greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
2483-
3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
2484-
Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
24852477
eta_cutoff (`float`, *optional*):
24862478
Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly
24872479
between 0 and 1, a token is only considered if it is greater than either eta_cutoff or sqrt(eta_cutoff)
@@ -2497,9 +2489,6 @@ def text_to_speech(
24972489
probability, scaled by sqrt(eta_cutoff). In the paper, suggested values range from 3e-4 to 2e-3,
24982490
depending on the size of the model. See [Truncation Sampling as Language Model
24992491
Desmoothing](https://hf.co/papers/2210.15191) for more details.
2500-
the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
2501-
See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
2502-
for more details.
25032492
max_length (`int`, *optional*):
25042493
The maximum length (in tokens) of the generated text, including the input.
25052494
max_new_tokens (`int`, *optional*):
@@ -2511,30 +2500,23 @@ def text_to_speech(
25112500
num_beam_groups (`int`, *optional*):
25122501
Number of groups to divide num_beams into in order to ensure diversity among different groups of beams.
25132502
See [this paper](https://hf.co/papers/1610.02424) for more details.
2514-
groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
25152503
num_beams (`int`, *optional*):
25162504
Number of beams to use for beam search.
25172505
penalty_alpha (`float`, *optional*):
25182506
The value balances the model confidence and the degeneration penalty in contrastive search decoding.
2519-
search decoding.
25202507
temperature (`float`, *optional*):
25212508
The value used to modulate the next token probabilities.
25222509
top_k (`int`, *optional*):
25232510
The number of highest probability vocabulary tokens to keep for top-k-filtering.
25242511
top_p (`float`, *optional*):
25252512
If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to
25262513
top_p or higher are kept for generation.
2527-
that add up to top_p or higher are kept for generation.
25282514
typical_p (`float`, *optional*):
25292515
Local typicality measures how similar the conditional probability of predicting a target token next is
25302516
to the expected conditional probability of predicting a random token next, given the partial text
25312517
already generated. If set to float < 1, the smallest set of the most locally typical tokens with
25322518
probabilities that add up to typical_p or higher are kept for generation. See [this
25332519
paper](https://hf.co/papers/2202.00666) for more details.
2534-
to the expected conditional probability of predicting a random token next, given the partial text
2535-
already generated. If set to float < 1, the smallest set of the most locally typical tokens with
2536-
probabilities that add up to typical_p or higher are kept for generation. See [this
2537-
paper](https://hf.co/papers/2202.00666) for more details.
25382520
use_cache (`bool`, *optional*):
25392521
Whether the model should use the past last key/values attentions to speed up decoding
25402522
@@ -2756,8 +2738,6 @@ def visual_question_answering(
27562738
top_k (`int`, *optional*):
27572739
The number of answers to return (will be chosen by order of likelihood). Note that we return less than
27582740
topk answers if there are not enough options available within the context.
2759-
return less than topk answers if there are not enough options available within the
2760-
context.
27612741
Returns:
27622742
`List[VisualQuestionAnsweringOutputElement]`: a list of [`VisualQuestionAnsweringOutputElement`] items containing the predicted label and associated probability.
27632743
@@ -2808,13 +2788,9 @@ def zero_shot_classification(
28082788
Whether multiple candidate labels can be true. If false, the scores are normalized such that the sum of
28092789
the label likelihoods for each sequence is 1. If true, the labels are considered independent and
28102790
probabilities are normalized for each candidate.
2811-
If False, the labels are considered mutually exclusive and the probability over all labels always sums to 1. Defaults to False.
28122791
hypothesis_template (`str`, *optional*):
28132792
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
28142793
the placeholder with the candidate labels.
2815-
Zero-shot classifiers are based on NLI models, which evaluate if a hypothesis is entailed in another text or not.
2816-
For example, with hypothesis_template="This text is about {}." and labels=["economics", "politics"], the system internally creates the two hypotheses "This text is about economics." and "This text is about politics.".
2817-
The model then evaluates for both hypotheses if they are entailed in the provided `text` or not.
28182794
model (`str`, *optional*):
28192795
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
28202796
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot classification model will be used.
@@ -2914,7 +2890,6 @@ def zero_shot_image_classification(
29142890
hypothesis_template (`str`, *optional*):
29152891
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
29162892
the placeholder with the candidate labels.
2917-
placeholder with the candidate labels.
29182893
Returns:
29192894
`List[ZeroShotImageClassificationOutputElement]`: List of [`ZeroShotImageClassificationOutputElement`] items containing the predicted labels and their confidence.
29202895

src/huggingface_hub/inference/_generated/_async_client.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,6 @@ async def fill_mask(
11271127
When passed, the model will limit the scores to the passed targets instead of looking up in the whole
11281128
vocabulary. If the provided targets are not in the model vocab, they will be tokenized and the first
11291129
resulting token will be used (with a warning, and that might be slower).
1130-
in the whole vocabulary. If the provided targets are not in the model vocab, they will be
1131-
tokenized and the first resulting token will be used (with a warning, and that might be
1132-
slower).
11331130
top_k (`int`, *optional*):
11341131
When passed, overrides the number of predictions to return.
11351132
Returns:
@@ -1543,28 +1540,22 @@ async def question_answering(
15431540
align_to_words (`bool`, *optional*):
15441541
Attempts to align the answer to real words. Improves quality on space separated languages. Might hurt
15451542
on non-space-separated languages (like Japanese or Chinese)
1546-
languages. Might hurt on non-space-separated languages (like Japanese or Chinese).
15471543
doc_stride (`int`, *optional*):
15481544
If the context is too long to fit with the question for the model, it will be split in several chunks
15491545
with some overlap. This argument controls the size of that overlap.
1550-
several chunks with some overlap. This argument controls the size of that overlap.
15511546
handle_impossible_answer (`bool`, *optional*):
15521547
Whether to accept impossible as an answer.
15531548
max_answer_len (`int`, *optional*):
15541549
The maximum length of predicted answers (e.g., only answers with a shorter length are considered).
1555-
considered).
15561550
max_question_len (`int`, *optional*):
15571551
The maximum length of the question after tokenization. It will be truncated if needed.
15581552
max_seq_len (`int`, *optional*):
15591553
The maximum length of the total sentence (context + question) in tokens of each chunk passed to the
15601554
model. The context will be split in several chunks (using docStride as overlap) if needed.
1561-
passed to the model. The context will be split in several chunks (using docStride as
1562-
overlap) if needed.
15631555
top_k (`int`, *optional*):
15641556
The number of answers to return (will be chosen by order of likelihood). Note that we return less than
15651557
topk answers if there are not enough options available within the context.
1566-
return less than topk answers if there are not enough options available within the
1567-
context.
1558+
15681559
Returns:
15691560
Union[`QuestionAnsweringOutputElement`, List[`QuestionAnsweringOutputElement`]]:
15701561
When top_k is 1 or not provided, it returns a single `QuestionAnsweringOutputElement`.
@@ -2451,11 +2442,9 @@ async def text_to_image(
24512442
num_inference_steps (`int`, *optional*):
24522443
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
24532444
expense of slower inference.
2454-
expense of slower inference.
24552445
guidance_scale (`float`, *optional*):
24562446
A higher guidance scale value encourages the model to generate images closely linked to the text
24572447
prompt, but values too high may cause saturation and other artifacts.
2458-
usually at the expense of lower image quality.
24592448
model (`str`, *optional*):
24602449
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
24612450
Inference Endpoint. If not provided, the default recommended text-to-image model will be used.
@@ -2550,9 +2539,6 @@ async def text_to_speech(
25502539
epsilon_cutoff will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on
25512540
the size of the model. See [Truncation Sampling as Language Model
25522541
Desmoothing](https://hf.co/papers/2210.15191) for more details.
2553-
greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
2554-
3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
2555-
Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
25562542
eta_cutoff (`float`, *optional*):
25572543
Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly
25582544
between 0 and 1, a token is only considered if it is greater than either eta_cutoff or sqrt(eta_cutoff)
@@ -2568,9 +2554,6 @@ async def text_to_speech(
25682554
probability, scaled by sqrt(eta_cutoff). In the paper, suggested values range from 3e-4 to 2e-3,
25692555
depending on the size of the model. See [Truncation Sampling as Language Model
25702556
Desmoothing](https://hf.co/papers/2210.15191) for more details.
2571-
the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
2572-
See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
2573-
for more details.
25742557
max_length (`int`, *optional*):
25752558
The maximum length (in tokens) of the generated text, including the input.
25762559
max_new_tokens (`int`, *optional*):
@@ -2582,30 +2565,23 @@ async def text_to_speech(
25822565
num_beam_groups (`int`, *optional*):
25832566
Number of groups to divide num_beams into in order to ensure diversity among different groups of beams.
25842567
See [this paper](https://hf.co/papers/1610.02424) for more details.
2585-
groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
25862568
num_beams (`int`, *optional*):
25872569
Number of beams to use for beam search.
25882570
penalty_alpha (`float`, *optional*):
25892571
The value balances the model confidence and the degeneration penalty in contrastive search decoding.
2590-
search decoding.
25912572
temperature (`float`, *optional*):
25922573
The value used to modulate the next token probabilities.
25932574
top_k (`int`, *optional*):
25942575
The number of highest probability vocabulary tokens to keep for top-k-filtering.
25952576
top_p (`float`, *optional*):
25962577
If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to
25972578
top_p or higher are kept for generation.
2598-
that add up to top_p or higher are kept for generation.
25992579
typical_p (`float`, *optional*):
26002580
Local typicality measures how similar the conditional probability of predicting a target token next is
26012581
to the expected conditional probability of predicting a random token next, given the partial text
26022582
already generated. If set to float < 1, the smallest set of the most locally typical tokens with
26032583
probabilities that add up to typical_p or higher are kept for generation. See [this
26042584
paper](https://hf.co/papers/2202.00666) for more details.
2605-
to the expected conditional probability of predicting a random token next, given the partial text
2606-
already generated. If set to float < 1, the smallest set of the most locally typical tokens with
2607-
probabilities that add up to typical_p or higher are kept for generation. See [this
2608-
paper](https://hf.co/papers/2202.00666) for more details.
26092585
use_cache (`bool`, *optional*):
26102586
Whether the model should use the past last key/values attentions to speed up decoding
26112587
@@ -2830,8 +2806,6 @@ async def visual_question_answering(
28302806
top_k (`int`, *optional*):
28312807
The number of answers to return (will be chosen by order of likelihood). Note that we return less than
28322808
topk answers if there are not enough options available within the context.
2833-
return less than topk answers if there are not enough options available within the
2834-
context.
28352809
Returns:
28362810
`List[VisualQuestionAnsweringOutputElement]`: a list of [`VisualQuestionAnsweringOutputElement`] items containing the predicted label and associated probability.
28372811
@@ -2883,13 +2857,9 @@ async def zero_shot_classification(
28832857
Whether multiple candidate labels can be true. If false, the scores are normalized such that the sum of
28842858
the label likelihoods for each sequence is 1. If true, the labels are considered independent and
28852859
probabilities are normalized for each candidate.
2886-
If False, the labels are considered mutually exclusive and the probability over all labels always sums to 1. Defaults to False.
28872860
hypothesis_template (`str`, *optional*):
28882861
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
28892862
the placeholder with the candidate labels.
2890-
Zero-shot classifiers are based on NLI models, which evaluate if a hypothesis is entailed in another text or not.
2891-
For example, with hypothesis_template="This text is about {}." and labels=["economics", "politics"], the system internally creates the two hypotheses "This text is about economics." and "This text is about politics.".
2892-
The model then evaluates for both hypotheses if they are entailed in the provided `text` or not.
28932863
model (`str`, *optional*):
28942864
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
28952865
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot classification model will be used.
@@ -2991,7 +2961,6 @@ async def zero_shot_image_classification(
29912961
hypothesis_template (`str`, *optional*):
29922962
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
29932963
the placeholder with the candidate labels.
2994-
placeholder with the candidate labels.
29952964
Returns:
29962965
`List[ZeroShotImageClassificationOutputElement]`: List of [`ZeroShotImageClassificationOutputElement`] items containing the predicted labels and their confidence.
29972966

utils/check_task_parameters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,7 @@ def update_inference_client(update: bool):
813813

814814
# Construct a mapping between method names and their parameters dataclass names
815815
method_params = {}
816-
for method_name, _ in [
817-
("question_answering", None)
818-
]: # inspect.getmembers(InferenceClient, predicate=inspect.isfunction)
816+
for method_name, _ in inspect.getmembers(InferenceClient, predicate=inspect.isfunction):
819817
if method_name.startswith("_") or method_name not in tasks:
820818
continue
821819
parameter_type_name = _get_parameter_type_name(method_name)

0 commit comments

Comments
 (0)