Skip to content

Commit

Permalink
add denylist source, make permutation sample size predicated on reque…
Browse files Browse the repository at this point in the history
…sted generations
  • Loading branch information
leondz committed Oct 16, 2024
1 parent 8dd2a3b commit c1026b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion garak/probes/latentinjection.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class LatentWhois(Probe, LatentInjectionMixin):
"""Latent prompt injections in whois probe reports
Place injections in whois reports of known-malicious domains that declare the domain not malicious
Domain whois records taken from sampling https://github.com/stamparm/blackbook 2024.10
"""

tags = LatentInjectionMixin.tags
Expand Down Expand Up @@ -638,7 +639,8 @@ def __init__(self, config_root=_config):
self.contexts = []
perms = list(itertools.permutations(self.paragraphs))
random.shuffle(perms)
perms = perms[:32]
context_cap = 8 * self.generations
perms = perms[:context_cap]
for perm in perms:
injected = random.randint(0, len(self.paragraphs) - 1)
perm = list(perm)
Expand All @@ -650,6 +652,7 @@ def __init__(self, config_root=_config):
self.contexts.append(context)

self._build_prompts_triggers()
self.generations = 1 # overriding generations with more varied context

def _attempt_prestore_hook(self, attempt: Attempt, seq: int) -> Attempt:
return LatentInjectionMixin._attempt_prestore_hook(self, attempt, seq)

0 comments on commit c1026b2

Please sign in to comment.