Skip to content

docs: batch embeddings (Fixes #147) #569

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

Closed
wants to merge 2 commits into from

Conversation

aparna534
Copy link

Description

This adds a working example of batch text embeddings using genai.embed_content().

Key Changes:

  • New file: examples/gemini/python/batched_embeddings.py
    • It processes multiple texts in a single API call
    • It uses environment variables for API key configuration
    • It includes comprehensive error handling
  • Updated: examples/gemini/python/README.md with instructions

Verification:

# Local test output

Success! Generated 5 embeddings:
Text 1: First 5 dims: [0.053, -0.001, -0.065, -0.005, 0.026]
Text 2: First 5 dims: [0.045, -0.028, -0.061, 0.012, 0.011]

@aparna534 aparna534 requested a review from a team as a code owner April 15, 2025 19:55
Copy link

google-cla bot commented Apr 15, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the status:awaiting review PR awaiting review from a maintainer label Apr 15, 2025
@aparna534 aparna534 force-pushed the fix/batched-embeddings branch from 2563ebc to 3a124b3 Compare April 15, 2025 20:08
@aparna534 aparna534 force-pushed the fix/batched-embeddings branch from 3a124b3 to 79e614f Compare April 16, 2025 09:35
@aparna534
Copy link
Author

@googlebot I signed the CLA

@aparna534 aparna534 closed this Apr 16, 2025
@github-actions github-actions bot removed the status:awaiting review PR awaiting review from a maintainer label Apr 16, 2025
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