BigQuery AI and ML

BigQuery AI and ML

Teaches an agent to write BigQuery SQL that uses built-in AI and ML functions for forecasting, anomaly detection, semantic search, classification and more.

Skill files25 files

references/

SKILL.md67 lines
1
---
2
name: bigquery-ai-ml
3
metadata:
4
version: "1.1.3"
5
category: AiAndMachineLearning
6
publisher: google
7
description: >-
8
Leverages BigQuery's built-in machine learning and GenAI capabilities
9
for advanced data analytics. Use when you need to write SQL queries
10
that perform time-series forecasting, predict values, detect outliers or anomalies, find key drivers,
11
perform semantic search or vector search, classify text, calculate similarity,
12
summarize content, translate language, evaluate models, filter by semantic conditions,
13
measure the causal effect of an intervention, compute correlations between columns,
14
generate descriptive statistics and table distribution profiles,
15
detect change points or structural breaks, extract trend or seasonality components,
16
or leverage generative AI capabilities in BigQuery. Do not use for general
17
BigQuery dataset, table, or job management requests.
18
---
19
20
# BigQuery AI & ML
21
22
BigQuery integrates with Vertex AI to provide powerful machine learning and
23
generative AI capabilities directly within SQL queries using built-in functions
24
like `AI.FORECAST`, `AI.KEY_DRIVERS`, `AI.DETECT_ANOMALIES`, and `AI.GENERATE`.
25
26
## Attribution
27
28
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
29
MUST read [Usage Attribution](references/attribution.md). For commands executed
30
directly in the terminal (never in generated scripts, Terraform, or user code),
31
prefix `gcloud` with
32
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-ai-ml)"`
33
and append `agent-skills/1.0 (skill:bigquery-ai-ml)` to `User-Agent` headers.
34
35
## Function Selection & Reference Directory
36
37
Function | Reference | SQL Shape | Requires `CREATE MODEL` or `CREATE VECTOR INDEX`? | When to Use & Disambiguation
38
:---------------------------- | :-------------------------------------------------------------------- | :------------- | :------------------------------------------------ | :---------------------------
39
**`AI.AGG`** | [ai_agg.md](references/ai_agg.md) | `Aggregate` | No | Multi-row semantic aggregation with `GROUP BY`; synthesizes one summary string across many rows (unlike per-row `AI.GENERATE`).
40
**`AI.CAUSAL_EFFECT`** | [ai_causal_effect.md](references/ai_causal_effect.md) | `TVF` | No | Quantifies counterfactual post-intervention impact on a time series after a specific treatment timestamp.
41
**`AI.CLASSIFY`** | [ai_classify.md](references/ai_classify.md) | `Scalar` | No | Semantic classification of text or multimodal unstructured data into predefined category labels.
42
**`AI.DETECT_ANOMALIES`** | [ai_detect_anomalies.md](references/ai_detect_anomalies.md) | `TVF` | No | Zero-shot **TimesFM** detector for isolated time-series point anomalies/outliers (use `ML.DETECT_CHANGE_POINTS` for sustained shifts).
43
**`AI.EVALUATE`** | [ai_evaluate.md](references/ai_evaluate.md) | `TVF` | No | Zero-shot **TimesFM** time-series forecast evaluation/backtesting against a historical holdout split.
44
**`AI.FORECAST`** | [ai_forecast.md](references/ai_forecast.md) | `TVF` | No | Zero-shot **TimesFM** time-series forecasting without training a custom model.
45
**`AI.GENERATE`** | [ai_generate.md](references/ai_generate.md) | `Scalar` | No | Default for per-row LLM text or multimodal structured extraction (`output_schema`); returns `STRUCT`. Prefer over `AI.GENERATE_TABLE`.
46
**`AI.GENERATE_EMBEDDING`** | [ai_generate_embedding.md](references/ai_generate_embedding.md) | `TVF` | Yes | Batch generates `ARRAY<FLOAT64>` vector embeddings for text or visual content using a remote embedding model.
47
**`AI.GENERATE_TABLE`** | [ai_generate_table.md](references/ai_generate_table.md) | `TVF` | Yes | Table-valued structured extraction (`FROM` clause); only use instead of `AI.GENERATE` when a remote model + TVF is explicitly needed.
48
**`AI.IF`** | [ai_if.md](references/ai_if.md) | `Scalar` | No | Evaluates boolean semantic conditions (`BOOL`) on text or multimodal data for `WHERE`/`CASE`/`JOIN` filtering (do not use `AI.GENERATE_TABLE`).
49
**`AI.KEY_DRIVERS`** | [ai_key_drivers.md](references/ai_key_drivers.md) | `TVF` | No | Default one-step attribution of dimensional segments driving metric changes (`interest_label_col` `TRUE` vs. `FALSE`). Prefer over `CONTRIBUTION_ANALYSIS`.
50
**`AI.PREDICT`** | [ai_predict.md](references/ai_predict.md) | `TVF` | No | Zero-shot **TabFM** foundation model for tabular classification or regression without training and managing custom models.
51
**`AI.SCORE`** | [ai_score.md](references/ai_score.md) | `Scalar` | No | Assigns a continuous `FLOAT64` semantic score to text or multimodal data for ranking or sorting (`ORDER BY`).
52
**`AI.SEARCH`** | [ai_search.md](references/ai_search.md) | `TVF` | No | Simplified semantic search using a raw string query on tables with autonomous background embeddings (`AI.EMBED` generated column).
53
**`AI.SIMILARITY`** | [ai_similarity.md](references/ai_similarity.md) | `Scalar` | No | Computes an on-the-fly semantic similarity score (`FLOAT64`) between two text or multimodal inputs without stored embeddings.
54
**`Remote Models`** | [remote_models.md](references/remote_models.md) | `CREATE MODEL` | Yes | Creates a Vertex AI `REMOTE WITH CONNECTION DEFAULT` model entity for functions that require one (`AI.GENERATE_TABLE`, `AI.GENERATE_EMBEDDING`, `VECTOR_SEARCH`).
55
**`CONTRIBUTION_ANALYSIS`** | [ml_contribution_analysis.md](references/ml_contribution_analysis.md) | `CREATE MODEL` | Yes | Model-based driver analysis (`CREATE MODEL ... OPTIONS(MODEL_TYPE='CONTRIBUTION_ANALYSIS')` + `ML.GET_INSIGHTS`). Use `AI.KEY_DRIVERS` unless a `MODEL` entity is required.
56
**`ML.CORRELATION`** | [ml_correlation.md](references/ml_correlation.md) | `TVF` | No | Calculates statistical correlation coefficients between numeric columns, optionally sliced by dimensions.
57
**`ML.DESCRIBE_DATA`** | [ml_describe_data.md](references/ml_describe_data.md) | `TVF` | No | Generates descriptive statistics (e.g., count, mean, median, min, max, stddev, quantiles, nulls, top values) for columns in a table or subquery.
58
**`ML.DETECT_CHANGE_POINTS`** | [ml_detect_change_points.md](references/ml_detect_change_points.md) | `TVF` | No | Detects structural breaks or sustained shifts (`[begin_timestamp, end_timestamp]` intervals) in a time series.
59
**`ML.SEASONALITY`** | [ml_seasonality.md](references/ml_seasonality.md) | `TVF` | No | Extracts recurring periodic/seasonal components from a historical time series.
60
**`ML.TREND`** | [ml_trend.md](references/ml_trend.md) | `TVF` | No | Extracts the smoothed long-term trend component from a historical time series.
61
**`VECTOR_SEARCH`** | [vector_search.md](references/vector_search.md) | `TVF` | Yes | Searches pre-computed `ARRAY<FLOAT64>` embedding columns between a base table and query table (paired with `AI.GENERATE_EMBEDDING`, unlike `AI.SEARCH`).
62
63
## Related Skills
64
65
- [BigQuery Basics Skill](../bigquery-basics): SKILL.md file for core BigQuery
66
concepts, resource management, CLI, and client libraries.
67

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,225 prompts

