LLM Strategies
While AST mutations are deterministic and safe, they are limited to structural transformations. LLM strategies unlock semantic mutations — the kind of creative refactoring that requires understanding what the code does, not just how it is structured.
Enabling LLM mutations
hezgene run src/utils.py --llmThe --llm flag adds LLM-generated mutants to the arena alongside AST mutants. Both compete equally — the best one wins regardless of origin.
Available strategies
| Strategy | Focus | Technique |
|---|---|---|
| optimize_speed | Execution speed | Algorithm replacement, caching, vectorization |
| optimize_memory | Memory usage | Generator expressions, lazy evaluation, pooling |
| simplify | Readability | Reduce complexity, extract helpers, clearer naming |
| algorithmic | Big-O improvement | Replace O(n²) with O(n log n), use hash maps |
| robust | Error handling | Add guards, handle edge cases, defensive coding |
Supported providers
# Ollama (local, free)
hezgene config --set llm.provider ollama
hezgene config --set llm.model gemma2:2b
# OpenAI
hezgene config --set llm.provider openai
hezgene config --set llm.model gpt-4o-mini
# Anthropic
hezgene config --set llm.provider anthropic
hezgene config --set llm.model claude-sonnet-4-20250514
# Google Gemini
hezgene config --set llm.provider gemini
hezgene config --set llm.model gemini-2.5-flashLocal first
Ollama runs entirely on your machine with no API key required. It is the recommended provider for users who want LLM mutations without sending code to external services.
LLM safety guarantees
LLM mutations go through the exact same Fitness Arena as AST mutations. Even if an LLM produces creative but incorrect code, it will be caught and killed in Ring 1 (Correctness). The LLM is a suggestion engine — the Arena is the judge.
Was this page helpful?