Developers Can Now Build Privacy-First CBT Chatbots That Run Entirely in the Browser
A new tutorial published on DEV Community demonstrates how to build a Cognitive Behavioral Therapy assistant that operates entirely within a user's browser, sending no data to external servers. The project uses WebLLM, TVM Unity, and React, leveraging the WebGPU standard to run large language models such as Llama 3 or Mistral directly on a device's local GPU. TVM Unity compiles machine learning models into optimised kernels executed via the WebGPU API, enabling low-latency inference without a cloud backend. The assistant is designed with a specialised CBT system prompt that guides the model to identify cognitive distortions, apply Socratic questioning, and surface emergency resources if self-harm is mentioned. The approach addresses growing concerns about the sensitivity of mental health data by keeping all conversation history strictly on the user's device.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in