Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update Patents Understanding Notebook to use Batch Prediction #1609

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

holtskinner
Copy link
Collaborator

@holtskinner holtskinner commented Jan 8, 2025

Description

Use Batch Prediction to save on latency/processing costs and load data directly to/from BigQuery.

NOTE: Will change to Gemini 2.0 once it supports Batch Prediction to use higher quality Object Detection capabilities.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi @holtskinner and reviewers,

I'm currently reviewing this pull request and will post my feedback in a few minutes. In the meantime, I'm providing this summary of the pull request's content to help you and other reviewers quickly understand the changes and intent.

This pull request, titled "fix: Update Patents Understanding Notebook to use Batch Prediction", aims to improve the efficiency and cost-effectiveness of the patents understanding notebook by switching from individual predictions to batch prediction using Vertex AI. The description mentions that publishing should wait until Gemini 2.0 fully supports batch prediction for optimal object detection.

Here's a summary of the changes:

  • gemini/use-cases/document-processing/patents_understanding.ipynb: This Jupyter Notebook has undergone several modifications:
    • Lines 103-106: Added hyperlinks to Michael Munn's and Michael Sherman's GitHub profiles in the overview section.
    • Lines 114-117: Updated the description to explicitly mention using "Batch Prediction for Gemini 2.0 Flash in Vertex AI" and provided a link to the relevant documentation.
    • Lines 142, 202: Execution counts were updated (1 -> null, null -> 3).
    • Lines 227-243: Removed unnecessary imports (import json, from google.genai.types import GenerateContentConfig, Part, import pandas as pd).
    • Line 288: Changed the model ID from gemini-2.0-flash-exp to gemini-1.5-flash-002.
    • Lines 317-323: Added a note indicating that the BigQuery query is limited to 5 documents for tutorial purposes.
    • Lines 342-347: Added LIMIT 5 to the BigQuery query to reduce processing time.
    • Line 363: Execution count updated (102 -> 43).
    • Lines 478-827: The notebook was significantly restructured to incorporate batch prediction. This involved creating a BigQuery dataset and table for batch prediction requests, creating JSON requests for batch processing, submitting the batch job to Vertex AI, polling for job completion, and loading and processing the results. The original individual prediction processing was removed.

I hope this helps!


Here's a little haiku to brighten your day:

Batch jobs hum along,
Data flows, a silent stream,
Efficiency reigns.

Copy link
Contributor

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

@holtskinner holtskinner marked this pull request as ready for review January 9, 2025 20:30
@holtskinner holtskinner requested a review from a team as a code owner January 9, 2025 20:30
@holtskinner holtskinner merged commit 86220f1 into main Jan 9, 2025
10 checks passed
@holtskinner holtskinner deleted the patents-batch branch January 9, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant