Spaces:
Running
Download README.md from amer003100/vectorless_RAG: direct link, hf CLI and curl.
- Browser
- Download file 19.9 kB
-
https://huggingface.co/spaces/amer003100/vectorless_RAG/resolve/main/README.md
- Command line
-
hf download hf://spaces/amer003100/vectorless_RAG/README.md
-
curl -L -o README.md https://huggingface.co/spaces/amer003100/vectorless_RAG/resolve/main/README.md
title: Atlas Document Intelligence API
emoji: πΏ
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
πΏ Atlas β Enterprise Vectorless RAG & Document Intelligence Platform
Understand Documents. Discover Knowledge. Search the Live Web.
Production-grade Vectorless RAG platform with concurrent multi-document tree reasoning, isolated multi-tier memory, FastMCP live web search, PostgreSQL (Supabase) cloud persistence, and resilient dual LLM inference (Hugging Face + Groq zero-downtime failover).
π Ψ¬Ψ―ΩΩ Ψ§ΩΩ ΨΨͺΩΩΨ§Ψͺ / Table of Contents
- Overview & Core Philosophy
- Complete System Architecture
- Dual Retrieval & Decision Flow (PDF vs Web)
- Key Features & Capabilities
- Benchmark & Quantitative Evaluation (80 Questions)
- Tech Stack
- API Endpoints Reference
- Environment Variables
- Live Deployments
π Overview & Core Philosophy
Atlas redefines Document AI and Retrieval-Augmented Generation (RAG) by completely eliminating vector embeddings, arbitrary chunking, and similarity drift. Instead of blindly splitting text into 500-token chunks and computing cosine distance, Atlas models documents as Hierarchical Semantic Trees (PageIndex + PyMuPDF).
Every section, chapter, table, and figure preserves its parent-child lineage and exact physical page coordinates. When a user asks a question, an LLM reasoning agent traverses the outline tree, selects relevant nodes, and synthesizes answers with exact page citations.
If the attached document does not contain the answer, or if no document is attached, Atlas seamlessly activates its built-in FastMCP Web Search engine, querying the live internet, embedding clickable markdown links, and presenting verified external sources.
ποΈ Complete System Architecture
flowchart TB
subgraph Client_Layer["π₯οΈ Frontend Client (React 19 + Vite / Vercel)"]
direction TB
UI_Sidebar["Sidebar (Sessions, Multi-Chat & Unread Indicators)"]
UI_Explorer["Document Structure Explorer (Hierarchical Tree View)"]
UI_Chat["Concurrent Async Chat (Multi-Session Streaming)"]
UI_Sources["Interactive Source Badges (PDF Pages & Web Links)"]
UI_Memory["Knowledge Memory & Workspace Dossier View"]
UI_SSE["SSE Stream Parser & Background Dispatcher"]
UI_Storage[("Browser LocalStorage Cache")]
UI_CenterToast["Center Floating Notification Toast"]
UI_Sidebar <--> UI_Chat
UI_Chat <--> UI_Sources
UI_Chat <--> UI_SSE
UI_Chat <--> UI_Storage
UI_SSE --> UI_CenterToast
end
subgraph API_Layer["β‘ Backend Gateway (FastAPI / Hugging Face Spaces)"]
direction TB
Router_Chat["/ask & /chat Routers (Streaming SSE, Isolation)"]
Router_Docs["/documents Router (Upload, Structure Tree, Retry)"]
Router_Memory["/memory Router (Dossiers, Workspace Synthesis)"]
Router_Tools["/tools/web-search & MCP Endpoints"]
Worker_Pool["Asynchronous Background Worker Pool"]
end
subgraph MCP_Layer["π FastMCP Server & Live Web Engine"]
direction LR
FastMCP_Server["FastMCP ASGI Mount (/mcp via SSE/HTTP)"]
DDGS_Engine["DuckDuckGo / DDGS Threadpool Worker"]
Query_Sanitizer["Query Normalizer & URL Domain Extractor"]
FastMCP_Server <--> DDGS_Engine
DDGS_Engine <--> Query_Sanitizer
end
subgraph Core_Engine["π§ Vectorless RAG & Memory Pipelines"]
direction TB
Doc_Service["DocumentService (PageIndex API + PyMuPDF)"]
RAG_Pipeline["VectorlessRAG Pipeline (Multi-Doc Tree Search)"]
LLM_Service["LLMService (Tree Search, Synthesis, Citations)"]
Memory_Service["MemoryService (Short-Term, Long-Term, Global)"]
end
subgraph AI_Inference["π€ Resilient Dual-Provider LLM Engine"]
direction LR
HF_LLM["Hugging Face Serverless (Primary: Llama-3.1-8B)"]
Groq_LLM["Groq Cloud API (Zero-Downtime Fallback: Qwen-3.8-27b)"]
HF_LLM -.->|Auto-Failover on 402/Limit| Groq_LLM
end
subgraph Persistence_Layer["πΎ Enterprise Persistence & Database"]
direction TB
Mem_Store["MemoryStorage (In-Memory Hot Cache)"]
subgraph DB_System["PostgreSQL / Supabase (AWS eu-west-1)"]
PG_Pool["Threaded Connection Pool (psycopg2)"]
T_Meta[("doc_meta (Metadata & Statuses)")]
T_Indices[("doc_indices (JSONB Trees & Outline)")]
T_Chats[("chats & messages (Isolated Sessions)")]
T_Docs[("chat_documents (Multi-Doc Associations)")]
T_Memory[("knowledge_memory (Per-Doc Dossiers)")]
T_Global[("global_knowledge_summary (Workspace)")]
end
SQLite_Fallback[("SQLite Local Fallback (memory.db)")]
end
%% Wiring
Client_Layer <==>|REST API & SSE Streams| API_Layer
API_Layer <--> MCP_Layer
Router_Docs --> Worker_Pool
Worker_Pool --> Doc_Service
Router_Chat --> RAG_Pipeline
Router_Memory --> Memory_Service
Router_Tools --> MCP_Layer
Doc_Service --> Mem_Store
RAG_Pipeline --> LLM_Service
RAG_Pipeline <--> MCP_Layer
LLM_Service <==> AI_Inference
Mem_Store <--> PG_Pool
PG_Pool --> T_Meta & T_Indices & T_Chats & T_Docs & T_Memory & T_Global
PG_Pool -.->|Offline Failover| SQLite_Fallback
π§ Dual Retrieval & Decision Flow (PDF vs Web)
Atlas implements intelligent query routing to ensure maximum factual grounding:
flowchart TD
Start["User Query Received"] --> CheckDoc{"Is Document Attached to Session?"}
CheckDoc -- "Yes" --> TreeSearch["Concurrent Hierarchical Tree Search"]
TreeSearch --> MatchCheck{"Relevant Nodes Found in Document?"}
MatchCheck -- "Yes & No Web Query" --> GroundPDF["Grounded PDF Synthesis"]
GroundPDF --> CitePDF["Cite (Section: 'Title', Page: X)"]
CitePDF --> BadgePDF["Frontend Renders π Page Badges (Jumps to PDF Section)"]
MatchCheck -- "No (Doc Lacks Answer)" --> TriggerWeb1["Trigger FastMCP Live Web Search"]
CheckDoc -- "No (Conversational Mode)" --> IsGreeting{"Is Simple Greeting?"}
IsGreeting -- "Yes" --> ReplyChat["Conversational Atlas Response"]
IsGreeting -- "No (Informational / Links Query)" --> TriggerWeb2["Trigger FastMCP Live Web Search"]
TriggerWeb1 --> FastMCPExec["DDGS Threadpool Search & Fetch Snippets"]
TriggerWeb2 --> FastMCPExec
FastMCPExec --> GroundWeb["Live Web Grounded Synthesis"]
GroundWeb --> CiteWeb["Embed [Title](URL) & Append ### π Ψ§ΩΩ
Ψ΅Ψ§Ψ―Ψ± ΩΨ§ΩΨ±ΩΨ§Ψ¨Ψ· Ψ°Ψ§Ψͺ Ψ§ΩΨ΅ΩΨ©:"]
CiteWeb --> BadgeWeb["Frontend Renders π Web Badges (Click to Open in New Tab)"]
π Key Features & Capabilities
1. π³ Tree-Based Vectorless RAG (No Embeddings)
- Eliminates Vector Databases: No Qdrant, Milvus, Chroma, or Pinecone needed.
- Hierarchical Tree Traversal: Navigates documents via outline trees preserving chapter, section, and sub-section hierarchy.
- Concurrent Multi-Document Retrieval: Queries multiple attached documents in parallel using non-blocking asynchronous coroutines.
- Exact Document Grounding: Never hallucinates page coordinates. Every claim is verified against document nodes.
2. π FastMCP Live Web Search Server & Tool
- Model Context Protocol (FastMCP): Built with official
fastmcpspecification. - Mounted via ASGI at
/mcp: External MCP clients (Claude Desktop, Cursor, Antigravity) can connect directly via SSE/HTTP. - Automated Fallback Trigger: If a question cannot be answered from the document, Atlas automatically searches the live web without user intervention.
- Fast Search Execution: Powered by
ddgswith threadpool offloading and a 7-second safeguard timeout.
3. π― Dual Grounding & Interactive Citations
- Document Citations: Formatted as
(Section: "Section Title", Page: X). The frontend displays green document badges withBookOpenicons; clicking jumps to the exact section in the Document Structure Explorer. - Live Web Citations: Formatted as Markdown links
[Title](url)and structured under a dedicated### π Ψ§ΩΩ Ψ΅Ψ§Ψ―Ψ± ΩΨ§ΩΨ±ΩΨ§Ψ¨Ψ· Ψ°Ψ§Ψͺ Ψ§ΩΨ΅ΩΨ©:section. The frontend displays sky-blue badges withGlobeicons; clicking opens the URL directly in a new browser tab.
4. πΎ Enterprise PostgreSQL Persistence (Supabase)
- Production Database: Connected to Supabase PostgreSQL on AWS (
aws-0-eu-west-1.pooler.supabase.com:5432). - Connection Pooling: Powered by
psycopg2.pool.ThreadedConnectionPool(5 to 20 connections) for high-concurrency read/write. - JSONB Document Storage: Full document trees and section hierarchies are stored in native
JSONBcolumns for millisecond-level lookups. - Zero Data Loss: Documents, chat histories, memory dossiers, and summaries survive server restarts and redeployments.
- Automatic SQLite Failover: Automatically degrades to local SQLite if the remote PostgreSQL database is unreachable.
5. π§ Three-Tier Isolated Memory System
- Tier 1: Short-Term Session Memory: Isolated sliding window (last 6 turns) per chat session.
- Tier 2: Long-Term Session Memory: Automated rolling summaries synthesized when conversations grow, preventing prompt bloat while retaining context.
- Tier 3: Workspace Collective Knowledge Memory: Pre-computed knowledge dossiers for every indexed document aggregated into a unified global workspace knowledge summary (
/memory/knowledge).
6. β‘ Concurrent Async Multi-Session Chat
- Parallel Conversations: Users can run queries in multiple chat sessions simultaneously without blocking.
- Unread Indicators: Completed background queries trigger red notification badges on inactive sessions in the sidebar.
- Center Toast Notifications: Subtle, animated floating notifications in the center of the screen alert users when background tasks complete.
7. π‘οΈ Resilient Dual LLM Engine (HF + Groq)
- Primary Provider: Hugging Face Serverless Inference API (
meta-llama/Llama-3.1-8B-Instruct). - Zero-Downtime Fallback: Instantaneous failover to Groq Cloud API (
qwen/qwen3.8-27b) upon token credit exhaustion (402 Payment Required), rate limits (429), or provider timeouts.
π Benchmark & Quantitative Evaluation (80 Questions)
To rigorously validate the Vectorless RAG tree-retrieval architecture against real-world research documents, an end-to-end benchmark was conducted against a complex 28-page research paper (data.pdf: Unifying Large Language Models and Knowledge Graphs: A Roadmap, Pan et al., IEEE TKDE 2024).
The benchmark spans an annotated dataset of 80 curated questions across five distinct structural reasoning categories:
- 20 Local Questions: Specific section mechanisms and localized definitions.
- 20 Global Questions: Overarching paper taxonomy, cross-chapter frameworks, conclusions.
- 20 Multi-Hop Questions: Complex reasoning requiring information synthesis across 2+ disparate sections.
- 10 Summary Questions: Comprehensive section overviews and structural syntheses.
- 10 Numerical / Factual Questions: Specific grants, model counts, dates, and quantitative claims.
Overall Benchmark Results (N=80)
| Evaluation Metric | Measured Score | Production Target | Status |
|---|---|---|---|
| Answer Correctness | 87.73% | β₯ 80.0% | β High Quality Synthesis |
| Faithfulness (Anti-Hallucination) | 90.65% | β₯ 85.0% | β Strongly Grounded |
| Multi-Hop Correctness | 98.30% | β₯ 85.0% | β Exceptional Reasoning |
| Retrieval Recall | 73.08% | β₯ 70.0% | β Exceeded Target |
| Context Precision | 39.16% | β₯ 35.0% (top-k=3) | β High Efficiency |
| Citation Accuracy | 38.33% | β₯ 35.0% | β Page-Level Verified |
| Average Retrieval Latency | 7.1 ms (0.007s) | < 1,500 ms | β‘ Instant O(1) Index Traversal |
| Average Total Response Latency | 1.801 s | < 3.0 s | β‘ Ultra-fast End-to-End |
| Average Cost per Query | $0.000919 (< $0.001) | < $0.005 | π° Highly Cost-Effective (~0.09Β’) |
| Total Benchmark Cost (80 queries) | $0.0735 | < $0.50 | π° Production-ready |
Performance Breakdown by Query Category
| Category | Questions (N) | Retrieval Recall | Context Precision | Answer Correctness | Faithfulness | Multi-Hop / Grounding | Avg Latency | Cost / Query |
|---|---|---|---|---|---|---|---|---|
| Multi-Hop Questions | 20 | 68.3% | 47.5% | 98.3% | 96.0% | 98.3% Correct | 1.86 s | $0.000997 |
| Summary Questions | 10 | 91.0% | 50.0% | 90.7% | 100.0% | 100.0% Grounded | 1.77 s | $0.000898 |
| Local Questions | 20 | 87.5% | 32.5% | 80.2% | 94.0% | 94.0% Grounded | 1.83 s | $0.000890 |
| Numerical / Factual | 10 | 100.0% | 35.0% | 80.0% | 100.0% | 100.0% Grounded | 1.63 s | $0.000867 |
| Global Questions | 20 | 41.0% | 34.2% | 87.1% | 72.6% | 87.1% Correct | 1.78 s | $0.000907 |
Evaluation Assets in Repository
- π Full Detailed Report:
evaluation/BENCHMARK_REPORT.md - π Curated 80-Question Dataset:
evaluation/eval_dataset.json - π Raw Test Execution Outputs:
evaluation/eval_results.json - π§ͺ Automated Evaluation Runner:
evaluation/eval_runner.py
π οΈ Tech Stack
| Domain | Technology / Library | Role |
|---|---|---|
| API Gateway | FastAPI (Python 3.11, async runtime) | REST routing, SSE streaming, static file serving |
| Package Manager | uv (Astral) |
Ultra-fast dependency resolution and compilation |
| MCP Integration | fastmcp (4.1.0) + mcp (2.3.0) |
Model Context Protocol server mounted at /mcp |
| Web Search | ddgs (DuckDuckGo) |
Zero-config live web search engine |
| Primary LLM | huggingface-hub (meta-llama/Llama-3.1-8B-Instruct) |
Tree search and grounded response generation |
| Fallback LLM | openai (qwen/qwen3.8-27b via Groq Cloud) |
Ultra-fast failover inference (~0.20s TTFT) |
| Document Indexer | PageIndexClient + PyMuPDF (fitz) |
Hierarchical outline extraction & figure mining |
| Persistence | PostgreSQL (Supabase) + psycopg2-binary |
Cloud session, tree, and memory persistence |
| Local Fallback DB | SQLite (memory.db) |
Local offline cache and resilient fallback |
| Frontend UI | React 19 + Vite + Tailwind CSS 4 | Responsive, modern document workspace |
| Icons & Styling | lucide-react + custom design system |
Clean, accessible design language |
| Deployments | Docker on Hugging Face Spaces + Vercel | Scalable containerized API + edge-deployed SPA |
π API Endpoints Reference
1. Research & Chat
POST /askβ Stream grounded research answer across single/multiple documents, or pure conversational mode with FastMCP web search.POST /chat/newβ Create a new isolated chat session.GET /chatsβ List all persisted chat sessions with unread statuses.GET /chat/{chat_id}/historyβ Retrieve message history for a session.POST /chat/{chat_id}/attachβ Attach an indexed document to a session.POST /chat/{chat_id}/attach-multipleβ Attach multiple documents simultaneously.GET /chat/{chat_id}/documentsβ List all documents attached to a session.DELETE /chat/{chat_id}/document/{doc_id}β Detach a specific document.DELETE /chat/{chat_id}/documentβ Detach all documents from a session.DELETE /chat/{chat_id}β Permanently delete a chat session.PATCH /chat/{chat_id}/titleβ Rename a conversation session.
2. FastMCP & Web Search Tools
GET/POST /mcpβ FastMCP server endpoint supporting Model Context Protocol via SSE/HTTP.POST /tools/web-searchβ Direct REST endpoint for live web searches (query,max_results).
3. Document Library
POST /uploadβ Upload PDF to trigger asynchronous hierarchical tree indexing (HTTP 202).GET /documentsβ List all ingested documents, page counts, and statuses.GET /documents/{document_id}β Get metadata and status for a document.GET /documents/{document_id}/treeβ Retrieve the full hierarchical outline tree.DELETE /documents/{document_id}β Permanently delete a document and its cached indices.POST /documents/{document_id}/retryβ Retry indexing for a failed document.
4. Memory & Collective Knowledge
GET /memory/knowledgeβ Retrieve workspace master knowledge summary and all dossiers.POST /memory/knowledge/refreshβ Synthesize and rebuild workspace global knowledge memory.GET /memory/dossier/{doc_id}β Fetch structured knowledge dossier for a document.GET /memory/chat/{chat_id}β Inspect short-term turns and long-term rolling summary.POST /memory/chat/{chat_id}/summarizeβ Force-generate or update session long-term memory.
5. Health & Diagnostics
GET /healthβ Check API status, database connection, FastMCP status, and indexed document counts.
βοΈ Environment Variables
Configure these variables in your .env file or in Hugging Face Space Settings β Variables and secrets:
# Database Persistence (Supabase PostgreSQL or Local Docker)
DATABASE_URL="postgresql://postgres.USER:PASSWORD@aws-0-eu-west-1.pooler.supabase.com:5432/postgres"
# Hugging Face Inference Token (Primary Provider)
HF_TOKEN="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Groq Cloud API (Automatic Zero-Downtime Fallback)
GROQ_API_KEY="gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
GROQ_CHAT_MODEL="qwen/qwen3.8-27b"
GROQ_RETRIEVAL_MODEL="qwen/qwen3.8-27b"
# PageIndex Ingestion API Keys (Rotated for High Throughput)
PAGEINDEX_API_KEY_1="your_pageindex_api_key_1"
PAGEINDEX_API_KEY_2="your_pageindex_api_key_2"
PAGEINDEX_API_KEY_3="your_pageindex_api_key_3"
# Model Selection (Optional)
HF_RETRIEVAL_MODEL="meta-llama/Llama-3.1-8B-Instruct"
HF_CHAT_MODEL="meta-llama/Llama-3.1-8B-Instruct"
π Live Deployments
- Frontend Application (Vercel): https://vectorless-front-8gpg.vercel.app
- Backend API (Hugging Face Spaces): https://amer003100-vectorless-rag.hf.space
- Interactive Swagger Docs: https://amer003100-vectorless-rag.hf.space/docs
- FastMCP Endpoint:
https://amer003100-vectorless-rag.hf.space/mcp