Skip to content

Commit c76b60e

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 dbd164f commit c76b60e

File tree

17 files changed

+88
-1030
lines changed

17 files changed

+88
-1030
lines changed

docs/source/de/guides/inference.md

Lines changed: 28 additions & 116 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
> [`InferenceClient`] ist ein Python-Client, der HTTP-Anfragen an unsere APIs stellt. Wenn Sie die HTTP-Anfragen direkt mit Ihrem bevorzugten Tool (curl, postman,...) durchführen möchten, lesen Sie bitte die Dokumentationsseiten der [Inferenz API](https://huggingface.co/docs/api-inference/index) oder der [Inferenz Endpunkte](https://huggingface.co/docs/inference-endpoints/index).
@@ -77,34 +76,34 @@ Aufrufe, die mit dem [`InferenceClient`] gemacht werden, können mit einem [User
7776

7877
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:
7978

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

109108

110109
> [!TIP]
@@ -175,90 +174,3 @@ Einige Aufgaben erfordern binäre Eingaben, zum Beispiel bei der Arbeit mit Bild
175174
[{'score': 0.9779096841812134, 'label': 'Blenheim spaniel'}, ...]
176175
```
177176

178-
## Legacy InferenceAPI client
179-
180-
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).
181-
182-
Hier finden Sie eine kurze Anleitung, die Ihnen hilft, von [`InferenceApi`] zu [`InferenceClient`] zu migrieren.
183-
184-
### Initialisierung
185-
186-
Ändern Sie von
187-
188-
```python
189-
>>> from huggingface_hub import InferenceApi
190-
>>> inference = InferenceApi(repo_id="bert-base-uncased", token=API_TOKEN)
191-
```
192-
193-
zu
194-
195-
```python
196-
>>> from huggingface_hub import InferenceClient
197-
>>> inference = InferenceClient(model="bert-base-uncased", token=API_TOKEN)
198-
```
199-
200-
### Ausführen einer bestimmten Aufgabe
201-
202-
Ändern Sie von
203-
204-
```python
205-
>>> from huggingface_hub import InferenceApi
206-
>>> inference = InferenceApi(repo_id="paraphrase-xlm-r-multilingual-v1", task="feature-extraction")
207-
>>> inference(...)
208-
```
209-
210-
zu
211-
212-
```python
213-
>>> from huggingface_hub import InferenceClient
214-
>>> inference = InferenceClient()
215-
>>> inference.feature_extraction(..., model="paraphrase-xlm-r-multilingual-v1")
216-
```
217-
218-
> [!TIP]
219-
> Dies ist der empfohlene Weg, um Ihren Code an [`InferenceClient`] anzupassen. Dadurch können Sie von den aufgabenspezifischen Methoden wie `feature_extraction` profitieren.
220-
221-
### Eigene Anfragen ausführen
222-
223-
Ändern Sie von
224-
225-
```python
226-
>>> from huggingface_hub import InferenceApi
227-
>>> inference = InferenceApi(repo_id="bert-base-uncased")
228-
>>> inference(inputs="The goal of life is [MASK].")
229-
[{'sequence': 'the goal of life is life.', 'score': 0.10933292657136917, 'token': 2166, 'token_str': 'life'}]
230-
```
231-
zu
232-
233-
```python
234-
>>> from huggingface_hub import InferenceClient
235-
>>> client = InferenceClient()
236-
>>> response = client.post(json={"inputs": "The goal of life is [MASK]."}, model="bert-base-uncased")
237-
>>> response.json()
238-
[{'sequence': 'the goal of life is life.', 'score': 0.10933292657136917, 'token': 2166, 'token_str': 'life'}]
239-
```
240-
241-
### Mit Parametern ausführen
242-
243-
Ändern Sie von
244-
245-
```python
246-
>>> from huggingface_hub import InferenceApi
247-
>>> inference = InferenceApi(repo_id="typeform/distilbert-base-uncased-mnli")
248-
>>> inputs = "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
249-
>>> params = {"candidate_labels":["refund", "legal", "faq"]}
250-
>>> inference(inputs, params)
251-
{'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]}
252-
```
253-
254-
zu
255-
256-
```python
257-
>>> from huggingface_hub import InferenceClient
258-
>>> client = InferenceClient()
259-
>>> inputs = "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
260-
>>> params = {"candidate_labels":["refund", "legal", "faq"]}
261-
>>> response = client.post(json={"inputs": inputs, "parameters": params}, model="typeform/distilbert-base-uncased-mnli")
262-
>>> response.json()
263-
{'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]}
264-
```

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
> [`InferenceClient`] is a Python client making HTTP calls to our APIs. If you want to make the HTTP calls directly using
2016
> your preferred tool (curl, postman,...), please refer to the [Inference Providers](https://huggingface.co/docs/inference-providers/index) documentation

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)