template-verbalizer-design
Design, load, validate, and troubleshoot OpenPrompt templates, verbalizers, calibration, LM-BFF generators, and bundled prompt assets without depending on the original repository checkout.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- template-verbalizer-design
- license
- Apache 2.0
- metadata
- { "repo": "OpenPrompt", "package": "openprompt", "disco-role": "operating", "source-commit": "f6fb080ef755c37c01b7959e7560d007049510e8", "source-version": "1.0.1" }
- description
- Design, load, validate, and troubleshoot OpenPrompt templates, verbalizers, calibration, LM-BFF generators, and bundled prompt assets without depending on the original repository checkout.
- disable-model-invocation
- true
02 资源文件 85
- 参考文档references/api-reference.md9.7 KB
- 参考文档references/prompt-assets.md6.2 KB
- 参考文档references/prompt-assets/ADAPTATIONS.md1.1 KB
- 参考文档references/prompt-assets/MANIFEST.json13.3 KB
- 参考文档references/prompt-assets/scripts/CondGen/webnlg_2017/manual_template.txt50 B
- 参考文档references/prompt-assets/scripts/CoT/csqa.txt2.1 KB
- 参考文档references/prompt-assets/scripts/FewGLUE/BoolQ/manual_template.txt86 B
- 参考文档references/prompt-assets/scripts/FewGLUE/BoolQ/manual_verbalizer.txt7 B
- 参考文档references/prompt-assets/scripts/FewGLUE/BoolQ/ptuning_template.txt100 B
- 参考文档references/prompt-assets/scripts/FewGLUE/BoolQ/soft_manual_template.txt104 B
- 参考文档references/prompt-assets/scripts/FewGLUE/CB/manual_template.txt76 B
- 参考文档references/prompt-assets/scripts/FewGLUE/CB/manual_verbalizer.txt13 B
- 参考文档references/prompt-assets/scripts/FewGLUE/CB/ptuning_template.txt80 B
- 参考文档references/prompt-assets/scripts/FewGLUE/RTE/manual_template.txt86 B
- 参考文档references/prompt-assets/scripts/FewGLUE/RTE/manual_verbalizer.txt7 B
- 参考文档references/prompt-assets/scripts/FewGLUE/RTE/ptuning_template.txt91 B
- 参考文档references/prompt-assets/scripts/FewGLUE/RTE/soft_manual_template.txt104 B
- 参考文档references/prompt-assets/scripts/FewGLUE/WiC/manual_template.txt87 B
- 参考文档references/prompt-assets/scripts/FewGLUE/WiC/manual_verbalizer.txt7 B
- 参考文档references/prompt-assets/scripts/FewGLUE/WiC/ptuning_template.txt97 B
- 参考文档references/prompt-assets/scripts/LMBFF/SNLI/initial_verbalizer.json61 B
- 参考文档references/prompt-assets/scripts/LMBFF/SNLI/manual_template.txt149 B
- 参考文档references/prompt-assets/scripts/LMBFF/SNLI/template_for_auto_t.txt180 B
- 参考文档references/prompt-assets/scripts/LMBFF/SST-2/manual_template.txt37 B
- 参考文档references/prompt-assets/scripts/LMBFF/SST-2/manual_verbalizer.txt14 B
- 参考文档references/prompt-assets/scripts/LMBFF/SST-2/template_for_auto_t.txt65 B
- 参考文档references/prompt-assets/scripts/RelationClassification/ReTACRED/ptr_template.txt112 B
- 参考文档references/prompt-assets/scripts/RelationClassification/ReTACRED/ptr_verbalizer.jsonl2.9 KB
- 参考文档references/prompt-assets/scripts/RelationClassification/SemEval/temp.txt984 B
- 参考文档references/prompt-assets/scripts/RelationClassification/TACRED/ptr_template.txt112 B
- 参考文档references/prompt-assets/scripts/RelationClassification/TACRED/ptr_verbalizer.jsonl3.1 KB
- 参考文档references/prompt-assets/scripts/RelationClassification/TACREV/ptr_template.txt112 B
- 参考文档references/prompt-assets/scripts/RelationClassification/TACREV/ptr_verbalizer.jsonl3.1 KB
- 参考文档references/prompt-assets/scripts/SuperGLUE/BoolQ/generation_verbalizer.txt30 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/BoolQ/manual_verbalizer.txt6 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/BoolQ/soft_template.txt493 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/CB/generation_verbalizer.txt68 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/CB/manual_verbalizer.txt12 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/CB/soft_template.txt524 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/COPA/generation_verbalizer.txt41 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/COPA/manual_verbalizer.txt3 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/COPA/soft_template.txt268 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/MultiRC/generation_verbalizer.txt31 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/MultiRC/manual_verbalizer.txt6 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/MultiRC/soft_template.txt537 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/RECORD/generation_verbalizer.txt19 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/RECORD/soft_template.txt132 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/RTE/generation_verbalizer.txt50 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/RTE/manual_verbalizer.txt6 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/RTE/soft_template.txt330 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WiC/generation_verbalizer.txt32 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WiC/manual_verbalizer.txt6 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WiC/soft_template.txt466 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WSC/generation_verbalizer.txt50 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WSC/manual_verbalizer.txt7 B
- 参考文档references/prompt-assets/scripts/SuperGLUE/WSC/soft_template.txt110 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/knowledgeable_verbalizer.txt12.7 KB
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/manual_template.txt411 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/manual_verbalizer.txt37 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/mixed_template.txt103 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/multiwords_verbalizer.jsonl332 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/ptuning_template.txt378 B
- 参考文档references/prompt-assets/scripts/TextClassification/agnews/soft_template.txt63 B
- 参考文档references/prompt-assets/scripts/TextClassification/amazon/knowledgeable_verbalizer.txt4.0 KB
- 参考文档references/prompt-assets/scripts/TextClassification/amazon/manual_template.txt203 B
- 参考文档references/prompt-assets/scripts/TextClassification/amazon/manual_verbalizer.txt8 B
- 参考文档references/prompt-assets/scripts/TextClassification/dbpedia/knowledgeable_verbalizer.txt61.1 KB
- 参考文档references/prompt-assets/scripts/TextClassification/dbpedia/manual_template.txt508 B
- 参考文档references/prompt-assets/scripts/TextClassification/dbpedia/manual_verbalizer.txt106 B
- 参考文档references/prompt-assets/scripts/TextClassification/imdb/knowledgeable_verbalizer.txt4.0 KB
- 参考文档references/prompt-assets/scripts/TextClassification/imdb/manual_template.txt209 B
- 参考文档references/prompt-assets/scripts/TextClassification/imdb/manual_verbalizer.txt8 B
- 参考文档references/prompt-assets/scripts/TextClassification/mnli/mixed_template.txt260 B
- 参考文档references/prompt-assets/scripts/TextClassification/mnli/multiwords_verbalizer.jsonl117 B
- 参考文档references/prompt-assets/scripts/TextClassification/yahoo_answers_topics/knowledgeable_verbalizer.json64.6 KB
- 参考文档references/prompt-assets/scripts/TextClassification/yahoo_answers_topics/manual_template.txt309 B
- 参考文档references/prompt-assets/scripts/TextClassification/yahoo_answers_topics/manual_verbalizer.json401 B
- 参考文档references/prompt-assets/scripts/Typing/FewNERD/fewnerd_verbalizer.json2.6 KB
- 参考文档references/prompt-assets/scripts/Typing/FewNERD/knowledeable_verbalizer.json24.9 KB
- 参考文档references/prompt-assets/scripts/Typing/FewNERD/manual_template.txt195 B
- 参考文档references/prompt-assets/scripts/Typing/FewNERD/mixed_template.txt79 B
- 参考文档references/prompt-assets/scripts/UltraChat/template.txt119 B
- 参考文档references/troubleshooting.md9.8 KB
- 参考文档references/workflows.md7.9 KB
- 脚本scripts/validate_prompt_assets.py26.0 KB
03 SKILL.md 正文
OpenPrompt Template and Verbalizer Design
Use this sub-skill when a task asks you to write or debug OpenPrompt prompt components: template grammar, hard/mixed/soft/prefix/P-tuning/PTR templates, manual/one2one/knowledgeable/automatic/generation/soft/proto/PTR verbalizers, LM-BFF template or label-word generation, calibration, or prompt asset files.
Do not use this sub-skill for full training loops, dataset acquisition, runner selection, or benchmark reproduction. Route those to the OpenPrompt data/config and training/generation sub-skills when available.
Required mental model
OpenPrompt separates prompt design into two cooperating objects:
- A
Templatewraps eachInputExampleinto pieces containing literal text, placeholders fromtext_a/text_bormeta, soft tokens, special tokens, and one or more mask positions. - A
Verbalizermaps language-model outputs at mask positions into task labels, usually through label words.
The most common failure mode is treating template text, class order, and label-word files as independent. They are coupled:
- every ordinary classification template needs at least one
{"mask"}; - each verbalizer file must match the dataset class order or class names;
- multi-mask templates need a multi-mask-aware verbalizer such as
PTRVerbalizeror generation logic; - label words that tokenize into multiple tokens are model/tokenizer-dependent and should be checked before training.
Fast operating procedure
-
Choose the prompt family.
- Hard textual prompt:
ManualTemplate+ManualVerbalizer. - Hard + learned soft tokens:
MixedTemplateorPtuningTemplate. - Prefix-tuning for supported T5/GPT2-style models:
PrefixTuningTemplate. - Appended soft prompt:
SoftTemplate; learned head verbalizer:SoftVerbalizer. - Relation extraction with several masks:
PTRTemplate+PTRVerbalizer. - Text-generation labels or dynamic target text:
GenerationVerbalizer. - Search/auto prompt design:
T5TemplateGenerator,RobertaVerbalizerGenerator, orAutomaticVerbalizer.
- Hard textual prompt:
-
Write the template string. Use OpenPrompt's Python-dict-like grammar:
{"placeholder": "text_a"},{"placeholder": "text_b"},{"meta": "field"},{"mask"},{"text": "literal"},{"special": "<sep>"},{"soft"},{"soft": "seed text"}, and optionalshortenable,post_processing,soft_id,duplicate, orsameattributes. -
Choose class mapping. For dict verbalizers, pass
classes=[...]matching dataset labels exactly. For list/text verbalizers, ensure the file line order matches label ids. -
Load from code or assets. Use
from_file(path, choice=...)for one-line-per-template files and OpenPrompt verbalizer files. Use the bundled assets underreferences/prompt-assets/scripts/when you need repo-maintained examples without the original checkout. -
Validate before model work. Run the bundled static validator:
python scripts/validate_prompt_assets.py # or, from this sub-skill directory: python scripts/validate_prompt_assets.py --assets-dir references/prompt-assets/scriptsAdd
--tokenizer /path-or-name --allow-remote-tokenizeronly if the user permits downloads; otherwise it uses local tokenizer files only. -
Only then connect training.
PromptForClassificationextracts model outputs atloss_ids > 0, then the verbalizer processes them.PromptForGenerationandGenerationVerbalizeruse generation-style targets instead of fixed class label words.
Runtime references
references/api-reference.md— class signatures, loader keys, base method behavior, and file format contracts.references/workflows.md— tested design workflows for manual/mixed/soft/PTR/generation/LM-BFF/calibration usage.references/troubleshooting.md— common grammar, mask, prefix-space, class-order, tokenizer, calibration, and file-format failures.references/prompt-assets.md— bundled asset corpus layout, adaptation notes, and validation policy.references/prompt-assets/scripts/— self-contained copy/adaptation of the reposcripts/**/*.txt|json|jsonlprompt assets.scripts/validate_prompt_assets.py— static checker for bundled or user-supplied prompt assets.
Evidence provenance
This sub-skill was distilled from OpenPrompt commit f6fb080ef755c37c01b7959e7560d007049510e8 using openprompt/prompt_base.py, openprompt/prompts/*.py, openprompt/utils/calibrate.py, docs/source/notes/template.rst, docs/source/notes/verbalizer.rst, tutorials 1.*, 3.1_LMBFF.py, 4.1_all_tasks_are_generation.py, and the repository scripts/ prompt assets.
Acceptance checklist before handing work to another agent
- Template strings parse with balanced dict/set tokens and contain expected masks.
- Verbalizer assets parse as OpenPrompt
.txt,.json, or.jsonlformats. - Class names/order and number of label groups are documented.
- Multi-mask designs name the matching verbalizer strategy.
- Multi-token label words are checked statically and, when model choice matters, with the target tokenizer.
- Any generated/edited assets are copied into the self-contained prompt-asset subtree or supplied explicitly by the user.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).