Allow custom model names for Dense, Sparse embeddings, fix Sparse Embeddings#146
Allow custom model names for Dense, Sparse embeddings, fix Sparse Embeddings#146tomaarsen wants to merge 6 commits intoalibaba:mainfrom
Conversation
Cuiyus
left a comment
There was a problem hiding this comment.
I think the _get_model_class function is a good design. Here, it can be renamed to _loading_model to make the meaning clearer.
Furthermore, I believe the aforementioned design can address the issues you mentioned: Fix SparseEncoder model loading and Removed _manual_sparse_encode.
Thank you again for your submission! If you have any questions, we can continue to communicate. Additionally, if you have time, please continue to be responsible for the current PR and supplement the corresponding tests. (Of course, I can also take over and make adjustments and fixes for the issues raised in this PR.)
python/zvec/extension/sentence_transformer_embedding_function.py
Outdated
Show resolved
Hide resolved
|
Thank you for the review! I'd be glad to help move this PR forward together. I fixed one of your concerns, and I had a question for the other one. You're also free to take over the PR if you prefer (I know I sometimes find it easier 😄).
|
|
@greptile |
Greptile SummaryThis PR refactors model loading across Dense, Sparse, and ReRanker classes by introducing a Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Last reviewed commit: 9abce9f |
Let's work together to merge PR. ❤️ |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This will effectively never happen, but it technically can
|
I addressed greptile's valid comments and ran
|
| return str(model.device) | ||
| return self._device or "cpu" | ||
|
|
||
| @property |
There was a problem hiding this comment.
Why is _get_model_class being decorated with @Property here (instead of being defined as an abstract method and not exposed externally)?
Are you hoping to expose the Sentence Transformer class so that users can perform other operations or learn more about Sentence Transformer?
There was a problem hiding this comment.
Ah, yeah it really doesn't need to be a property. I think I got distracted by the model_name, model_source, and device properties above 😄 I'll turn it into a normal method. Resolved in 2211e4d
Hello!
Pull Request overview
DefaultLocalSparseEmbeddingandDefaultLocalDenseEmbedding_get_modelacross DenseEmbedding, SparseEmbedding, and ReRanker via a_get_model_classpropertyencode_query&encode_documentexists for both SparseEncoder and SentenceTransformer._manual_sparse_encodefor older Sentence Transformer: I would recommend requiring at least Sentence Transformers v5.0 so the SparseEncoder can be used.SentenceTransformerReRankerwithDefaultLocalReRankerin the docs, as the previous doesn't exist anymore.Details:
This PR extends the support for local dense, sparse, and reranker models a good bit. I've had some installation issues, so I'm unable to properly run the tests at the moment, but you should get much clearer results for the SparseEmbedding class. I also simplified the sparse embedding post-processing using
model.decode, which also removes some issues with SparseCUDA and SparseCPU not implementing all operations.Please do let me know if you have any questions.