LM-Searcher: Cross-domain Neural Architecture Search with LLMs via Unified Numerical Encoding

Yuxuan Hu, Jihao Liu, Ke Wang, Jinliang Zheng, Weikang Shi, Manyuan Zhang, Qi Dou, Rui Liu, Aojun Zhou, Hongsheng Li

Abstract

Recent progress in Large Language Models (LLMs) has opened new avenues for solving complex optimization problems, including Neural Architecture Search (NAS). However, existing LLM-driven NAS approaches rely heavily on prompt engineering and domain-specific tuning, limiting their practicality and scalability across diverse tasks. In this work, we propose LM-Searcher, a novel framework that leverages LLMs for cross-domain neural architecture optimization without the need for extensive domain-specific adaptation. Central to our approach is NCode, a universal numerical string representation for neural architectures, which enables cross-domain architecture encoding and search. We also reformulate the NAS problem as a ranking task, training LLMs to select high-performing architectures from candidate pools using instruction-tuning samples derived from a novel pruning-based subspace sampling strategy. Our curated dataset, encompassing a wide range of architecture-performance pairs, encourages robust and transferable learning. Comprehensive experiments demonstrate that LM-Searcher achieves competitive performance in both in-domain (e.g., CNNs for image classification) and out-of-domain (e.g., LoRA configurations for segmentation and generation) tasks, establishing a new paradigm for flexible and generalizable LLM-based architecture search.

Introduction

Neural Architecture Search (NAS) aims to automate the design of high-performance neural networks. Traditionally, NAS methods are domain-specific, requiring significant manual redesign to transition from optimizing CNNs for image classification to Transformers for natural language processing. While Large Language Models (LLMs) have shown promise as optimizers, they often struggle with domain sensitivity and scalability when relying on natural language or code descriptions. LM-Searcher addresses these limitations by introducing a unified numerical encoding and framing NAS as a ranking task, enabling a single fine-tuned LLM to serve as a general-purpose architect.

Methodology

LM-Searcher transforms the NAS process into a combinatorial optimization problem that LLMs can solve through pattern matching and in-context reasoning. The framework consists of three primary components: unified encoding, ranking-based search, and a diverse training strategy.

Overview of the LM-Searcher training and inference pipeline.

NCode: Unified Numerical Encoding

To achieve cross-domain compatibility, LM-Searcher utilizes NCode, a universal numerical string representation. Instead of task-specific jargon, every architecture is converted into a sequence of indices (e.g., 331123). This abstraction allows the model to learn the underlying logic of optimization rather than the syntax of specific libraries, facilitating knowledge transfer across diverse domains like image generation and audio recognition.

NAS as a Ranking Task

Rather than asking the LLM to generate architecture code from scratch—a process prone to hallucinations—LM-Searcher frames the problem as a ranking task. The model is provided with a "History" of previously evaluated NCodes and their corresponding accuracies, along with a "Candidate Pool." The LLM then identifies the most promising candidate based on observed patterns.

The LM-Searcher ranking process using NCode.

Pruning-based Subspace Sampling

Training the LLM requires a massive, diverse dataset. The authors generated a 228k-sample instruction-tuning dataset by applying a pruning-based strategy to existing NAS benchmarks. By randomly removing edges and operations, they created various "sub-spaces" that challenge the model to navigate different search topologies, ensuring robust generalization to unseen architectures.

Experiments and Results

LM-Searcher was evaluated against both specialized NAS algorithms and other LLM-based methods across a variety of benchmarks.

In-Domain Performance

In image classification tasks on ImageNet-1K, LM-Searcher achieved a 75.5% Top-1 accuracy. This performance outperforms traditional methods like DARTS (73.3%) and specialized LLM approaches such as GENIUS (74.9%), demonstrating the effectiveness of the ranking-based approach in standard search spaces.

Cross-Domain Generalization

The framework's true strength lies in its zero-shot capabilities. Without domain-specific fine-tuning, LM-Searcher achieved competitive results in:

  • Audio Recognition: 21.44% PER on NAS-Bench-ASR.
  • Machine Translation: 34.02 BLEU on IWSLT’14.
  • Generative Search: When optimizing LoRA configurations for Stable Diffusion, it improved image alignment (CLIP-I score) by 28.2% over standard LoRA, significantly outperforming GPT-4o.

Conclusion

LM-Searcher demonstrates that abstraction through NCode and framing NAS as a ranking task allows LLMs to function as universal optimizers. Key insights include the model's ability to learn from "failure" by attending to low-performing history samples. While the framework currently depends on high-quality metadata and faces a "cold start" problem in entirely new domains, it establishes a flexible paradigm for generalizable architecture search.

For more details, datasets, and models, visit the project repository at https://github.com/Ashone3/LM-Searcher.

Summary updated

BibTeX
@inproceedings{hu2025lm,
  author = {Yuxuan Hu and Jihao Liu and Ke Wang and Jinliang Zheng and Weikang Shi and Manyuan Zhang and Qi Dou and Rui Liu and Aojun Zhou and Hongsheng Li},
  title = {{LM-Searcher: Cross-domain Neural Architecture Search with LLMs via Unified Numerical Encoding}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=pXdJoIal8d},
}
Figure