Minimizing Overhead for BigQuery Batch Predictions with TensorFlow Models

PMLE By islever Editorial Last updated

Serving models. Building models given the task considering cost, complexity, latency, and scalability.

Short answer

A Export the model to BigQuery ML to run predictions natively on the data without moving it to Cloud Storage.

Question

You have trained a text classification model in TensorFlow using AI Platform. You want to use the trained model for batch predictions on text data stored in BigQuery while minimizing computational overhead.
What should you do?
  1. Export the model to BigQuery ML. Correct Answer
  2. Deploy and version the model on AI Platform.
  3. Use Dataflow with the SavedModel to read the data from BigQuery.
  4. Submit a batch prediction job on AI Platform that points to the model location in Cloud Storage.

Key Takeaways

The trap is choosing AI Platform batch prediction (D), which requires exporting data from BigQuery to Cloud Storage, adding unnecessary overhead compared to native BigQuery ML inference.

To minimize computational overhead for batch predictions on BigQuery data, export your TensorFlow model to BigQuery ML. This allows direct SQL-based inference without data export to Cloud Storage.

Common mistake: Candidates often select Option D because AI Platform supports batch predictions. However, they fail to realize that AI Platform requires input data in Cloud Storage, necessitating a costly and time-consuming export from BigQuery, whereas BigQuery ML processes data in place.

Expert Analysis

Identify the Core Constraint: Minimizing Computational Overhead The question explicitly asks to minimize computational overhead when performing batch predictions on text data stored in BigQuery. This constraint is critical for eliminating options that require data movement or external service orchestration.

Analyze Option D (AI Platform Batch Prediction) Submitting a batch prediction job on AI Platform (now Vertex AI) requires the input data to be in Cloud Storage (CSV, JSONL, etc.). Since the source data is in BigQuery, you would first need to export the BigQuery table to Cloud Storage. This extra step of exporting data adds latency and cost, violating the "minimize overhead" requirement. Comments supporting this option often overlook the data format incompatibility between BigQuery tables and AI Platform's expected input formats.

Analyze Option A (Export/Import to BigQuery ML) BigQuery ML allows you to import pre-trained TensorFlow models directly into BigQuery. Once imported, you can run ML.PREDICT using standard SQL against the existing BigQuery table. The key advantage here is that the data never leaves BigQuery. There is no need to export data to Cloud Storage, nor is there a need to spin up separate compute instances for inference beyond the managed BigQuery SQL execution engine. This approach significantly reduces data transfer overhead and simplifies the pipeline.

Eliminate Other Options

  • Option B involves deploying a model as an online endpoint, which is designed for real-time, low-latency requests, not batch processing. It incurs continuous hosting costs and is architecturally mismatched for batch jobs.
  • Option C suggests using Dataflow with a SavedModel. While possible, this requires building and maintaining a custom ETL/inference pipeline, managing resources, and handling code complexity. This is far more computationally and operationally intensive than the native BigQuery ML integration.

Conclusion Option A is the correct answer because it leverages BigQuery's native capabilities to perform inference on data already within the warehouse, avoiding data egress to Cloud Storage and eliminating the need for external processing services.

Official Reference

Exam Strategy

When questions emphasize 'minimizing overhead' or 'keeping data in place', prioritize managed services that operate natively on the data source. For BigQuery data, always check if BigQuery ML can handle the task before considering external pipelines like Dataflow or AI Platform, which typically require data movement.

Frequently Asked Questions

Why is Option D incorrect for minimizing overhead?

Option D requires input data to be in Cloud Storage. Since the data is in BigQuery, you must export it first, adding latency and storage costs. BigQuery ML avoids this by processing data in situ.

Can I use Dataflow for batch predictions on BigQuery data?

Yes, but it is not the most efficient method for minimizing overhead. It requires building a custom pipeline, managing resources, and transferring data, making it more complex than BigQuery ML.

More PMLE FAQ →

Community Votes

A
80%
D
20%

80% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 50 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 30 of 50

  1. maartenalexander 👍 22
    A. You would want to minimize computational overhead–BigQuery minimizes such overhead
  2. chohan 👍 11
    I think it's A https://cloud.google.com/bigquery-ml/docs/making-predictions-with-imported-tensorflow-models#importing_models
  3. ms_lemon 👍 11
    you can import a TF model in BQ ML
  4. gcp2021go 👍 6
    agree. https://cloud.google.com/bigquery-ml/docs/making-predictions-with-imported-tensorflow-models
  5. NamitSehgal 👍 3 Answered A
    CREATE OR REPLACE MODEL example_dataset.imported_tf_model OPTIONS (MODEL_TYPE='TENSORFLOW', MODEL_PATH='gs://cloud-training-demos/txtclass/export/exporter/1549825580/*')
