# How to test EmbeddingGemma 2 in BigQuery without breaking retrieval

Build a shadow set of BigQuery vectors, compare search results on the same queries and check truncation and costs before switching.

By Paras Madan | 2026-11-24


Two embedding models can return arrays of the same length and still produce vectors that shouldn't be searched together. That's the first thing I would check if your pipeline currently embeds documentation through an endpoint and you want to try the new built-in EmbeddingGemma 2 model in BigQuery.

Google added `model => 'embeddinggemma-2'` to `AI.EMBED` in preview on November 23. The [BigQuery release notes](https://docs.cloud.google.com/bigquery/docs/release-notes) describe it as a model for text and code that runs inside BigQuery. The useful test is to rebuild one slice of your corpus beside the existing one and run the same searches against both.

## Run a small batch first

The [AI.EMBED reference](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-embed) documents a 768-dimensional output and an 8,192-token input limit. Use the built-in `model` argument instead of `endpoint`. Remove endpoint settings such as `task_type`, `title`, `model_params`, and `connection_id` from this call. In particular, don't carry over an endpoint setting that requested a different vector size.

For a developer documentation search, start with a fixture table containing a stable `doc_id` and the exact text chunk used by the current pipeline:

```sql
SELECT
  doc_id,
  AI.EMBED(chunk_text, model => 'embeddinggemma-2') AS embedded
FROM `my_project.scratch.doc_chunks_fixture`;
```

Save both `embedded.result` and `embedded.status` in your scratch output. Count errors and missing results before comparing rankings. If a whole subtree of the docs has dropped out of your candidate table, you want to find it now rather than assume the model simply dislikes those pages.

## Keep query vectors and document vectors paired

Rebuild the candidate document vectors from the fixture, and embed the search queries with the built-in model as well. For the baseline, keep using the original query encoder and its corresponding document vectors. Use the same chunk IDs and source text on both sides. Don't switch chunk length and model together.

The [VECTOR_SEARCH reference](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/search_functions) requires matching array dimensions for precomputed vectors. That check catches a shape mismatch, but the query can still run when different models both return 768 values. Keep separate tables or columns even if both arrays pass validation. If you cache embeddings, include the encoder and input version in the cache key so the first test never reuses a vector from the old endpoint. On a small slice, use the same distance measure and brute-force search on both sides so an approximate index doesn't become another variable.

## Judge which links people would actually open

Pick a few specific queries before reading the results. For instance, if your docs contain two SDKs with a method called `createSession`, write one search that specifies TypeScript and another that uses an old Python method name. Mark the expected pages in advance. Compare whether the correct page is in the first five results and whether a deprecated guide outranks it.

Include one long chunk whose important detail is near the end. The function docs say input beyond the token limit is truncated. You can use the retrieval test to decide whether to split chunks differently, but run that as a separate comparison after the model-only test.

## Measure cost before backfilling the corpus

The built-in path doesn't send the request to Agent Platform. It still charges the query project for input tokens and ordinary query compute; [BigQuery pricing](https://cloud.google.com/bigquery/pricing) is the place to check current rates. Measure the one-time document backfill separately from recurring query embedding and search. Also check the function reference's location rules and Assured Workloads limitation before trying it with approved data.

If the candidate passes your relevance, cost and coverage checks, store its vectors as a separate version. Switch the query encoder and its target vector table together. Keep the old pair available while you verify live searches, so rolling back does not leave half of the pipeline on the new model.

I'm Paras. I work at the intersection of AI, engineering and distribution.

I help AI and data teams explain product changes through clear technical writing and practical storytelling.

[Book a 30-minute call](https://cal.com/paras-madan/30min).
