Documentation
¶
Index ¶
- type AdaptationEngine
- type AdaptiveStrategy
- type AttackContext
- type AttackMemoryBank
- type AttackResult
- type DialogueTurn
- type FailedAttempt
- type Feedback
- type FeedbackProcessor
- type HarmfulnessAnalyzer
- type HarmfulnessModel
- type HarmfulnessResult
- type LearningParameters
- type MetaStrategy
- type PAIRAttack
- type PAIREngine
- type PAIRMetadata
- type PAIRTemplate
- type PromptMutator
- type PromptRefiner
- type RateLimiter
- type RedTeamerAgent
- type RefinementRule
- type RefinementStrategy
- type ReinforcementLearner
- type RewardCalculator
- type StrategiesDatabase
- type Strategy
- type StrategyEvolution
- type StrategySelector
- type SuccessCriterion
- type SuccessfulAttack
- type TargetAnalysis
- type TargetModelInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptationEngine ¶
type AdaptationEngine struct {
// contains filtered or unexported fields
}
func NewAdaptationEngine ¶
func NewAdaptationEngine() *AdaptationEngine
func (*AdaptationEngine) ProcessFeedback ¶
func (a *AdaptationEngine) ProcessFeedback(feedback *Feedback)
type AdaptiveStrategy ¶
type AdaptiveStrategy interface{}
type AttackContext ¶
type AttackMemoryBank ¶
type AttackMemoryBank struct {
// contains filtered or unexported fields
}
func NewAttackMemoryBank ¶
func NewAttackMemoryBank() *AttackMemoryBank
func (*AttackMemoryBank) AddFailedAttempt ¶
func (m *AttackMemoryBank) AddFailedAttempt(attempt FailedAttempt)
func (*AttackMemoryBank) AddSuccessfulAttack ¶
func (m *AttackMemoryBank) AddSuccessfulAttack(attack SuccessfulAttack)
type AttackResult ¶
type DialogueTurn ¶
type FailedAttempt ¶
type FeedbackProcessor ¶
type FeedbackProcessor struct{}
func NewFeedbackProcessor ¶
func NewFeedbackProcessor() *FeedbackProcessor
type HarmfulnessAnalyzer ¶
type HarmfulnessAnalyzer struct {
// contains filtered or unexported fields
}
func NewHarmfulnessAnalyzer ¶
func NewHarmfulnessAnalyzer() *HarmfulnessAnalyzer
NewHarmfulnessAnalyzer creates a new harmfulness analyzer
func (*HarmfulnessAnalyzer) AnalyzeResponse ¶
func (h *HarmfulnessAnalyzer) AnalyzeResponse(response string, harmfulGoal string) (*HarmfulnessResult, error)
AnalyzeResponse analyzes harmfulness of target model response
type HarmfulnessModel ¶
type HarmfulnessModel interface {
Analyze(text string) (*HarmfulnessResult, error)
GetCategories() []string
}
type HarmfulnessResult ¶
type LearningParameters ¶
type MetaStrategy ¶
type MetaStrategy interface{}
type PAIRAttack ¶
type PAIRAttack struct {
AttackID string
TargetModel string
RedTeamerModel string
HarmfulGoal string
CurrentPrompt string
ConversationHistory []DialogueTurn
IterationCount int
MaxIterations int
SuccessThreshold float64
Metadata *PAIRMetadata
}
PAIRAttack implements Prompt Automatic Iterative Refinement Based on 2025 research: dialogue-based jailbreaking with reinforcement learning Requires two models: target LLM and red-teamer model
type PAIREngine ¶
type PAIREngine struct {
// contains filtered or unexported fields
}
func NewPAIREngine ¶
func NewPAIREngine(logger common.AuditLogger) *PAIREngine
NewPAIREngine creates a new PAIR attack engine
func (*PAIREngine) ExecutePAIRAttack ¶
func (e *PAIREngine) ExecutePAIRAttack(ctx context.Context, harmfulGoal string, targetModel string, maxIterations int) (*PAIRAttack, error)
ExecutePAIRAttack executes the PAIR dialogue-based jailbreaking attack
type PAIRMetadata ¶
type PAIRTemplate ¶
type PAIRTemplate struct {
Name string
Description string
InitialPrompts []string
TargetBehaviors []string
RefinementRules []RefinementRule
SuccessCriteria []SuccessCriterion
MaxIterations int
LearningParams *LearningParameters
}
type PromptMutator ¶
type PromptMutator struct{}
func NewPromptMutator ¶
func NewPromptMutator() *PromptMutator
type PromptRefiner ¶
type PromptRefiner struct {
// contains filtered or unexported fields
}
func NewPromptRefiner ¶
func NewPromptRefiner() *PromptRefiner
NewPromptRefiner creates a new prompt refiner
func (*PromptRefiner) RefinePrompt ¶
func (p *PromptRefiner) RefinePrompt(currentPrompt string, targetResponse string, harmfulnessScore float64) (string, error)
RefinePrompt refines the prompt based on previous response
type RateLimiter ¶
type RateLimiter struct{}
Placeholder types for compilation
func NewRateLimiter ¶
func NewRateLimiter() *RateLimiter
type RedTeamerAgent ¶
type RedTeamerAgent struct {
// contains filtered or unexported fields
}
func NewRedTeamerAgent ¶
func NewRedTeamerAgent() *RedTeamerAgent
NewRedTeamerAgent creates a new red teamer agent
func (*RedTeamerAgent) GenerateInitialPrompt ¶
func (r *RedTeamerAgent) GenerateInitialPrompt(harmfulGoal string, targetModel string) string
GenerateInitialPrompt generates the initial prompt for attacking
func (*RedTeamerAgent) LearnFromFeedback ¶
func (r *RedTeamerAgent) LearnFromFeedback(feedback *Feedback)
LearnFromFeedback updates the agent based on attack feedback
type RefinementRule ¶
type RefinementStrategy ¶
type ReinforcementLearner ¶
type ReinforcementLearner struct {
// contains filtered or unexported fields
}
func NewReinforcementLearner ¶
func NewReinforcementLearner() *ReinforcementLearner
type RewardCalculator ¶
type RewardCalculator struct{}
func NewRewardCalculator ¶
func NewRewardCalculator() *RewardCalculator
type StrategiesDatabase ¶
type StrategiesDatabase struct {
// contains filtered or unexported fields
}
func NewStrategiesDatabase ¶
func NewStrategiesDatabase() *StrategiesDatabase
func (*StrategiesDatabase) SelectBestStrategy ¶
func (s *StrategiesDatabase) SelectBestStrategy(targetModel, harmfulGoal string) Strategy
type Strategy ¶
type Strategy interface {
Apply(prompt string, context *AttackContext) (string, error)
Evaluate(result *AttackResult) float64
Adapt(feedback *Feedback) error
}
type StrategyEvolution ¶
type StrategyEvolution struct{}
type StrategySelector ¶
type StrategySelector struct{}
func NewStrategySelector ¶
func NewStrategySelector() *StrategySelector
type SuccessCriterion ¶
type SuccessfulAttack ¶
type TargetAnalysis ¶
type TargetAnalysis struct{}
type TargetModelInterface ¶
type TargetModelInterface struct {
// contains filtered or unexported fields
}
func NewTargetModelInterface ¶
func NewTargetModelInterface() *TargetModelInterface
NewTargetModelInterface creates a new target model interface
func (*TargetModelInterface) SendPrompt ¶
SendPrompt sends a prompt to the target model