Skip to content

Added Examples for Batched Text Embeddings #571

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
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 on how to run the new example.

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]
Text 3: First 5 dims: [0.042, -0.009, -0.079, -0.047, 0.038]
Text 4: First 5 dims: [0.033, -0.023, -0.034, 0.013, 0.023]
Text 5: First 5 dims: [0.051, -0.038, -0.081, -0.007, 0.026]

@aparna534 aparna534 requested a review from a team as a code owner April 16, 2025 17:34
@github-actions github-actions bot added the status:awaiting review PR awaiting review from a maintainer label Apr 16, 2025
@aparna534 aparna534 changed the title Add Example for Batched Text Embeddings Added Examples for Batched Text Embeddings Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:awaiting review PR awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant