<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sébastien Descloux</title>
    <description>The latest articles on DEV Community by Sébastien Descloux (@sdx_development).</description>
    <link>https://dev.to/sdx_development</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4106878%2Fc3dfd247-539f-47a6-a7ce-100d3e95245b.png</url>
      <title>DEV Community: Sébastien Descloux</title>
      <link>https://dev.to/sdx_development</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sdx_development"/>
    <language>en</language>
    <item>
      <title>I Built a RAG AI Assistant That Runs in the Browser with WebGPU</title>
      <dc:creator>Sébastien Descloux</dc:creator>
      <pubDate>Sun, 27 Sep 2026 19:28:01 +0000</pubDate>
      <link>https://dev.to/sdx_development/i-built-a-rag-ai-assistant-that-runs-in-the-browser-with-webgpu-2m4n</link>
      <guid>https://dev.to/sdx_development/i-built-a-rag-ai-assistant-that-runs-in-the-browser-with-webgpu-2m4n</guid>
      <description>&lt;p&gt;A website may already contain the answers visitors need.&lt;/p&gt;

&lt;p&gt;The real problem is often finding them.&lt;/p&gt;

&lt;p&gt;So I built and deployed a first version of a &lt;strong&gt;RAG AI assistant&lt;/strong&gt; for my own website, with one particular constraint:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The response model runs directly in the visitor's browser using WebGPU.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This was not meant to be another chatbot connected to an API.&lt;/p&gt;

&lt;p&gt;I wanted to explore what happens when retrieval, local inference, source-based answers, conversation context, and a CMS are designed as one complete workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the architecture works
&lt;/h2&gt;

&lt;p&gt;The system splits the work between the website server and the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The CMS prepares the knowledge base
&lt;/h3&gt;

&lt;p&gt;Selected website content is split into passages and indexed.&lt;/p&gt;

&lt;p&gt;The CMS also lets me manage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which documents are available to the assistant&lt;/li&gt;
&lt;li&gt;model profiles&lt;/li&gt;
&lt;li&gt;search parameters&lt;/li&gt;
&lt;li&gt;assistant instructions&lt;/li&gt;
&lt;li&gt;activation and validation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The browser understands the question
&lt;/h3&gt;

&lt;p&gt;The browser can use recent conversation context to reformulate follow-up questions.&lt;/p&gt;

&lt;p&gt;An embedding model then converts the query into a vector.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The server performs vector search
&lt;/h3&gt;

&lt;p&gt;The vector is sent to the website API.&lt;/p&gt;

&lt;p&gt;The server searches the document index and returns the most relevant passages together with their sources.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. WebGPU generates the answer locally
&lt;/h3&gt;

&lt;p&gt;The response model runs on the visitor's GPU.&lt;/p&gt;

&lt;p&gt;It receives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the question&lt;/li&gt;
&lt;li&gt;recent conversation context&lt;/li&gt;
&lt;li&gt;retrieved passages&lt;/li&gt;
&lt;li&gt;CMS instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first result is not displayed immediately.&lt;/p&gt;

&lt;p&gt;A second pass checks the draft against the retrieved sources, and the system can perform one corrective search if necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The visitor gets an answer with sources
&lt;/h3&gt;

&lt;p&gt;The final response contains links back to the original website content.&lt;/p&gt;

&lt;p&gt;If the available information is not sufficient, the assistant is expected to say so instead of inventing an answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why run the model in the browser?
&lt;/h2&gt;

&lt;p&gt;The main experiment was to avoid calling a hosted generation API for every message.&lt;/p&gt;

&lt;p&gt;This changes several things.&lt;/p&gt;

&lt;h3&gt;
  
  
  No per-response generation API call
&lt;/h3&gt;

&lt;p&gt;Once the models are loaded, generation happens on the visitor's device.&lt;/p&gt;

&lt;p&gt;That does not make the system free — hosting, downloads, development and maintenance still have costs — but there is no token bill for every generated response in this workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  More control over conversation data
&lt;/h3&gt;

&lt;p&gt;The conversation is not sent to an external generation API to produce the answer.&lt;/p&gt;

&lt;p&gt;Optional conversation memory is also stored locally in the browser.&lt;/p&gt;

&lt;p&gt;The server is still involved in document retrieval, so this is not a fully offline system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local memory
&lt;/h2&gt;

&lt;p&gt;I also added optional semantic memory using IndexedDB.&lt;/p&gt;

&lt;p&gt;It can keep previous exchanges locally for a limited period and retrieve an older, related question when useful.&lt;/p&gt;

&lt;p&gt;An important design decision was to keep three concepts separate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;documents&lt;/strong&gt; are the factual source&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;recent conversation&lt;/strong&gt; maintains context&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;local memory&lt;/strong&gt; helps recover previous intent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An old AI-generated answer never becomes a new factual source.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limitations are just as important
&lt;/h2&gt;

&lt;p&gt;Running AI models in the browser comes with real constraints.&lt;/p&gt;

&lt;p&gt;The current response model requires roughly &lt;strong&gt;2 GB of downloads&lt;/strong&gt;, plus about &lt;strong&gt;279 MB&lt;/strong&gt; for the embedding model.&lt;/p&gt;

&lt;p&gt;Browser support is another factor.&lt;/p&gt;

&lt;p&gt;Having &lt;code&gt;navigator.gpu&lt;/code&gt; available does not automatically mean that every model and inference engine will work correctly on that device.&lt;/p&gt;

&lt;p&gt;Drivers, GPU capabilities, memory limits and browser implementation all matter.&lt;/p&gt;

&lt;p&gt;Latency is also very different from a fast cloud API.&lt;/p&gt;

&lt;p&gt;With the models already cached, one documented test produced a reviewed answer in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;36.11 seconds&lt;/strong&gt; on a Samsung Galaxy S25 Ultra&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;13.06 seconds&lt;/strong&gt; on a desktop with an NVIDIA Ampere GPU&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are measurements from my own test devices, not performance guarantees.&lt;/p&gt;

&lt;p&gt;More complex mobile requests can take over a minute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I still find this architecture interesting
&lt;/h2&gt;

&lt;p&gt;The goal is not to replace every search box with an AI assistant.&lt;/p&gt;

&lt;p&gt;The interesting use cases are situations where users have a real question and the website already has reliable information that can answer it.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;product catalogs&lt;/li&gt;
&lt;li&gt;technical documentation&lt;/li&gt;
&lt;li&gt;training websites&lt;/li&gt;
&lt;li&gt;tourism or accommodation&lt;/li&gt;
&lt;li&gt;business software&lt;/li&gt;
&lt;li&gt;real-estate search&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A user can express a need naturally, while structured data and RAG keep the response connected to information that can actually be verified.&lt;/p&gt;

&lt;p&gt;The model is only one part of the solution.&lt;/p&gt;

&lt;p&gt;The real value comes from combining:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;data + retrieval + business rules + UX + performance + validation&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned from this first version
&lt;/h2&gt;

&lt;p&gt;Building this project reinforced something I increasingly see in applied AI work:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A better model does not automatically create a better product.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The difficult parts are often around the model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;preparing reliable knowledge&lt;/li&gt;
&lt;li&gt;keeping retrieval consistent&lt;/li&gt;
&lt;li&gt;managing context&lt;/li&gt;
&lt;li&gt;handling model downloads and caching&lt;/li&gt;
&lt;li&gt;keeping the interface responsive&lt;/li&gt;
&lt;li&gt;validating answers&lt;/li&gt;
&lt;li&gt;testing on real devices&lt;/li&gt;
&lt;li&gt;deciding when the system should simply say "I don't know"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This first version is now running in production on my own website, and I am continuing to test lighter models, additional browsers, GPUs and possible business applications.&lt;/p&gt;




&lt;p&gt;I wrote a more complete article with the architecture, limitations, benchmarks and potential use cases:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://sdx-development.com/en/news/applied-ai/rag-webgpu-ai-assistant-first-version" rel="noopener noreferrer"&gt;RAG and WebGPU: When Your Website Becomes an AI Assistant&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is also a deeper technical case study covering the complete RAG pipeline, CMS integration, embeddings, local memory and model choices.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>webgpu</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
