Professional Machine Learning Engineer
Supervised tuning requires structured datasets with prompt-response pairs that teach the model how to handle your specific task. In BigQuery ML, you store these pairs in standard tables where one column holds the input prompts and another column holds the expected outputs. The supported Gemini models for supervised tuning include gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash-001, gemini-2.0-flash-lite-001, gemini-2.5-pro, and gemini-2.5-flash-lite. When working with images, audio, or video alongside text, you store the media files in Cloud Storage and reference them in BigQuery through object tables, which act as pointers to the external files.
Data preparation cleans raw records and formats them into consistent examples that the model can learn from. BigQuery provides built-in tools and visual pipelines that recommend ways to clean data, split arrays, and standardize schemas. When you don't have enough real examples, you can use BigQuery DataFrames combined with Gemini models to generate synthetic training data, which increases the variety of prompts the model sees during training. For fastest processing during training jobs, store preprocessed datasets as materialized tables rather than views or dynamic queries, because materialized tables are pre-computed and ready to read.
Data validation catches problems before they reach the training process and corrupt your model. BigQuery ML provides functions like ML.DESCRIBE_DATA and ML.TFDV_DESCRIBE that compute statistics and check whether your data matches the expected schema. You can use ML.VALIDATE_DATA_SKEW to detect when your serving data differs from your training data, and ML.VALIDATE_DATA_DRIFT to spot gradual changes in data patterns over time. Automated quality scans enforce rules across all training records to ensure labels are accurate, relevant, and safe.
Fine-tuning requires establishing a secure connection between BigQuery and Vertex AI, which involves specific Identity and Access Management (IAM) roles. The user needs BigQuery Data Editor (roles/bigquery.dataEditor) to manage dataset tables and BigQuery Connections Admin (roles/bigquery.connectionsAdmin) to create the connection resource. A Project IAM Admin (roles/resourcemanager.projectIamAdmin) must then grant the connection's service account access to the Vertex AI endpoint with the roles/aiplatform.user role. Once these permissions are in place and the user has BigQuery Job User (roles/bigquery.jobUser), the CREATE MODEL statement can transfer training parameters across the project boundary to execute fine-tuning.
A remote model in BigQuery ML is a model object that points to a Gemini foundation model running in Vertex AI rather than storing model parameters directly in BigQuery. You create this remote model using the CREATE MODEL statement, which specifies the BigQuery connection, the target Gemini endpoint, and the fine-tuning options. The connection uses a service account that must have roles/aiplatform.user permission in the project hosting the Vertex AI endpoint. You can specify the endpoint either as a full resource URL for a specific regional deployment or simply as a model name like gemini-2.5-flash, which uses the global endpoint for better availability.
The fine-tuning configuration lives in the CREATE MODEL statement's OPTIONS clause, where you define how the model learns from your data. The key parameter is MAX_ITERATIONS, which sets the number of training steps; BigQuery ML converts this into epochs based on your dataset size, where one epoch means seeing each training example once. By default, MAX_ITERATIONS equals your row count, giving you one epoch, and you increase it to train for multiple epochs. You also set DATA_SPLIT_METHOD (options include AUTO_SPLIT, RANDOM, CUSTOM, or NO_SPLIT) to determine how BigQuery divides your data between training and evaluation sets, and optionally DATA_SPLIT_EVAL_FRACTION to specify what portion goes to evaluation.
When you run the CREATE MODEL statement, BigQuery ML submits the fine-tuning job to the Gemini Enterprise Agent Platform, which manages all the compute resources automatically. The job consumes quota for "Global concurrent tuning jobs," and the platform scales resources based on your dataset size and parameters. You monitor job progress and view metrics through BigQuery ML system tables rather than the Vertex AI console. Upon completion, the tuned model appears in the Agent Platform Model Registry and becomes accessible via its model resource name for predictions directly from BigQuery.
A remote model serves as the bridge between BigQuery and Vertex AI, letting you invoke Gemini models using standard SQL functions while the actual model runs in Vertex AI. To create a remote model for supervised tuning, you use the CREATE MODEL statement with the REMOTE model type, pointing to a supported Gemini endpoint. The supported models include gemini-2.5-pro, gemini-2.5-flash-lite, gemini-2.0-flash-001, and gemini-2.0-flash-lite-001. During creation, you configure tuning settings that control how the model adapts to your data, such as the number of epochs and learning rate, while Vertex AI handles the computational infrastructure.
After fine-tuning, you assess model quality using the ML.EVALUATE function in BigQuery ML, which returns metrics measuring how well the model generates outputs. The evaluation function works with both pre-trained and fine-tuned Gemini models, providing metrics that indicate response quality, relevance, and alignment with expected outputs. You compare these metrics against your baselineāthe original foundation model without fine-tuningāto determine whether the tuning improved performance for your specific task. If performance is insufficient, you iterate by adjusting training data or hyperparameters and re-evaluating. Evaluation results are stored in BigQuery, creating a history you can track over time.
Once validated, you can deploy fine-tuned models for inference through either BigQuery ML or Vertex AI endpoints depending on your use case. For batch inference on data already in BigQuery, you use ML.GENERATE_TEXT to pass prompts to the model and receive generated text in response, processing large volumes without moving data outside BigQuery. For real-time applications requiring low latency, you deploy to a Vertex AI endpoint, which provides autoscaling and managed serving infrastructure. Fine-tuned models automatically register in the Vertex AI Model Registry, where you manage versions, track lineage, and assign models to endpoints using aliases for controlled releases.
The fine-tuning workflow requires specific IAM roles at each step to ensure proper access control. You need BigQuery Data Editor (roles/bigquery.dataEditor) to create datasets, tables, and models, and BigQuery Connections Admin (roles/bigquery.connectionsAdmin) to create the connection that links BigQuery to Vertex AI. Granting the connection's service account access to Vertex AI requires Project IAM Admin (roles/resourcemanager.projectIamAdmin) on the project containing the endpoint. BigQuery Job User (roles/bigquery.jobUser) allows you to create and run jobs. If no default connection exists, you need BigQuery Admin (roles/bigquery.admin) to create one as part of the CREATE MODEL statement.
Fine-tuned models integrate with the Gemini Enterprise Agent Platform, which provides additional lifecycle management tools. After tuning, models appear in the Vertex AI Model Registry under Managed tuning, where you can view status, access details, and deploy for inference. The Model Registry tracks versions and supports aliases for deployment strategies like canary releases, where you gradually shift traffic to the new model. The platform offers security features including VPC peering for network isolation, VPC Service Controls to prevent data exfiltration, customer-managed encryption keys, and IAM for fine-grained access, ensuring your models meet organizational compliance requirements.
CREATE MODEL statement configures fine-tuning parameters including MAX_ITERATIONS (converted to epochs) and DATA_SPLIT_METHOD for dividing training and evaluation data.ML.EVALUATE to compare fine-tuned model metrics against the baseline foundation model before deployment.ML.GENERATE_TEXT for batch inference within BigQuery or Vertex AI endpoints for real-time serving with autoscaling.Use BigQuery ML inference when your data already lives in BigQuery and you want to process large batches using SQL queries without moving data. Use Vertex AI endpoints when you need real-time, low-latency responses with autoscaling for production applications.
The default MAX_ITERATIONS equals the number of rows in your training data, which represents one epoch where the model sees each example once. To train for multiple epochs, set MAX_ITERATIONS to a multiple of your row count; if it's not an exact multiple, BigQuery rounds up to the nearest epoch.
Prepare and test your skills
Prepare and test your skills