NeMo: A Neuron-Level Modularizing-While-Training Approach for Decomposing DNN Models

Xiaohan Bi, Binhang Qi, Hailong Sun, Xiang Gao, Yue Yu, Xiaojun Liang · DOI

Abstract

Modern Deep Neural Networks (DNNs) are often over-parameterized for specific sub-tasks, leading to significant inefficiencies when large models are reused for simpler applications. This paper introduces NeMo, a novel framework that decomposes DNNs into specialized, reusable modules during the training process. By operating at the neuron level, NeMo achieves architecture-agnostic modularization, allowing for the creation of lightweight sub-models. Experimental results demonstrate that NeMo reduces module size by over 58% and inference costs (FLOPs) by up to 82% while maintaining or improving classification accuracy across diverse domains including computer vision and natural language processing.

Introduction

The development of state-of-the-art DNNs is computationally expensive, prompting a trend where developers reuse pre-trained models for downstream tasks. However, this "one-size-fits-all" approach is inherently inefficient. For instance, employing a 100-class classifier to distinguish between only two classes results in unnecessary memory overhead and latency.

Modularization—the process of breaking a model into functional components—offers a solution. While previous "Modularizing-while-Training" (MwT) approaches attempted this, they were often restricted to specific architectures (like CNNs) or failed to scale effectively. NeMo addresses these limitations by shifting the focus from coarse-grained structures to individual neurons, providing a universal and scalable framework for model decomposition.

The NeMo Framework

NeMo introduces three primary innovations to enable efficient, architecture-agnostic modularization:

1. Neuron-Level Granularity

Previous modularization efforts focused on convolutional kernels, which limited their applicability to specific architectures. NeMo operates at the level of individual neurons. Since neurons are the fundamental units of almost all modern architectures—including Convolutional Neural Networks (CNNs), Transformers (ViT), and Fully Connected Neural Networks (FCNNs)—NeMo serves as a universal modularization tool. This fine-grained control is particularly crucial for Transformers, where modularizing at the "Attention Head" level is often too coarse for complex label sets.

2. Neuron Identifier and Masking

To determine which neurons are essential for specific tasks, NeMo attaches a small sub-network, the Neuron Identifier, to each layer during training. This identifier generates a class-specific "mask" for every input, dynamically identifying the subset of neurons required to process that specific class. This allows the model to learn functional boundaries in real-time.

3. Contrastive Modular Training

NeMo utilizes a composite loss function rooted in Contrastive Learning to optimize the modular structure. The training objective focuses on two key metrics:

  • Cohesion: Ensuring that samples belonging to the same class consistently activate the same set of neurons.
  • Coupling: Minimizing the overlap between neurons used by different classes to ensure distinct functional specialization.

By employing a temperature-scaled exponential loss (similar to InfoNCE), NeMo effectively manages the optimization of thousands of neurons, a task where simpler additive losses typically fail.

4. Structured Decomposing and On-demand Padding

Once training is complete, irrelevant neurons are physically pruned to create specialized modules. To address the "dimension mismatch" that occurs in residual connections after pruning, NeMo introduces On-demand Padding. This technique ensures architectural integrity without the computational burden of adding dummy kernels or maintaining the original model's full width.

Experimental Evaluation

The authors evaluated NeMo across a wide range of tasks and architectures to prove its versatility:

  • Image Classification: Tested on CIFAR-10, SVHN, and FashionMNIST.
  • Object Detection: Evaluated using the RSOD remote sensing dataset.
  • Natural Language & Code: Applied to CodeSearchNet (covering six programming languages) and BigCloneBench (Java code clone detection).

Key Results

  • Accuracy Improvements: NeMo outperformed existing state-of-the-art MwT methods by an average of 1.72% in module classification accuracy. In several cases, specialized modules performed better than the original monolithic model because they were optimized for specific features without interference from irrelevant data.
  • Efficiency Gains: The framework achieved a 58.10% reduction in module size (Neuron Retention Rate). In practical deployment scenarios, this translated to an inference speedup of up to 82.99% in FLOPs for 2-class sub-tasks.
  • Cross-Domain Versatility: In a case study involving CodeBERT, NeMo successfully extracted a Java-specific module that retained only 43.58% of the original neurons while maintaining a high accuracy of 96.55%.

Discussion and Limitations

While NeMo represents a significant step forward, it introduces certain trade-offs. The integration of the Neuron Identifier increases training time by approximately 30% to 70%. However, the authors posit that this is a justifiable one-time cost for models intended for widespread reuse.

Furthermore, scaling to extremely large label sets (e.g., ImageNet with 1000 classes) remains a challenge, as the finite number of neurons in a model can become a bottleneck when attempting to assign unique, non-overlapping sets to every class. Future research will also need to explore how neuron-level modularization can be applied to autoregressive generative models, such as Large Language Models (LLMs), where complex token interdependencies make functional decomposition more difficult.

Conclusion

NeMo demonstrates that modularity is most effective when integrated directly into the training process at a granular level. By treating neurons as the primary unit of specialization and leveraging contrastive learning, NeMo provides a path toward more efficient, reusable, and specialized AI systems that do not sacrifice performance for compactness.

Summary updated

BibTeX
@article{bi2026nemo,
  author = {Xiaohan Bi and Binhang Qi and Hailong Sun and Xiang Gao and Yue Yu and Xiaojun Liang},
  title = {{NeMo: A Neuron-Level Modularizing-While-Training Approach for Decomposing DNN Models}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2026},
  doi = {10.1145/3757740},
}
Figure