From 05b88586319f402feffc2b567067489b0533ae82 Mon Sep 17 00:00:00 2001 From: Celina Hanouti Date: Tue, 8 Oct 2024 17:48:40 +0200 Subject: [PATCH] Fix chat completion package reference links --- docs/api-inference/tasks/chat-completion.md | 12 +++++++----- scripts/api-inference/scripts/generate.ts | 8 ++++---- .../templates/task/chat-completion.handlebars | 6 ++++-- .../templates/task/image-text-to-text.handlebars | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/api-inference/tasks/chat-completion.md b/docs/api-inference/tasks/chat-completion.md index c2aff1979..7246beae5 100644 --- a/docs/api-inference/tasks/chat-completion.md +++ b/docs/api-inference/tasks/chat-completion.md @@ -15,11 +15,12 @@ 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. @@ -27,6 +28,7 @@ This is a subtask of [`text-generation`](./text_generation) and [`image-text-to- - [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 @@ -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). @@ -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). @@ -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). @@ -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). diff --git a/scripts/api-inference/scripts/generate.ts b/scripts/api-inference/scripts/generate.ts index 0f5638f5b..0aae82e57 100644 --- a/scripts/api-inference/scripts/generate.ts +++ b/scripts/api-inference/scripts/generate.ts @@ -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" }, @@ -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("-", ""), }); }); diff --git a/scripts/api-inference/templates/task/chat-completion.handlebars b/scripts/api-inference/templates/task/chat-completion.handlebars index 565f9dbe3..ddeff3e4d 100644 --- a/scripts/api-inference/templates/task/chat-completion.handlebars +++ b/scripts/api-inference/templates/task/chat-completion.handlebars @@ -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}} @@ -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 diff --git a/scripts/api-inference/templates/task/image-text-to-text.handlebars b/scripts/api-inference/templates/task/image-text-to-text.handlebars index 93143ae92..8aa03f37e 100644 --- a/scripts/api-inference/templates/task/image-text-to-text.handlebars +++ b/scripts/api-inference/templates/task/image-text-to-text.handlebars @@ -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).