Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 45 ยท AI on Google Cloud

Pre-trained AI APIs and Machine Learning Workflows

Compare pre-trained Google Cloud AI APIs (Vision, Speech, Translation, Natural Language) with AutoML, custom training and BigQuery ML, plus a scikit-learn stand-in.

You do not always need to train a model. Google Cloud offers ready-made APIs that recognize objects in photos, turn speech into text, translate languages and analyze text, and each one is a single request away. When those do not fit your data, you can step up to AutoML, to training your own model, or even to training with plain SQL inside BigQuery.

The skill is choosing the lowest level that solves the problem. This lesson walks through the options from easiest to most flexible, then lets you train a tiny classifier in your browser so you can see what "training" and "prediction" actually mean. The Google services themselves need a billed project, so their code is read-only.

The ladder of options

Pick the lowest rung that works

Pre-trained APIs No training. Send data, get answers.
BigQuery ML Train and predict with SQL.
AutoML style Bring labeled data, let the platform choose.
Custom training Your code, your framework, full control.

Each step down needs more data, skill and money.

1 / 2

Pre-trained APIs

These services are already trained by Google on very large data sets. You send an input and get a structured result:

  • Vision API: labels, text in images (OCR), faces, landmarks and explicit-content detection.
  • Speech-to-Text and Text-to-Speech: transcribe audio and generate spoken audio.
  • Translation: translate text between many languages.
  • Natural Language API: sentiment, entities (people, places, organizations) and syntax.
  • Document AI: extract fields from invoices, forms and other documents.

A Vision request in Python (read-only; it needs the client library, credentials and a billed project):

Python
from google.cloud import vision

client = vision.ImageAnnotatorClient()
image = vision.Image(source=vision.ImageSource(
    image_uri="gs://my-bucket/photos/cat.jpg"
))

response = client.label_detection(image=image)
for label in response.label_annotations:
    print(label.description, round(label.score, 2))

The result is a list of labels with confidence scores between 0 and 1. The image can live in Cloud Storage, which keeps large files out of the request. Features, names and limits change, so check the current documentation, and note that these APIs are billed per unit (per image, per minute of audio or per character).

Always check the score. A label with 0.55 confidence is a guess, so choose a threshold that fits your use case and send low-confidence cases to a person.

When pre-trained is not enough

Pre-trained APIs know general things. They do not know your categories: which of your products is damaged, which support tickets are urgent, which customers will cancel. For that you need a model trained on your own labeled examples. Two common paths:

  • AutoML-style training (offered in Vertex AI for tabular, image, text and video data): you supply labeled data and the platform searches for a good model for you. Less code, less control, and you pay for training time. Check the current Vertex AI product list for which data types are available.
  • Custom training: you write training code in a framework such as scikit-learn, TensorFlow, PyTorch or XGBoost, package it in a container, and run it as a managed job on CPUs or GPUs. The trained model is then registered and deployed to an endpoint for online predictions, or used for batch prediction over a large file or table.

Custom training is the most flexible and also the most work, so use it only when the simpler options cannot reach the quality you need.

BigQuery ML

If your data already sits in BigQuery, you can create and use models with SQL, without moving the data. A sketch (read-only; the dataset, table and column names are invented):

SQL
CREATE OR REPLACE MODEL shop.churn_model
OPTIONS (model_type = 'LOGISTIC_REG', input_label_cols = ['churned']) AS
SELECT tenure_months, orders_last_90d, support_tickets, churned
FROM shop.customers;

SELECT *
FROM ML.PREDICT(MODEL shop.churn_model,
  (SELECT tenure_months, orders_last_90d, support_tickets
   FROM shop.new_customers));

CREATE MODEL trains, ML.EVALUATE reports quality, and ML.PREDICT scores new rows. This is excellent for analysts who know SQL, and for tabular problems such as classification, regression, forecasting and clustering. Training scans data, so the cost-control habits from the BigQuery lessons still apply.

The workflow behind any model

Whatever the tool, machine learning follows the same loop:

  1. Define the question and a success measure (for example "flag urgent tickets with at least 90% recall").
  2. Collect and label data, then split it into a training set and a test set that the model never sees during training.
  3. Train a model on the training set.
  4. Evaluate it on the test set, comparing with a simple baseline.
  5. Deploy it behind an endpoint or batch job.
  6. Monitor for drift: real-world data changes, and quality slowly falls.

Stand-in: train a tiny classifier

This runs in real Python (Pyodide, with scikit-learn) on your device. It is not a Google Cloud service. It trains a small decision tree on toy data about support tickets, then evaluates it on held-out rows. The point is the workflow: split, train, evaluate, predict.

Python Stand-in: train, test and predict

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A model that does not beat the baseline has learned nothing useful. Always compare with a simple baseline before celebrating a number.

Stand-in: apply a confidence threshold

Pre-trained APIs return scores. This second stand-in shows a routing rule on made-up results shaped like a label-detection response, so you can see how a threshold splits automatic decisions from human review.

Python Stand-in: route by confidence score

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Responsible choices

  • Check each API's pricing and limits before sending large batches.
  • Be careful with personal data (faces, voices, documents). Know where it is processed and stored, and whether you are allowed to send it.
  • Test on data that looks like your users, since quality varies across languages, accents and image types.
  • For text generation, summarization and chat, use Gemini on Vertex AI instead of the older task-specific APIs when it fits.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which option needs no training data from you?

    Pre-trained APIs are already trained. You only send input and read the result.
  2. 2. Why split data into training and test sets?

    Evaluating on training data hides overfitting. A held-out test set gives an honest estimate.
  3. 3. What does ML.PREDICT in BigQuery ML do?

    CREATE MODEL trains. ML.PREDICT applies the trained model to new input rows.
  4. 4. A Vision API label comes back with a score of 0.52. What is sensible?

    Scores express confidence. Choose thresholds that fit the cost of a wrong answer.

Summary

  • Start with pre-trained APIs (Vision, Speech, Translation, Natural Language, Document AI) before training anything.
  • Use BigQuery ML when your tabular data is already in BigQuery and your team knows SQL.
  • AutoML-style tools trade control for convenience; custom training gives full control at a higher effort.
  • Every ML project follows define, split, train, evaluate, deploy and monitor, and a model must beat a simple baseline.
  • Use confidence scores and thresholds, and keep humans in the loop for uncertain results.

Next: Cost Management and Optimization