From 6c1bd1f75f157a2c695a1803030887d4606876c5 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 22 Jul 2024 13:17:49 -0500 Subject: [PATCH] convert mutation_generator to use `load_plugin` Signed-off-by: Jeffrey Martin --- garak/resources/autodan/autodan.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/garak/resources/autodan/autodan.py b/garak/resources/autodan/autodan.py index a140bcc64..de82ef9a6 100644 --- a/garak/resources/autodan/autodan.py +++ b/garak/resources/autodan/autodan.py @@ -9,7 +9,8 @@ import gc -from garak.generators import Generator, load_generator +from garak._plugins import load_plugin +from garak.generators import Generator from garak.generators.huggingface import Model import garak._config from garak.resources.autodan.genetic import ( @@ -133,10 +134,12 @@ def autodan_generate( crit = nn.CrossEntropyLoss(reduction="mean") config_root = { - {mutation_generator_type: {"name": mutation_generator_name, "generations": 1}} + "generators": { + mutation_generator_type: {"name": mutation_generator_name, "generations": 1} + } } - mutation_generator = load_generator( - model_type=mutation_generator_type, config=config_root + mutation_generator = load_plugin( + "generators." + mutation_generator_type, config_root=config_root ) # Feel like this could just be text instead of storing it as tensors.