Skip to content

Commit

Permalink
Clean up code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgalinkin committed Dec 12, 2023
1 parent 1ca76dd commit f4ea467
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions garak/resources/autodan/autodan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
import numpy as np
import torch
import torch.nn as nn
from garak.resources.autodan.genetic import get_score_autodan, autodan_ga, autodan_hga, apply_gpt_mutation
from garak.resources.autodan.model_utils import load_conversation_template, check_for_attack_success
from garak.resources.autodan.genetic import (
get_score_autodan,
autodan_ga,
autodan_hga,
apply_gpt_mutation,
)
from garak.resources.autodan.model_utils import (
load_conversation_template,
check_for_attack_success,
)
import argparse
import os
from logging import getLogger
Expand Down Expand Up @@ -93,20 +101,23 @@
]


def autodan_generate(generator: Generator,
prompt: str,
target: str,
num_steps: int = 100,
batch_size: int = 8,
num_elites: int = 2,
crossover_rate: float = 0.5,
num_points: int = 5,
mutation_rate: float = 0.1,
hierarchical: bool = False,
out_path: str = f"{Path(__file__).parents[0]}/data/autodan_prompts.txt",
init_prompt_path: str = f"{Path(__file__).parents[0]}/data/autodan_init.txt",
reference_path: str = f"{Path(__file__).parents[0]}/data/prompt_group.pth",
low_memory: bool = False, random_seed: int = None):
def autodan_generate(
generator: Generator,
prompt: str,
target: str,
num_steps: int = 100,
batch_size: int = 8,
num_elites: int = 2,
crossover_rate: float = 0.5,
num_points: int = 5,
mutation_rate: float = 0.1,
hierarchical: bool = False,
out_path: str = f"{Path(__file__).parents[0]}/data/autodan_prompts.txt",
init_prompt_path: str = f"{Path(__file__).parents[0]}/data/autodan_init.txt",
reference_path: str = f"{Path(__file__).parents[0]}/data/prompt_group.pth",
low_memory: bool = False,
random_seed: int = None
):
"""
Execute base AutoDAN generation
Args:
Expand Down

0 comments on commit f4ea467

Please sign in to comment.