mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-07 18:35:22 +03:00
The sentence transformers was a dup of the HF one. This is a breaking change (model_name vs. model) for anyone using `SentenceTransformerEmbeddings(model="some/nondefault/model")`, but since it was landed only this week it seems better to do this now rather than doing a wrapper.
3.0 KiB
3.0 KiB
In [1]:
!pip install sentence_transformers > /dev/null[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m A new release of pip is available: [0m[31;49m23.0.1[0m[39;49m -> [0m[32;49m23.1.1[0m [1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m To update, run: [0m[32;49mpip install --upgrade pip[0m
In [2]:
from langchain.embeddings import HuggingFaceEmbeddings, SentenceTransformerEmbeddings In [ ]:
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
# Equivalent to SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")In [4]:
text = "This is a test document."In [5]:
query_result = embeddings.embed_query(text)In [6]:
doc_result = embeddings.embed_documents([text, "This is not a test document."])In [ ]: