How to use TrueLens with Ollama and Langchain Conversational Rag #1927
Replies: 1 comment 4 replies
-
Hello @El-Moghazy2! I'm Dosu, here to help you solve bugs, answer your questions, and guide you as you work on your project. I'm ready to assist you while we wait for a human maintainer. How can I help you today? To use TruLens with your Conversational Retrieval Chain setup involving Ollama and Langchain, and evaluate it using LiteLLM as a provider, follow these steps:
This setup allows you to evaluate your Conversational Retrieval Chain using TruLens with LiteLLM as a provider, leveraging the RAG setup with Ollama and Langchain. The feedback function evaluates the relevance of the retrieved context using a chain of thought methodology [1][2]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the following RAG:
`llm = ChatOllama(
model='llama3.1:8b-instruct-q8_0',
temperature=0)
def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)
prompt = PromptTemplate(template=prompt_template_str,
input_variables=['context', 'question'])
def construct_rag_chain(llm, prompt, retriever):
memory = ConversationBufferMemory(
memory_key="chat_history",
return_messages=True,
output_key='answer'
)
rag_chain = ConversationalRetrievalChain.from_llm(
llm,
retriever=retriever,
memory=memory,
return_source_documents=True
)
return rag_chain
rag_chain = construct_rag_chain(llm, prompt, retriever)`
It is not obvious to me how to use TruLens with to evaluate this chain given LiteLLM as a provider:
provider = LiteLLM( model_engine="ollama/llama3.1:8b-instruct-q8_0", api_base="http://localhost:11434" )
If I follow the documentation which uses openAI provider I get different errors as it is not compatible.
Beta Was this translation helpful? Give feedback.
All reactions