Skip to content

Commit

Permalink
Fix spec for summarization and translation outputs (#503)
Browse files Browse the repository at this point in the history
Output key must be `summary_text` instead of `generated_text`. See
https://huggingface.co/docs/api-inference/detailed_parameters#summarization-task.

**EDIT:** same for `translation`. See
https://huggingface.co/docs/api-inference/detailed_parameters#translation-task.
  • Loading branch information
Wauplin authored Feb 23, 2024
1 parent 825e080 commit 8ad5507
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
9 changes: 3 additions & 6 deletions packages/tasks/src/tasks/summarization/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ export interface Text2TextGenerationParameters {
export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";

/**
* Outputs for Summarization inference
*
* Outputs of inference for the Text2text Generation task
* Outputs of inference for the Summarization task
*/
export interface SummarizationOutput {
generatedText: unknown;
/**
* The generated text.
* The summarized text.
*/
generated_text?: string;
summary_text: string;
[property: string]: unknown;
}
11 changes: 9 additions & 2 deletions packages/tasks/src/tasks/summarization/spec/output.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"$ref": "/inference/schemas/text2text-generation/output.json",
"$id": "/inference/schemas/summarization/output.json",
"$schema": "http://json-schema.org/draft-06/schema#",
"description": "Outputs of inference for the Summarization task",
"title": "SummarizationOutput",
"description": "Outputs for Summarization inference"
"type": "object",
"properties": {
"summary_text": {
"type": "string",
"description": "The summarized text."
}
},
"required": ["summary_text"]
}
9 changes: 3 additions & 6 deletions packages/tasks/src/tasks/translation/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ export interface Text2TextGenerationParameters {
export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";

/**
* Outputs for Translation inference
*
* Outputs of inference for the Text2text Generation task
* Outputs of inference for the Translation task
*/
export interface TranslationOutput {
generatedText: unknown;
/**
* The generated text.
* The translated text.
*/
generated_text?: string;
translation_text: string;
[property: string]: unknown;
}
11 changes: 9 additions & 2 deletions packages/tasks/src/tasks/translation/spec/output.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"$ref": "/inference/schemas/text2text-generation/output.json",
"$id": "/inference/schemas/translation/output.json",
"$schema": "http://json-schema.org/draft-06/schema#",
"description": "Outputs of inference for the Translation task",
"title": "TranslationOutput",
"description": "Outputs for Translation inference"
"type": "object",
"properties": {
"translation_text": {
"type": "string",
"description": "The translated text."
}
},
"required": ["translation_text"]
}

0 comments on commit 8ad5507

Please sign in to comment.