forked from GoogleCloudPlatform/generative-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into thinking-0127
- Loading branch information
Showing
10 changed files
with
449 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -958,6 +958,7 @@ podcast | |
podcasts | ||
podfile | ||
podhelper | ||
podman | ||
powerups | ||
praw | ||
prcntg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
gemini/sample-apps/e2e-gen-ai-app-starter-pack/app/patterns/multimodal_live_agent/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3.11-slim | ||
|
||
RUN pip install --no-cache-dir poetry==1.6.1 | ||
|
||
RUN poetry config virtualenvs.create false | ||
|
||
WORKDIR /code | ||
|
||
COPY ./pyproject.toml ./README.md ./poetry.lock* ./ | ||
|
||
COPY ./app ./app | ||
|
||
RUN poetry install --no-interaction --no-ansi --no-dev | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "8080"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__pycache__ | ||
pipeline.json | ||
venv | ||
local/local_outputs | ||
local/pipeline.json | ||
local/venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Gen AI MLOps Tune and Evaluation | ||
|
||
Author: [Chris Willis](https://github.com/willisc7) | ||
|
||
This tutorial will take you through using Vertex AI Pipelines to automate tuning an LLM and evaluating it against a previously tuned LLM. The example used is an LLM that summarizes a week of glucose values for a diabetes patient. | ||
|
||
![Diagram](https://storage.googleapis.com/github-repo/generative-ai/gemini/tuning/mlops-tune-and-eval/diagram.png) | ||
|
||
## Optional: Prepare the data | ||
|
||
This step is optional because I've already prepared the data in `gs://github-repo/generative-ai/gemini/tuning/mlops-tune-and-eval/patient_1_glucose_examples.jsonl`. | ||
|
||
- Create a week of glucose sample data for one patient using the following prompt with Gemini: | ||
|
||
```none | ||
Create a CSV with a week's worth of example glucose values for a diabetic patient. The columns should be date, time, patient ID, and glucose value. Each day there should be timestamps for 7am, 8am, 11am, 12pm, 5pm, and 6pm. Most of the glucose values should be between 70 and 100. Some of the glucose values should be 100-150. | ||
``` | ||
|
||
- Flatten the CSV by doing the following: | ||
1. Open the CSV | ||
2. Press Ctrl + a to select all text | ||
3. Press Alt + Shift + i to go to the end of each line | ||
4. Add a newline character (i.e. \n) | ||
5. Press Delete to squash it all to a single line | ||
- Copy `glucose_examples_template.jsonl` (or create it if it doesn't exist) to `patient_X_glucose_examples.jsonl` | ||
- Copy the flattened CSV and paste it into the patient_X_glucose_examples.jsonl | ||
- Flatten the contents of the patient_X_glucose_examples.jsonl file using a JSON to JSONL converter online | ||
|
||
## Setup IAM, Tuning Examples, and Vertex AI Pipelines | ||
|
||
- Grant Default Compute Service Account IAM permissions | ||
|
||
```sh | ||
PROJECT_NUMBER=$(gcloud projects describe $(gcloud config get-value project) --format="value(projectNumber)") | ||
SERVICE_ACCOUNT="${PROJECT_NUMBER}[email protected]" | ||
|
||
gcloud projects add-iam-policy-binding $PROJECT_NUMBER \ | ||
--member="serviceAccount:${SERVICE_ACCOUNT}" \ | ||
--role="roles/aiplatform.user" | ||
gcloud projects add-iam-policy-binding $PROJECT_NUMBER \ | ||
--member="serviceAccount:${SERVICE_ACCOUNT}" \ | ||
--role="roles/storage.objectUser" | ||
``` | ||
|
||
- Enable the Cloud Resource Manager API | ||
|
||
```sh | ||
gcloud services enable cloudresourcemanager.googleapis.com | ||
``` | ||
|
||
- Create the pipeline root bucket | ||
|
||
```sh | ||
gsutil mb gs://vertex-ai-pipeline-root-$(date +%Y%m%d) | ||
``` | ||
|
||
## Run Vertex AI Pipelines | ||
|
||
- Install required packages and compile the pipeline | ||
|
||
```sh | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
pip install -r requirements.txt | ||
kfp dsl compile --py pipeline.py --output pipeline.json | ||
``` | ||
|
||
- Edit `pipeline.py` and change the following: | ||
|
||
- `project` - change to your project ID | ||
|
||
- Edit `submit_pipeline_job.py` and change the following: | ||
|
||
- `pipeline_root` - change to the `gs://vertex-ai-pipeline-root-<DATETIME>` bucket you created earlier | ||
- `project` - change to your project ID | ||
|
||
- Create the pipeline run | ||
|
||
```sh | ||
python submit_pipeline_job.py | ||
``` | ||
|
||
- For subsequent runs, change `baseline_model_endpoint` in `submit_pipeline_job.py` to a tuned model endpoint you want to compare against (typically the previously trained endpoint) |
Oops, something went wrong.