All ML Kit features make use of Google-trained machine learning models (known as
base models) by default. This guide is only applicable to base models. [See here
for guidance on custom models.](https://developers.google.com/ml-kit/custom-models)

Models in ML Kit APIs can be installed in one of three ways:

1. **Unbundled:** Models are downloaded and managed via Google Play Services.
2. **Bundled:** Models are statically linked to your app at build time.
3. **Dynamically downloaded:** Models are downloaded on demand.

## Supported installation paths for each API

The table below shows which model installation paths are supported by each ML
Kit feature:

|---|---|---|---|
|   | **Unbundled** | **Bundled** | **Dynamically downloaded** |
| [Text recognition v2](https://developers.google.com/ml-kit/vision/text-recognition/v2/android.md.txt) | ✅ | ✅ |   |
| [Face detection](https://developers.google.com/ml-kit/vision/face-detection/android.md.txt) | ✅ | ✅ |   |
| [Face mesh detection](https://developers.google.com/ml-kit/vision/face-mesh-detection/android.md.txt) |   | ✅ |   |
| [Pose detection](https://developers.google.com/ml-kit/vision/pose-detection/android.md.txt) |   | ✅ |   |
| [Selfie segmentation](https://developers.google.com/ml-kit/vision/selfie-segmentation/android.md.txt) |   | ✅ |   |
| [Barcode scanning](https://developers.google.com/ml-kit/vision/barcode-scanning/android.md.txt) | ✅ | ✅ |   |
| [Image labeling](https://developers.google.com/ml-kit/vision/image-labeling/android.md.txt) | ✅ | ✅ |   |
| [Object detection and tracking](https://developers.google.com/ml-kit/vision/object-detection/android.md.txt) |   | ✅ |   |
| [Digital ink recognition](https://developers.google.com/ml-kit/vision/digital-ink-recognition/android.md.txt) |   |   | ✅ |
| [Document scanner](https://developers.google.com/ml-kit/vision/doc-scanner.md.txt) | ✅ |   |   |
| [Subject segmentation](https://developers.google.com/ml-kit/vision/subject-segmentation/android.md.txt) | ✅ |   |   |
| [Google code scanner](https://developers.google.com/ml-kit/code-scanner) | ✅ |   |   |
| [Language identification](https://developers.google.com/ml-kit/language/identification/android.md.txt) | ✅ | ✅ |   |
| [Translation](https://developers.google.com/ml-kit/language/translation/android.md.txt) |   |   | ✅ |
| [Smart Reply](https://developers.google.com/ml-kit/language/smart-reply/android.md.txt) | ✅ | ✅ |   |
| [Entity Extraction](https://developers.google.com/ml-kit/language/entity-extraction/android.md.txt) |   |   | ✅ |

API-specific guides show which installation options are available for the given
API.

## Key differences between installation options

|---|---|---|---|
|   | **Unbundled** | **Bundled** | **Dynamically downloaded** |
| **Where are models stored?** | Resides in Google Play Services and is not counted towards the storage used by this app | Saved in [app-specific storage](https://developer.android.com/training/data-storage/app-specific) after installation | Saved in [app-specific storage](https://developer.android.com/training/data-storage/app-specific) after model download |
| **How does model size affect app size?** | Does not contribute to app size | Directly contributes to app size | Does not contribute to app size but increase the [app-specific storage](https://developer.android.com/training/data-storage/app-specific) |
| **When are models updated?** | Automatically updated when a newer version is released | [Need to update the app to update model](https://developers.google.com/ml-kit/tips/installation-paths.md.txt#update-model) | [Need to update the app to update model](https://developers.google.com/ml-kit/tips/installation-paths.md.txt#update-model) |
| **When are models downloaded?** | [Models must be downloaded before use](https://developers.google.com/ml-kit/tips/installation-paths.md.txt#download-models) | All models and features are included when the app is installed, so are usable immediately | Model downloads, updates, and deletions must be managed manually using the [RemoteModelManager](https://developers.google.com/android/reference/com/google/mlkit/common/model/RemoteModelManager.md.txt) API |
| **When are models removed from the device?** | Google Play Services will only remove the model from storage if all apps that depend on the model are uninstalled | Models are removed from [app-specific storage](https://developer.android.com/training/data-storage/app-specific) when the app is uninstalled | Downloaded models are removed from [app-specific storage](https://developer.android.com/training/data-storage/app-specific) when the app is uninstalled |

## How to choose between bundled and unbundled

If an API supports both the bundled and unbundled installation options:

- Use the bundled option if you prioritize:

  - Complete feature functionality immediately after app installation
  - Feature functionality without network connection after app installation
- Use the unbundled option if you prioritize:

  - Smaller app size
  - Automated model updates by Google Play Services

## How to download models

When using the unbundled model option, you can specify how you want models to be
downloaded to the device:

- You can enable **install-time model downloads** by adding a declaration to
  your app's `AndroidManifest.xml` file. For example, the code snippet below
  shows how to configure your app to automatically download the Barcode
  Scanning model after your app is installed from the Play Store:

      <application ...>
            ...
            <meta-data
                android:name="com.google.mlkit.vision.DEPENDENCIES"
                android:value="barcode" >
            <!-- To use multiple models: android:value="barcode,model2,model3" -->
      </application>

- You can **request explicit download** through Google Play Services
  [ModuleInstallClient API](https://developers.google.com/android/guides/module-install-apis.md.txt).

- If you don't enable install-time model downloads or request explicit
  download, the model will be downloaded the first time you run the feature.
  Until the download is completed, inference requests will fail.

## How to update models

To update your models when using the bundled model or the dynamically downloaded
models option:

1. Update your app's gradle file to use the latest ML Kit feature client
   library.

       dependencies {
         implementation 'com.google.mlkit:barcode-scanning: 17.3.0' // The latest version number of the API
       }

2. Rebuild your app.

## Why some APIs offer dynamically downloaded models

Some ML Kit API have too many model options to bundle. For example, [Digital ink
recognition](https://developers.google.com/ml-kit/vision/digital-ink-recognition) supports [300+
languages](https://developers.google.com/ml-kit/vision/digital-ink-recognition/base-models), and it's not
always necessary to put every language inside the feature during installation.
For that purpose, we provide the third installation option, in which models are
downloaded on demand after installation. Currently, only [Digital ink
recognition](https://developers.google.com/ml-kit/vision/digital-ink-recognition),
[Translation](https://developers.google.com/ml-kit/language/translation.md.txt) and [Entity
extraction](https://developers.google.com/ml-kit/language/entity-extraction) have this option.