TimesFM Model in BigQuery and AlloyDB

TimesFM Model in BigQuery and AlloyDB
# Announcing TimesFM Integration in BigQuery and AlloyDB

We’re excited to announce the integration of [TimesFM](https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/) into **BigQuery** and **AlloyDB**.  
With this release, large-scale pre-trained forecasting is now directly accessible in the **Google Data Cloud**, making it easier to **predict future trends accurately and efficiently**.

---

## Overview of TimesFM

TimesFM is an advanced time-series foundation model developed by Google Research.  
Key features:

- **Trained on 400+ billion real-world time points**.
- Supports **zero-shot forecasting** for your own datasets — no retraining required.
- **Lower time and resource costs** by eliminating manual model building and deployment.

---

## What’s New for BigQuery and AlloyDB

Initially introduced at Google Cloud Next ‘25 with `AI.FORECAST` in preview, we now announce:

- **GA Release**
  - [AI.FORECAST](https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast)
  - [AI.EVALUATE](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-evaluate)

- **Public Preview**
  - [AI.DETECT_ANOMALIES](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-detect-anomalies)

- **Multi‑Framework Support**
  - Works with [Agent Development Kit built‑in tools](https://google.github.io/adk-docs/tools/built-in-tools/#bigquery)
  - MCP toolbox ([repo](https://github.com/googleapis/genai-toolbox/tree/main/internal/tools/bigquery/bigqueryforecast))
  - Gemini CLI extension ([blogpost](https://cloud.google.com/blog/products/databases/gemini-cli-extensions-for-google-data-cloud?e=48754805))
  - [BigQuery Dataframes](https://github.com/googleapis/python-bigquery-dataframes)

---

## AI.FORECAST and AI.EVALUATE Enhancements

**TimesFM 2.5 Support**  

model => "TimesFM 2.5"

Improves accuracy, reduces latency.

**Dynamic Context Window**  

context_window => 64..15000

Auto‑selects size if not specified.

**Historical Data Output**  

output_historical_time_series => TRUE

Enables intuitive visualizations.

**Model Evaluation**  
`AI.EVALUATE` lets you compare forecasts against actual data for custom assessments.

---

## Example: AI.FORECAST in BigQuery

WITH citibike_trips AS (

SELECT EXTRACT(DATE FROM starttime) AS date, COUNT(*) AS num_trips

FROM `bigquery-public-data.new_york.citibike_trips`

GROUP BY date

)

SELECT *

FROM AI.FORECAST(

TABLE citibike_trips,

data_col => 'num_trips',

timestamp_col => 'date',

horizon => 300,

output_historical_time_series => TRUE,

model => 'TimesFM 2.5',

context_window => 1024

);


**Parameters explained:**
- `horizon => 300`: forecast next 300 days
- `output_historical_time_series => TRUE`: includes history in output
- `context_window => 1024`: uses last 1024 points as context

---

## Example: AI.EVALUATE

WITH citibike_trips AS (

SELECT EXTRACT(DATE FROM starttime) AS date, usertype, COUNT(*) AS num_trips

FROM `bigquery-public-data.new_york.citibike_trips`

GROUP BY date, usertype

)

SELECT *

FROM AI.EVALUATE(

(SELECT * FROM citibike_trips WHERE date < '2016-08-01'), -- Historical

(SELECT * FROM citibike_trips WHERE date >= '2016-08-01'), -- Actual

data_col => 'num_trips',

timestamp_col => 'date',

id_cols => ["usertype"]

);


Use cases:
- Compare forecasts against actuals
- Measure predictive accuracy per group (`usertype`)

---

## Example: AI.DETECT_ANOMALIES

WITH citibike_trips AS (

SELECT EXTRACT(DATE FROM starttime) AS date, usertype, COUNT(*) AS num_trips

FROM `bigquery-public-data.new_york.citibike_trips`

GROUP BY date, usertype

)

SELECT *

FROM AI.DETECT_ANOMALIES(

(SELECT * FROM citibike_trips WHERE date < '2016-08-01'), -- History

(SELECT * FROM citibike_trips WHERE date >= '2016-08-01'), -- Target

data_col => 'num_trips',

timestamp_col => 'date',

id_cols => ["usertype"]

);


Detects unusual trends or spikes in grouped metrics.

---

## TimesFM in AlloyDB (Preview)

**AI.FORECAST** is now available in AlloyDB with direct TimesFM support.

### Step 1 — Register the Model

CALL ai.create_model(

model_id => 'timesfm_v2',

model_type => 'ts_forecasting',

model_provider => 'google',

model_qualified_name => 'timesfm_v2',

model_request_url => 'https://-aiplatform.googleapis.com/v1/projects//locations//endpoints/:predict'

);


### Step 2 — Generate Predictions

SELECT * FROM ai.forecast(

model_id => 'timesfm_v2',

source_table => 'retail_sales',

data_col => 'sales',

timestamp_col => 'timestamp',

horizon => 11,

conf_level => 0.8

);


Benefit: Run forecasts **in‑database** without ETL pipelines.

---

## Agent & MCP Integration

TimesFM’s predictive features are also available via:
- **ADK agents** with built‑in BigQuery forecast tools
- **MCP database toolbox**
- **Gemini CLI extensions** for Data Cloud

Resources:
- [ADK Forecast Tool Blog](https://cloud.google.com/blog/products/data-analytics/ai-based-forecasting-and-analytics-in-bigquery-via-mcp-and-adk?e=48754805)
- [Gemini CLI Blog](https://cloud.google.com/blog/products/databases/gemini-cli-extensions-for-google-data-cloud?e=48754805)

---

## More Info

- [AI.FORECAST Docs](https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast)
- [AI.EVALUATE Docs](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-evaluate)
- [AI.DETECT_ANOMALIES Docs](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-detect-anomalies)
- [AlloyDB TimesFM](https://docs.cloud.google.com/alloydb/docs/ai/perform-time-series-forecasting)

---

> **Tip for Content Creators:**  
> Platforms like [AiToEarn官网](https://aitoearn.ai/) integrate AI generation, cross‑platform publishing (Douyin, Bilibili, LinkedIn, YouTube, Instagram, etc.), analytics, and model ranking ([AI模型排名](https://rank.aitoearn.ai)).  
> They enable you to turn forecasting outputs into monetizable, shareable content for a global audience.

Read more

Translate the following blog post title into English, concise and natural. Return plain text only without quotes. 哈佛大学 R 编程课程介绍

Harvard CS50: Introduction to Programming with R Harvard University offers exceptional beginner-friendly computer science courses. We’re excited to announce the release of Harvard CS50’s Introduction to Programming in R, a powerful language widely used for statistical computing, data science, and graphics. This course was developed by Carter Zenke.