GeneticOptimizer<T>

Models & Types ยท AiDotNet.PromptEngineering.Optimization

Optimizer that uses genetic algorithms to evolve better prompts.

Inheritance: PromptOptimizerBase<T> โ†’ GeneticOptimizer<T>

For Beginners

Evolves prompts like nature evolves species.

Example:

How it works:

  • Start with variations of the initial prompt (population)
  • Evaluate how well each performs (fitness)
  • Select the best performers
  • Combine them (crossover) and introduce random changes (mutation)
  • Repeat for many generations

How It Works

This optimizer mimics natural evolution: prompts are mutated, crossed over, and selected based on fitness (performance scores).

Constructors

Constructor Summary
GeneticOptimizer(int populationSize, double mutationRate, double crossoverRate, int eliteCount, int? seed) Initializes a new instance of the GeneticOptimizer class.

Methods

Method Summary
void AddBuildingBlocks(IEnumerable<string> prefixes, IEnumerable<string> suffixes, IEnumerable<string> connectors) Adds custom genetic building blocks for mutation.