mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-15 22:44:36 +00:00
community[minor]: Add support for modle2vec embeddings (#28507)
This PR add an embeddings integration for model2vec, the `Model2vecEmbeddings` class. - **Description**: [Model2Vec](https://github.com/MinishLab/model2vec) lets you turn any sentence transformer into a really small static model and makes running the model faster. - **Issue**: - **Dependencies**: model2vec ([pypi](https://pypi.org/project/model2vec/)) - **Twitter handle:**: - [x] **Add tests and docs**: - [Test](https://github.com/blacksmithop/langchain/blob/model2vec_embeddings/libs/community/langchain_community/embeddings/model2vec.py), [docs](https://github.com/blacksmithop/langchain/blob/model2vec_embeddings/docs/docs/integrations/text_embedding/model2vec.ipynb) - [x] **Lint and test**: --------- Co-authored-by: Abhinav KM <abhinav.m@zerone-consulting.com> Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@ EXPECTED_ALL = [
|
||||
"MlflowAIGatewayEmbeddings",
|
||||
"MlflowEmbeddings",
|
||||
"MlflowCohereEmbeddings",
|
||||
"Model2vecEmbeddings",
|
||||
"ModelScopeEmbeddings",
|
||||
"TensorflowHubEmbeddings",
|
||||
"SagemakerEndpointEmbeddings",
|
||||
|
11
libs/community/tests/unit_tests/embeddings/test_model2vec.py
Normal file
11
libs/community/tests/unit_tests/embeddings/test_model2vec.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from langchain_community.embeddings.model2vec import Model2vecEmbeddings
|
||||
|
||||
|
||||
def test_hugginggface_inferenceapi_embedding_documents_init() -> None:
|
||||
"""Test model2vec embeddings."""
|
||||
try:
|
||||
embedding = Model2vecEmbeddings("minishlab/potion-base-8M")
|
||||
assert len(embedding.embed_query("hi")) == 256
|
||||
except Exception:
|
||||
# model2vec is not installed
|
||||
assert True
|
Reference in New Issue
Block a user