Fix LlamaIndexEmbeddingOperator returning None vectors for all chunks#68424
Closed
bujjibabukatta wants to merge 1 commit into
Closed
Fix LlamaIndexEmbeddingOperator returning None vectors for all chunks#68424bujjibabukatta wants to merge 1 commit into
bujjibabukatta wants to merge 1 commit into
Conversation
…turning None vectors VectorStoreIndex._get_node_with_embedding() calls node.copy() internally before attaching embeddings, so reading node.embedding from the original node list after index construction always returned None. Fix by calling embed_model.get_text_embedding_batch() before building the index and assigning the results directly to the original node objects. VectorStoreIndex then skips re-embedding nodes that already carry a vector. Closes apache#68416
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LlamaIndexEmbeddingOperatorwas returningvector: Nonefor every chunk in its output, making the results unusable for downstream vector storage tasks.Root cause:
VectorStoreIndex._get_node_with_embedding()inllama-index-corecallsnode.copy()internally before attaching embedding vectors. This means embeddings are only stored on the internal copies, The original node objects in thenodeslist retainembedding=None.Minimal reproduction:
Fix
Pre-embed the nodes using embed_model.get_text_embedding_batch() before building the index and assign the results directly to the original node objects. Since VectorStoreIndex skips re-embedding nodes that already carry a vector, this avoids redundant API calls while ensuring node.embedding is correctly set on the objects we read from later.
Changes
providers/common/ai/.../operators/llamaindex_embedding.py - added pre-embedding step before VectorStoreIndex construction
providers/common/ai/tests/.../test_llamaindex_embedding.py - updated existing tests to mock get_text_embedding_batch, added regression test