Skip to main content

hackagent.attacks.techniques.adaptive.pap.taxonomy

Persuasion taxonomy and prompt templates for the PAP attack.

Contains the full taxonomy of 40 persuasion techniques with definitions and examples, plus the few-shot prompt templates used to paraphrase harmful queries into persuasive adversarial prompts.

Ported from the original PAP codebase: https://github.com/CHATS-lab/persuasive_jailbreaker

Based on: https://arxiv.org/abs/2401.06373

get_technique_names​

def get_technique_names() -> List[str]

Return all 40 technique names in taxonomy order.

get_technique_by_name​

def get_technique_by_name(name: str) -> Dict[str, str]

Lookup a technique entry by name (case-insensitive).

ALL_TECHNIQUES​

Every technique in the taxonomy, in taxonomy order.

TOP_5_TECHNIQUES​

The five techniques the paper's broad scan found most effective.

resolve_techniques​

def resolve_techniques(selection: Union[str, Sequence[str]]) -> List[str]

Resolve "top5", "all", or explicit names to technique names.

Raises ValueError for a name the taxonomy does not define.

build_mutation_prompt​

def build_mutation_prompt(goal: str, technique_name: str) -> str

Build the attacker prompt to paraphrase goal using technique_name.

Arguments:

  • goal - The original harmful goal to paraphrase.
  • technique_name - Name of the persuasion technique to apply.

Returns:

A fully-formatted prompt string for the attacker LLM.

extract_mutated_text​

def extract_mutated_text(response: str) -> str

Extract the mutated adversarial prompt from the attacker LLM response.

Looks for the ``mutated_text_with_same_specific_harmful_or_unlawful_intention: tag in the response. Falls back to the full response if the tag is missing.

Arguments:

  • response - Raw text response from the attacker LLM.

Returns:

Extracted mutated text.