<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gunasekaran K Sengodan on Medium]]></title>
        <description><![CDATA[Stories by Gunasekaran K Sengodan on Medium]]></description>
        <link>https://medium.com/@gunasekaran.sengodan?source=rss-c5f0123b1e65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zo0NdAil56WUr9XinVD9dw.jpeg</url>
            <title>Stories by Gunasekaran K Sengodan on Medium</title>
            <link>https://medium.com/@gunasekaran.sengodan?source=rss-c5f0123b1e65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 02:24:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gunasekaran.sengodan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond RAG: 10-Brain AI Lab That Turns Federal Regulations Into Executable Code]]></title>
            <link>https://medium.com/@gunasekaran.sengodan/beyond-rag-10-brain-ai-lab-that-turns-federal-regulations-into-executable-code-431be525b2a1?source=rss-c5f0123b1e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/431be525b2a1</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[duckdb]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Gunasekaran K Sengodan]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 17:50:43 GMT</pubDate>
            <atom:updated>2026-10-29T17:50:43.458Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Federal Register AI Expert Lab</strong></p><h3>Beyond RAG: 10-Brain AI Lab That Turns Federal Regulations Into Executable Code</h3><h4>Compute-first regulatory intelligence in your browser &gt;&gt; $0 infra, &lt;100ms SQL, 650k docs, 100% auditable</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KnYlJ1qILyo9qqNCjB-GhQ.jpeg" /><figcaption>10-Brain AI Lab That Turns Federal Regulations Into Executable Code</figcaption></figure><p>Why retrieval-augmented generation fails on the Federal Register &gt;&gt; and how a compute-first, $0 infra architecture with DuckDB-WASM, Knowledge Graphs and on-device Gemma 2B makes 650,000 regulatory documents truly auditable.</p><blockquote><em>I built a 10-brain AI lab that reads </em><strong><em>Federal Register</em></strong><em> like a lawyer &gt;&gt; in your browser. No Pinecone. No OpenAI bill. DuckDB-WASM over Parquet + Gemma 2B on WebGPU + Knowledge Graph. Every answer has a FR citation and SQL proof.</em></blockquote><blockquote><strong>Proof:</strong> $0 infra | &lt;100ms SQL | 650k docs | 100% auditable</blockquote><p>I spent sometime trying to make RAG work on the Federal Register. 650,000 documents, 90 years of regulatory history, agencies contradicting each other, rules referencing rules that reference rules. Vector database collapsed under the same problem: <em>regulations are not searchable documents. They are executable programs with dependencies.</em></p><h3>Why RAG Fails for Federal Regulations</h3><p>Traditional RAG chunks regulations into top-12 vectors. You lose,</p><ul><li><strong>Citation</strong>: Which FR Doc? What page? What agency?</li><li><strong>Audit</strong>: How did you get there? Can legal verify?</li><li><strong>Cost</strong>: Pinecone $700/mo + OpenAI $1200/mo + EC2</li><li><strong>Privacy</strong>: Your regulatory query goes to a server</li></ul><p>Regulations are not blog posts. They are executable code with effective dates, agencies, CFR references and contradictions.</p><p>RAG assumes language is fuzzy. Law is not. A single word change in 21 CFR § 820.75 can shut down a medical device line. Embedding similarity at 0.87 cosine doesn’t mean compliance &gt;&gt; it means liability.</p><p><strong>Hallucination tax &gt;&gt; </strong>RAG invents CFR sections. 12% of GPT-4 citations on Federal Register queries don’t exist. You can’t audit a hallucination.</p><p><strong>Latency death &gt;&gt; </strong>Pinecone + OpenAI: 2.3s p95 per query. For a compliance officer checking 40 sections, that’s 92 seconds of waiting. Unusable.</p><p><strong>Cost bleed &gt;&gt; </strong>$1900/month for 650k docs at 1536-dim. Every new Federal Register issue adds $12. You pay to get less accurate over time.</p><p>More critically &gt;&gt; regulations have execution semantics. Effective dates, sunset clauses, agency hierarchies, cross-references like “see § 1.121 as amended by 89 FR 12345”.</p><p>RAG flattens all that into chunks. You lose the program.</p><h3>The Compute-First Thesis: SQL is the interface</h3><p>If you can UNNEST it, you don’t need to embed it.</p><p>Federal Register JSON has agency_names[], cfr_references[], effective_on. That&#39;s a columnar dataset, not a document lake. Parquet + DuckDB gives you &lt;100ms exact queries on the client. No vector DB. No API key.</p><h3><strong><em>This flips the stack</em></strong></h3><p>Instead of retrieving then reasoning, we compute exact sets first, then use LLMs only for vague-to-exact translation and private synthesis. The database is the source of truth, not the LLM.</p><h4>PRINCIPLE 1: EXACT BEFORE FUZZY</h4><h4>PRINCIPLE 2: CLIENT IS THE CLOUD</h4><h4>PRINCIPLE 3: EVERY ANSWER HAS A SQL RECEIPT</h4><p><strong>Retrieval is Compute, not Search.</strong></p><pre>SELECT * WHERE agency_names CONTAINS &#39;FAA&#39; AND publication_date &gt; &#39;2024-01-01&#39;</pre><p><strong>Data is Parquet, not JSON API.</strong><br>GadgetSoftware/federal-register on HuggingFace &gt;&gt; 650k docs, partitioned by year, columnar.</p><p><strong>LLM is Local, not Hosted.</strong><br>Gemma 2B via MLC WebLLM on WebGPU &gt;&gt; your query never leaves browser.</p><p><strong>Result</strong>: Zero server cost. Private by design. Every answer verifiable.</p><h3>Architecture: 10 Specialized Brains</h3><pre>HuggingFace Parquet (GadgetSoftware/federal-register)    <br>↓<br>DuckDB-WASM Worker (Apache Arrow)    <br>↓<br>SQL + Transformers.js (vague-to-exact)    <br>↓<br>Knowledge Graph (agency ↔ document ↔ CFR ↔ topic)    <br>↓<br>10-Brain Lab    <br>↓<br>WebGPU Gemma 2B Summarization    <br>↓<br>Auditable Trace: doc_number, agency_names, publication_date, confidence, SQL</pre><p><strong>10 Brains:</strong><br>01 Exact SQL (DuckDB-WASM)<br>02 Vague-to-Exact (Embedding → SQL proof)<br>03 Knowledge Graph (Relations)<br>04 Prediction (Time-to-final rule)<br>05 Contradiction (Conflict detection)<br>06 Private LLM (Gemma 2B on WebGPU)<br>07 Agentic Action (Cited workflows)<br>08 Neuro-Symbolic (Rules + reason)<br>09 What-If Simulation (Scenario engine)<br>10 Fusion (FR + EDGAR)</p><h3>The 10 Brains. One pipeline, zero black boxes.</h3><p>Not 10 agents chatting. 10 deterministic stages, each auditable, each replaceable. Inspired by neuro-symbolic AI:</p><p>separate what should be exact from what must be fuzzy.</p><h4><strong>01 </strong>DuckDB-WASM &gt;&gt; <strong>Exact SQL</strong></h4><p>Columnar Parquet from GadgetSoftware/federal-register. UNNEST agency_names, filter by effective_on, aggregate by CFR. &lt;100ms on device, 650k rows. No server.</p><h4><strong>02 </strong>Embedding→proof: <strong>Vague-to-Exact</strong></h4><p>Transformers.js all-MiniLM on client turns ‘EPA rules last month’ into {agency: EPA, date &gt; now-30d}. Embedding never answers. it only proposes SQL.</p><h4><strong>03 </strong>Relations: Knowledge Graph</h4><p>Extracts (Agency)-[:ISSUES]-&gt;(Rule)-[:AMENDS]-&gt;(CFR). Built in-browser from cfr_references. Enables transitive closure: what rules does this final rule break?</p><h4><strong>04 </strong>Time-to-final: Prediction</h4><p>Regression on publication &gt;&gt; final rule lag. Uses effective_on deltas. Predicts rulemaking velocity per agency. FDA avg 187 days, EPA 94.</p><h4><strong>05 </strong>Conflict detection: Contradiction</h4><p>Symbolic checks: two rules with same CFR, overlapping dates, different agencies. Flags potential conflicts before they become lawsuits.</p><h4><strong>06 </strong>Gemma 2B: Private LLM</h4><p>MLC WebLLM runs Gemma 2B quantized entirely in WebGPU. No data leaves browser. Summarizes exact result sets, not raw docs. Private by architecture.</p><h4><strong>07 </strong>Cited workflows: Agentic Action</h4><p>Generates executable compliance checklists with SQL receipts attached. Each step links to FR document + CFR. You can run the checklist, not just read it.</p><h4><strong>08 </strong>Rules+reason: Neuro-Symbolic</h4><p>Hard rules (date logic, CFR validity) in JS, soft reasoning in LLM. If rule says effective_on &lt; today, no LLM can override it. Auditable by design.</p><h4><strong>09 </strong>Simulation: What-If</h4><p>Scenario engine: what if effective_on slips 30 days? Re-runs downstream CFR graph. Shows affected rules, agencies, compliance windows.</p><h4><strong>10 </strong>FR+EDGAR: Fusion</h4><p>Joins Federal Register with SEC EDGAR filings (same Parquet pipeline). Which public companies mention this rule in 10-K risk factors? Now compliance has P&amp;L impact.</p><h3>Auditable trace: Parquet → Proof</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ytSg0fHhw0Za6kZYUvx0RQ.png" /></figure><p>ALL CLIENT-SIDE • ZERO INFRA • EVERY STEP HAS A SQL RECEIPT</p><p>• VERIFIED AT v0-federal-register-ai-gunasekaran.vercel.app</p><p>No backend. Parquet files from HuggingFace are fetched once, cached in OPFS, queried by DuckDB-WASM worker. Transformers.js and Gemma 2B run in same browser context. If you open DevTools, you see the SQL, not a prompt.</p><h3>Tech Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C5wVO8gZUAd2lC7pU2mQw.png" /></figure><h3>Code &gt;&gt; The 3 Brains That Matter</h3><h3>01 &gt;&gt; Exact SQL (Fix for agency column bug)</h3><pre>-- Federal Register AI Lab — exact query<br>-- No embedding, no RAG, pure SQL on 650k docs<br><br>SELECT<br>  unnest_agency as agency,<br>  COUNT(*) as rules,<br>  COUNT(DISTINCT cfr) as cfr_sections,<br>  MIN(effective_on) as earliest,<br>  MAX(effective_on) as latest<br>FROM (<br>  SELECT <br>    UNNEST(agency_names) as unnest_agency,<br>    UNNEST(cfr_references) as cfr,<br>    effective_on::DATE as effective_on<br>  FROM &#39;https://huggingface.co/datasets/GadgetSoftware/federal-register/resolve/main/federal_register.parquet&#39;<br>  WHERE publication_date &gt;= &#39;2024-01-01&#39;<br>    AND type = &#39;Rule&#39;<br>)<br>GROUP BY unnest_agency<br>HAVING rules &gt; 20<br>ORDER BY rules DESC<br>LIMIT 20;<br>-- p95: 87ms in DuckDB-WASM (MacBook Air M1, no server)</pre><h3>02 &gt;&gt; Private LLM on WebGPU</h3><pre>// Runs entirely in browser WebGPU — no API key, no data leaves<br>import { CreateMLCEngine } from &quot;@mlc-ai/web-llm&quot;;<br><br>const engine = await CreateMLCEngine(&quot;gemma-2-2b-it-q4f16_1-MLC&quot;, {<br>  initProgressCallback: (p) =&gt; console.log(p.text)<br>});<br><br>// Synthesis only sees exact SQL results, never raw docs<br>const exactResults = await duckdb.query(`<br>  SELECT title, cfr_references FROM federal_register <br>  WHERE agency_names @&gt; [&#39;Environmental Protection Agency&#39;]<br>  LIMIT 5<br>`);<br><br>const prompt = `You are a compliance analyst. <br>Exact results: ${JSON.stringify(exactResults)}<br>Task: Summarize affected CFR sections with citations.<br>Rule: If not in exact results, say &quot;Not in audited set&quot;.`;<br><br>const summary = await engine.chat.completions.create({<br>  messages: [{ role: &quot;user&quot;, content: prompt }],<br>  // 42 tok/s in WebGPU, fully private<br>});</pre><h3>03 &gt;&gt; Knowledge Graph Extraction</h3><pre>// Build CFR graph client-side from Parquet<br>// (Agency)-[:ISSUES]-&gt;(Rule)-[:AMENDS]-&gt;(CFR)<br><br>function buildGraph(rows) {<br>  const graph = { nodes: new Map(), edges: [] };<br>  <br>  for (const r of rows) {<br>    const ruleId = r.document_number;<br>    graph.nodes.set(ruleId, { type: &#39;Rule&#39;, title: r.title });<br>    <br>    for (const agency of r.agency_names || []) {<br>      graph.nodes.set(agency, { type: &#39;Agency&#39; });<br>      graph.edges.push({ from: agency, to: ruleId, rel: &#39;ISSUES&#39; });<br>    }<br>    <br>    for (const cfr of r.cfr_references || []) {<br>      graph.nodes.set(cfr, { type: &#39;CFR&#39;, part: cfr });<br>      graph.edges.push({ from: ruleId, to: cfr, rel: &#39;AMENDS&#39; });<br>      <br>      // Transitive: find conflicting rules on same CFR<br>      const conflicts = rows.filter(x =&gt; <br>        x.cfr_references?.includes(cfr) &amp;&amp; <br>        x.document_number !== ruleId &amp;&amp;<br>        dateOverlap(x.effective_on, r.effective_on)<br>      );<br>      for (const c of conflicts) {<br>        graph.edges.push({ <br>          from: ruleId, <br>          to: c.document_number, <br>          rel: &#39;POTENTIAL_CONFLICT&#39;,<br>          cfr <br>        });<br>      }<br>    }<br>  }<br>  return graph; // Fully auditable, no LLM needed<br>}</pre><h3>Cost Comparison &gt;&gt; Why Compute-First Wins. $1900 RAG vs $0 Compute-First</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2K7hMnoax0gN87nfhRJbMg.png" /></figure><h3>How to Use in &gt;&gt; 5 Steps</h3><p><strong>01 Open the live lab</strong></p><p>Go to v0-federal-register-ai-gunasekaran.vercel.app — no sign-up, no API key. Everything runs in your browser. First load caches Parquet (~187MB) in OPFS.</p><p><strong>02 Start with exact</strong></p><p>Use SQL box:</p><p>try SELECT agency_names, COUNT(*) FROM federal_register GROUP BY 1. See &lt;100ms receipts. This is your source of truth, not LLM.</p><p><strong>03 Vague → Exact translation</strong></p><p>Type natural language like ‘EPA final rules that amend 40 CFR 112 last 90 days’. Embedding proposes filter, SQL executes. You can edit the SQL before running.</p><p><strong>04 Inspect 10 Brains</strong></p><p>Toggle each brain: Knowledge Graph shows CFR dependencies, Contradiction flags overlaps, Prediction estimates time-to-final, What-If simulates effective date slips.</p><p><strong>05 Export auditable trace</strong></p><p>Every answer exports as markdown with SQL + citations + graph JSON. Paste into compliance memo. Auditor can re-run SQL receipt and get same result. No black box.</p><h3>Deployment &gt;&gt; Zero Server Cost</h3><p>v0 → Deploy → Vercel<br>Domains: federal-register-ai-gunasekaran.vercel.app (alias)</p><p><strong>Live &gt;&gt; </strong>https://federal-register-ai.vercel.app<br><strong>GitHub &gt;&gt;</strong> https://github.com/gunasekaransengodan<br><strong>Dataset &gt;&gt;</strong> https://huggingface.co/datasets/GadgetSoftware/federal-register</p><h3>References &amp; Footnotes</h3><ol><li>Federal Register bulk data via GadgetSoftware/federal-register on HuggingFace. 650k JSON documents → Parquet, 187MB</li><li>DuckDB-WASM performance: &lt;100ms for UNNEST queries on 650k rows measured in Chrome 120, MacBook Air M1, worker thread</li><li>Transformers.js all-MiniLM-L6-v2 for vague-to-exact translation, 384-dim, runs at 45ms/query in WASM</li><li>MLC WebLLM Gemma 2B q4f16_1–1.4B params effective after quantization, 42 tok/s in WebGPU on M1, 18 tok/s on Intel iGPU</li><li>RAG failure rate: evaluated 200 FR questions, GPT-4 + Pinecone invented 24 CFR citations (12%). Compute-First invented 0</li><li>Knowledge Graph relations extracted via cfr_references array, no LLM needed. Conflict detection is symbolic date overlap</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=431be525b2a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>