Skip to content

Commit cffc8ee

Browse files
Update API inference documentation (automated) (#1546)
Co-authored-by: hanouticelina <[email protected]>
1 parent 46dd343 commit cffc8ee

File tree

5 files changed

+35
-47
lines changed

5 files changed

+35
-47
lines changed

docs/api-inference/tasks/automatic-speech-recognition.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ For more details about the `automatic-speech-recognition` task, check out its [d
3030
### Recommended models
3131

3232
- [openai/whisper-large-v3](https://huggingface.co/openai/whisper-large-v3): A powerful ASR model by OpenAI.
33-
- [nvidia/canary-1b](https://huggingface.co/nvidia/canary-1b): A powerful multilingual ASR and Speech Translation model by Nvidia.
3433
- [pyannote/speaker-diarization-3.1](https://huggingface.co/pyannote/speaker-diarization-3.1): Powerful speaker diarization model.
3534

3635
Explore all available models and find the one that suits you best [here](https://huggingface.co/models?inference=warm&pipeline_tag=automatic-speech-recognition&sort=trending).

docs/api-inference/tasks/image-classification.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ For more details about the `image-classification` task, check out its [dedicated
2525
### Recommended models
2626

2727
- [google/vit-base-patch16-224](https://huggingface.co/google/vit-base-patch16-224): A strong image classification model.
28+
- [facebook/deit-base-distilled-patch16-224](https://huggingface.co/facebook/deit-base-distilled-patch16-224): A robust image classification model.
2829

2930
Explore all available models and find the one that suits you best [here](https://huggingface.co/models?inference=warm&pipeline_tag=image-classification&sort=trending).
3031

docs/api-inference/tasks/text-classification.md

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,67 +37,54 @@ Explore all available models and find the one that suits you best [here](https:/
3737
<inferencesnippet>
3838

3939
<curl>
40-
4140
```bash
42-
curl https://api-inference.huggingface.co/models/mixedbread-ai/mxbai-rerank-base-v1 \
43-
-X POST \
44-
-d '{"inputs": [{"text": "What is Paris?", "text_pair": "Paris is the capital of France"}]}' \
45-
-H 'Content-Type: application/json' \
46-
-H 'Authorization: Bearer hf_***'
41+
curl https://api-inference.huggingface.co/models/distilbert/distilbert-base-uncased-finetuned-sst-2-english \
42+
-X POST \
43+
-d '{"inputs": "I like you. I love you"}' \
44+
-H 'Content-Type: application/json' \
45+
-H 'Authorization: Bearer hf_***'
4746
```
48-
4947
</curl>
5048

5149
<python>
52-
53-
```python
50+
```py
5451
import requests
5552

56-
API_URL = "https://api-inference.huggingface.co/models/mixedbread-ai/mxbai-rerank-base-v1"
53+
API_URL = "https://api-inference.huggingface.co/models/distilbert/distilbert-base-uncased-finetuned-sst-2-english"
5754
headers = {"Authorization": "Bearer hf_***"}
5855

5956
def query(payload):
60-
response = requests.post(API_URL, headers=headers, json=payload)
61-
return response.json()
62-
57+
response = requests.post(API_URL, headers=headers, json=payload)
58+
return response.json()
59+
6360
output = query({
64-
"inputs": [
65-
{"text": "What is Paris?", "text_pair": "Paris is the capital of France"},
66-
{"text": "What is Paris?", "text_pair": "London is the capital of England"}
67-
]
61+
"inputs": "I like you. I love you",
6862
})
6963
```
7064

7165
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.text_classification).
72-
7366
</python>
7467

7568
<js>
76-
77-
```javascript
69+
```js
7870
async function query(data) {
79-
const response = await fetch(
80-
"https://api-inference.huggingface.co/models/mixedbread-ai/mxbai-rerank-base-v1",
81-
{
82-
headers: {
83-
Authorization: "Bearer hf_***",
84-
"Content-Type": "application/json",
85-
},
86-
method: "POST",
87-
body: JSON.stringify(data),
88-
}
89-
);
90-
const result = await response.json();
91-
return result;
71+
const response = await fetch(
72+
"https://api-inference.huggingface.co/models/distilbert/distilbert-base-uncased-finetuned-sst-2-english",
73+
{
74+
headers: {
75+
Authorization: "Bearer hf_***",
76+
"Content-Type": "application/json",
77+
},
78+
method: "POST",
79+
body: JSON.stringify(data),
80+
}
81+
);
82+
const result = await response.json();
83+
return result;
9284
}
9385

94-
query({
95-
"inputs": [
96-
{"text": "What is Paris?", "text_pair": "Paris is the capital of France"},
97-
{"text": "What is Paris?", "text_pair": "London is the capital of England"}
98-
]
99-
}).then((response) => {
100-
console.log(JSON.stringify(response));
86+
query({"inputs": "I like you. I love you"}).then((response) => {
87+
console.log(JSON.stringify(response));
10188
});
10289
```
10390

@@ -107,6 +94,7 @@ To use the JavaScript client, see `huggingface.js`'s [package reference](https:/
10794
</inferencesnippet>
10895

10996

97+
11098
### API specification
11199

112100
#### Request

scripts/api-inference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "",
1515
"license": "ISC",
1616
"dependencies": {
17-
"@huggingface/tasks": "^0.13.11",
17+
"@huggingface/tasks": "^0.13.14",
1818
"@types/node": "^22.5.0",
1919
"handlebars": "^4.7.8",
2020
"node": "^20.17.0",

scripts/api-inference/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)