Skip to content

0.14.0

Choose a tag to compare

@decitre decitre released this 24 Nov 14:23
· 43 commits to main since this release

lmLite is now described as browser machine learning from Python, and the API follows: the LLM class is for large language models only, pipeline() is a top-level function, and embeddings and classification have their own classes. Old code keeps working in this release and warns.

Upgrading

  • LLM.create(embedding_model=...), LLM.create(classification_model=...), llm.embed(), llm.classify() and llm.similarity_search() still work and raise a DeprecationWarning. They will be removed in 0.15. Use Embedder.create(model) and Classifier.create(model) instead:

    from lmlite import Classifier, Embedder, LLM
    
    llm = await LLM.create(generator_model="distilgpt2")
    embedder = await Embedder.create("all-MiniLM-L6-v2", backend="wasm", dtype="q8")  # was embedding_model, embedding_backend, embedding_dtype
    vector = await embedder.embed("Hello")
    results = await embedder.similarity_search("a query", docs, k=2)
    classifier = await Classifier.create("distilbert-base-uncased-finetuned-sst-2-english")
    labels = await classifier.classify("I love it", top_k=2)

    A model that was loaded together with a generator is now a second object with its own dispose().

  • Notebooks are renumbered. Old notebook URLs (?path=ch08b_vision.ipynb and the others) no longer exist. The pipeline notebooks are chapters 8 to 15 (tasks, vision, image outputs, camera, speech, microphone, ONNX models, text to image) and orchestration, streaming, token probabilities, tokenizers and WebGPU are 16 to 20. Chapters 1 to 7 and ch99 keep their numbers.

  • from lmlite.llm import Pipeline (or Speech, Tokenizer, ModelInfo, clear_cache, ...) no longer works. llm.py is split into modules; import from the package: from lmlite import Pipeline. Everything public is still exported from lmlite.

  • The JavaScript runtime file is lmlite.js (it was llm.js), with BrowserRuntime and createRuntime. globalThis.lmLite still has BrowserLLM and createLLM as aliases.

New

  • Top-level functions: pipeline, tokenizer, model_info, model_task and hosted_base, for what is not about language models. LLM.pipeline(...) and the other class methods call them and keep working.
  • audio-classification task (pipeline("audio-classification", model=...)), with the same audio inputs as speech recognition, top_k and map(). Tested with onnx-community/Musical-Instrument-Classification-ONNX (nine instruments; MIT). The model is weak: on four short test clips it got three right, with best scores of 0.26 to 0.33, so show the top three. The microphone notebook has a section that names the instrument you play.
  • CameraCapture widget (pip install 'lmlite[camera]'): take a photo with the camera of a laptop, tablet or phone and pass the JPEG to any image pipeline. A new notebook, ch11_camera, detects objects in the photo. Tested with fake cameras in Chromium and Firefox, not on a real phone or tablet.

Docs

  • The README and the docs now say what lmLite is: browser machine learning from Python, with the pipeline API as a primary API. They no longer claim there is no native inference fallback: the lmlite[native] backend runs Embedder, Classifier, greedy generation, OnnxModel and the tokenizer outside a browser.
  • The documentation is published at https://decitre.github.io/lmlite/ and linked from PyPI, together with the issue tracker, the releases page and the demo.
  • The coverage badges in the README are labelled python and javascript.

Notes

  • Embedder and the other new objects are separate JavaScript runtimes: the demo and the retrieval notebook now create two objects instead of one. I did not measure whether that costs anything.
  • Real Safari is still untested.