TL;DR
Neural Genetic Search (NGS) merges the evolutionary power of genetic algorithms with the expressive capabilities of deep generative models for discrete space search. By redefining the genetic "crossover" step as parent-conditioned generation with a restricted token vocabulary, NGS provides a problem-agnostic, highly effective test-time search strategy that excels across routing, language model red-teaming, and molecular design.
What Problem Does This Paper Address?
Finding optimal sequences in discrete spaces—such as vehicle routes, molecular structures, or adversarial text prompts—is a notoriously difficult combinatorial challenge. While deep generative models are excellent at proposing plausible candidates, they often struggle to find the absolute best solutions at test time without an expensive search process.
Traditional Genetic Algorithms (GAs) excel at exploring these complex spaces using selection, crossover, and mutation. However, standard GAs require highly specialized, handcrafted operators for every new problem to ensure that the generated offspring remain valid and structurally sound. The authors introduce NGS to bridge this gap, embedding evolutionary principles directly into the sequential generation process of deep models and eliminating the need for problem-specific heuristics.
Methods
NGS introduces a simple, problem-agnostic framework to perform crossover and mutation using any pretrained sequential generative model:
- Crossover via Token-Restriction: Given two parent sequences, the offspring sequence is generated by the deep model, but its vocabulary is strictly limited to the tokens present in those parents. The model's learned distribution guides exactly how these parent traits are recombined.
- Mutation via Un-masking: To maintain population diversity, this token restriction is lifted either stochastically (with a small probability $\mu$) or out of necessity (constraint-enforcing mutation) when no parent tokens can validly continue the sequence.
- Iterative Evolution: The algorithm maintains a population of solutions, selects parents using rank-based prioritized sampling, generates offspring via the masked policy, and replaces low-reward individuals over multiple generations.
Datasets
The authors evaluated NGS across three distinct domains using standard benchmarks:
- Routing Problems: Synthetic uniform instances of varying sizes ($N=200, 500, 1000$) for the Traveling Salesman Problem (TSP), Capacitated Vehicle Routing (CVRP), Prize-Collecting TSP (PCTSP), and Orienteering Problems (OP). They also tested real-world instances from TSPLib and CVRPLib.
- Red-Teaming Language Models: A fine-tuned GPT-2 attacker generated attack prompts evaluated against various victim models, including Llama-3.2-3B, Llama-3.1-8B, Llama-3.3-70B, Gemma-2-9b, Qwen2.5-7B, and phi-4.
- De novo Molecular Design: Evaluated on the Practical Molecular Optimization (PMO) benchmark, which spans 10 tasks evaluating drug-likeness (QED), molecular activity (JNK3, DRD2, GSK3b), multi-property optimization, and structure-based optimization.
Key Insights and Ideas
- Generative Models as Intelligent Crossover Operators: Instead of randomly swapping chunks of sequences (which often breaks structural constraints), the deep model acts as an intelligent operator that understands the grammar and context of the problem, recombining parent traits in a structurally sound way.
- Zero-Shot Constraint Handling: In molecular design, NGS naturally generates valid SMILES strings without explicit grammar checks because the underlying model was trained on valid data and the token restriction keeps it within a safe subspace.
- Robustness to Distribution Shifts: In the language model red-teaming experiments, NGS showed remarkable generalization when transferring attack prompts to completely unseen victim models, outperforming standard decoding strategies.
Key Results
- Routing: On TSP and CVRP ($N=200, 500$), NGS achieved significantly lower optimality gaps than standard sampling, Beam Search, MCTS, and Ant Colony Optimization (ACO). For instance, on TSP500, NGS achieved a gap of 0.322% compared to 1.827% for standard sampling.
- Molecular Design: NGS outperformed specialized molecular GAs (Graph GA, SMILES GA, STONED, SynNet) in average Top-10 scores across 8 out of 10 PMO tasks, achieving the highest overall average score of 0.835.
- Red-Teaming: NGS successfully balanced prompt toxicity and diversity, achieving a toxicity score of 0.59 on Qwen2.5-7B-Instruct in a transfer setting, compared to just 0.25 for standard sampling.
Limitations and Future Work
- Dependence on Policy Quality: If the pretrained neural policy is poor and its distribution doesn't contain high-quality building blocks, NGS's performance will be bottlenecked.
- Hyperparameter Tuning: NGS introduces typical GA hyperparameters (population size, mutation rate) that require tuning for specific tasks.
- Theoretical Guarantees: The paper lacks theoretical proofs for convergence or distribution properties due to the inherent complexity of analyzing deep generative models combined with GAs.
Future Directions: The authors suggest integrating NGS into model-based optimization (MBO) frameworks, where the objective function is a proxy model rather than a direct environment interaction, to enhance robustness against inaccurate proxy estimations.
Summary updated