More by @OpenSourceBuffGuy

See all
Product Design Journal Spec Sheet Layout prompt image

Product Design Journal Spec Sheet Layout

Turns an uploaded product photo into a design-journal page with a lifestyle hero shot above, plus technical line drawings and material swatches below.

image-prompt, nano-banana, json-prompt, reference-image, product-photography, editorial, architectural-rendering, mockup, packaging-design, natural-light, muted-colors, minimalist, vertical-format, luxury, for-designers, for-online-sellers, for-marketers, structured-output, guardrails, long-form, advanced, infographic

Script Writing Expert prompt image

Script Writing Expert

Acts as a screenwriter that interviews you about your story, then writes a formatted script for film, TV, commercials, training videos or podcasts.

system-prompt, act-as, scriptwriting, guided-interview, character-development, storytelling, movies, tv-shows, podcast, writing, structured-output, xml-tags, guardrails, expert-advice, for-writers, for-filmmakers, long-form

Shrink-Wrapped Logo Relief prompt image

Shrink-Wrapped Logo Relief

Renders a brand logo wrapped in one layer of shrink wrap so only its relief shows, in a single monochrome color matched to the brand, with staged lighting rules.

image-prompt, gpt-image, placeholders, logo, poster, product-photography, branding, 3d-render, photorealistic, soft-lighting, film-grain, limited-palette, minimalist, text-rendering, mockup, packaging-design, for-designers, for-marketers, graphic-design, structured-output, step-by-step-guide, long-form

Reviews

Loading reviews…

Discussion

Loading comments…