Skip to content
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

[Bot] Update API inference documentation #1503

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/audio-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Explore all available models and find the one that suits you best [here](https:/
curl https://api-inference.huggingface.co/models/ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition \
-X POST \
--data-binary '@sample1.flac' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -74,7 +74,7 @@ async function query(filename) {
"https://api-inference.huggingface.co/models/ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/automatic-speech-recognition.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Explore all available models and find the one that suits you best [here](https:/
curl https://api-inference.huggingface.co/models/openai/whisper-large-v3 \
-X POST \
--data-binary '@sample1.flac' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -75,7 +75,7 @@ async function query(filename) {
"https://api-inference.huggingface.co/models/openai/whisper-large-v3",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/chat-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The API supports:
<curl>
```bash
curl 'https://api-inference.huggingface.co/models/google/gemma-2-2b-it/v1/chat/completions' \
-H "Authorization: Bearer hf_***" \
-H 'Authorization: Bearer hf_***' \
-H 'Content-Type: application/json' \
--data '{
"model": "google/gemma-2-2b-it",
Expand Down Expand Up @@ -209,7 +209,7 @@ To use the JavaScript client, see `huggingface.js`'s [package reference](https:/
<curl>
```bash
curl 'https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision-Instruct/v1/chat/completions' \
-H "Authorization: Bearer hf_***" \
-H 'Authorization: Bearer hf_***' \
-H 'Content-Type: application/json' \
--data '{
"model": "meta-llama/Llama-3.2-11B-Vision-Instruct",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/feature-extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ curl https://api-inference.huggingface.co/models/thenlper/gte-large \
-X POST \
-d '{"inputs": "Today is a sunny day and I will get some ice cream."}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -74,7 +74,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/thenlper/gte-large",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/fill-mask.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ curl https://api-inference.huggingface.co/models/google-bert/bert-base-uncased \
-X POST \
-d '{"inputs": "The answer to the universe is [MASK]."}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -70,7 +70,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/google-bert/bert-base-uncased",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/image-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Explore all available models and find the one that suits you best [here](https:/
curl https://api-inference.huggingface.co/models/google/vit-base-patch16-224 \
-X POST \
--data-binary '@cats.jpg' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -69,7 +69,7 @@ async function query(filename) {
"https://api-inference.huggingface.co/models/google/vit-base-patch16-224",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/image-segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Explore all available models and find the one that suits you best [here](https:/
curl https://api-inference.huggingface.co/models/openmmlab/upernet-convnext-small \
-X POST \
--data-binary '@cats.jpg' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -70,7 +70,7 @@ async function query(filename) {
"https://api-inference.huggingface.co/models/openmmlab/upernet-convnext-small",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/image-text-to-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ curl https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision
-X POST \
-d '{"inputs": "Can you please let us know more details about your "}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -96,7 +96,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision-Instruct",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/object-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Explore all available models and find the one that suits you best [here](https:/
curl https://api-inference.huggingface.co/models/facebook/detr-resnet-50 \
-X POST \
--data-binary '@cats.jpg' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -69,7 +69,7 @@ async function query(filename) {
"https://api-inference.huggingface.co/models/facebook/detr-resnet-50",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
5 changes: 2 additions & 3 deletions docs/api-inference/tasks/question-answering.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ For more details about the `question-answering` task, check out its [dedicated p

- [deepset/roberta-base-squad2](https://huggingface.co/deepset/roberta-base-squad2): A robust baseline model for most question answering domains.
- [distilbert/distilbert-base-cased-distilled-squad](https://huggingface.co/distilbert/distilbert-base-cased-distilled-squad): Small yet robust model that can answer questions.
- [google/tapas-base-finetuned-wtq](https://huggingface.co/google/tapas-base-finetuned-wtq): A special model that can answer questions from tables.

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

Expand All @@ -41,7 +40,7 @@ curl https://api-inference.huggingface.co/models/deepset/roberta-base-squad2 \
-X POST \
-d '{"inputs": { "question": "What is my name?", "context": "My name is Clara and I live in Berkeley." }}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -74,7 +73,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/deepset/roberta-base-squad2",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/summarization.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ curl https://api-inference.huggingface.co/models/facebook/bart-large-cnn \
-X POST \
-d '{"inputs": "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -69,7 +69,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/facebook/bart-large-cnn",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
11 changes: 5 additions & 6 deletions docs/api-inference/tasks/table-question-answering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ For more details about the `table-question-answering` task, check out its [dedic

### Recommended models

- [google/tapas-base-finetuned-wtq](https://huggingface.co/google/tapas-base-finetuned-wtq): A robust table question answering model.

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

Expand All @@ -35,19 +34,19 @@ Explore all available models and find the one that suits you best [here](https:/

<curl>
```bash
curl https://api-inference.huggingface.co/models/google/tapas-base-finetuned-wtq \
curl https://api-inference.huggingface.co/models/<REPO_ID> \
-X POST \
-d '{"inputs": { "query": "How many stars does the transformers repository have?", "table": { "Repository": ["Transformers", "Datasets", "Tokenizers"], "Stars": ["36542", "4512", "3934"], "Contributors": ["651", "77", "34"], "Programming language": [ "Python", "Python", "Rust, Python and NodeJS" ] } }}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

<python>
```py
import requests

API_URL = "https://api-inference.huggingface.co/models/google/tapas-base-finetuned-wtq"
API_URL = "https://api-inference.huggingface.co/models/<REPO_ID>"
headers = {"Authorization": "Bearer hf_***"}

def query(payload):
Expand Down Expand Up @@ -78,10 +77,10 @@ To use the Python client, see `huggingface_hub`'s [package reference](https://hu
```js
async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/google/tapas-base-finetuned-wtq",
"https://api-inference.huggingface.co/models/<REPO_ID>",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/text-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl https://api-inference.huggingface.co/models/distilbert/distilbert-base-unca
-X POST \
-d '{"inputs": "I like you. I love you"}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -72,7 +72,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/distilbert/distilbert-base-uncased-finetuned-sst-2-english",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/text-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ curl https://api-inference.huggingface.co/models/google/gemma-2-2b-it \
-X POST \
-d '{"inputs": "Can you please let us know more details about your "}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -74,7 +74,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/google/gemma-2-2b-it",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/text-to-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ curl https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev \
-X POST \
-d '{"inputs": "Astronaut riding a horse"}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -84,7 +84,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/token-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl https://api-inference.huggingface.co/models/dslim/bert-base-NER \
-X POST \
-d '{"inputs": "My name is Sarah Jessica Parker but you can call me Jessica"}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -72,7 +72,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/dslim/bert-base-NER",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ curl https://api-inference.huggingface.co/models/google-t5/t5-base \
-X POST \
-d '{"inputs": "Меня зовут Вольфганг и я живу в Берлине"}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -69,7 +69,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/google-t5/t5-base",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-inference/tasks/zero-shot-classification.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ curl https://api-inference.huggingface.co/models/facebook/bart-large-mnli \
-X POST \
-d '{"inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!", "parameters": {"candidate_labels": ["refund", "legal", "faq"]}}' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer hf_***"
-H 'Authorization: Bearer hf_***'
```
</curl>

Expand Down Expand Up @@ -71,7 +71,7 @@ async function query(data) {
"https://api-inference.huggingface.co/models/facebook/bart-large-mnli",
{
headers: {
Authorization: "Bearer hf_***"
Authorization: "Bearer hf_***",
"Content-Type": "application/json",
},
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion scripts/api-inference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@huggingface/tasks": "^0.13.5",
"@huggingface/tasks": "^0.13.6",
"@types/node": "^22.5.0",
"handlebars": "^4.7.8",
"node": "^20.17.0",
Expand Down
10 changes: 5 additions & 5 deletions scripts/api-inference/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading