How do you create a mergable library?

Asked on 09/04/2024

1 search

To create a mergable library using Core ML models, you can utilize the new support for multifunction models introduced by Apple. Here's a brief overview of the process:

  1. Convert Models: First, convert your models using ct convert and save them as individual ML packages.

  2. Create a Multifunction Descriptor: Specify which models to merge and define the new function name in the merged model.

  3. Merge Models: Use the save multifunctionutil to produce a merged multifunction Core ML model. During this process, Core ML tools will deduplicate shared weights by calculating the hash values of weights.

  4. Load and Use the Model: When loading the multifunction model via the Core ML tools Python API, specify the function name to load the specific function and perform predictions as usual.

This approach allows you to merge models with a shared feature extractor, optimizing the use of resources and improving performance. For more detailed information, you can refer to the session Bring your machine learning and AI models to Apple silicon (26:31).