Skip to main content

lmLite — browser machine learning from Python

Tests codecov-python codecov-js Transformers.js Docs Try xeus-python Try Pyodide

lmLite

Package version: 0.14.1

Browser machine learning from Python — run language models, embeddings, vision, speech and bare ONNX models entirely in your browser, and reach the microphone and camera, from a Python kernel in JupyterLite (or headless, with onnxruntime).

Try it, nothing to install: xeus-python (recommended) or Pyodide. Documentation · All notebooks

Quick start

from lmlite import LLM, Classifier, Embedder, pipeline

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

# Chat with memory: keep the conversation in a list and pass it back at each turn
history = [{"role": "user", "content": "What is Python?"}]
history.append({"role": "assistant", "content": await llm.chat(history)})
history.append({"role": "user", "content": "What can I use it for?"})  # "it" is Python
print(await llm.chat(history))

# Embeddings and similarity search
embedder = await Embedder.create("all-MiniLM-L6-v2")
docs = ["JupyterLite runs in the browser.", "Python is widely used for ML."]
print(await embedder.similarity_search("Where does JupyterLite run?", docs))

# Text classification
classifier = await Classifier.create("distilbert-base-uncased-finetuned-sst-2-english")
print(await classifier.classify("I love lmLite!", top_k=2))

# Any Transformers.js task is an awaitable callable: here, the objects in a photo
detector = await pipeline("object-detection", model="detr-resnet-50")
print(await detector("https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg", threshold=0.6))

What you get

  • pipeline(): Transformers.js tasks as awaitable Python callables (vision, speech, audio, images out, translation, zero-shot classification), with map() over many inputs, progress and cancel.
  • LLM, Embedder, Classifier: generation and chat with streaming and token probabilities; sentence embeddings with similarity search; text classification.
  • OnnxModel: any single .onnx file, NumPy in and NumPy out, with caching, hosted files and a SHA-256 check.
  • Notebook widgets: record the microphone, take a photo with the camera, manage the model cache.
  • Local and private: inference runs in your browser, on WebAssembly or WebGPU, with no server and no API key. Downloaded models stay cached and can be exported as ZIP files.
  • A headless native backend: pip install 'lmlite[native]' runs the same ONNX files with onnxruntime, for fast tuning loops checked against the browser.

Extras: images (NumPy and Pillow), audio and camera (the widgets), native.

Note: Installing the package on a desktop does not run models in a browser. pipeline(), OnnxModel, LLM, Embedder, Classifier and the widgets need a browser kernel (xeus-python or the JupyterLite Pyodide kernel) with JavaScript interoperability. The native extra covers Embedder, Classifier, greedy LLM.generate(), OnnxModel and tokenizer(). See docs/RUNTIME.md.

Notebooks

An astronaut riding a horse on Mars, generated with SD-Turbo from the prompt 'a photo of an astronaut riding a horse on mars'
Generated in the browser with SD-Turbo by the text-to-image notebook.

All the notebooks, from the first demo to a retrieval-augmented chat, are listed in the documentation.

Apps, built with Voici: what is in front of the camera? and say it in English, hear it in French.

Documentation

The documentation site has the tutorials (the notebooks), guides for one task at a time, a reference with the API generated from the docstrings, and explanations of backends and the Python/JavaScript bridge. Setup and tests are in the development guide.

Contributing

lmLite is experimental. Feedback on the API, on other Transformers.js tasks to expose, and on model compatibility and browser limits is welcome through GitHub Issues.

Parts of this project were developed with the assistance of generative AI tools. The maintainer is responsible for the architecture, review, testing and published code. AI-assisted contributions are welcome, provided contributors understand, review and test their changes and take responsibility for them. AGENTS.md is a short guide to the layout, the commands and the usual mistakes, for people and for coding agents.

License

Apache License 2.0. See LICENSE. Models have their own licences, and some tested ones are non-commercial: check the model card before use, and see the model guide.

Citation

@software{lmlite2026,
  author = {Decitre, Emmanuel},
  title = {lmLite: Browser machine learning from Python},
  year = {2026},
  url = {https://github.com/decitre/lmlite}
}

Acknowledgements

lmLite builds on Transformers.js and ONNX Runtime for inference, on JupyterLite, xeus-python and Pyodide for Python in the browser, and on the models that the Hugging Face community publishes. The full list is on the credits page.


Metadata

Release files for lmlite 0.14.1

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.14.1
File Size Uploaded Provenance Actions
lmlite-0.14.1.tar.gz 139.2 kB With provenance Details for lmlite-0.14.1.tar.gz

Built distribution (wheel)

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

Total release size: 243.1 kB

Release files / lmlite-0.14.1.tar.gz

Download URL lmlite-0.14.1.tar.gz
Size 139.2 kB
Tags Source
SHA-256 checksum
How to use checksums
005077d680681175c882475bbb27ddf0d58dcfacf4da7291c165ddee6e54d1e4
BLAKE2b-256 checksum
How to use checksums
72b236df4b3d7032f0a870bdb87a112ba6b0cd27f1c618fb975c12bc796fdd3d
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 Nov 25, 2026.

Transparency log

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

Download URL lmlite-0.14.1-py3-none-any.whl
Size 103.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2e45d20e42b7106845853c3b7e369c63e6c8d2af69b47517c42501385673eae
BLAKE2b-256 checksum
How to use checksums
c28a9ef257473d09c5b6247628cd34846b19534ac49a1d110f780a80b3cd7285
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 Nov 25, 2026.

Transparency log

Security for lmlite 0.14.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lmlite-0.14.1.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 Nov 25, 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.

Release history Release notifications | RSS feed

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