react-llm  by r2d4

React hooks for in-browser LLM inference via WebGPU

created 2 years ago
693 stars

Top 50.0% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides headless React Hooks for running Large Language Models (LLMs) directly in the browser using WebGPU, enabling privacy-preserving AI applications. It targets React developers seeking to integrate LLM capabilities client-side without server dependencies.

How It Works

The library leverages Apache TVM and MLC Relax, compiled for the browser via Emscripten, to run LLMs like Vicuna 7B. A SentencePiece tokenizer, also compiled via Emscripten, handles text processing. The model and runtime are loaded from a CDN and cached in browser storage. Off-the-main-thread WebWorkers execute the model, ensuring a responsive UI.

Quick Start & Requirements

  • Install: npm install @react-llm/headless
  • Requirements: WebGPU-enabled browser.
  • Demo: cd packages/retro-ui && pnpm install && pnpm dev

Highlighted Details

  • Supports Vicuna 7B models.
  • Enables custom system prompts and role names.
  • Offers completion options (max tokens, stop sequences).
  • No data leaves the browser.
  • Persistent conversation storage.
  • Model caching for faster reloads.

Maintenance & Community

No specific contributors, sponsorships, or community links (Discord/Slack) are mentioned in the README.

Licensing & Compatibility

MIT License for the core library. The code under packages/headless/worker/lib/tvm is licensed under Apache 2.0. Compatible with commercial use and closed-source applications.

Limitations & Caveats

The README mentions Vicuna 7B, but the "How does it work?" section states Vicuna 13B. The project appears to be in early stages, with a focus on demonstrating core functionality.

Health Check
Last commit

2 years ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
2 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Simon Willison Simon Willison(Author of Django), and
1 more.

Lumos by andrewnguonly

0.1%
2k
Chrome extension for local LLM web RAG co-piloting
created 1 year ago
updated 6 months ago
Feedback? Help us improve.