Repository navigation
0.14.0
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()andllm.similarity_search()still work and raise aDeprecationWarning. They will be removed in 0.15. UseEmbedder.create(model)andClassifier.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.ipynband 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 andch99keep their numbers. -
from lmlite.llm import Pipeline(orSpeech,Tokenizer,ModelInfo,clear_cache, ...) no longer works.llm.pyis split into modules; import from the package:from lmlite import Pipeline. Everything public is still exported fromlmlite. -
The JavaScript runtime file is
lmlite.js(it wasllm.js), withBrowserRuntimeandcreateRuntime.globalThis.lmLitestill hasBrowserLLMandcreateLLMas aliases.
New
- Top-level functions:
pipeline,tokenizer,model_info,model_taskandhosted_base, for what is not about language models.LLM.pipeline(...)and the other class methods call them and keep working. audio-classificationtask (pipeline("audio-classification", model=...)), with the same audio inputs as speech recognition,top_kandmap(). Tested withonnx-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.CameraCapturewidget (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 runsEmbedder,Classifier, greedy generation,OnnxModeland 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
pythonandjavascript.
Notes
Embedderand 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.