Skip to main content

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

xeus-badge pyodide-badge

lmLite

Package version: 0.6.0

A Python bridge to Transformers.js for JupyterLite — run language models and embedding workflows entirely in your browser.

Quick Start

Try online (no installation required):

Basic usage:

from lmlite import LLM

# Instruction-tuned chat with SmolLM2
llm = await LLM.create(
    generator_model="HuggingFaceTB/SmolLM2-360M-Instruct",
    backend="wasm",
    dtype="q4",
)
response = await llm.chat([
    {"role": "user", "content": "Explain embeddings in simple terms."}
])
print(response)

# Text completion with GPT-2
llm = await LLM.create(generator_model="gpt2")
text = await llm.generate("Python is a great language because")
print(text)

# Embeddings and similarity search
llm = await LLM.create(embedding_model="all-MiniLM-L6-v2")
embedding = await llm.embed("Hello world")

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

Features

  • Browser-native: Run LLMs entirely in the browser, no server required
  • Instruction-tuned models: Chat and instruction-following with browser-compatible models such as SmolLM2-360M-Instruct.
  • Composable workflows: Build simple RAG pipelines and conversational interfaces with memory using Python.
  • 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
  • Task pipelines: Zero-shot classification, speech recognition and translation via LLM.pipeline(task, model=...)
  • 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, similarity search, and additional Transformers.js task pipelines
  • 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 supported browser-based Python environment (xeus-python or the JupyterLite Pyodide kernel) with JavaScript interoperability. See docs/RUNTIME.md for details.

Feedback and Contributions

lmLite is an experimental project exploring Python access to browser-native machine learning through Transformers.js.

Feedback is particularly welcome on:

  • The usefulness and design of the asynchronous Python API.
  • Additional Transformers.js tasks and capabilities to expose.
  • Model compatibility, performance, and browser runtime limitations.
  • Potential applications beyond JupyterLite.

Please share suggestions, bug reports, and use cases through GitHub Issues.

Documentation

Interactive Notebooks

Try lmLite directly in your browser, without installing anything.

  • Basic demo — Text generation, embeddings, classification, and similarity search.
  • Task pipelines — Zero-shot classification, translation and speech recognition with LLM.pipeline().
  • LLM orchestration — A simple retrieval-augmented generation (RAG) workflow and interactive multi-turn chat with conversation memory, using SmolLM2-360M-Instruct (WASM/q4) and MiniLM embeddings (WASM/q8).

These examples run locally in the browser using Transformers.js.

How It Works

┌─────────────────────────────────────┐
│   Python (JupyterLite)              │
│   ├─ xeus-python (recommended)      │
│   └─ pyodide (alternative)          │
│                                     │
│   from lmlite import LLM            │
│   llm = await LLM.create()          │
│   text = await llm.generate(...)    │
└─────────────┬───────────────────────┘
              │ Bridge (xeus-python: pjs / Pyodide: pyodide.ffi)
┌─────────────▼───────────────────────┐
│   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}
}

Acknowledgements

lmLite builds on several open-source projects:

Thanks to the developers and maintainers of these projects and the broader Jupyter and Hugging Face communities.


Metadata

Release files for lmlite 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmlite 0.6.0
File Size Uploaded Provenance Actions
lmlite-0.6.0.tar.gz 59.9 kB With provenance Details for lmlite-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lmlite 0.6.0
File Interpreter ABI Platform Actions
lmlite-0.6.0-py3-none-any.whl Python 3 none any Details for lmlite-0.6.0-py3-none-any.whl

Total release size: 99.3 kB

Release files / lmlite-0.6.0.tar.gz

Download URL lmlite-0.6.0.tar.gz
Size 59.9 kB
Tags Source
SHA-256 checksum
How to use checksums
50f57826d0da6b3a3c8042f856f67c59e09c754e93d9342e39c4795e79f0148b
BLAKE2b-256 checksum
How to use checksums
2f6413e40dc07a48b95cfc122d4ab32117ca86ea4df98f738cf8347ad4638b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / lmlite-0.6.0-py3-none-any.whl

Download URL lmlite-0.6.0-py3-none-any.whl
Size 39.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
390ea031bfba12461cfbd7545561ff87dfca82f4414412419b805ca4f5ec39de
BLAKE2b-256 checksum
How to use checksums
569ef93eb7d88fa8ad65919bd0d0cdde8715d3e4be2f9f057723a7f53aea8124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for lmlite 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lmlite-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page