Zack Saadioui
8/24/2024
1
2
bash
pip install langchain huggingface-hub sentence-transformers datasets1
2
python
from langchain_huggingface.embeddings import HuggingFaceEmbeddings1
HuggingFaceEmbeddings1
2
3
python
model_name = "sentence-transformers/all-mpnet-base-v2"
embeddings = HuggingFaceEmbeddings(model_name=model_name)1
HuggingFaceEmbeddings1
2
3
4
5
6
python
text = "This is an example document to test the embeddings."
docs = [
    "Hugging Face creates powerful AI applications.",
    "LangChain is a useful tool for manipulating language data."
]1
2
3
python
query_result = embeddings.embed_query(text)
doc_results = embeddings.embed_documents(docs)1
embed_query1
2
3
python
print(query_result:5)
print(doc_results)1
huggingface-hub1
2
bash
pip install huggingface-hubCopyright © Arsturn 2025