Skip to content

No more text2text #1590

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions packages/inference/src/snippets/getInferenceSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const HF_JS_METHODS: Partial<Record<WidgetType, string>> = {
"table-question-answering": "tableQuestionAnswering",
"text-classification": "textClassification",
"text-generation": "textGeneration",
"text2text-generation": "textGeneration",
"token-classification": "tokenClassification",
"text-to-speech": "textToSpeech",
translation: "translation",
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions packages/inference/test/InferenceClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down Expand Up @@ -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",
Expand Down
9 changes: 1 addition & 8 deletions packages/tasks/src/library-to-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[
sklearn: ["tabular-classification", "tabular-regression", "text-classification"],
spacy: ["token-classification", "text-classification", "sentence-similarity"],
"span-marker": ["token-classification"],
speechbrain: [
"audio-classification",
"audio-to-audio",
"automatic-speech-recognition",
"text-to-speech",
"text2text-generation",
],
speechbrain: ["audio-classification", "audio-to-audio", "automatic-speech-recognition", "text-to-speech"],
stanza: ["token-classification"],
timm: ["image-classification", "image-feature-extraction"],
transformers: [
Expand All @@ -62,7 +56,6 @@ export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[
"question-answering",
"summarization",
"table-question-answering",
"text2text-generation",
"text-classification",
"text-generation",
"text-to-audio",
Expand Down
10 changes: 4 additions & 6 deletions packages/tasks/src/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,6 @@ export const PIPELINE_DATA = {
type: "language-modeling",
name: "Language Modeling",
},
],
modality: "nlp",
},
"text2text-generation": {
name: "Text2Text Generation",
subtasks: [
{
type: "text-simplification",
name: "Text simplification",
Expand Down Expand Up @@ -271,6 +265,10 @@ export const PIPELINE_DATA = {
type: "closed-book-qa",
name: "Closed Book QA",
},
{
type: "text2text-generation",
name: "Text2Text Generation",
},
],
modality: "nlp",
},
Expand Down
3 changes: 0 additions & 3 deletions packages/tasks/src/snippets/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ const inputsTextGeneration = (model: ModelDataMinimal): string | ChatCompletionI
return `"Can you please let us know more details about your "`;
};

const inputsText2TextGeneration = () => `"The answer to the universe is"`;

const inputsFillMask = (model: ModelDataMinimal) => `"The answer to the universe is ${model.mask_token}."`;

const inputsSentenceSimilarity = () =>
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions packages/tasks/src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
"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",
Expand Down Expand Up @@ -245,7 +244,6 @@ export const TASKS_DATA: Record<PipelineType, TaskData | undefined> = {
"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),
Expand Down
2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/placeholder/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/summarization/data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TaskDataCustom } from "../index.js";

const taskData: TaskDataCustom = {
canonicalId: "text2text-generation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we replace by

        canonicalId: "text-generation",

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well no, because since those examples were created, we added dedicated pipelines for both summarization and translation, iiuc, cc @SBrandeis

or is it not how it works? ^^'

canonicalId: "text-generation",
datasets: [
{
description:
Expand Down
15 changes: 1 addition & 14 deletions packages/tasks/src/tasks/text-generation/about.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
51 changes: 0 additions & 51 deletions packages/tasks/src/tasks/text2text-generation/inference.ts

This file was deleted.

54 changes: 0 additions & 54 deletions packages/tasks/src/tasks/text2text-generation/spec/input.json

This file was deleted.

14 changes: 0 additions & 14 deletions packages/tasks/src/tasks/text2text-generation/spec/output.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/translation/data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TaskDataCustom } from "../index.js";

const taskData: TaskDataCustom = {
canonicalId: "text2text-generation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here ?

canonicalId: "text-generation",
datasets: [
{
description: "A dataset of copyright-free books translated into 16 different languages.",
Expand Down
Loading