Abstract
The deployment of deep learning on resource-constrained microcontrollers (TinyML) is hindered by strict memory limits and the high computational cost of traditional Neural Architecture Search (NAS). This paper presents a novel framework that leverages the reasoning capabilities of Large Language Models (LLMs) to automate the design of efficient and explainable neural networks. By integrating LLM-guided search with Pareto optimization and Vision Transformer (ViT)-based knowledge distillation, we developed the LMaNet series. Our flagship model, LMaNet-Elite, achieves 74.50% accuracy on CIFAR-100 while maintaining a peak SRAM footprint of only 165KB, significantly outperforming existing state-of-the-art models like MCUNet in both performance and search efficiency.
1. Introduction
TinyML represents the frontier of edge computing, enabling intelligence on low-power microcontrollers like the STM32H7. However, these devices typically possess less than 512KB of SRAM, rendering standard mobile architectures like MobileNet impractical. Traditional solutions involve either labor-intensive manual design or automated NAS. While NAS can find high-performing models, it is often computationally expensive and functions as a "black box," offering little insight into the architectural decisions made. This research explores whether LLMs can bridge this gap by providing an efficient, reasoning-based approach to architecture discovery that balances performance with explainability.
2. The LMaNet Framework
The proposed framework utilizes a multi-stage optimization pipeline designed to balance accuracy, efficiency, and transparency.
2.1 LLM-Guided Architecture Search
Instead of relying on reinforcement learning or evolutionary algorithms, the framework employs instruction-tuned LLMs (including Llama 3.1, Llama 3.2, and Qwen 2.5) as the primary search engine. The LLM explores a hierarchical search space across five stages, selecting between Depthwise Separable Convolution (DWSepConv) and Mobile Inverted Bottleneck (MBConv) blocks. Unlike random search, the LLM can "understand" constraints; for instance, if a model exceeds SRAM limits, the LLM strategically suggests reducing expansion factors or output channels in specific layers.
2.2 Pareto-Guided Feedback Loop
The search is iterative. Each candidate architecture undergoes a "mini-training" phase of 30 epochs. Performance metrics—including accuracy, Multiply-Accumulate operations (MACs), and parameter counts—are returned to the LLM. Using this data, the LLM refines its subsequent proposals to target the Pareto front, ensuring an optimal trade-off where one metric cannot be improved without degrading another.
2.3 Knowledge Distillation and Explainability
To further enhance performance, the discovered architectures undergo knowledge distillation (KD) using a pre-trained Vision Transformer (ViT-B/16) as a teacher. This allows the tiny convolutional student models to capture global contextual relationships, boosting accuracy by approximately 1.3% without increasing the model's physical size. Crucially, the LLM provides natural language justifications for its design choices—such as explaining that a specific stride was chosen to reduce computational cost in early blocks—thereby adding a layer of explainability (XAI) to the NAS process.
3. Experimental Results
The framework was evaluated on the CIFAR-100 dataset and profiled for the STM32H743 microcontroller.
3.1 Performance and Efficiency
The resulting models, LMaNet-Elite, LMaNet-Core, and QwNet-Core, set new standards for the STM32H7 platform. LMaNet-Elite achieved an accuracy of 74.50%, surpassing previous state-of-the-art models such as MCUNet (72.86%) and XiNet (72.27%). All proposed models successfully stayed under the 100 million MAC threshold.
3.2 Resource Constraints
A critical advantage of the LMaNet series is its memory efficiency. While models like MCUNet-in4 require 456KB of SRAM—exceeding the 320KB limit of many common microcontroller configurations—LMaNet-Elite requires only 165KB of peak SRAM. This ensures the model fits comfortably within the strict hardware constraints of the STM32H7.
3.3 Search Speed
The LLM-driven approach proved significantly faster than traditional methods. LMaNet models were discovered in approximately 1.5 days, representing a 4x to 8x speedup compared to the 12.5 days typically required by benchmarks like MCUNet.
4. Discussion and Conclusion
This research demonstrates that LLMs can effectively navigate complex architectural search spaces by reasoning over hardware constraints. Larger models, such as Llama 3.1-8B, showed superior optimization capabilities compared to smaller variants, suggesting that the "reasoning" capacity of the LLM is directly tied to the quality of the resulting TinyML model.
While the results on CIFAR-100 are compelling, future work will focus on scaling this framework to more complex datasets and a wider variety of hardware targets beyond the STM32H7. Additionally, while LLM-generated explanations provide a significant step forward for XAI, these justifications still require human oversight to ensure technical precision. In conclusion, LLM-guided design represents a promising shift toward more transparent, efficient, and accessible TinyML development.
Summary updated