diff --git a/packages/inference/src/snippets/getInferenceSnippets.ts b/packages/inference/src/snippets/getInferenceSnippets.ts index b63a91cc58..cae64f6a0c 100644 --- a/packages/inference/src/snippets/getInferenceSnippets.ts +++ b/packages/inference/src/snippets/getInferenceSnippets.ts @@ -121,7 +121,6 @@ const HF_JS_METHODS: Partial> = { "table-question-answering": "tableQuestionAnswering", "text-classification": "textClassification", "text-generation": "textGeneration", - "text2text-generation": "textGeneration", "token-classification": "tokenClassification", "text-to-speech": "textToSpeech", translation: "translation", @@ -359,7 +358,6 @@ const snippets: Partial< "text-to-image": snippetGenerator("textToImage"), "text-to-speech": snippetGenerator("textToSpeech"), "text-to-video": snippetGenerator("textToVideo"), - "text2text-generation": snippetGenerator("basic"), "token-classification": snippetGenerator("basic"), translation: snippetGenerator("basic"), "zero-shot-classification": snippetGenerator("zeroShotClassification"), diff --git a/packages/inference/test/InferenceClient.spec.ts b/packages/inference/test/InferenceClient.spec.ts index e4b358b26b..8e98ccbd00 100644 --- a/packages/inference/test/InferenceClient.spec.ts +++ b/packages/inference/test/InferenceClient.spec.ts @@ -1429,7 +1429,7 @@ describe.skip("InferenceClient", () => { providerId: "mistralai/Devstral-Small-2505", hfModelId: "mistralai/Devstral-Small-2505", status: "live", - task: "text2text-generation", + task: "text-generation", }, }; @@ -1479,7 +1479,7 @@ describe.skip("InferenceClient", () => { expect(res[0]).toEqual(expect.arrayContaining([expect.any(Number)])); }); - it("text2textGeneration", async () => { + it("textGeneration", async () => { const res = await client.textGeneration({ model: "mistralai/Devstral-Small-2505", provider: "nebius", diff --git a/packages/tasks/src/library-to-tasks.ts b/packages/tasks/src/library-to-tasks.ts index e1628df3a5..1986c93e05 100644 --- a/packages/tasks/src/library-to-tasks.ts +++ b/packages/tasks/src/library-to-tasks.ts @@ -35,13 +35,7 @@ export const LIBRARY_TASK_MAPPING: Partial `"The answer to the universe is"`; - const inputsFillMask = (model: ModelDataMinimal) => `"The answer to the universe is ${model.mask_token}."`; const inputsSentenceSimilarity = () => @@ -147,7 +145,6 @@ const modelInputSnippets: { "text-to-video": inputsTextToVideo, "text-to-speech": inputsTextToSpeech, "text-to-audio": inputsTextToAudio, - "text2text-generation": inputsText2TextGeneration, "token-classification": inputsTokenClassification, translation: inputsTranslation, "zero-shot-classification": inputsZeroShotClassification, diff --git a/packages/tasks/src/tasks/index.ts b/packages/tasks/src/tasks/index.ts index fa7bf1cd26..379515b01e 100644 --- a/packages/tasks/src/tasks/index.ts +++ b/packages/tasks/src/tasks/index.ts @@ -158,7 +158,6 @@ export const TASKS_MODEL_LIBRARIES: Record = { "text-to-speech": ["espnet", "tensorflowtts", "transformers", "transformers.js"], "text-to-audio": ["transformers", "transformers.js"], "text-to-video": ["diffusers"], - "text2text-generation": ["transformers", "transformers.js"], "time-series-forecasting": [], "token-classification": [ "adapter-transformers", @@ -245,7 +244,6 @@ export const TASKS_DATA: Record = { "text-to-speech": getData("text-to-speech", textToSpeech), "text-to-audio": undefined, "text-to-video": getData("text-to-video", textToVideo), - "text2text-generation": undefined, "time-series-forecasting": undefined, "token-classification": getData("token-classification", tokenClassification), translation: getData("translation", translation), diff --git a/packages/tasks/src/tasks/placeholder/data.ts b/packages/tasks/src/tasks/placeholder/data.ts index 5fc9bbb8fd..c103e16a88 100644 --- a/packages/tasks/src/tasks/placeholder/data.ts +++ b/packages/tasks/src/tasks/placeholder/data.ts @@ -14,7 +14,7 @@ const taskData: TaskDataCustom = { widgetModels: [], youtubeId: undefined, /// If this is a subtask, link to the most general task ID - /// (eg, text2text-generation is the canonical ID of translation) + /// (eg, text-generation is the canonical ID of text-simplification) canonicalId: undefined, }; diff --git a/packages/tasks/src/tasks/summarization/data.ts b/packages/tasks/src/tasks/summarization/data.ts index de7eb4e4c3..744503ece0 100644 --- a/packages/tasks/src/tasks/summarization/data.ts +++ b/packages/tasks/src/tasks/summarization/data.ts @@ -1,7 +1,7 @@ import type { TaskDataCustom } from "../index.js"; const taskData: TaskDataCustom = { - canonicalId: "text2text-generation", + canonicalId: "text-generation", datasets: [ { description: diff --git a/packages/tasks/src/tasks/text-generation/about.md b/packages/tasks/src/tasks/text-generation/about.md index 234a9dd5a2..4b5df67c4e 100644 --- a/packages/tasks/src/tasks/text-generation/about.md +++ b/packages/tasks/src/tasks/text-generation/about.md @@ -1,4 +1,4 @@ -This task covers guides on both [text-generation](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads) and [text-to-text generation](https://huggingface.co/models?pipeline_tag=text2text-generation&sort=downloads) models. Popular large language models that are used for chats or following instructions are also covered in this task. You can find the list of selected open-source large language models [here](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), ranked by their performance scores. +This task covers guides on [text-generation](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads) models. Popular large language models that are used for chats or following instructions are also covered in this task. You can find the list of selected open-source large language models [here](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), ranked by their performance scores. ## Use Cases @@ -58,19 +58,6 @@ generator("Hello, I'm a language model", max_length = 30, num_return_sequences=3 ## {'generated_text': "Hello, I'm a language modeler. I write and maintain software in Python. I love to code, and that includes coding things that require writing"}, ... ``` -[Text-to-Text generation models](https://huggingface.co/models?pipeline_tag=text2text-generation&sort=downloads) have a separate pipeline called `text2text-generation`. This pipeline takes an input containing the sentence including the task and returns the output of the accomplished task. - -```python -from transformers import pipeline - -text2text_generator = pipeline("text2text-generation") -text2text_generator("question: What is 42 ? context: 42 is the answer to life, the universe and everything") -[{'generated_text': 'the answer to life, the universe and everything'}] - -text2text_generator("translate from English to French: I'm very happy") -[{'generated_text': 'Je suis très heureux'}] -``` - You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer text classification models on Hugging Face Hub. ```javascript diff --git a/packages/tasks/src/tasks/text2text-generation/inference.ts b/packages/tasks/src/tasks/text2text-generation/inference.ts deleted file mode 100644 index 0aaf87474d..0000000000 --- a/packages/tasks/src/tasks/text2text-generation/inference.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Inference code generated from the JSON schema spec in ./spec - * - * Using src/scripts/inference-codegen - */ -/** - * Inputs for Text2text Generation inference - */ -export interface Text2TextGenerationInput { - /** - * The input text data - */ - inputs: string; - /** - * Additional inference parameters for Text2text Generation - */ - parameters?: Text2TextGenerationParameters; - [property: string]: unknown; -} -/** - * Additional inference parameters for Text2text Generation - */ -export interface Text2TextGenerationParameters { - /** - * Whether to clean up the potential extra spaces in the text output. - */ - clean_up_tokenization_spaces?: boolean; - /** - * Additional parametrization of the text generation algorithm - */ - generate_parameters?: { - [key: string]: unknown; - }; - /** - * The truncation strategy to use - */ - truncation?: Text2TextGenerationTruncationStrategy; - [property: string]: unknown; -} -export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second"; -/** - * Outputs of inference for the Text2text Generation task - */ -export interface Text2TextGenerationOutput { - generatedText: unknown; - /** - * The generated text. - */ - generated_text?: string; - [property: string]: unknown; -} diff --git a/packages/tasks/src/tasks/text2text-generation/spec/input.json b/packages/tasks/src/tasks/text2text-generation/spec/input.json deleted file mode 100644 index 1b0456738f..0000000000 --- a/packages/tasks/src/tasks/text2text-generation/spec/input.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$id": "/inference/schemas/text2text-generation/input.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "description": "Inputs for Text2text Generation inference", - "title": "Text2TextGenerationInput", - "type": "object", - "properties": { - "inputs": { - "description": "The input text data", - "type": "string" - }, - "parameters": { - "description": "Additional inference parameters for Text2text Generation", - "$ref": "#/$defs/Text2textGenerationParameters" - } - }, - "$defs": { - "Text2textGenerationParameters": { - "title": "Text2textGenerationParameters", - "type": "object", - "properties": { - "clean_up_tokenization_spaces": { - "type": "boolean", - "description": "Whether to clean up the potential extra spaces in the text output." - }, - "truncation": { - "title": "Text2textGenerationTruncationStrategy", - "type": "string", - "description": "The truncation strategy to use", - "oneOf": [ - { - "const": "do_not_truncate" - }, - { - "const": "longest_first" - }, - { - "const": "only_first" - }, - { - "const": "only_second" - } - ] - }, - "generate_parameters": { - "title": "generateParameters", - "type": "object", - "description": "Additional parametrization of the text generation algorithm" - } - } - } - }, - "required": ["inputs"] -} diff --git a/packages/tasks/src/tasks/text2text-generation/spec/output.json b/packages/tasks/src/tasks/text2text-generation/spec/output.json deleted file mode 100644 index 0da61f103d..0000000000 --- a/packages/tasks/src/tasks/text2text-generation/spec/output.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$id": "/inference/schemas/text2text-generation/output.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "description": "Outputs of inference for the Text2text Generation task", - "title": "Text2TextGenerationOutput", - "type": "object", - "properties": { - "generated_text": { - "type": "string", - "description": "The generated text." - } - }, - "required": ["generatedText"] -} diff --git a/packages/tasks/src/tasks/translation/data.ts b/packages/tasks/src/tasks/translation/data.ts index 535f9a84c6..1f7cb112c2 100644 --- a/packages/tasks/src/tasks/translation/data.ts +++ b/packages/tasks/src/tasks/translation/data.ts @@ -1,7 +1,7 @@ import type { TaskDataCustom } from "../index.js"; const taskData: TaskDataCustom = { - canonicalId: "text2text-generation", + canonicalId: "text-generation", datasets: [ { description: "A dataset of copyright-free books translated into 16 different languages.",