Skip to content

Comments

fix: batch embedding calls to prevent provider limit errors#73

Open
haosenwang1018 wants to merge 1 commit intozilliztech:mainfrom
haosenwang1018:fix/embed-batch-size-limit
Open

fix: batch embedding calls to prevent provider limit errors#73
haosenwang1018 wants to merge 1 commit intozilliztech:mainfrom
haosenwang1018:fix/embed-batch-size-limit

Conversation

@haosenwang1018
Copy link

Problem

memsearch index crashes with ClientError: 400 INVALID_ARGUMENT when a markdown file produces more than 100 chunks while using the Google embedding provider. This is because _embed_and_store() sends all chunks to embed() in a single call with no batching.

Fixes #72

Fix

Add batching in _embed_and_store() with a default batch_size of 96, which stays safely under the lowest known provider limit (Google: 100).

Changes

  • src/memsearch/core.py: Batch embed() calls in _embed_and_store()

The change is minimal and backward-compatible — behavior is identical for files that produce fewer than 96 chunks.

When a markdown file produces more than 100 chunks, the single embed()
call exceeds Google's BatchEmbedContentsRequest limit of 100 items,
causing a 400 INVALID_ARGUMENT error.

Add batching in _embed_and_store() with a default batch_size of 96,
which stays safely under the lowest known provider limit (Google: 100).
This also future-proofs against similar limits in other providers
(Voyage: 128, OpenAI: 2048).

Fixes zilliztech#72
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.

[BUG] Google embedding provider fails with >100 chunks: BatchEmbedContentsRequest limit

1 participant