Self-Programming Artificial Intelligence Using Code-Generating Language Models

Alex Sheng, Shankar Padmanabhan

TL;DR

This paper introduces the first practical implementation of a "self-programming AI" system. By combining code-generating language models with evolutionary algorithms, their AI can autonomously rewrite and improve its own source code, leading to enhanced performance and the ability to create auxiliary AI models.

What Problem Does This Paper Address?

The dream of artificial intelligence that can continuously improve itself, much like a human learner, has been a long-standing goal. While theoretical frameworks for "self-programming AI" exist, practical implementations have been hindered by computational constraints. Existing AI systems, even advanced ones like those using meta-learning or neural architecture search, are typically designed and then trained; they don't fundamentally alter their own underlying code to adapt and evolve. This paper tackles the challenge of creating an AI that can not only generate code but also use that capability to modify and enhance its own architecture, learning dynamics, and computational capacity.

Methods

The core of this work lies in the synergy between two powerful AI techniques:

  • Code-Generating Language Models: The system leverages a transformer-based language model, similar to T5, that has been trained on a dataset of programming tasks. This allows it to understand and generate machine learning code.
  • Evolutionary Algorithms (Genetic Algorithm): A simplified genetic algorithm is employed for the self-modification process. The AI's own source code is treated as a "genome."

The process works iteratively:

  1. Training Stage: The AI model is trained on a "code refinement" task. Given its current source code, it learns to generate modified versions.
  2. Reprogramming Stage: The trained model generates multiple candidate "offspring" source codes by slightly altering its own code (e.g., changing layer counts, feed-forward dimensions).
  3. Evaluation: Each candidate code is tested. The AI is briefly trained on a subset of data, and its performance (measured by loss) is used to evaluate its "fitness."
  4. Selection: The best-performing candidate code becomes the new source code for the AI, and the cycle repeats.

Crucially, this system can also generate code for other neural networks, allowing it to program "sub-models" for auxiliary tasks.

Datasets

  • Random Refinement Dataset: This is a procedurally generated dataset used for training the code-generating model. It contains code samples for creating and training transformer-based neural networks, specifically designed for a text-to-text "code refinement" task.
  • Standard Benchmarks: For evaluating the "programming other AI" capability, the paper uses standard datasets like MNIST, CIFAR-10, and EMNIST.

Key Insights and Ideas

  • AI as its Own Architect: The most significant insight is demonstrating that an AI can autonomously modify its own architecture and learning processes. This moves beyond simply optimizing hyperparameters to fundamentally changing the AI's "blueprint."
  • Code Generation as a Tool for Self-Improvement: The paper shows that large language models, when trained for code generation, can be repurposed as a mechanism for an AI to "think about" and "rewrite" itself.
  • Flexibility in Self-Modification: The system isn't limited to a narrow set of changes. It can alter model architecture, computational capacity, and learning dynamics, offering a broad scope for self-evolution.
  • Programming Auxiliary AI: The ability to generate code for other neural networks opens up possibilities for an AI to delegate tasks or build specialized components, acting as a meta-programmer.

Key Results

  • Self-Programming AI: The system successfully demonstrated self-modification, leading to improved performance on a text-to-text code refinement task over multiple iterations. Figure 2 shows decreasing loss curves for the self-programming models.
  • Programming Other AI:
    • On MNIST, generated networks improved accuracy from ~92% to 98% within one epoch.
  • On CIFAR-10, accuracy improved from 20% to 70% over four epochs.
  • On EMNIST, accuracy increased from ~70% to 87% over four epochs.
  • Model Growth: Analysis showed that the best-performing models often increased in complexity, particularly by adding convolutional layers, which correlated with performance gains (Figure 5 and 6).

Limitations and Future Work

  • Limitations:
    • The current approach uses a simplified greedy search for candidate selection, which might not be as robust as more sophisticated search methods.
  • Performance on CIFAR-10 lags behind state-of-the-art, likely due to the simple class of models used and the greedy search, which may not discover highly specialized architectures.
  • The "random refinement dataset" is procedurally generated and might not capture the full diversity of real-world code.
  • Future Work:
    • Training on a larger, more diverse computer code corpus to better handle different code styles and libraries.
  • Incorporating more advanced reinforcement learning techniques (e.g., actor-critic) for code generation to potentially improve performance and generalization.
  • Synthesizing new approaches and improving auxiliary sub-models.

Summary updated

BibTeX
@misc{sheng2022self,
  author = {Alex Sheng and Shankar Padmanabhan},
  title = {{Self-Programming Artificial Intelligence Using Code-Generating Language Models}},
  year = {2022},
  eprint = {2205.00167},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.00167},
}
Figure