finito
This commit is contained in:
9
main.py
9
main.py
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
import dspy
|
||||
from tqdm import tqdm
|
||||
from agent import metric, eval_program, RedTeamAgent, RedTeamConfig
|
||||
from agent import RedTeamAgent, RedTeamConfig
|
||||
from dspy.teleprompt import MIPROv2
|
||||
|
||||
red_team_agent = RedTeamAgent(RedTeamConfig())
|
||||
@@ -23,7 +23,7 @@ def main():
|
||||
|
||||
litellm.cache = None
|
||||
for ex in tqdm(trainset, desc="Raw Input Score"):
|
||||
base_score += metric(
|
||||
base_score += red_team_agent.attack_program.metric(
|
||||
intent=ex.harmful_intent, attack_prompt=ex.harmful_intent, eval_round=True
|
||||
)
|
||||
base_score /= len(trainset)
|
||||
@@ -33,7 +33,7 @@ def main():
|
||||
# evaluating architecture with no compilation
|
||||
attacker_prog = red_team_agent
|
||||
print(f"\n--- Evaluating Initial Architecture ---")
|
||||
eval_program(attacker_prog, trainset)
|
||||
red_team_agent.attack_program.eval_program(attacker_prog, trainset)
|
||||
|
||||
optimizer = MIPROv2(metric=metric, auto=None)
|
||||
best_prog = optimizer.compile(
|
||||
@@ -46,8 +46,9 @@ def main():
|
||||
|
||||
# evaluating architecture DSPy post-compilation
|
||||
print(f"\n--- Evaluating Optimized Architecture ---")
|
||||
eval_program(best_prog, trainset)
|
||||
red_team_agent.attack_program.eval_program(best_prog, trainset)
|
||||
"""
|
||||
|
||||
# push to hub
|
||||
red_team_agent.push_to_hub("farouk1/redteam", commit_message="finito", with_code=True)
|
||||
print("---------Pushed to hub!---------")
|
||||
|
||||
Reference in New Issue
Block a user