Skip to content

Add Structured Prompt Templates Registry for LLM / VLM / Diffusion Tasks #41518

@Aki-07

Description

@Aki-07

Feature request

Introduce transformers.prompt_templates — a YAML-based registry and accessor API:

from transformers import PromptTemplates

PromptTemplates.get("summarization")      # "Summarize the following text:"
PromptTemplates.list_tasks()              # ["summarization","vqa","ocr",...]
  • Templates stored as yaml/json under src/transformers/prompt_templates/templates/.
  • Accessor + validation in registry.py.
  • Optional CLI command transformers-cli list-prompts.
  • Pipelines can import a template by task name instead of hard-coding.

Motivation

Every pipeline and model today embeds its own prompt strings (e.g., summarization, OCR, VQA).
This duplication makes results inconsistent and hard to benchmark.
A central registry of task-specific prompt templates would unify defaults and enable easy community additions.

Your contribution

I’ll implement the registry module, add unit tests and docs, and migrate 1–2 pipelines (summarization / captioning) to use it.
Contributor: @Aki-07

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions