Skip to content

Commit

Permalink
Fix chat completion package reference links
Browse files Browse the repository at this point in the history
  • Loading branch information
hanouticelina committed Oct 8, 2024
1 parent 5977ab7 commit 05b8858
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions docs/api-inference/tasks/chat-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ For more details, check out:
## Chat Completion

Generate a response given a list of messages in a conversational context, supporting both conversational Language Models (LLMs) and conversational Vision-Language Models (VLMs).
This is a subtask of [`text-generation`](./text_generation) and [`image-text-to-text`](./image_text_to_text).
This is a subtask of [`text-generation`](https://huggingface.co/docs/api-inference/tasks/text-generation) and [`image-text-to-text`](https://huggingface.co/docs/api-inference/tasks/image-text-to-text).

### Recommended models

#### Conversational Large Language Models (LLMs)

- [google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it): A text-generation model trained to follow instructions.
- [meta-llama/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct): Very powerful text generation model trained to follow instructions.
- [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct): Small yet powerful text generation model.
- [HuggingFaceH4/starchat2-15b-v0.1](https://huggingface.co/HuggingFaceH4/starchat2-15b-v0.1): Strong coding assistant model.
- [mistralai/Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407): Very strong open-source large language model.

#### Conversational Vision-Language Models (VLMs)

- [microsoft/Phi-3.5-vision-instruct](https://huggingface.co/microsoft/Phi-3.5-vision-instruct): Strong image-text-to-text model.

### Using the API
Expand Down Expand Up @@ -72,7 +74,7 @@ for message in client.chat_completion(
print(message.choices[0].delta.content, end="")
```

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

<js>
Expand All @@ -90,7 +92,7 @@ for await (const chunk of inference.chatCompletionStream({
}
```
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#conversationaltext-generation).
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#chatcompletion).
</js>
</inferencesnippet>
Expand Down Expand Up @@ -150,7 +152,7 @@ for message in client.chat_completion(
print(message.choices[0].delta.content, end="")
```
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.conversational_image-text-to-text).
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.chat_completion).
</python>
<js>
Expand All @@ -177,7 +179,7 @@ for await (const chunk of inference.chatCompletionStream({
}
```
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#conversationalimage-text-to-text).
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#chatcompletion).
</js>
</inferencesnippet>
Expand Down
8 changes: 4 additions & 4 deletions scripts/api-inference/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,10 @@ TASKS.forEach((task) => {
///////////////////////////////////////////////

function fetchChatCompletion() {
const baseName = "chat-completion";
const conversationalTasks = [
{
name: "conversational-text-generation",
name: "chat-completion",
baseName: "text-generation",
pipelineTag: "text-generation"
},
Expand Down Expand Up @@ -491,11 +492,10 @@ function fetchChatCompletion() {
// @ts-ignore
javascript: GET_SNIPPET_FN["js"](mainModelData, "hf_***"),
};

DATA.snippets[task.name] = SNIPPETS_TEMPLATE({
taskSnippets,
taskSnakeCase: task.name.replace("-", "_"),
taskAttached: task.name.replace("-", ""),
taskSnakeCase: baseName.replace("-", "_"),
taskAttached: baseName.replace("-", ""),
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ This is a subtask of [`text-generation`](https://huggingface.co/docs/api-inferen
### Recommended models

#### Conversational Large Language Models (LLMs)
{{#each models.conversational-text-generation}}

{{#each models.chat-completion}}
- [{{this.id}}](https://huggingface.co/{{this.id}}): {{this.description}}
{{/each}}

#### Conversational Vision-Language Models (VLMs)

{{#each models.conversational-image-text-to-text}}
- [{{this.id}}](https://huggingface.co/{{this.id}}): {{this.description}}
{{/each}}
Expand All @@ -25,7 +27,7 @@ The API supports:

#### Code snippet example for conversational LLMs

{{{snippets.conversational-text-generation}}}
{{{snippets.chat-completion}}}

#### Code snippet example for conversational VLMs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Image-text-to-text models take in an image and text prompt and output text. Thes

### API specification

For the API specification for conversational image-text-to-text models, please refer to the [Chat Completion API documentation](https://huggingface.co/docs/api-inference/tasks/chat-completion#api-specification).
For the API specification of conversational image-text-to-text models, please refer to the [Chat Completion API documentation](https://huggingface.co/docs/api-inference/tasks/chat-completion#api-specification).


0 comments on commit 05b8858

Please sign in to comment.