Skip to content

pranavchokda/RunInBrowser

Repository files navigation

LLM/VLM in browser experiments

Vision-language model demos running entirely in the browser — no server, no Python, no GPU required.

Models are loaded from HuggingFace via Transformers.js and run using WebGPU (with automatic fallback to WASM).

Live site: https://pranavchokda.github.io/RunInBrowser/


Demos

# Demo Description
01 SmolVLM Upload an image and get a natural-language description from SmolVLM-256M-Instruct

Project Structure

RunInBrowser/
├── .github/
│   └── workflows/
│       └── deploy.yml          # Auto-deploy to GitHub Pages on push to main
├── examples/
│   └── 01_smolvlm/
│       ├── index.html          # Demo page markup
│       ├── main.ts             # Inference logic (model load, image processing, generation)
│       ├── style.css           # UI styles
│       └── vite.demo.config.ts # Vite build config for this demo
├── dist/                       # Production build output (generated, not committed)
├── index.html                  # Landing page linking to all demos
├── package.json
├── tsconfig.json
├── dev.sh                      # Helper script to start/stop dev servers
└── README.md

Each demo lives in its own examples/NN_name/ folder with its own Vite config, so they can be developed and built independently.


Prerequisites


Getting Started

# 1. Install Node dependencies
npm install

# 2. Start the dev server
./dev.sh start

# 3. Open http://localhost:5173

Or start the dev server directly with npm:

npm run dev

All dev.sh commands

./dev.sh start    # Start dev server in the background (prints PID + URL)
./dev.sh stop     # Stop the dev server
./dev.sh status   # Check if the server is running
./dev.sh restart  # Stop then start

Building for Production

npm run build

Output goes to dist/. The GitHub Actions workflow runs this automatically on every push to main and deploys the result to GitHub Pages.


Deploying to GitHub Pages

  1. Push the repo to GitHub (repo name: RunInBrowser).
  2. Go to Settings → Pages and set the source to GitHub Actions.
  3. Push to main — the workflow in .github/workflows/deploy.yml handles the rest.

Note: If your repo name differs from RunInBrowser, update the base field in examples/01_smolvlm/vite.demo.config.ts to match.


How SmolVLM Works in the Browser

  1. Load Model — weights are downloaded from HuggingFace (~300 MB for the 256M model) and cached in the browser's Cache Storage. Subsequent loads are instant.
  2. Runtime — inference runs via WebGPU when available, falling back to WebAssembly automatically. No data leaves your device.
  3. Usage — drop or upload an image, optionally edit the prompt, and click Describe.

License

This project is released under the MIT License.


Acknowledgements

  • Hugging Face for Transformers.js and for hosting the SmolVLM model weights
  • HuggingFaceTB for training and releasing SmolVLM-256M-Instruct
  • Guido Zuidhof for coi-serviceworker, which makes cross-origin isolation work on static hosts like GitHub Pages
  • Microsoft / ONNX Runtime team for ONNX Runtime Web, the inference engine underneath Transformers.js
  • Vite for the fast dev/build tooling
  • Claude (Anthropic) for assisting with the implementation, tooling setup, and documentation of this project

Third-Party Licenses

Package Author License
@huggingface/transformers Hugging Face Apache 2.0
SmolVLM-256M-Instruct HuggingFaceTB Apache 2.0
onnxruntime-web Microsoft MIT
coi-serviceworker Guido Zuidhof MIT
vite Evan You & Vite contributors MIT

References

Transformers.js

WebGPU

ONNX Runtime Web

  • ONNX Runtime Web docs — the inference engine underneath Transformers.js; explains WebGPU vs WASM execution providers and quantization formats (q4, fp16, etc.)

SharedArrayBuffer / Cross-Origin Isolation

About

Running an LLM/VLM model in web browser

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors