Skip to content
Back to skills

Inverse Task Prompt Template

ASecurity

Structured prompt template for recovering the instruction that transformed one text into another, with labeled original/rewritten fields and explicit task framing

  • 61 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 12, 2026
developmentpythonaws

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill inverse-task-prompt-template --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Inverse Task Prompt Template?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Inverse Task Prompt Template
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-inverse-task-prompt-template/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-inverse-task-prompt-template)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: llm-inverse-task-prompt-template
description: Structured prompt template for recovering the instruction that transformed one text into another, with labeled original/rewritten fields and explicit task framing
---

# Inverse Task Prompt Template

## Overview

To recover an unknown prompt from an (original, rewritten) text pair, frame the task explicitly: show the LLM both texts with clear labels, state that one was derived from the other via a prompt, and ask it to infer that prompt. The template structure — labeled fields, task description, output format constraint — is critical for consistent results across different LLMs.

## Quick Start

```python
TEMPLATE = """Below, the `Original Text` has been rewritten into `Rewritten Text`
by an LLM with a certain prompt/instruction. Analyze the differences
and infer the specific prompt that was used.

Original Text:
{original_text}

Rewritten Text:
{rewritten_text}

The prompt was:"""

def build_recovery_prompt(original, rewritten):
    return TEMPLATE.format(
        original_text=original[:1000],
        rewritten_text=rewritten[:1000])

prompt = build_recovery_prompt(row['original_text'], row['rewritten_text'])
output = model.generate(tokenizer(prompt, return_tensors='pt').to(device),
                        max_new_tokens=50, do_sample=False)
recovered = tokenizer.decode(output[0], skip_special_tokens=True)
recovered = recovered.split("The prompt was:")[-1].strip()
```

## Workflow

1. Label both texts clearly (`Original Text:`, `Rewritten Text:`)
2. State the task: one was derived from the other via an LLM prompt
3. Ask the model to analyze differences (style, tone, structure, content)
4. End with a response anchor (`The prompt was:`) to constrain output format
5. Parse only the text after the anchor

## Key Decisions

- **Response anchor**: ending with `The prompt was:` forces concise output without preamble
- **Truncation**: limit input texts to 300-1000 words to fit context window
- **do_sample=False**: greedy decoding for deterministic, focused outputs
- **Model choice**: instruction-tuned models (7B-IT, Mistral-Instruct) follow the template better

## References

- [Prompt Recovery with Gemma - KerasNLP Starter](https://www.kaggle.com/code/awsaf49/prompt-recovery-with-gemma-kerasnlp-starter)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…