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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RAG Engine - Interactive Architecture Showcase</title>
|
| 7 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 10 |
+
<link rel="stylesheet" href="style.css">
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<div class="app-container">
|
| 14 |
+
<!-- Sidebar -->
|
| 15 |
+
<aside class="sidebar">
|
| 16 |
+
<div class="brand">
|
| 17 |
+
<div class="brand-icon">🧠</div>
|
| 18 |
+
<div class="brand-info">
|
| 19 |
+
<h2>RAG Engine</h2>
|
| 20 |
+
<span class="badge">Architecture Showcase</span>
|
| 21 |
+
</div>
|
| 22 |
+
</div>
|
| 23 |
+
|
| 24 |
+
<nav class="nav-menu">
|
| 25 |
+
<button class="nav-item active" onclick="switchTab('ask')">
|
| 26 |
+
<span class="icon">💬</span> Ask & Retrieve
|
| 27 |
+
</button>
|
| 28 |
+
<button class="nav-item" onclick="switchTab('inspector')">
|
| 29 |
+
<span class="icon">🔬</span> Pipeline Inspector
|
| 30 |
+
</button>
|
| 31 |
+
<button class="nav-item" onclick="switchTab('knowledge')">
|
| 32 |
+
<span class="icon">📚</span> Knowledge Base
|
| 33 |
+
</button>
|
| 34 |
+
<button class="nav-item" onclick="switchTab('architecture')">
|
| 35 |
+
<span class="icon">📐</span> How RAG Works
|
| 36 |
+
</button>
|
| 37 |
+
</nav>
|
| 38 |
+
|
| 39 |
+
<div class="sidebar-stats">
|
| 40 |
+
<h4>Knowledge Base Stats</h4>
|
| 41 |
+
<div class="stat-row">
|
| 42 |
+
<span>Documents:</span>
|
| 43 |
+
<strong id="stat-docs">3</strong>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="stat-row">
|
| 46 |
+
<span>Indexed Chunks:</span>
|
| 47 |
+
<strong id="stat-chunks">6</strong>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="stat-row">
|
| 50 |
+
<span>Retrieval:</span>
|
| 51 |
+
<strong>Hybrid (Vector + BM25)</strong>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div class="sidebar-footer">
|
| 56 |
+
<a href="https://github.com/JayanGupta/RAG-Engine" target="_blank" class="github-link">
|
| 57 |
+
<svg height="16" width="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
|
| 58 |
+
View Python Source Code
|
| 59 |
+
</a>
|
| 60 |
+
</div>
|
| 61 |
+
</aside>
|
| 62 |
+
|
| 63 |
+
<!-- Main Content Area -->
|
| 64 |
+
<main class="main-content">
|
| 65 |
+
<!-- Tab 1: Ask & Retrieve -->
|
| 66 |
+
<section id="tab-ask" class="tab-content active">
|
| 67 |
+
<header class="content-header">
|
| 68 |
+
<h1>Ask Grounded Questions</h1>
|
| 69 |
+
<p>Enter any query to see hybrid semantic search, context augmentation, and answer synthesis in real time.</p>
|
| 70 |
+
</header>
|
| 71 |
+
|
| 72 |
+
<div class="sample-queries">
|
| 73 |
+
<span>Try asking:</span>
|
| 74 |
+
<button class="sample-pill" onclick="setQuery('What temperature must superconducting qubits operate at?')">Quantum: Operating Temperature?</button>
|
| 75 |
+
<button class="sample-pill" onclick="setQuery('What is the primary mirror of the James Webb Space Telescope made of?')">JWST: Mirror Composition?</button>
|
| 76 |
+
<button class="sample-pill" onclick="setQuery('What technologies are used for long-duration energy storage exceeding 8 hours?')">Energy: Long-Duration Storage?</button>
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
<div class="search-box-card">
|
| 80 |
+
<div class="search-input-wrapper">
|
| 81 |
+
<input type="text" id="query-input" placeholder="Ask a question based on indexed knowledge..." value="What temperature must superconducting qubits operate at?">
|
| 82 |
+
<button class="btn-primary" onclick="runQuery()">Execute Query</button>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
|
| 86 |
+
<div id="answer-section" class="answer-section">
|
| 87 |
+
<!-- Populated dynamically -->
|
| 88 |
+
</div>
|
| 89 |
+
</section>
|
| 90 |
+
|
| 91 |
+
<!-- Tab 2: Pipeline Inspector -->
|
| 92 |
+
<section id="tab-inspector" class="tab-content">
|
| 93 |
+
<header class="content-header">
|
| 94 |
+
<h1>🔬 RAG Pipeline Inspector</h1>
|
| 95 |
+
<p>Observe how the query is broken down across Dense Vector Search, Sparse BM25 Keyword Search, and Reciprocal Rank Fusion (RRF).</p>
|
| 96 |
+
</header>
|
| 97 |
+
|
| 98 |
+
<div class="inspector-grid">
|
| 99 |
+
<div class="inspector-card">
|
| 100 |
+
<h3>1️⃣ Dense Vector Search</h3>
|
| 101 |
+
<p class="subtitle">Measures semantic similarity via cosine distance.</p>
|
| 102 |
+
<div id="dense-results-list" class="results-mini-list"></div>
|
| 103 |
+
</div>
|
| 104 |
+
|
| 105 |
+
<div class="inspector-card">
|
| 106 |
+
<h3>2️⃣ Sparse BM25 Search</h3>
|
| 107 |
+
<p class="subtitle">Captures exact lexical matches and keyword occurrences.</p>
|
| 108 |
+
<div id="bm25-results-list" class="results-mini-list"></div>
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
<div class="rrf-section">
|
| 113 |
+
<h3>3️⃣ Reciprocal Rank Fusion (RRF) Merge</h3>
|
| 114 |
+
<p class="subtitle">Combines dense and sparse rankings: <code>Score = sum( weight / (60 + rank) )</code></p>
|
| 115 |
+
<div id="fused-results-list" class="fused-table-card"></div>
|
| 116 |
+
</div>
|
| 117 |
+
</section>
|
| 118 |
+
|
| 119 |
+
<!-- Tab 3: Knowledge Base -->
|
| 120 |
+
<section id="tab-knowledge" class="tab-content">
|
| 121 |
+
<header class="content-header">
|
| 122 |
+
<h1>📚 Knowledge Base Manager</h1>
|
| 123 |
+
<p>View pre-loaded articles or add your own custom notes to test real-time client-side chunking and indexing.</p>
|
| 124 |
+
</header>
|
| 125 |
+
|
| 126 |
+
<div class="kb-layout">
|
| 127 |
+
<div class="kb-list-pane">
|
| 128 |
+
<h3>Indexed Documents</h3>
|
| 129 |
+
<div id="kb-docs-list" class="kb-docs-list"></div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<div class="kb-add-pane">
|
| 133 |
+
<h3>Index a New Document</h3>
|
| 134 |
+
<input type="text" id="new-doc-title" placeholder="Document Title (e.g. Transformers in Deep Learning)" class="form-input">
|
| 135 |
+
<textarea id="new-doc-text" placeholder="Paste document text here..." class="form-textarea" rows="6"></textarea>
|
| 136 |
+
<button class="btn-primary" onclick="addNewDocument()">Index into Knowledge Base</button>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</section>
|
| 140 |
+
|
| 141 |
+
<!-- Tab 4: How RAG Works -->
|
| 142 |
+
<section id="tab-architecture" class="tab-content">
|
| 143 |
+
<header class="content-header">
|
| 144 |
+
<h1>📐 How Retrieval-Augmented Generation Works</h1>
|
| 145 |
+
<p>A transparent breakdown of the architecture, trade-offs, and why hybrid search outperforms naive vector-only systems.</p>
|
| 146 |
+
</header>
|
| 147 |
+
|
| 148 |
+
<div class="architecture-cards-grid">
|
| 149 |
+
<div class="arch-card">
|
| 150 |
+
<div class="arch-step">Step 1</div>
|
| 151 |
+
<h3>Document Chunking</h3>
|
| 152 |
+
<p>Embedding a 50-page document into a single vector averages out specific facts. We split text into overlapping windows (~400 words with 50-word overlap) to preserve local semantic meaning.</p>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="arch-card">
|
| 155 |
+
<div class="arch-step">Step 2</div>
|
| 156 |
+
<h3>Dual Indexing</h3>
|
| 157 |
+
<p>Chunks are indexed in two distinct data structures: a <strong>vector index</strong> for conceptual similarity and a <strong>BM25 index</strong> for exact identifiers and numerical values.</p>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="arch-card">
|
| 160 |
+
<div class="arch-step">Step 3</div>
|
| 161 |
+
<h3>Hybrid Retrieval & RRF</h3>
|
| 162 |
+
<p>Dense search finds synonyms; BM25 finds exact terms. Reciprocal Rank Fusion (RRF) merges both lists without requiring score normalization.</p>
|
| 163 |
+
</div>
|
| 164 |
+
<div class="arch-card">
|
| 165 |
+
<div class="arch-step">Step 4</div>
|
| 166 |
+
<h3>Prompt Augmentation</h3>
|
| 167 |
+
<p>The top ranked passages are injected into the LLM system prompt. The LLM is instructed to answer strictly from the retrieved evidence and cite sources.</p>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<div class="transparency-card">
|
| 172 |
+
<h3>🛠️ Engineering Transparency Note</h3>
|
| 173 |
+
<p>
|
| 174 |
+
This project was built and documented by <strong>Jayan Gupta</strong>. AI coding tools were used for rapid scaffolding. The hybrid retrieval logic, mathematical RRF formulation, and evaluation pipeline were designed and validated to provide a clear, educational reference implementation.
|
| 175 |
+
</p>
|
| 176 |
+
<p>
|
| 177 |
+
<strong>GitHub Repository:</strong> <a href="https://github.com/JayanGupta/RAG-Engine" target="_blank">github.com/JayanGupta/RAG-Engine</a>
|
| 178 |
+
</p>
|
| 179 |
+
</div>
|
| 180 |
+
</section>
|
| 181 |
+
</main>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
<script src="app.js"></script>
|
| 185 |
+
</body>
|
| 186 |
+
</html>
|