Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def generate_text() -> object:
messages.append({"role": "user", "content": "What is the weather in Boston?"})

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=messages,
tools=tools,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def generate_text() -> object:
messages.append({"role": "user", "content": "What is the weather in Boston, MA?"})

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=messages,
tools=tools,
tool_choice="auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=[
{
"role": "user",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=[
{
"role": "user",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object:
)

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
stream=True,
)
Expand Down
4 changes: 2 additions & 2 deletions generative_ai/evaluation/pairwise_summarization_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def evaluate_output() -> EvalResult:
eval_dataset = pd.DataFrame({"prompt": [prompt]})

# Baseline model for pairwise comparison
baseline_model = GenerativeModel("gemini-2.0-flash-lite-001")
baseline_model = GenerativeModel("gemini-1.5-flash")

# Candidate model for pairwise comparison
candidate_model = GenerativeModel(
"gemini-2.0-flash-001", generation_config={"temperature": 0.4}
"gemini-1.5-pro", generation_config={"temperature": 0.4}
)
Comment on lines +55 to 60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In a pairwise evaluation, comparing the exact same model (gemini-1.5-flash) against itself defeats the purpose of demonstrating a pairwise comparison between two different models (e.g., a lighter/faster model vs. a larger/more capable model). To make this sample more meaningful and illustrative, consider using gemini-1.5-pro as the candidate model while keeping gemini-1.5-flash as the baseline.

Suggested change
baseline_model = GenerativeModel("gemini-1.5-flash")
# Candidate model for pairwise comparison
candidate_model = GenerativeModel(
"gemini-2.0-flash-001", generation_config={"temperature": 0.4}
"gemini-1.5-flash", generation_config={"temperature": 0.4}
)
baseline_model = GenerativeModel("gemini-1.5-flash")
# Candidate model for pairwise comparison
candidate_model = GenerativeModel(
"gemini-1.5-pro", generation_config={"temperature": 0.4}
)


prompt_template = MetricPromptTemplateExamples.get_prompt_template(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def generate_text() -> object:
messages.append({"role": "user", "content": "What is the weather in Boston?"})

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=messages,
tools=tools,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def generate_text() -> object:
messages.append({"role": "user", "content": "What is the weather in Boston, MA?"})

response = client.chat.completions.create(
model="google/gemini-2.0-flash-001",
model="google/gemini-1.5-flash",
messages=messages,
tools=tools,
tool_choice="auto",
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/labels/labels_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def generate_content() -> GenerationResponse:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-2.0-flash-001")
model = GenerativeModel("gemini-1.5-flash")

prompt = "What is Generative AI?"
response = model.generate_content(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def gemini_tuning_advanced() -> sft.SupervisedTuningJob:
# vertexai.init(encryption_spec_key_name="your-kms-key")

sft_tuning_job = sft.train(
source_model="gemini-2.0-flash-001",
source_model="gemini-1.5-flash",
# 1.5 and 2.0 models use the same JSONL format
train_dataset="gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl",
# The following parameters are optional
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/model_tuning/supervised_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def gemini_tuning_basic() -> sft.SupervisedTuningJob:
vertexai.init(project=PROJECT_ID, location="us-central1")

sft_tuning_job = sft.train(
source_model="gemini-2.0-flash-001",
source_model="gemini-1.5-flash",
# 1.5 and 2.0 models use the same JSONL format
train_dataset="gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl",
)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def prompt_create() -> Prompt:
{"movie1": "The Lion King", "movie2": "Frozen"},
{"movie1": "Inception", "movie2": "Interstellar"},
],
model_name="gemini-2.0-flash-001",
model_name="gemini-1.5-flash",
system_instruction="You are a movie critic. Answer in a short sentence.",
# generation_config=GenerationConfig, # Optional,
# safety_settings=SafetySetting, # Optional,
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def delete_prompt() -> None:
{"movie1": "The Lion King", "movie2": "Frozen"},
{"movie1": "Inception", "movie2": "Interstellar"},
],
model_name="gemini-2.0-flash-001",
model_name="gemini-1.5-flash",
system_instruction="You are a movie critic. Answer in a short sentence.",

)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_prompt() -> Prompt:
prompt = Prompt(
prompt_name="meteorologist",
prompt_data="How should I dress for weather in August?",
model_name="gemini-2.0-flash-001",
model_name="gemini-1.5-flash",
system_instruction="You are a meteorologist. Answer in a short sentence.",

)
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_list_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def list_prompt_version() -> list:
prompt = Prompt(
prompt_name="zoologist",
prompt_data="Which animal is the fastest on earth?",
model_name="gemini-2.0-flash-001",
model_name="gemini-1.5-flash",
system_instruction="You are a zoologist. Answer in a short sentence.",
)
# Save Prompt to online resource.
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_restore_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# prompt = Prompt(
# prompt_name="zoologist",
# prompt_data="Which animal is the fastest on earth?",
# model_name="gemini-2.0-flash-001",
# model_name="gemini-1.5-flash",
# system_instruction="You are a zoologist. Answer in a short sentence.",
# )
# # Save Prompt to online resource.
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/prompts/prompt_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def prompt_template_example() -> list[GenerationResponse]:
# define prompt template
prompt = Prompt(
prompt_data="Do {animal} {activity}?",
model_name="gemini-2.0-flash-001",
model_name="gemini-1.5-flash",
variables=variables,
system_instruction="You are a helpful zoologist"
# generation_config=generation_config, # Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def generate_content() -> str:
request_metadata=[("x-vertex-ai-llm-request-type", "shared")],
)

model = GenerativeModel("gemini-2.0-flash-001")
model = GenerativeModel("gemini-1.5-flash")

response = model.generate_content(
"What's a good name for a flower shop that specializes in selling bouquets of dried flowers?"
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/rag/generate_content_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def generate_content_with_rag(
genai_client = genai.Client(enterprise=True, project=PROJECT_ID, location="us-central1")

response = genai_client.models.generate_content(
model="gemini-2.5-pro",
model="gemini-2.5-flash",
contents="Why is the sky blue?",
config=genai_types.GenerateContentConfig(
tools=[rag_retrieval_tool]
Expand Down
2 changes: 1 addition & 1 deletion generative_ai/text_generation/text_example01.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generate_from_text_input() -> str:
# PROJECT_ID = "your-project-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

model = GenerativeModel("gemini-2.0-flash-001")
model = GenerativeModel("gemini-1.5-flash")

response = model.generate_content(
"What's a good name for a flower shop that specializes in selling bouquets of dried flowers?"
Expand Down