Local document Q&A powered by Mistral 7b — no vectors, no embeddings, no cloud.
RAG-Vectorless uses PageIndex to build a hierarchical tree index of your documents, then navigates that tree with a local Mistral 7b model (via Ollama) to answer questions in natural language. Everything runs on your machine.
┌─────────────────┐ index() ┌──────────────────┐ PageIndex ┌─────────────────┐
│ Streamlit UI │ ───────────► │ RAG-Vectorless │ ────────────► │ DocumentIndexer │
│ or CLI │ │ (facade) │ │ (tree builder) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
query() │ save / load PageIndex JSON tree
▼ │
┌─────────────────┐ ▼
│ WorkspaceManager│ ┌───────────────────┐
│ (JSON on disk) │ │ workspace/*.json │
└─────────────────┘ └───────────────────┘
│
▼
┌─────────────────┐ ReAct loop ┌─────────────────┐
│ RAGAgent │ ────────────► │ OllamaClient │
│ (tool loop) │ tool calls │ (Mistral 7b) │
└─────────────────┘ ◄──────────── └─────────────────┘
The agent follows a ReAct loop:
- Calls
get_document_structureto see the document tree - Calls
get_page_contenton the most relevant pages - Produces a clean, cited answer — no hallucination of source references
- No vector database — document navigation via hierarchical tree index
- Fully local — Mistral 7b runs on-device via Ollama, no cloud API calls
- Streamlit chat UI — mobile-style chat interface with structured responses
- Multi-document — index and query PDFs and Markdown files
- Customer support persona — agent responds as a helpful support agent
- Answer sanitisation — strips page citations, doc references, and planning artefacts from output
- Thread-safe workspace — atomic JSON writes with file locking
- Typed exceptions — full exception hierarchy for precise error handling
- Dependency injection — swap LLM or workspace backend for testing
| Requirement | Version |
|---|---|
| Python | 3.9+ (tested on 3.14) |
| Ollama | Latest |
| Mistral model | ollama pull mistral |
| OS | macOS / Linux (tested on Mac Mini M4, 24 GB RAM) |
# 1. Clone the repo git clone https://github.com/Pramjeetk/RAG-Vectorless.git cd RAG-Vectorless # 2. Create and activate a virtual environment python3 -m venv .venv source .venv/bin/activate # 3. Install PageIndex (vendored) pip install -e PageIndex/ # 4. Install RAG-Vectorless pip install -e . # 5. Install Streamlit UI dependencies pip install streamlit markdown # 6. Pull the Mistral model ollama pull mistral
streamlit run ui/app.py
Open http://localhost:8501 in your browser.
Pages:
- Home — Overview and quick-start guide
- Documents — Upload and index PDF or Markdown files
- Chat — Select a document and ask questions in a mobile-style chat interface
# Check Ollama is reachable rag health # Index a PDF or Markdown file rag index ~/Documents/report.pdf # → doc_id: 20dc7696-d197-48c0-b30c-334bb3ac96fc # Ask a question rag query 20dc7696-d197-48c0-b30c-334bb3ac96fc "What are the key findings?" # JSON output (for scripting) rag query 20dc7696-... "What are the key findings?" --format json # List all indexed documents rag list # Delete a document rag delete 20dc7696-d197-48c0-b30c-334bb3ac96fc --yes
from rag_system import VectorlessRAG rag = VectorlessRAG() # Index once doc_id = rag.index("report.pdf") # Query any number of times result = rag.query(doc_id, "What are the main benefits?") print(result.answer) # List all documents for doc in rag.list_documents(): print(doc.id, doc.name) # Delete rag.delete_document(doc_id)
All settings can be overridden via environment variables or a .env file.
| Setting | Default | Environment Variable |
|---|---|---|
| Ollama server URL | http://localhost:11434 |
OLLAMA_BASE_URL |
| Ollama model | mistral |
OLLAMA_MODEL |
| Workspace directory | ./workspace |
WORKSPACE_DIR |
| Max agent turns | 10 |
MAX_AGENT_TURNS |
| LLM timeout (seconds) | 120.0 |
LLM_TIMEOUT |
| Log level | INFO |
LOG_LEVEL |
| Retry attempts | 3 |
RETRY_ATTEMPTS |
Copy .env.example to .env and edit as needed.
RAG-Vectorless/
├── ui/ # Streamlit UI
│ ├── app.py # Entry point — run this
│ ├── _shared.py # Shared helpers and RAG singleton
│ ├── assets/ # Logo and static assets
│ └── pages/
│ ├── 1_📄_Documents.py # Upload and index documents
│ └── 2_💬_Chat.py # Chat interface
├── rag_system/ # Core library
│ ├── agent.py # ReAct agent loop + ToolRegistry
│ ├── rag.py # VectorlessRAG facade
│ ├── indexer.py # PageIndex integration
│ ├── workspace.py # Thread-safe document store
│ ├── llm.py # OllamaClient with retry logic
│ ├── config.py # Settings (YAML + env vars)
│ ├── models.py # Pydantic domain models
│ ├── exceptions.py # Typed exception hierarchy
│ ├── interfaces.py # Protocol definitions (DI)
│ ├── logger.py # Centralised logging
│ └── cli.py # Typer CLI
├── PageIndex/ # Vendored PageIndex library
├── data/ # Sample knowledge base documents
├── tests/ # Test suite
├── .streamlit/config.toml # Streamlit theme (green/white)
├── pyproject.toml # Package metadata
└── requirements-dev.txt # Test dependencies
pip install -r requirements-dev.txt pytest tests/ -v
- No streaming — responses are returned after the full ReAct loop completes.
- No async — all operations are synchronous.
- Ollama only — other LLM providers require a new
LLMClientProtocolimplementation. - Local files only — workspace stores documents as JSON on disk; S3/cloud backends not implemented.
- Mistral 7b quality — small models may not always follow tool-calling instructions precisely; the answer sanitiser handles common artefacts.
MIT