Skip to main content
QUICK REVIEW

[Paper Review] Language Model Crossover: Variation through Few-Shot Prompting

Elliot Meyerson, Mark Nelson|arXiv (Cornell University)|Feb 23, 2023
Evolutionary Algorithms and ApplicationsComputer Science6 citations
TL;DR

This paper introduces Language Model Crossover (LMX), a novel evolutionary variation operator that leverages few-shot prompting in large language models (LLMs) to generate high-quality offspring by combining text-based genotypes such as code, equations, or sentences. By prompting an LLM with a few input genotypes, LMX enables intelligent, semantically aware recombination across diverse domains—including binary strings, mathematical expressions, and Python code—demonstrating strong versatility and effectiveness with minimal implementation overhead.

ABSTRACT

This paper pursues the insight that language models naturally enable an intelligent variation operator similar in spirit to evolutionary crossover. In particular, language models of sufficient scale demonstrate in-context learning, i.e. they can learn from associations between a small number of input patterns to generate outputs incorporating such associations (also called few-shot prompting). This ability can be leveraged to form a simple but powerful variation operator, i.e. to prompt a language model with a few text-based genotypes (such as code, plain-text sentences, or equations), and to parse its corresponding output as those genotypes' offspring. The promise of such language model crossover (which is simple to implement and can leverage many different open-source language models) is that it enables a simple mechanism to evolve semantically-rich text representations (with few domain-specific tweaks), and naturally benefits from current progress in language models. Experiments in this paper highlight the versatility of language-model crossover, through evolving binary bit-strings, sentences, equations, text-to-image prompts, and Python code. The conclusion is that language model crossover is a promising method for evolving genomes representable as text.

Motivation & Objective

  • To develop a general-purpose, domain-agnostic variation operator for evolutionary computation using the in-context learning capabilities of large language models.
  • To explore whether LLMs can serve as intelligent pattern-completion engines for evolutionary recombination, mimicking biological crossover.
  • To evaluate the effectiveness and versatility of LMX across diverse text-based representations, including code, equations, and natural language.
  • To investigate how parent ordering and prompt engineering can bias offspring distribution toward higher fitness or specific attributes.
  • To demonstrate that LMX can be implemented with minimal code and leverages existing open-source LLMs and APIs for broad applicability.

Proposed method

  • LMX constructs a prompt by concatenating multiple text-based genotypes (parents) as few-shot examples, followed by a target input to be completed.
  • The LLM processes the prompt and generates a new output, which is parsed as a novel offspring genotype, effectively performing crossover through pattern completion.
  • The method relies on the LLM’s in-context learning ability to infer underlying patterns from a few input-output pairs and generalize to new inputs.
  • Parent ordering in the prompt is manipulated to bias offspring toward higher fitness or specific traits, such as sorting by fitness or leading 1s count in binary strings.
  • The approach is agnostic to domain and can be applied to any text-representable genome, including code, equations, sentences, and text-to-image prompts.
  • LMX integrates seamlessly into evolutionary algorithms and can be combined with other operators like LLM-based mutation or fine-tuned models for enhanced performance.

Experimental results

Research questions

  • RQ1Can large language models act as intelligent variation operators by performing pattern-completion across diverse text-based genotypes?
  • RQ2How does the ordering of parent genotypes in the prompt influence the fitness distribution of the offspring generated by the LLM?
  • RQ3To what extent can LMX generate high-quality, semantically meaningful offspring across different domains such as code, equations, and natural language?
  • RQ4Can LMX be effectively combined with other evolutionary operators like mutation or fine-tuned models to improve search performance?
  • RQ5How does the performance of LMX depend on the underlying LLM’s training data and domain alignment?

Key findings

  • LMX successfully generates high-quality offspring across five distinct domains: binary strings, mathematical expressions, English sentences, text-to-image prompts, and Python code.
  • When parents are sorted in ascending order of fitness, LMX produces offspring with a statistically significant skew toward higher fitness, particularly for scores of 6 or more in the 10-bit one-max problem.
  • For low-fitness parents (5 or fewer 1s), offspring are more likely to come from parents sorted in descending order, indicating a measurable bias based on parent ordering.
  • The method demonstrates that parent ordering, such as by leading 1s count, can consistently bias offspring toward specific fitness ranges, enabling targeted search.
  • LMX achieves strong results with minimal code and computational cost, with experiments running efficiently on Google Colab or a single GPU using HuggingFace APIs.
  • The approach is highly extensible and can be enhanced by integrating with domain-specific LLMs, fine-tuning, or combining with mutation operators for improved evolutionary performance.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.