Skip to content
decitrePublic

About

Run transformer models in the browser, orchestrated from Python in JupyterLite

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Python package codecov-python codecov-js Pixi Badge Transformers.js

xeus-badge pyodide-badge

lmLite

Package version: 0.5.7

Browser-native LLM orchestration in JupyterLite - run language models entirely in your browser using WebAssembly or WebGPU.

Quick Start

Try online (no installation required):

Basic usage:

from lmlite import LLM

# Create LLM instance (downloads model on first run)
llm = await LLM.create(
    generator_model="gpt2",
    embedding_model="all-MiniLM-L6-v2"
)

# Generate text
text = await llm.generate("Python is a great language because")

# Generate embeddings
embedding = await llm.embed("Hello world")

# Similarity search
docs = ["JupyterLite runs in the browser.", "Python is widely used for ML."]
results = await llm.similarity_search("Where does JupyterLite run?", docs)

Features

  • Browser-native: Run LLMs entirely in the browser, no server required
  • Privacy-first: All computation happens locally in your browser
  • Zero setup: No installation or API keys for hosted demos
  • Multiple backends: WebAssembly (WASM) or WebGPU
  • Multiple models: GPT-2, DistilGPT-2, TinyLlama, and more via Transformers.js
  • Embeddings & classification: Sentence vectors and text classification
  • Model caching: Browser-cached downloads and portable ZIP export/import
  • Pythonic API: Clean, async Python interface

What is lmLite?

lmLite is a lightweight Python-to-JavaScript bridge for local LLM inference in the browser, designed for JupyterLite notebooks. It provides:

  • Async Python API for text generation, embeddings, classification, and similarity search
  • Model loading, caching, and portable ZIP workflows
  • Independent backend/dtype controls for embeddings and generation

Inference is powered by Transformers.js and ONNX Runtime. lmLite is not a new model engine or native Python inference backend. Its similarity search is an in-memory cosine ranking helper, not a vector database.

Best suited for: Teaching, interactive experiments, and browser-local prototypes where avoiding remote inference services matters.

Note: Installing the Python package on desktop does not enable desktop inference. LLM.create() requires a browser Python runtime (xeus-python or Pyodide) with JavaScript bridge. See docs/RUNTIME.md for details.

Documentation

Notebooks

Open demo.ipynb in the online demo to see lmLite in action. See the notebooks directory for all examples.

How It Works

┌─────────────────────────────────────┐
│   Python (JupyterLite)              │
│   ├─ xeus-python (recommended)      │
│   └─ pyodide (alternative)          │
│                                     │
│   from lmlite import LLM            │
│   llm = await LLM.create()          │
│   text = await llm.generate(...)    │
└─────────────┬───────────────────────┘
              │ Bridge (pyodide.ffi / pjs)
┌─────────────▼───────────────────────┐
│   JavaScript (Browser)              │
│   Transformers.js + ONNX Runtime    │
│   ├─ WebAssembly (WASM)             │
│   └─ WebGPU (optional)              │
└─────────────────────────────────────┘

License

Apache License 2.0. See LICENSE for details.

Dependencies: Transformers.js v4 (Apache 2.0)

Note: Individual model licenses may vary. Check model cards on HuggingFace before use.

Citation

@software{lmlite2026,
  author = {Decitre, Emmanuel},
  title = {lmLite: Browser-native LLM orchestration in JupyterLite},
  year = {2026},
  url = {https://github.com/decitre/lmlite}
}

Acknowledgments


About

Run transformer models in the browser, orchestrated from Python in JupyterLite

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages