Response is not pulling from the knowledge base?

from phi.agent import Agent
from phi.model.ollama import Ollama
from phi.embedder.ollama import OllamaEmbedder
from phi.vectordb.qdrant import Qdrant
from phi.storage.agent.sqlite import SqlAgentStorage
from phi.playground import Playground, serve_playground_app

import os
#QDRANT_URL = os.getenv(“QDRANT_URL”)
QDRANT_URL_LOCAL = “http://localhost:6333/dashboard
#QDRANT_API_KEY = os.getenv(“QDRANT_API_KEY”)

#create vector DB
vector_db = Qdrant(
collection = “phidata-qdrant”,
url = QDRANT_URL_LOCAL,
embedder = OllamaEmbedder()
)

from phi.knowledge.pdf import PDFUrlKnowledgeBase
knowledge_base = PDFUrlKnowledgeBase(
urls=[“https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf”],
vector_db = vector_db
)

agent_ollama = Agent(
name = “Agentic RAG”,
agent_id = ‘agentic-rag’,
model = Ollama(id=‘llama3.1:8b’),
knowledge = knowledge_base,
use_tools=True,
search_knowledge = True,
read_chat_history = True,
show_tool_calls = True,
storage = SqlAgentStorage(table_name=‘phidata’,db_file=“agents_rag.db”),
instructions = [
“Always search your knowledge base first and use it of available.”,
“share the page number or source URL of the information you used in your response.”,
“Important: Use tables where possible.”,

],
debug_mode=True,
markdown=True,

)

app = Playground(agents=[agent_ollama]).get_app()

if name == “main”:
serve_playground_app(“agentic_rag_ui:app”, reload=True)

Hi @konasudheer
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 24 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hi @konasudheer

Did you run
knowledge_base.load(recreate=False)
the first time?

hi @konasudheer . i’m facing the same issue and it seems like the problem is with the Ollama model. Maybe its a limitation of it.

Hello @Duarte and @konasudheer

Instead of setting search_knowledge = True, , can you please set add_references=True. The difference is that with search_knowledge, we provide the model with a tool to query the knowledge base, enabling Agentic RAG. But if you set add_references, we add the relevant data from the document to your prompt, enabling traditional RAG.

Ollama models are not the most reliable at tool calling so tradition RAG works better with them. Please let me know if you have any questions

Hello @yash ,
Thanks for the suggestion. I’ve made the change using the llama3.2 model but unfortunately the results aren’t that good. The response are not accurate and there are too many hallucinations. Is there any plan or ongoing action to enable the agentic rag for ollama models?

Thanks

Hey @Duarte, have you had a chance to try Llama 3.3? It has native tool-calling support, and I’ve been using it for RAG with really promising results! At the end of the day, it all comes down to how well the model handles tool calls, and this one does a great job. Would love to hear your thoughts if you get a chance to test it out!

Hi @manthanguptaa ,
Thanks for taking time to reply to my message. Well, the problem now would be capability to have it running locally since it is a huge model requiring a lot to use it. Do you have any suggestion of an open source light weight model?

Can you try llama3.2 with the class OllamaTools? Let me know if you are able to get better results