You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added a very descriptive title to this question.
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
Commit to Help
I commit to help with one of those options 👆
Example Code
fromlangchain.llmsimportOllamafromlangchain.promptsimportPromptTemplatefromlangchain.chainsimportRetrievalQAfromlangchain.vectorstoresimportChromafromlangchain.embeddingsimportOllamaEmbeddings# Initialize Ollama embeddings and LLMollama_embeddings=OllamaEmbeddings(model="bge-m3:latest", base_url="http://localhost:11434")
ollama_llm=Ollama(model="gemma3:27b", base_url="http://localhost:11434")
# Load the vector store from diskchroma_db=Chroma(persist_directory="./text2/chroma_db", embedding_function=ollama_embeddings)
# Define a prompt templateprompt_template=PromptTemplate(
input_variables=["context", "question"],
template="From the context below, extract the exact number for the question. If not found, say 'Not Available'. Context: {context}. Question: {question}."
)
# Create the RetrievalQA chainqa_chain=RetrievalQA.from_chain_type(
llm=ollama_llm,
retriever=chroma_db.as_retriever(search_kwargs={"k": 300}),
chain_type_kwargs={"prompt": prompt_template}
)
# Function to answer questions with debug outputdefanswer_question(question):
# Retrieve context for debuggingdocs=chroma_db.similarity_search(question, k=300)
retrieved_context="\n".join([doc.page_contentfordocindocs])
print("Retrieved Context:\n", retrieved_context)
result=qa_chain({"query": question})
returnresult["result"]
# Example usagequestion="how many incidents were there in 2019?"answer=answer_question(question)
print(f"Question: {question}")
print(f"Answer: {answer}")
Description
Hi guys, i am working on this RAG implementation running on Langchain, Ollama and ChromaDB.
preface: this is a smaller version of the workflow that I am running for my own testing, my desktop specifications are not ideal but ill have to make do.
The retrival from the vector database using BGE-m3 is working fine. The issue arises when it comes to the model answering the question based on the information from the vector database. The picture below shows the response from the model.
do let me know if there are any modifications i can make to the code to improve the model reasoning and answering.
my initial thoughts on this issue:
model is not receiving information from the vector database
model is not good enough (interms of generalization)
model has a small context length that does not allow large amount of information to be taken into account
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
Hi guys, i am working on this RAG implementation running on Langchain, Ollama and ChromaDB.
preface: this is a smaller version of the workflow that I am running for my own testing, my desktop specifications are not ideal but ill have to make do.
The retrival from the vector database using BGE-m3 is working fine. The issue arises when it comes to the model answering the question based on the information from the vector database. The picture below shows the response from the model.
do let me know if there are any modifications i can make to the code to improve the model reasoning and answering.
my initial thoughts on this issue:
System Info
AMD 6800
i5-10400F
16 GB DDR4
Beta Was this translation helpful? Give feedback.
All reactions