support batch embeddings and zero-copy numpy returns#2077
Closed
kavorite wants to merge 2 commits intoabetlen:mainfrom
Closed
support batch embeddings and zero-copy numpy returns#2077kavorite wants to merge 2 commits intoabetlen:mainfrom
kavorite wants to merge 2 commits intoabetlen:mainfrom
Conversation
- Add n_seq_max parameter to `Llama` class to enable batch embeddings (defaults to 1 for backward compatibility) - Add `return_numpy` support to convert between numpy arrays and lists with zero copies - Update `normalize_embedding()` to keep numpy arrays as numpy arrays for zero-copy efficiency - Update `test_embed_numpy` to use `n_seq_max=16` for batch embedding tests Enables batch embedding support which was previously failing with llama_decode errors due to `n_seq_max=1` limitation.
Replace 'Any' with proper Union types and add @overload signatures to provide precise type hints based on input type (str vs List[str]), return_numpy flag, and return_count flag. This enables better IDE autocomplete and type checking for callers.
Author
|
this is addressed in #2058, which is cleaner. I think perhaps I will keep this locally until that is merged; if it is reopened it will address the numpy piece only, and hopefully with less bloat due to spuriously altered formatting |
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.
Llamaclass to enable batch embeddings (defaults to 1 for backward compatibility)return_numpysupport to convert between numpy arrays and lists with zero copiesnormalize_embedding()to keep numpy arrays as numpy arrays for zero-copy efficiencytest_embed_numpyto usen_seq_max=16for batch embedding testsEnables batch embedding support which was previously failing with llama_decode errors due to
n_seq_max=1limitation. This also fixes a bug in a repo I was working on that consumes this functionality to mass index GitHub repos for semantic multivector search on the machine under my desk (luh mao).