Cookies

With your permission, we use Google Analytics cookies to measure visits and improve the site. Necessary cookies are always on. You can change your choice or withdraw consent anytime in the footer, under Cookie settings. Cookie Policy

Skip to content

RAG and Knowledge ·Intermediate

Qwen 3 Local RAG Reasoning Agent

About this app

Qwen3 (1.7b, 8b) - Alibaba's latest language models - Gemma3 (1b, 4b) - Google's efficient language models with multimodal capabilities - DeepSeek (1.5b) - Alternative model option - Comprehensive RAG System:

  • Complete open-source code
  • Step-by-step tutorial
  • Runs on your computer

Technical sheet

Category
RAG and Knowledge
Difficulty
Intermediate
Models
Llama, DeepSeek, Qwen
Frameworks
Agno, LangChain, Ollama (local)
Runs locally?
Yes (Ollama)
Required keys
None

License Apache-2.0 · content curated and maintained by Doutor AI.

Full tutorial

This RAG Application demonstrates how to build a powerful Retrieval-Augmented Generation (RAG) system using locally running Qwen 3 and Gemma 3 models via Ollama. It combines document processing, vector search, and web search capabilities to provide accurate, context-aware responses to user queries. Built with Agno v2.0.

Features

  • 🧠 Multiple Local LLM Options:
  • Qwen3 (1.7b, 8b) - Alibaba's latest language models
  • Gemma3 (1b, 4b) - Google's efficient language models with multimodal capabilities
  • DeepSeek (1.5b) - Alternative model option
  • 📚 Comprehensive RAG System:
  • Upload and process PDF documents
  • Extract content from web URLs
  • Intelligent chunking and embedding
  • Similarity search with adjustable threshold
  • 🌐 Web Search Integration:
  • Fallback to web search when document knowledge is insufficient
  • Configurable domain filtering
  • Source attribution in responses
  • 🔄 Flexible Operation Modes:
  • Toggle between RAG and direct LLM interaction
  • Force web search when needed
  • Adjust similarity thresholds for document retrieval
  • 💾 Vector Database Integration:
  • Qdrant vector database for efficient similarity search
  • Persistent storage of document embeddings
  • 🔧 Agno v2.0 Framework:
  • Uses Agno v2.0 Knowledge embedder system
  • Debug mode for enhanced development experience
  • Modern agent architecture with improved tool integration

How to Get Started

Prerequisites

  • Ollama installed locally
  • Python 3.8+
  • Qdrant running locally (via Docker) for vector storage
  • Exa API key (optional, for web search capability)
  • Agno v2.0 installed

Installation

  1. Clone the GitHub repository
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd rag_tutorials/qwen_local_rag
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Pull the required models using Ollama:
ollama pull qwen3:1.7b # Or any other model you want to use
ollama pull snowflake-arctic-embed # For embeddings
  1. Run Qdrant locally through Docker:
docker pull qdrant/qdrant

docker run -p 6333:6333 -p 6334:6334 \
    -v "$(pwd)/qdrant_storage:/qdrant/storage:z" \
    qdrant/qdrant
  1. Get your API keys (optional):
  • Exa API key (for web search fallback capability)
  1. Run the application:
streamlit run qwen_local_rag_agent.py

How It Works

  1. Document Processing:
  • PDF files are processed using PyPDFLoader
  • Web content is extracted using WebBaseLoader
  • Documents are split into chunks with RecursiveCharacterTextSplitter
  • Metadata is added to track source types and timestamps
  1. Vector Database:
  • Document chunks are embedded using Ollama's embedding models via Agno's OllamaEmbedder
  • Embeddings are stored in Qdrant vector database
  • Similarity search retrieves relevant documents based on query with configurable threshold
  1. Query Processing:
  • User queries are analyzed to determine the best information source
  • System checks document relevance using similarity threshold
  • Falls back to web search if no relevant documents are found (when enabled)
  • Supports forced web search mode via toggle
  1. Response Generation:
  • Local LLM (Qwen/Gemma/DeepSeek) generates responses based on retrieved context
  • Agno agents use debug mode for enhanced visibility into tool calls
  • Sources are cited and displayed to the user
  • Web search results are clearly indicated when used
  • Reasoning process is displayed for reasoning models

Configuration Options

  • Model Selection: Choose between different Qwen, Gemma, and DeepSeek models
  • RAG Mode: Toggle between RAG-enabled and direct LLM interaction
  • Search Tuning: Adjust similarity threshold (0.0-1.0) for document retrieval
  • Web Search: Enable/disable web search fallback and configure domain filtering
  • Debug Mode: Agents use debug mode by default for better visibility into tool calls and execution flow

Use Cases

  • Document Q&A: Ask questions about your uploaded documents
  • Research Assistant: Combine document knowledge with web search
  • Local Privacy: Process sensitive documents without sending data to external APIs
  • Offline Operation: Run advanced AI capabilities with limited or no internet access

Requirements

See requirements.txt for the complete list of dependencies.

From the same category

RAG and KnowledgeIntermediate

Agentic RAG Embedding Gemma

This Streamlit app demonstrates an agentic Retrieval-Augmented Generation (RAG) Agent using Google's EmbeddingGemma for embeddings and Llama 3.2 as th…

  • Llama
  • local
RAG and KnowledgeIntermediate

Agentic RAG with GPT-5

An agentic RAG application built with the Agno framework, featuring GPT-5 and LanceDB for efficient knowledge retrieval and question answering.

  • OpenAI

Need a tailor-made solution?

Not sure where to start with AI in your business? Get a free assessment and a tailored plan - no commitment.

Save hours every week with AI, no hassle

Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.

See plans