Stay organized with collections Save and categorize content based on your preferences.
The CREATE MODEL statement for importing TensorFlow Lite modelsThis document describes the CREATE MODEL
statement for importing TensorFlow Lite models into BigQuery by using SQL. Alternatively, you can use the Google Cloud console user interface to create a model by using a UI (Preview) instead of constructing the SQL statement yourself.
For information about the supported SQL statements and functions for each model type, see End-to-end user journey for each model.
CREATE MODEL
syntax
{CREATE MODEL | CREATE MODEL IF NOT EXISTS | CREATE OR REPLACE MODEL} model_name OPTIONS(MODEL_TYPE = 'TENSORFLOW_LITE', MODEL_PATH = string_value [, KMS_KEY_NAME = string_value ] );
CREATE MODEL
Creates and trains a new model in the specified dataset. If the model name exists, CREATE MODEL
returns an error.
CREATE MODEL IF NOT EXISTS
Creates and trains a new model only if the model doesn't exist in the specified dataset.
CREATE OR REPLACE MODEL
Creates and trains a model and replaces an existing model with the same name in the specified dataset.
model_name
The name of the model you're creating or replacing. The model name must be unique in the dataset: no other model or table can have the same name. The model name must follow the same naming rules as a BigQuery table. A model name can:
model_name
is not case-sensitive.
If you don't have a default project configured, then you must prepend the project ID to the model name in the following format, including backticks:
`[PROJECT_ID].[DATASET].[MODEL]`
For example, `myproject.mydataset.mymodel`.
MODEL_TYPE
Syntax
MODEL_TYPE = 'TENSORFLOW_LITE'
Description
Specifies the model type. This option is required.
MODEL_PATH
Syntax
MODEL_PATH = string_value
Description
Specifies the Cloud Storage URI of the TensorFlow Lite model to import. This option is required.
Arguments
A STRING
value specifying the URI of a Cloud Storage bucket that contains the model to import.
BigQuery ML imports the model from Cloud Storage by using the credentials of the user who runs the CREATE MODEL
statement.
Example
MODEL_PATH = 'gs://bucket/path/to/tflite_model/*'
KMS_KEY_NAME
Syntax
KMS_KEY_NAME = string_value
Description
The Cloud Key Management Service customer-managed encryption key (CMEK) to use to encrypt the model.
Arguments
A STRING
value containing the fully-qualified name of the CMEK. For example,
'projects/my_project/locations/my_location/keyRings/my_ring/cryptoKeys/my_key'
Supported data types for input and output columns
BigQuery ML converts some TensorFlow Lite model input and output columns to BigQuery ML types, and some TensorFlow Lite types aren't supported. Supported data types for input and output columns include the following:
TensorFlow Lite types Supported BigQuery typeUINT8, UINT16, UINT32, UINT64, INT8, INT16, INT32, INT64
Supported INT64
FLOAT16, FLOAT32, FLOAT64
Supported FLOAT64
COMPLEX64, COMPLEX128
Unsupported N/a BOOL
Supported BOOL
STRING
Supported STRING
RESOURCE
Unsupported N/a VARIANT
Unsupported N/a Locations
For information about supported locations, see Locations for non-remote models.
LimitationsImported TensorFlow Lite models have the following limitations:
.tflite
format.ML.PREDICT
function.The following example imports a TensorFlow Lite model into BigQuery as a BigQuery ML model. The example assumes that there is an existing TensorFlow Lite model located at gs://bucket/path/to/tflite_model/*
.
CREATE MODEL `project_id.mydataset.mymodel` OPTIONS(MODEL_TYPE='TENSORFLOW_LITE', MODEL_PATH="gs://bucket/path/to/tflite_model/*")
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[[["The `CREATE MODEL` statement imports TensorFlow Lite models into BigQuery, allowing for model creation, replacement, or creation only if a model of the same name doesn't exist."],["The `MODEL_TYPE` option must be set to `'TENSORFLOW_LITE'` and `MODEL_PATH` must specify a valid Cloud Storage URI containing the `.tflite` model to import."],["Imported TensorFlow Lite models have limitations, including requiring the models to be stored in Cloud Storage, be in `.tflite` format, use the `ML.PREDICT` function, and the model size must not exceed 450 MB."],["Only specific TensorFlow core and TensorFlow Text operations are supported for use, and only certain data types for input and output columns are compatible with BigQuery types."],["The `KMS_KEY_NAME` option can be used to specify a Cloud Key Management Service customer-managed encryption key (CMEK) for model encryption."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4