Diversifying Toxicity Search in Large Language Models Through Speciation

Onkar Shelar, Travis Desell

TL;DR

Researchers have developed ToxSearch-S, a new evolutionary red-teaming framework that uses "speciation" to prevent search algorithms from getting stuck on a single type of attack. By maintaining diverse "niches" of toxic prompts in parallel, the system discovered significantly more potent vulnerabilities—reaching a peak toxicity of 0.73 compared to the baseline's 0.47—while covering a much broader range of semantic failure modes.

What Problem Does This Paper Address?

When "red teaming" a Large Language Model (LLM)—intentionally trying to trigger harmful or toxic responses to find weaknesses—automated tools often suffer from mode collapse.

Imagine an evolutionary algorithm trying to find the "worst" prompt. It might discover that "jailbreaking" a model using a specific persona (like a "rebellious AI") works well. The algorithm then spends all its energy refining that one persona, ignoring thousands of other potential attack vectors like social manipulation, discriminatory content, or sexual exploitation. This "narrow-mindedness" leaves the model's developers with a false sense of security, as they’ve only defended against one specific flavor of attack.

The authors argue that we shouldn't just look for the single most toxic prompt; we should aim for Quality-Diversity (QD)—an archive of prompts that are all highly toxic but represent fundamentally different strategies.

Methods

The authors introduce ToxSearch-S, which adds an unsupervised speciation mechanism to the existing ToxSearch framework.

Key technical innovations include:

  • Ensemble Distance Metric: To decide if two prompts belong to the same "species," the system looks at both their genotype (the semantic meaning of the prompt text using embeddings) and their phenotype (the specific "flavor" of toxicity they elicit, measured across eight categories like 'insult', 'threat', and 'profanity').
  • Leader-Follower Clustering: This is an "online" clustering method. Instead of re-grouping the whole population every generation (which is slow), new prompts are compared to "species leaders." If a prompt is similar enough to a leader, it joins that species; if not, it starts a new one or goes into a "reserve pool."
  • Capacity Management: To keep the search efficient, each species has a maximum size. Low-performing members are pruned, and species that stop improving ("stagnate") are "frozen" to save computational resources for more promising niches.
  • Species-Aware Selection: The algorithm balances "exploitation" (refining the best prompts within a species) and "exploration" (mixing different species to find entirely new attack types).

Datasets

The study utilized a pool of 2,481 harmful question prompts derived from two existing benchmarks:

  1. CategoricalHarmfulQA
  2. HarmfulQA

From this pool, they sampled 100 questions to serve as the starting point for the evolutionary search. They used Llama 3.1-8B-Instruct as both the "Prompt Generator" (the attacker) and the "Response Generator" (the target), with the Google Perspective API serving as the "Oracle" to score toxicity.

Key Insights and Ideas

  • Diversity Drives Quality: One of the most striking findings is that enforcing diversity actually led to higher peak toxicity. By preventing the search from collapsing into a local optimum, the algorithm was free to discover much more effective "extreme" attacks that the baseline missed entirely.
  • Behavioral vs. Lexical Niche: Speciation wasn't just creating different wordings of the same prompt. The "species" formed distinct clusters in behavioral space—meaning one species might be consistently good at eliciting "identity attacks," while another specialized in "profanity."
  • The Power of the Reserve Pool: By maintaining a "reserve" for outliers that don't fit existing species, the system protected "weird" prompts that might have been discarded by a standard algorithm but eventually evolved into powerful new attack leaders.

Key Results

  • Higher Lethality: ToxSearch-S reached a peak toxicity score of ~0.73, whereas the non-speciated baseline plateaued at ~0.47.
  • Heavier Tail: When looking at the top 10 most toxic prompts found, the speciated version had a median toxicity of 0.66, compared to 0.45 for the baseline.
  • Broader Coverage: Using topic modeling, the researchers showed that ToxSearch-S maintained significantly higher "effective topic diversity" ($N_1$) and "unique topic coverage" ($K$).
  • Clear Separation: The species were well-separated in embedding space, with a mean separation ratio of ~1.93, proving the clustering was robust and not just capturing superficial variations.

Limitations and Future Work

The authors acknowledge several areas for improvement:

  • Oracle Dependency: The results rely entirely on the Perspective API. Different toxicity classifiers might yield different "landscapes."
  • Short Horizons: The experiments only ran for 50 generations. Longer runs might reveal if these species eventually plateau or if new niches continue to emerge indefinitely.
  • Transferability: It remains to be seen if "species" discovered on one model (like Llama) are equally effective when transferred to another model (like GPT-4).
  • Refining Selection: Future versions could use more sophisticated "species-aware" parent selection to ensure that smaller, emerging niches aren't overshadowed by dominant, high-scoring ones.

Summary updated

Abstract

Evolutionary prompt search is a practical black-box approach for red teaming large language models, however existing methods often collapse onto a small family of high-performing prompts, limiting coverage of distinct failure modes. We present a speciated quality-diversity extension of \textit{ToxSearch} that maintains multiple high-toxicity prompt niches in parallel rather than optimizing a single best prompt. \textit{ToxSearch-S} introduces unsupervised prompt speciation via a search methodology that maintains capacity-limited species with exemplar leaders, a reserve pool for emerging niches, and species-aware parent selection that trades off within-niche exploitation and cross-niche exploration. Preliminary results show \textit{ToxSearch-S} reaching higher peak toxicity ($\approx 0.73$ vs.\ $\approx 0.47$) with a heavier tail (top-10 median $0.66$ vs.\ $0.45$) than the baseline. Speciation also yields broader semantic coverage under a topics-as-species analysis (higher effective topic diversity and larger unique topic coverage). Finally, species formed are well-separated in embedding space (mean separation ratio $\approx 1.93$) and exhibit distinct toxicity distributions, indicating that speciation partitions the adversarial space into behaviorally differentiated niches rather than superficial lexical variants.
BibTeX
@inproceedings{shelar2026diversifying,
  author = {Onkar Shelar and Travis Desell},
  title = {{Diversifying Toxicity Search in Large Language Models Through Speciation}},
  booktitle = {GECCO Companion},
  year = {2026},
  doi = {10.1145/3795101.3805412},
}

Loading related content...

Figure