Show 25 more comments
  1. harithacML 👍 3
    No need . This is a text classification problem. need to convert words to numbers and use a classifier.
  2. q4exam 👍 3
    BQML doesnt support NLP model
  3. Darshan12 👍 2
    There are some drawbacks to option D. Cost: Submitting a batch prediction job on AI Platform is a paid service. The cost will depend on the size of the model and the amount of data that you are predicting. Complexity: Submitting a batch prediction job on AI Platform requires you to write some code. This can be a challenge if you are not familiar with AI Platform. Performance: Submitting a batch prediction job on AI Platform may not be as efficient as using BigQuery ML. This is because AI Platform needs to load the model into memory before it can run the predictions. Overall, option D is a viable option, but it may not be the best option for all situations.
  4. John_Pongthorn 👍 2 Answered D
    A is the correct in case you have ml model from local development, it is answer based on obsolete technology but I insist on D , it is best choice . Given that you have trained model on VertextAI ,why you waste your time importing it to BigQueryML? Vertext-AI accommodates all things to make batch predictions. https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/get-batch-predictions
  5. shankalman717 👍 2 Answered D
    You can use AI Platform Prediction to deploy and version the model, but this is not necessary for batch predictions. Instead, you can simply upload the trained model to a Cloud Storage bucket and then point the batch prediction job to that location. This will allow you to perform predictions on large volumes of data while minimizing computational overhead.
  6. kaike_reis 👍 2
    A is the correct. The required job would be to save your TF model into GS. D is not correct. Yes, AI Platform has a batch prediction job, but you need to have input files into GS, so you would have to move your BQ table to a csv file for example, which is impractical.
  7. OpenKnowledge 👍 2 Answered A
    IT is possible to import and use TensorFlow models within BigQuery ML. This allows to leverage BigQuery ML's inference capabilities and co-location with your data for predictions using custom TensorFlow models.
  8. harithacML 👍 2 Answered A
    Model : AI Platform. pred batch data : BigQuery constraint : computational overhead Same platform as data == less computation required to load and pass it to model
  9. tavva_prudhvi 👍 2
    This is an option that can be used to minimize computational overhead, but it is more complex to set up and requires you to have Dataflow installed.
  10. gcp2021go 👍 2
    I think a good mental model is - when you can solve problem with BQML, stay with BQML.
  11. Jason_Cloud_at 👍 2
    in the option D, it just mentioned GCS , BQ is no where to be found
  12. rexduo 👍 2 Answered A
    I think D have extra compute on extrating data frm BQ
  13. q4exam 👍 2
    There is a batch prediction API on AI platform....
  14. Aastha_Vashist 👍 2 Answered A
    Bquery to minimize computational overhead
  15. Liting 👍 2 Answered A
    minimize computational overhead–>BigQuery
  16. JobQ 👍 2
    You can call TF models from BQML, so A.
  17. Sum_Sum 👍 2 Answered A
    A - you can import TF models to BQ
  18. bc3f222 👍 2 Answered A
    BQML can rum imported TF models
  19. salsabilsf 👍 2
    Should be D
  20. Fatiy 👍 1 Answered D
    To perform batch predictions on text data stored in BigQuery using a trained TensorFlow model, you can submit a batch prediction job on AI Platform. The batch prediction job reads the input data from BigQuery and the model from Cloud Storage. This approach minimizes computational overhead since the job is handled by AI Platform, and it allows you to easily scale up or down depending on the size of the data.
  21. taylz876 👍 1 Answered A
    A- The text data already lives in BigQuery, and you want batch predictions with the least computational overhead. BigQuery ML can import a TensorFlow SavedModel, and then you run ML.PREDICT with plain SQL. The data never leaves BigQuery, and there's no extra service, endpoint or pipeline to set up. The option says "export", but it means moving the model into BigQuery ML.
  22. desertlotus1211 👍 1 Answered D
    A is incorrect: BigQuery ML is used to train and deploy models directly within BigQuery, but it does not support importing and deploying external TensorFlow models. You cannot export a TensorFlow model directly to BigQuery ML; AI Platform is the correct service for TensorFlow-based models.
  23. tavva_prudhvi 👍 1
    In this document(https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/get-batch-predictions), it mentions "For classification or regression models, you can provide input data in one of two formats: BigQuery tables, CSV objects in Cloud Storage. Now, is it A/D?
  24. tavva_prudhvi 👍 1
    In this document(https://cloud.google.com/vertex-ai/docs/tabular-data/classification-regression/get-batch-predictions), it mentions "For classification or regression models, you can provide input data in one of two formats: BigQuery tables, CSV objects in Cloud Storage.
  25. AmitK121981 👍 1 Answered A
    It has to be A as using Proc we can do it once or schedule it. Not D because it mentions GCS , but the data wud also needed to be taken from BQ to GCS as batch inference needs a JSONL file with details of batch data. lot of extra things to do

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide