BigQuery ML 内置了对批量预测的支持,无需使用 Vertex AI。您还可以将 BigQuery ML 模型注册到 Model Registry,以便在 Vertex AI 中使用 BigQuery 表作为输入来执行批量预测。不过,您只能使用 Vertex AI API 并将 InstanceConfig.instanceType 设置为 object 才能执行此操作。
在线预测
BigQuery ML 的内置推理功能针对大规模应用场景(例如批量预测)进行了优化。虽然 BigQuery ML 在处理小型输入数据时提供了低延迟推理结果,但您可以通过与 Vertex AI 的无缝集成来实现更快的在线预测。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-09。"],[[["\u003cp\u003eBigQuery ML supports batch inference through batch prediction and online prediction, enabling the operationalization of machine learning models for various tasks.\u003c/p\u003e\n"],["\u003cp\u003eInference in BigQuery ML uses the \u003ccode\u003eML.PREDICT\u003c/code\u003e function and is not limited to supervised learning models, but also covers unsupervised learning models like K-means, PCA, and Autoencoders.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery ML allows the use of imported models, including ONNX, TensorFlow, TensorFlow Lite, and XGBoost, for inference, leveraging BigQuery's data and processing capabilities.\u003c/p\u003e\n"],["\u003cp\u003eRemote models hosted in Vertex AI can be referenced and used for inference through BigQuery ML, enabling access to GPU-accelerated processing and simplifying the integration of models hosted on Vertex AI with SQL-based inference.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery ML's built-in batch prediction is designed for large-scale use cases, while integration with Vertex AI facilitates faster online predictions and access to Vertex AI's MLOps capabilities.\u003c/p\u003e\n"]]],[],null,["# Model inference overview\n========================\n\nThis document describes the types of batch inference that BigQuery ML\nsupports, which include:\n\n- [Batch prediction](#prediction)\n- [Online prediction](#online_prediction)\n\nMachine learning inference is the process of running data points into\na machine learning model to calculate an output such as a single numerical\nscore. This process is also referred to as \"operationalizing a machine learning\nmodel\" or \"putting a machine learning model into production.\"\n\nBatch prediction\n----------------\n\nThe following sections describe the available ways of performing prediction in\nBigQuery ML.\n\n### Inference using BigQuery ML trained models\n\n*Prediction* in BigQuery ML is used not only for supervised learning models, but\nalso unsupervised learning models.\n\nBigQuery ML supports prediction functionalities through the\n[`ML.PREDICT` function](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict),\nwith the following models:\n\n### Inference using imported models\n\nWith this approach, you create and train a model outside of\nBigQuery, import it by using the\n[`CREATE MODEL` statement](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create),\nand then run inference on it by using the\n[`ML.PREDICT` function](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict).\nAll inference processing occurs in BigQuery, using data from\nBigQuery. Imported models can perform supervised or\nunsupervised learning.\n\nBigQuery ML supports the following\ntypes of imported models:\n\n- [Open Neural Network Exchange (ONNX)](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-onnx) for models trained in PyTorch, scikit-learn, and other popular ML frameworks.\n- [TensorFlow](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-tensorflow)\n- [TensorFlow Lite](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-tflite)\n- [XGBoost](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-xgboost)\n\nUse this approach to make use of custom models developed with a range\nof ML frameworks while taking advantage of BigQuery ML's\ninference speed and co-location with data.\n\nTo learn more, try one of the following tutorials:\n\n- [Make predictions with imported TensorFlow models](/bigquery/docs/making-predictions-with-imported-tensorflow-models)\n- [Make predictions with scikit-learn models in ONNX format](/bigquery/docs/making-predictions-with-sklearn-models-in-onnx-format)\n- [Make predictions with PyTorch models in ONNX format](/bigquery/docs/making-predictions-with-pytorch-models-in-onnx-format)\n\n### Inference using remote models\n\nWith this approach, you can create a reference to a model\nhosted in [Vertex AI Inference](/vertex-ai/docs/predictions/get-predictions)\nby using the\n[`CREATE MODEL` statement](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-remote-model),\nand then run inference on it by using the\n[`ML.PREDICT` function](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict).\nAll inference processing occurs in Vertex AI, using data from\nBigQuery. Remote models can perform supervised or\nunsupervised learning.\n\nUse this approach to run inference against large models that require the GPU\nhardware support provided by Vertex AI. If most of your\nmodels are hosted by Vertex AI, this also lets you run\ninference against these models by using SQL, without having to manually build\ndata pipelines to take data to Vertex AI and bring prediction\nresults back to BigQuery.\n\nFor step-by-step instructions, see\n[Make predictions with remote models on Vertex AI](/bigquery/docs/bigquery-ml-remote-model-tutorial).\n\n### Batch inference with BigQuery models in Vertex AI\n\nBigQuery ML has built-in support for batch prediction, without the\nneed to use Vertex AI. It is also possible to register a\nBigQuery ML model to Model Registry in order to\nperform batch prediction in Vertex AI using a\nBigQuery table as input. However, this can only\nbe done by using the Vertex AI API and setting\n[`InstanceConfig.instanceType`](/vertex-ai/docs/reference/rest/v1/projects.locations.batchPredictionJobs#instanceconfig)\nto `object`.\n\nOnline prediction\n-----------------\n\nThe built-in inference capability of BigQuery ML is optimized for\nlarge-scale use cases, such as batch prediction. While BigQuery ML\ndelivers low latency inference results when handling small input data, you can\nachieve faster online prediction through seamless integration with\n[Vertex AI](/bigquery/docs/managing-models-vertex).\n\nYou can [manage BigQuery ML models within the Vertex AI environment](/bigquery/docs/managing-models-vertex),\nwhich eliminates the need to export models from BigQuery ML before\ndeploying them as Vertex AI endpoints. By managing models within\nVertex AI, you get access to all of the Vertex AI MLOps\ncapabilities, and also to features such as\n[Vertex AI Feature Store](/vertex-ai/docs/featurestore/latest/overview).\n\nAdditionally, you have the flexibility to\n[export BigQuery ML models](/bigquery/docs/exporting-models) to\nCloud Storage for availability on other model hosting platforms.\n\nWhat's next\n-----------\n\n- For more information about using Vertex AI models to generate text and embeddings, see [Generative AI overview](/bigquery/docs/generative-ai-overview).\n- For more information about using Cloud AI APIs to perform AI tasks, see [AI application overview](/bigquery/docs/ai-application-overview).\n- For information about supported model types and SQL functions for each type of inference, see the [End-to-end user journey for each model](/bigquery/docs/e2e-journey)."]]