← all repositories
thunlp/OpenPrompt

Prompt Engineering, But Make It Modular

OpenPrompt unifies scattered prompt-learning methods into a modular framework where templates, verbalizers, and pre-trained models snap together without rewriting training loops.

OpenPrompt
Not currently ranked — collecting fresh signals.
star history

What it does

OpenPrompt is a Python framework that standardizes the prompt-learning pipeline for adapting pre-trained language models to downstream NLP tasks. It wraps raw inputs with text templates and maps task labels to vocabulary words—templating and verbalizing—then trains and infers through a unified PromptModel. The library loads pre-trained backbones directly from Hugging Face transformers.

The interesting bit

The framework treats prompts as first-class objects: you compose a Template, a Verbalizer, and a PLM into a single PromptModel, which makes swapping prompt strategies a matter of rearranging components rather than rewriting training loops. It also tries to unify disparate prompting methods—templating, verbalizing, and optimization strategies such as prefix tuning—under one roof.

Key highlights

  • Implements templating, verbalizing, and optimization strategies under a single standard API.
  • Won ACL 2022 Best Demo Paper Award.
  • Supports loading PLMs directly from Hugging Face transformers, with experimental support for PaddlePaddle ERNIE.
  • Includes a GenerationVerbalizer that reframes classification and other tasks as text generation.
  • Provides benchmark download scripts and a growing performance-results table.

Caveats

  • The authors note that part of the documentation is outdated after recent major changes.
  • Performance coverage is incomplete; the maintainers admit there are too many method combinations to test exhaustively and invite user contributions.

Verdict

Worth a look if you are experimenting with prompt-tuning or need a consistent API across multiple prompting paradigms. Skip it if you just want drop-in fine-tuning without the template-engineering overhead.

Frequently asked

What is thunlp/OpenPrompt?
OpenPrompt unifies scattered prompt-learning methods into a modular framework where templates, verbalizers, and pre-trained models snap together without rewriting training loops.
Is OpenPrompt open source?
Yes — thunlp/OpenPrompt is open source, released under the Apache-2.0 license.
What language is OpenPrompt written in?
thunlp/OpenPrompt is primarily written in Python.
How popular is OpenPrompt?
thunlp/OpenPrompt has 4.9k stars on GitHub.
Where can I find OpenPrompt?
thunlp/OpenPrompt is on GitHub at https://github.com/thunlp/OpenPrompt.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.