prompt-optimization
Operate ProTeGi text prompt optimization and Promptist text-to-image prompt rewriting workflows for LMOps.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- prompt-optimization
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate ProTeGi text prompt optimization and Promptist text-to-image prompt rewriting workflows for LMOps.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/promptist-workflows.md5.3 KB
- 参考文档references/protegi-cli-and-api.md8.9 KB
- 参考文档references/troubleshooting.md5.9 KB
- 脚本scripts/promptist_rewrite_skeleton.py8.1 KB
- 脚本scripts/protegi_command_builder.py12.7 KB
03 SKILL.md 正文
Prompt Optimization
Use this operating sub-skill when the user asks for LMOps prompt optimization, prompt rewriting, or prompt-optimization run planning.
Route by task shape
- ProTeGi text prompt optimization: use for automatic optimization of zero-shot binary classification prompts with labeled train/test data, markdown seed prompts, and an approved chat/completion provider budget.
- Promptist prompt rewriting: use for text-to-image prompt rewriting with the pretrained Promptist prompter model, but plan offline first to avoid accidental model downloads.
- Promptist RL training: use only for planning or explicitly approved heavy execution; it needs training prompt data, a supervised prompter checkpoint, Stable Diffusion/CLIP/aesthetic reward assets, Accelerate/TRL, GPUs, and credentials.
- Retrieval-based prompt or demonstration selection: route to
../example-retrieval/SKILL.md. - Domain/instruction corpus conversion or model adaptation before prompt work: route to
../adaptation-and-training/SKILL.md. - Broad LMOps project routing: consult
../../references/project-index.mdif the user names a different LMOps project.
Required first checks
- Classify the request as ProTeGi optimization, Promptist pretrained rewrite planning, Promptist RL training planning, or a route-out case.
- Confirm required inputs before any expensive or external action:
- ProTeGi: task name, task data directory, seed prompt markdown file(s), output log path, evaluator, scorer, provider credentials, overwrite consent, and budget/concurrency limits.
- Promptist rewrite: plain text prompt(s), model id, tokenizer id, model cache or network consent, and CPU/GPU expectation for any real model load.
- Promptist RL training: data directory, supervised prompter checkpoint, Stable Diffusion model access, TRL/PPO config, checkpoint directory, distributed launch plan, GPU availability, Hugging Face access, and W&B/logging policy.
- Use the bundled safe planners before any source checkout run:
python scripts/protegi_command_builder.py --helppython scripts/promptist_rewrite_skeleton.py --help
- Read the focused runtime references:
references/protegi-cli-and-api.mdreferences/promptist-workflows.mdreferences/troubleshooting.md
Safe operating defaults
- Do not run model downloads, provider calls, image generation, PPO training, Docker/container startup, or multi-node launches unless the user explicitly asks and provides the needed environment and credentials.
- Treat bundled scripts as planners and validators. They do not import LMOps source code, call model providers, load Promptist models, download weights, generate images, or train.
- Promptist GPU/model-download workflows and multi-node RL training are documented but not creation-time verified by this sub-skill.
- Treat ProTeGi output files as user data: the native program removes an existing output file before writing, so ask before overwriting.
Quick ProTeGi planning pattern
- Choose one of the supported native task names:
ethos,jailbreak,liar, orar_sarcasm. - Stage task data in the required layout and one or more seed prompt markdown files with a
# Tasksection and{{ text }}placeholder. - Build a command without executing it:
python scripts/protegi_command_builder.py \
--task liar \
--data-dir data/my_binary_task \
--prompts prompts/seed.md \
--out runs/my_binary_task.ucb.out \
--evaluator ucb \
--scorer 01 \
--path-policy warn
- Resolve any warnings, confirm credentials and overwrite behavior, then run the emitted command only in a prepared ProTeGi environment.
Quick Promptist planning pattern
- Start with the offline skeleton and keep model loading off:
python scripts/promptist_rewrite_skeleton.py \
--plain-text "A rabbit is wearing a space suit" \
--model-id microsoft/Promptist \
--tokenizer-id gpt2 \
--show-prompts
- If the user approves a real rewrite run, confirm PyTorch/Transformers availability and whether the Promptist model and tokenizer are already cached or may be downloaded.
- If the user asks for RL training, move to the training checklist in
references/promptist-workflows.mdand do not treat it as a small smoke test.
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).