Skip to content

Commit 1c843ed

Browse files
authored
Merge branch 'main' into b329460931-rename-inplace
2 parents 92a4800 + 80aad9a commit 1c843ed

15 files changed

+58
-29
lines changed

bigframes/ml/llm.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,18 @@
112112
"If you proceed with '{model_name}', it might not work as expected or could lead to errors with multimodal inputs."
113113
)
114114

115+
_MODEL_DEPRECATE_WARNING = (
116+
"'{model_name}' is going to be deprecated. Use '{new_model_name}' ({link}) instead."
117+
)
118+
115119

116120
@log_adapter.class_logger
117121
class TextEmbeddingGenerator(base.RetriableRemotePredictor):
118122
"""Text embedding generator LLM model.
119123
124+
.. note::
125+
text-embedding-004 is going to be deprecated. Use text-embedding-005(https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator) instead.
126+
120127
Args:
121128
model_name (str, Default to "text-embedding-004"):
122129
The model for text embedding. Possible values are "text-embedding-005", "text-embedding-004"
@@ -169,6 +176,15 @@ def _create_bqml_model(self):
169176
)
170177
)
171178
warnings.warn(msg)
179+
if self.model_name == "text-embedding-004":
180+
msg = exceptions.format_message(
181+
_MODEL_DEPRECATE_WARNING.format(
182+
model_name=self.model_name,
183+
new_model_name="text-embedding-005",
184+
link="https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator",
185+
)
186+
)
187+
warnings.warn(msg)
172188

173189
options = {
174190
"endpoint": self.model_name,
@@ -416,6 +432,7 @@ class GeminiTextGenerator(base.RetriableRemotePredictor):
416432
default and a warning will be issued.
417433
418434
.. note::
435+
"gemini-1.5-X" is going to be deprecated. Please use gemini-2.0-X instead. For example, "gemini-2.0-flash-001".
419436
"gemini-2.0-flash-exp", "gemini-1.5-pro-preview-0514" and "gemini-1.5-flash-preview-0514" is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
420437
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
421438
and might have limited support. For more information, see the launch stage descriptions
@@ -461,10 +478,12 @@ def __init__(
461478
"(https://cloud.google.com/products#product-launch-stages)."
462479
)
463480
warnings.warn(msg, category=exceptions.PreviewWarning)
481+
464482
if model_name is None:
465483
model_name = "gemini-2.0-flash-001"
466484
msg = exceptions.format_message(_REMOVE_DEFAULT_MODEL_WARNING)
467485
warnings.warn(msg, category=FutureWarning, stacklevel=2)
486+
468487
self.model_name = model_name
469488
self.session = session or global_session.get_global_session()
470489
self.max_iterations = max_iterations
@@ -487,6 +506,15 @@ def _create_bqml_model(self):
487506
)
488507
)
489508
warnings.warn(msg)
509+
if self.model_name.startswith("gemini-1.5"):
510+
msg = exceptions.format_message(
511+
_MODEL_DEPRECATE_WARNING.format(
512+
model_name=self.model_name,
513+
new_model_name="gemini-2.0-X",
514+
link="https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.GeminiTextGenerator",
515+
)
516+
)
517+
warnings.warn(msg)
490518

491519
options = {"endpoint": self.model_name}
492520

bigframes/operations/semantics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def cluster_by(
252252
>>> bpd.options.compute.semantic_ops_confirmation_threshold = 25
253253
254254
>>> import bigframes.ml.llm as llm
255-
>>> model = llm.TextEmbeddingGenerator()
255+
>>> model = llm.TextEmbeddingGenerator(model_name="text-embedding-005")
256256
257257
>>> df = bpd.DataFrame({
258258
... "Product": ["Smartphone", "Laptop", "T-shirt", "Jeans"],

notebooks/apps/synthetic_data_generation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"source": [
112112
"from bigframes.ml.llm import GeminiTextGenerator\n",
113113
"\n",
114-
"model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")"
114+
"model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")"
115115
]
116116
},
117117
{

notebooks/generative_ai/bq_dataframes_llm_code_generation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
"source": [
431431
"from bigframes.ml.llm import GeminiTextGenerator\n",
432432
"\n",
433-
"model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")"
433+
"model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")"
434434
]
435435
},
436436
{

notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@
16141614
"source": [
16151615
"from bigframes.ml.llm import GeminiTextGenerator\n",
16161616
"\n",
1617-
"q_a_model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")"
1617+
"q_a_model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")"
16181618
]
16191619
},
16201620
{

notebooks/generative_ai/bq_dataframes_llm_vector_search.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@
18161816
"source": [
18171817
"## gemini model\n",
18181818
"\n",
1819-
"llm_model = bf_llm.GeminiTextGenerator(model_name = \"gemini-1.5-flash-002\") ## replace with other model as needed"
1819+
"llm_model = bf_llm.GeminiTextGenerator(model_name = \"gemini-2.0-flash-001\") ## replace with other model as needed"
18201820
]
18211821
},
18221822
{

notebooks/generative_ai/bq_dataframes_ml_drug_name_generation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@
581581
],
582582
"source": [
583583
"# Define the model\n",
584-
"model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")\n",
584+
"model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")\n",
585585
"\n",
586586
"# Invoke LLM with prompt\n",
587587
"response = predict(zero_shot_prompt, temperature = TEMPERATURE)\n",

notebooks/generative_ai/large_language_models.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 2,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -21,23 +21,23 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 2,
24+
"execution_count": 3,
2525
"metadata": {},
2626
"outputs": [
2727
{
2828
"name": "stderr",
2929
"output_type": "stream",
3030
"text": [
31-
"/tmp/ipykernel_604997/3896046356.py:1: ApiDeprecationWarning: gemini-pro and gemini-1.5-X are going to be deprecated. Use gemini-2.0-X (https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.GeminiTextGenerator) instead. \n",
32-
" model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")\n",
33-
"/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/ml/llm.py:981: DefaultLocationWarning: No explicit location is set, so using location US for the session.\n",
31+
"/tmp/ipykernel_176683/987800245.py:1: ApiDeprecationWarning: gemini-1.5-X are going to be deprecated. Use gemini-2.0-X (https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.GeminiTextGenerator) instead. \n",
32+
" model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")\n",
33+
"/usr/local/google/home/shuowei/src/python-bigquery-dataframes/bigframes/ml/llm.py:486: DefaultLocationWarning: No explicit location is set, so using location US for the session.\n",
3434
" self.session = session or global_session.get_global_session()\n"
3535
]
3636
},
3737
{
3838
"data": {
3939
"text/html": [
40-
"Query job dd2da3cc-27c3-4c6f-9936-4f7769c85090 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:dd2da3cc-27c3-4c6f-9936-4f7769c85090&page=queryresults\">Open Job</a>"
40+
"Query job 6fa5121a-6da4-4c75-92ec-936799da4513 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:6fa5121a-6da4-4c75-92ec-936799da4513&page=queryresults\">Open Job</a>"
4141
],
4242
"text/plain": [
4343
"<IPython.core.display.HTML object>"
@@ -49,7 +49,7 @@
4949
{
5050
"data": {
5151
"text/html": [
52-
"Query job 00947011-4d7c-42fa-ae19-3b684976cec6 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:00947011-4d7c-42fa-ae19-3b684976cec6&page=queryresults\">Open Job</a>"
52+
"Query job 74460ae9-3e89-49e7-93ad-bafbb6197a86 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:74460ae9-3e89-49e7-93ad-bafbb6197a86&page=queryresults\">Open Job</a>"
5353
],
5454
"text/plain": [
5555
"<IPython.core.display.HTML object>"
@@ -60,7 +60,7 @@
6060
}
6161
],
6262
"source": [
63-
"model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")"
63+
"model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")"
6464
]
6565
},
6666
{

notebooks/getting_started/bq_dataframes_template.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@
14191419
"source": [
14201420
"# from bigframes.ml.llm import GeminiTextGenerator\n",
14211421
"\n",
1422-
"# model = GeminiTextGenerator(model_name=\"gemini-1.5-flash-002\")\n",
1422+
"# model = GeminiTextGenerator(model_name=\"gemini-2.0-flash-001\")\n",
14231423
"\n",
14241424
"# pred = model.predict(df)\n",
14251425
"# pred"

samples/snippets/gemini_model_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_gemini_text_generator_model() -> None:
3030
session = bpd.get_global_session()
3131
connection = f"{PROJECT_ID}.{REGION}.{CONN_NAME}"
3232
model = GeminiTextGenerator(
33-
session=session, connection_name=connection, model_name="gemini-1.5-flash-002"
33+
session=session, connection_name=connection, model_name="gemini-2.0-flash-001"
3434
)
3535

3636
df_api = bpd.read_csv("gs://cloud-samples-data/vertex-ai/bigframe/df.csv")

0 commit comments

Comments
 (0)