Zack Saadioui
8/26/2024
1
2
bash
ollama pull llama3
1
2
bash
ollama list
1
2
bash
ollama run llama3
1
2
3
4
bash
python -m venv langchain-env
source langchain-env/bin/activate # For Mac/Linux
langchain-env\Scripts\activate # For Windows
1
2
bash
pip install langchain-ollama
1
OllamaEmbeddings
1 2 3 4
# Example text to work with text = "LangChain framework allows you to create applications using LLMs effectively!" vector = embeddings.embed_query(text) print(vector) # Will print your embedding vector!
1
2
3
4
5
6
7
8
9
python
def embed_multiple_documents(embeddings):
texts = [
"LangChain integrates with various models to provide flexibility across tasks.",
"Ollama makes it easier to run models locally without heavy hardware needs."
]
vectors = embeddings.embed_documents(texts)
for vector in vectors:
print(vector[:10]) # Print first 10 elements of each vector
1
embed_documents
1
2
3
4
5
6
python
def retrieve_info(vectorstore):
retriever = vectorstore.as_retriever()
query = "What do dogs represent?"
retrieved_documents = retriever.invoke(query)
print(retrieved_documents[0].page_content)
Copyright © Arsturn 2024