Skip to content

Commit 048050b

Browse files
Wauplinhanouticelina
authored andcommitted
Remove HfFolder and InferenceAPI classes (#3344)
* Remove HfFolder * Remove InferenceAPI * more recent gradio * bump pytest * fix python 3.9? * install gradio only on python 3.10+ * fix tests * fix tests * fix
1 parent a56a25f commit 048050b

File tree

17 files changed

+88
-1036
lines changed

17 files changed

+88
-1036
lines changed

docs/source/de/guides/inference.md

Lines changed: 28 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Inferenz ist der Prozess, bei dem ein trainiertes Modell verwendet wird, um Vorh
88
- [Inferenz API](https://huggingface.co/docs/api-inference/index): ein Service, der Ihnen ermöglicht, beschleunigte Inferenz auf der Infrastruktur von Hugging Face kostenlos auszuführen. Dieser Service ist eine schnelle Möglichkeit, um anzufangen, verschiedene Modelle zu testen und AI-Produkte zu prototypisieren.
99
- [Inferenz Endpunkte](https://huggingface.co/inference-endpoints/index): ein Produkt zur einfachen Bereitstellung von Modellen im Produktivbetrieb. Die Inferenz wird von Hugging Face in einer dedizierten, vollständig verwalteten Infrastruktur auf einem Cloud-Anbieter Ihrer Wahl durchgeführt.
1010

11-
Diese Dienste können mit dem [`InferenceClient`] Objekt aufgerufen werden. Dieser fungiert als Ersatz für den älteren [`InferenceApi`] Client und fügt spezielle Unterstützung für Aufgaben und das Ausführen von Inferenz hinzu, sowohl auf [Inferenz API](https://huggingface.co/docs/api-inference/index) als auch auf [Inferenz Endpunkten](https://huggingface.co/docs/inference-endpoints/index). Im Abschnitt [Legacy InferenceAPI client](#legacy-inferenceapi-client) erfahren Sie, wie Sie zum neuen Client migrieren können.
1211

1312
<Tip>
1413

@@ -89,34 +88,34 @@ Die Authentifizierung ist NICHT zwingend erforderlich, wenn Sie die Inferenz API
8988

9089
Das Ziel von [`InferenceClient`] ist es, die einfachste Schnittstelle zum Ausführen von Inferenzen auf Hugging Face-Modellen bereitzustellen. Es verfügt über eine einfache API, die die gebräuchlichsten Aufgaben unterstützt. Hier ist eine Liste der derzeit unterstützten Aufgaben:
9190

92-
| Domäne | Aufgabe | Unterstützt | Dokumentation |
93-
|--------|--------------------------------|--------------|------------------------------------|
94-
| Audio | [Audio Classification](https://huggingface.co/tasks/audio-classification) || [`~InferenceClient.audio_classification`] |
95-
| | [Automatic Speech Recognition](https://huggingface.co/tasks/automatic-speech-recognition) || [`~InferenceClient.automatic_speech_recognition`] |
96-
| | [Text-to-Speech](https://huggingface.co/tasks/text-to-speech) || [`~InferenceClient.text_to_speech`] |
97-
| Computer Vision | [Image Classification](https://huggingface.co/tasks/image-classification) || [`~InferenceClient.image_classification`] |
98-
| | [Image Segmentation](https://huggingface.co/tasks/image-segmentation) || [`~InferenceClient.image_segmentation`] |
99-
| | [Image-to-Image](https://huggingface.co/tasks/image-to-image) || [`~InferenceClient.image_to_image`] |
100-
| | [Image-to-Text](https://huggingface.co/tasks/image-to-text) || [`~InferenceClient.image_to_text`] |
101-
| | [Object Detection](https://huggingface.co/tasks/object-detection) || [`~InferenceClient.object_detection`] |
102-
| | [Text-to-Image](https://huggingface.co/tasks/text-to-image) || [`~InferenceClient.text_to_image`] |
103-
| | [Zero-Shot-Image-Classification](https://huggingface.co/tasks/zero-shot-image-classification) | | [`~InferenceClient.zero_shot_image_classification`] |
104-
| Multimodal | [Documentation Question Answering](https://huggingface.co/tasks/document-question-answering) || [`~InferenceClient.document_question_answering`] |
105-
| | [Visual Question Answering](https://huggingface.co/tasks/visual-question-answering) || [`~InferenceClient.visual_question_answering`] |
106-
| NLP | [Conversational](https://huggingface.co/tasks/conversational) || [`~InferenceClient.conversational`] |
107-
| | [Feature Extraction](https://huggingface.co/tasks/feature-extraction) || [`~InferenceClient.feature_extraction`] |
108-
| | [Fill Mask](https://huggingface.co/tasks/fill-mask) || [`~InferenceClient.fill_mask`] |
109-
| | [Question Answering](https://huggingface.co/tasks/question-answering) || [`~InferenceClient.question_answering`] |
110-
| | [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) || [`~InferenceClient.sentence_similarity`] |
111-
| | [Summarization](https://huggingface.co/tasks/summarization) || [`~InferenceClient.summarization`] |
112-
| | [Table Question Answering](https://huggingface.co/tasks/table-question-answering) || [`~InferenceClient.table_question_answering`] |
113-
| | [Text Classification](https://huggingface.co/tasks/text-classification) || [`~InferenceClient.text_classification`] |
114-
| | [Text Generation](https://huggingface.co/tasks/text-generation) || [`~InferenceClient.text_generation`] |
115-
| | [Token Classification](https://huggingface.co/tasks/token-classification) || [`~InferenceClient.token_classification`] |
116-
| | [Translation](https://huggingface.co/tasks/translation) || [`~InferenceClient.translation`] |
117-
| | [Zero Shot Classification](https://huggingface.co/tasks/zero-shot-classification) || [`~InferenceClient.zero_shot_classification`] |
118-
| Tabular | [Tabular Classification](https://huggingface.co/tasks/tabular-classification) || [`~InferenceClient.tabular_classification`] |
119-
| | [Tabular Regression](https://huggingface.co/tasks/tabular-regression) || [`~InferenceClient.tabular_regression`] |
91+
| Domäne | Aufgabe | Unterstützt | Dokumentation |
92+
| --------------- | --------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------- |
93+
| Audio | [Audio Classification](https://huggingface.co/tasks/audio-classification) | | [`~InferenceClient.audio_classification`] |
94+
| | [Automatic Speech Recognition](https://huggingface.co/tasks/automatic-speech-recognition) | | [`~InferenceClient.automatic_speech_recognition`] |
95+
| | [Text-to-Speech](https://huggingface.co/tasks/text-to-speech) | | [`~InferenceClient.text_to_speech`] |
96+
| Computer Vision | [Image Classification](https://huggingface.co/tasks/image-classification) | | [`~InferenceClient.image_classification`] |
97+
| | [Image Segmentation](https://huggingface.co/tasks/image-segmentation) | | [`~InferenceClient.image_segmentation`] |
98+
| | [Image-to-Image](https://huggingface.co/tasks/image-to-image) | | [`~InferenceClient.image_to_image`] |
99+
| | [Image-to-Text](https://huggingface.co/tasks/image-to-text) | | [`~InferenceClient.image_to_text`] |
100+
| | [Object Detection](https://huggingface.co/tasks/object-detection) | | [`~InferenceClient.object_detection`] |
101+
| | [Text-to-Image](https://huggingface.co/tasks/text-to-image) | | [`~InferenceClient.text_to_image`] |
102+
| | [Zero-Shot-Image-Classification](https://huggingface.co/tasks/zero-shot-image-classification) | | [`~InferenceClient.zero_shot_image_classification`] |
103+
| Multimodal | [Documentation Question Answering](https://huggingface.co/tasks/document-question-answering) | | [`~InferenceClient.document_question_answering`] |
104+
| | [Visual Question Answering](https://huggingface.co/tasks/visual-question-answering) | | [`~InferenceClient.visual_question_answering`] |
105+
| NLP | [Conversational](https://huggingface.co/tasks/conversational) | | [`~InferenceClient.conversational`] |
106+
| | [Feature Extraction](https://huggingface.co/tasks/feature-extraction) | | [`~InferenceClient.feature_extraction`] |
107+
| | [Fill Mask](https://huggingface.co/tasks/fill-mask) | | [`~InferenceClient.fill_mask`] |
108+
| | [Question Answering](https://huggingface.co/tasks/question-answering) | | [`~InferenceClient.question_answering`] |
109+
| | [Sentence Similarity](https://huggingface.co/tasks/sentence-similarity) | | [`~InferenceClient.sentence_similarity`] |
110+
| | [Summarization](https://huggingface.co/tasks/summarization) | | [`~InferenceClient.summarization`] |
111+
| | [Table Question Answering](https://huggingface.co/tasks/table-question-answering) | | [`~InferenceClient.table_question_answering`] |
112+
| | [Text Classification](https://huggingface.co/tasks/text-classification) | | [`~InferenceClient.text_classification`] |
113+
| | [Text Generation](https://huggingface.co/tasks/text-generation) | | [`~InferenceClient.text_generation`] |
114+
| | [Token Classification](https://huggingface.co/tasks/token-classification) | | [`~InferenceClient.token_classification`] |
115+
| | [Translation](https://huggingface.co/tasks/translation) | | [`~InferenceClient.translation`] |
116+
| | [Zero Shot Classification](https://huggingface.co/tasks/zero-shot-classification) | | [`~InferenceClient.zero_shot_classification`] |
117+
| Tabular | [Tabular Classification](https://huggingface.co/tasks/tabular-classification) | | [`~InferenceClient.tabular_classification`] |
118+
| | [Tabular Regression](https://huggingface.co/tasks/tabular-regression) | | [`~InferenceClient.tabular_regression`] |
120119

121120

122121
<Tip>
@@ -190,93 +189,3 @@ Einige Aufgaben erfordern binäre Eingaben, zum Beispiel bei der Arbeit mit Bild
190189
[{'score': 0.9779096841812134, 'label': 'Blenheim spaniel'}, ...]
191190
```
192191

193-
## Legacy InferenceAPI client
194-
195-
Der [`InferenceClient`] dient als Ersatz für den veralteten [`InferenceApi`]-Client. Er bietet spezifische Unterstützung für Aufgaben und behandelt Inferenz sowohl auf der [Inferenz API](https://huggingface.co/docs/api-inference/index) als auch auf den [Inferenz Endpunkten](https://huggingface.co/docs/inference-endpoints/index).
196-
197-
Hier finden Sie eine kurze Anleitung, die Ihnen hilft, von [`InferenceApi`] zu [`InferenceClient`] zu migrieren.
198-
199-
### Initialisierung
200-
201-
Ändern Sie von
202-
203-
```python
204-
>>> from huggingface_hub import InferenceApi
205-
>>> inference = InferenceApi(repo_id="bert-base-uncased", token=API_TOKEN)
206-
```
207-
208-
zu
209-
210-
```python
211-
>>> from huggingface_hub import InferenceClient
212-
>>> inference = InferenceClient(model="bert-base-uncased", token=API_TOKEN)
213-
```
214-
215-
### Ausführen einer bestimmten Aufgabe
216-
217-
Ändern Sie von
218-
219-
```python
220-
>>> from huggingface_hub import InferenceApi
221-
>>> inference = InferenceApi(repo_id="paraphrase-xlm-r-multilingual-v1", task="feature-extraction")
222-
>>> inference(...)
223-
```
224-
225-
zu
226-
227-
```python
228-
>>> from huggingface_hub import InferenceClient
229-
>>> inference = InferenceClient()
230-
>>> inference.feature_extraction(..., model="paraphrase-xlm-r-multilingual-v1")
231-
```
232-
233-
<Tip>
234-
235-
Dies ist der empfohlene Weg, um Ihren Code an [`InferenceClient`] anzupassen. Dadurch können Sie von den aufgabenspezifischen Methoden wie `feature_extraction` profitieren.
236-
237-
</Tip>
238-
239-
### Eigene Anfragen ausführen
240-
241-
Ändern Sie von
242-
243-
```python
244-
>>> from huggingface_hub import InferenceApi
245-
>>> inference = InferenceApi(repo_id="bert-base-uncased")
246-
>>> inference(inputs="The goal of life is [MASK].")
247-
[{'sequence': 'the goal of life is life.', 'score': 0.10933292657136917, 'token': 2166, 'token_str': 'life'}]
248-
```
249-
zu
250-
251-
```python
252-
>>> from huggingface_hub import InferenceClient
253-
>>> client = InferenceClient()
254-
>>> response = client.post(json={"inputs": "The goal of life is [MASK]."}, model="bert-base-uncased")
255-
>>> response.json()
256-
[{'sequence': 'the goal of life is life.', 'score': 0.10933292657136917, 'token': 2166, 'token_str': 'life'}]
257-
```
258-
259-
### Mit Parametern ausführen
260-
261-
Ändern Sie von
262-
263-
```python
264-
>>> from huggingface_hub import InferenceApi
265-
>>> inference = InferenceApi(repo_id="typeform/distilbert-base-uncased-mnli")
266-
>>> inputs = "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
267-
>>> params = {"candidate_labels":["refund", "legal", "faq"]}
268-
>>> inference(inputs, params)
269-
{'sequence': 'Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!', 'labels': ['refund', 'faq', 'legal'], 'scores': [0.9378499388694763, 0.04914155602455139, 0.013008488342165947]}
270-
```
271-
272-
zu
273-
274-
```python
275-
>>> from huggingface_hub import InferenceClient
276-
>>> client = InferenceClient()
277-
>>> inputs = "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
278-
>>> params = {"candidate_labels":["refund", "legal", "faq"]}
279-
>>> response = client.post(json={"inputs": inputs, "parameters": params}, model="typeform/distilbert-base-uncased-mnli")
280-
>>> response.json()
281-
{'sequence': 'Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!', 'labels': ['refund', 'faq', 'legal'], 'scores': [0.9378499388694763, 0.04914155602455139, 0.013008488342165947]}
282-
```

docs/source/en/guides/inference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ The `huggingface_hub` library provides a unified interface to run inference acro
1111
2. [Inference Endpoints](https://huggingface.co/docs/inference-endpoints/index): a product to easily deploy models to production. Inference is run by Hugging Face in a dedicated, fully managed infrastructure on a cloud provider of your choice.
1212
3. Local endpoints: you can also run inference with local inference servers like [llama.cpp](https://github.com/ggerganov/llama.cpp), [Ollama](https://ollama.com/), [vLLM](https://github.com/vllm-project/vllm), [LiteLLM](https://docs.litellm.ai/docs/simple_proxy), or [Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) by connecting the client to these local endpoints.
1313

14-
These services can all be called from the [`InferenceClient`] object. It acts as a replacement for the legacy
15-
[`InferenceApi`] client, adding specific support for tasks and third-party providers.
16-
Learn how to migrate to the new client in the [Legacy InferenceAPI client](#legacy-inferenceapi-client) section.
17-
1814
<Tip>
1915

2016
[`InferenceClient`] is a Python client making HTTP calls to our APIs. If you want to make the HTTP calls directly using

docs/source/en/package_reference/inference_client.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,3 @@ pip install --upgrade huggingface_hub[inference]
3434
## InferenceTimeoutError
3535

3636
[[autodoc]] InferenceTimeoutError
37-
38-
## InferenceAPI
39-
40-
[`InferenceAPI`] is the legacy way to call the Inference API. The interface is more simplistic and requires knowing
41-
the input parameters and output format for each task. It also lacks the ability to connect to other services like
42-
Inference Endpoints or AWS SageMaker. [`InferenceAPI`] will soon be deprecated so we recommend using [`InferenceClient`]
43-
whenever possible. Check out [this guide](../guides/inference#legacy-inferenceapi-client) to learn how to switch from
44-
[`InferenceAPI`] to [`InferenceClient`] in your scripts.
45-
46-
[[autodoc]] InferenceApi
47-
- __init__
48-
- __call__
49-
- all

0 commit comments

Comments
 (0)