Amin Musah built Forge, an open-source browser playground for Hugging Face models that dynamically generates user interfaces using a separate code model. The system creates a TSX component based on task specs, which the browser then compiles client-side with esbuild-wasm and runs in a sandboxed iframe.
- A dedicated server-side code model generates the UI component from a task spec describing input/output shapes.
- The browser compiles the generated code locally without a build server, retrying up to twice if compilation fails.
- The sandboxed UI is isolated from cookies and storage, communicating with the parent window only via messages for inference.
- A single background worker manages one model instance to handle weight loading, while a shared React instance prevents hook errors.
This approach allows users to test models locally on their GPU via transformers.js + WebGPU without manually building interfaces for each task type.