Discover how model merging combines multiple pre-trained models into one. Learn how to fuse Ultralytics YOLO26 weights to boost performance without extra latency.
Model merging is an innovative technique in machine learning (ML) that combines the learned parameters (weights) of multiple pre-trained models into a single, unified model. Unlike traditional multi-model setups, merging directly fuses the model weights in parameter space. This allows practitioners to combine the specialized knowledge of several models fine-tuned on different tasks or datasets without incurring the memory and computational costs of running multiple models simultaneously.
By applying operations directly to the weights, model merging maintains the architectural footprint of a single network. This is particularly valuable when deploying advanced computer vision (CV) pipelines to edge devices, where reducing inference latency and saving memory are critical.
It is helpful to differentiate model merging from related concepts like Model Ensemble and Transfer Learning.
Researchers have developed several methods to effectively combine weights without destroying the underlying capabilities of the network, as explored in recent academic research on arXiv.
Model merging is highly effective for building generalized systems without retraining from scratch.
You can easily perform basic model merging using PyTorch. The following example demonstrates how to average the state dictionaries of two identically structured models.
import torch
# Load the weights (state dicts) from two identical architectures
weights_a = torch.load("yolo26_task1.pt")["model"].state_dict()
weights_b = torch.load("yolo26_task2.pt")["model"].state_dict()
# Perform simple weight averaging
merged_weights = {k: (weights_a[k] + weights_b[k]) / 2.0 for k in weights_a.keys()}
# Save the newly merged model weights
torch.save({"model": merged_weights}, "yolo26_merged.pt")
For teams looking to simplify the complex workflows of dataset annotation, training, and deployment, the Ultralytics Platform provides an intuitive interface to manage end-to-end vision AI projects effortlessly.
Begin your journey with the future of machine learning