You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: GEMINI.md
+31-7Lines changed: 31 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Vertex AI Gemini CLI Extension
2
2
3
-
This extension provides tools to manage prompts and use the data-driven prompt
3
+
This extension provides tools to manage prompts and use prompt
4
4
optimization in Vertex AI directly from the Gemini CLI.
5
5
6
6
## Available Tools
@@ -12,8 +12,10 @@ optimization in Vertex AI directly from the Gemini CLI.
12
12
-`delete_prompt`: To remove prompts.
13
13
-`list_prompts`: To search and list prompts, useful for finding IDs.
14
14
15
-
### Data-Driven Optimization Tools
16
-
-`run_data_driven_optimize`: Starts a data-driven prompt optimization job on
15
+
### Prompt Optimization Tools
16
+
-`run_few_shot_optimization`: optimize user prompt based on examples provided
17
+
in the CSV file stored in the GCS bucket.
18
+
-`run_data_driven_optimize`: Starts a data-driven prompt optimization job on
17
19
Vertex AI using a configuration file stored in GCS.
18
20
-`analyze_data_driven_optimize_results`: Analyzes the output of a Data-Driven
19
21
Optimize job to identify trends and best-performing candidates.
@@ -275,6 +277,28 @@ If any tool call fails with an error indicating a project permission issue (e.g.
275
277
276
278
---
277
279
280
+
## Few-Shot Prompt Optimization Guide
281
+
Few-shot prompt optimization is a tool used to refine a prompt (or system instructions) based on user-provided examples. These examples are stored in a CSV file and user must provide a GCS path to this data. The examples must follow one of two formats:
282
+
`("prompt", "model_response", "target_response")` or
Copy file name to clipboardExpand all lines: README.md
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,10 @@ This extension provides tools to manage prompts and work with data-driven prompt
17
17
***Results Analysis**: Perform deep-dive analysis of optimization results, including learning curves and candidate comparisons.
18
18
***Automated Reporting**: Generate comprehensive HTML reports with tuning suggestions for subsequent runs.
19
19
20
+
### Few-Shot Prompt Optimizer
21
+
***Prompt Optimization**: tunes the given prompt by utilizing small set of user-provided examples using few-shot prompt optimization. For more details about the algorithm, please refer to this [documentation](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/few-shot-optimizer) or this [guide](@./src/vertex/prompt_optimizer/docs/few_shot_prompt_optimization_guide.md).
22
+
23
+
20
24
## Prerequisites
21
25
22
26
* You have the [Gemini CLI](https://github.com/google-gemini/gemini-cli) installed.
@@ -63,7 +67,7 @@ Here are a few examples:
63
67
64
68
For more detailed information on all available commands and their parameters, please refer to the `extension/commands` files.
65
69
66
-
### Prompt Optimizer Examples
70
+
### Data-Driven Prompt Optimizer Examples
67
71
68
72
***Analyze optimization results**:
69
73
```bash
@@ -82,6 +86,17 @@ For more detailed information on all available commands and their parameters, pl
82
86
83
87
For more detailed information on all available commands and workflows, please refer to the `GEMINI.md` file in this repository.
84
88
89
+
### Few-Shot Prompt Optimization Examples
90
+
***Few-shot optimization with target response**:
91
+
When user examples consit of `(question, model_response, target_response)`, few-shot optimization should be run with "target response" method.
92
+
```bash
93
+
gemini "Apply few-shot prompt optimization using target response with data from gs://your_bucket/your_examples.csv. Here is the prompt: '...'"
94
+
95
+
***Few-shot optimization with rubrics and evaluations**:
96
+
When user examples consit of `(question, model_response, rubrics, rubrics_evaluations)`, few-shot optimization should be run with "rubrics" method.
97
+
```bash
98
+
gemini "Apply few-shot prompt optimization using rubrics with data from gs://your_bucket/your_examples.csv. Here is the prompt: '...'"
The **Few-Shot Prompt Optimizer** helps you improve your system instructions by learning from examples.
4
+
5
+
You provide your current instructions you want to tune along with a CSV file containing questions(prompts), the model's current responses, and your feedback. The optimizer analyzes where the model fell short and automatically updates your instructions to fix those gaps.
6
+
7
+
Your example data must be saved as a CSV file in Google Cloud Storage (GCS). You can format your feedback using one of two methods:
8
+
9
+
## Method 1: Target Responses
10
+
11
+
Use this method to show the optimizer exactly what the model *should* have said. The tool compares the actual output to your ideal output and adjusts the instructions to bridge the gap.
12
+
13
+
Your CSV must include these three columns:
14
+
15
+
***`prompt`**: The original user instruction or question.
16
+
***`model_response`**: The current model output that needs improvement.
17
+
***`target_response`**: The ideal, correct response you want the model to generate.
18
+
19
+
## Method 2: Rubrics (Grading Criteria)
20
+
21
+
Use this method to score responses based on specific rules. The tool learns from which rules the model passed or failed. Rubrics can be consistent across all rows or customized for each individual example.
22
+
23
+
Your CSV must include these four columns:
24
+
25
+
***`prompt`**: The original user instruction or question.
26
+
***`model_response`**: The actual output generated by the model.
27
+
***`rubrics`**: A list of specific grading criteria (formatted as a string representation of a Python list of strings, e.g., `"['Tone is polite', 'Mentions pricing']"`).
28
+
***`rubrics_evaluations`**: True/False scores indicating if the model met each rule (formatted as a string representation of a Python list of booleans, e.g., `"['True', 'False']"`).
0 commit comments