# Development Guide This guide covers installation, development setup, testing, and building lmLite. ## Prerequisites - [pixi](https://pixi.sh/) - Package manager (required) - [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html) - Conda package manager (required for JupyterLite builds) **Supported Platforms**: macOS (Intel/Apple Silicon) and Linux. Windows is not currently supported for development. ## Installation 1. Clone the repository and install dependencies with [pixi](https://pixi.sh/): ```shell git clone https://github.com/decitre/lmlite.git cd lmlite pixi install ``` 2. Run the tests to verify installation: ```shell pixi run tests ``` **Note**: If `pixi run tests` fails with "Error launching 'pytest': No such file or directory", the `.pixi` environment cache may be corrupted. Rebuild it with: ```shell rm -rf .pixi pixi install --all ``` ## Development Tasks ### Running Tests ```bash # Python tests pixi run tests # JavaScript tests pixi run js-tests # Python coverage pixi run coverage # JavaScript coverage pixi run js-coverage # Linting pixi run lint pixi run lint-check ``` ### Node.js Version for JavaScript Tests JavaScript tests and coverage require a modern Node.js runtime. If `pixi run js-tests` or `pixi run js-coverage` fails with `Cannot find module 'node:path'`, Pixi may be picking up an old Node.js installation from your shell (e.g., Node.js 10 managed by nvm). Add Node.js 22 to the project's Pixi `dev` feature: ```bash pixi add --feature dev 'nodejs>=22,<23' pixi run js-coverage ``` The `pixi add` command updates the dependency manifest and lockfile; retain those changes to make the runtime requirement reproducible for other developers. ### Browser Smoke Tests #### Model Loading Smoke Test The browser smoke test loads `Xenova/gpt2` by default: ```bash pixi run install-browser pixi run model-smoke ``` To test TinyLlama instead: ```bash LMLITE_TEST_MODEL_ID=Xenova/TinyLlama-1.1B-Chat-v1.0 \ LMLITE_TEST_BACKEND=wasm pixi run model-smoke ``` #### Embedding Smoke Tests JavaScript unit tests mock Transformers.js. The separate, opt-in `embedding-smoke` task exercises lmLite's actual browser runtime against local bundled, randomly initialized BERT weights using Playwright, without downloading model assets during the test. This is a real transformer encoder, not a mocked pipeline; meaningful semantic rankings are not required for these contract checks: ```bash pixi run install-browser pixi run embedding-smoke ``` Both fp32 and q8 runs must return finite, 16-dimensional, unit-length sentence vectors for texts of different lengths. The harness also checks successful HTTP loading of the requested ONNX variant and tokenizer assets from the local server. It rejects alternate weight downloads. The current Transformers.js runtime makes Hub metadata probes even for HTTP-hosted models; for the bundled fixture, a test-only fetch adapter redirects those probes to the real local files. It does not mock pipeline outputs or change lmLite's production loading behavior. This verifies real pooling, normalization, and dtype file selection, not merely mocked pipeline options. It does not claim bit-identical embeddings across devices or that quantization must change every output value. The original fixture's six assets total 83002 bytes (about 81 KiB) and are included under `tests/fixtures/models/lmlite/tiny-bert/`, licensed Apache-2.0. They contain no pretrained weights or third-party tokenizer vocabulary. The smoke test verifies asset SHA-256 hashes recorded in `fixture.json`. Do not treat this randomly initialized model as a useful sentence-embedding model. **Regenerating the fixture:** ```bash pixi run --environment model-fixture generate-embedding-fixture ``` The export environment supports Apple Silicon macOS and Linux; normal smoke execution also supports Intel macOS. See the [fixture provenance and regeneration notes](https://github.com/decitre/lmlite/blob/main/tests/fixtures/models/lmlite/tiny-bert/README.md). **Optional representative sentence-model run:** ```bash pixi run hf Xenova/all-MiniLM-L6-v2 -- \ config.json tokenizer.json tokenizer_config.json \ onnx/model.onnx onnx/model_quantized.onnx LMLITE_TEST_EMBEDDING_MODEL=Xenova/all-MiniLM-L6-v2 pixi run embedding-smoke ``` That run checks 384-dimensional vectors with the same normalization and local-weight loading assertions. It permits upstream `Range: bytes=0-0` metadata probes but rejects non-metadata Hub requests. **WebGPU testing:** WASM is the default. To exercise WebGPU explicitly: ```bash LMLITE_TEST_EMBEDDING_BACKEND=webgpu pixi run embedding-smoke ``` WebGPU requires support in the browser, execution environment, model, and dtype; the test does not skip failures or fall back to WASM. Optional MiniLM model files stay under `models/Xenova/all-MiniLM-L6-v2/`; missing files fail with preparation instructions. Chromium and the Transformers.js/ONNX runtime dependencies must also be available. Runtime dependencies are loaded from the CDN, so the test is not fully offline. Only the optional MiniLM run also needs Hub metadata access. #### Native Backend Parity `pixi run native-parity` runs the same inputs through the browser and the native onnxruntime backend. Embeddings must agree within an L2 distance of `1e-4` for fp32, `1e-3` for fp16 (skipped when the model has no fp16 weights) and `0.1` for q8 (dynamic quantization amplifies ulp-level kernel differences, see [why quantized results differ between backends](explanation/backends-and-bridge.md#why-quantized-results-differ-between-backends)), and a nearest-anchor margin gate must make identical accept/reject decisions on a calibration set. A greedy fp32 GPT-2 generation check also runs when `models/Xenova/gpt2` exists (`pixi run hf Xenova/gpt2`). To gate a real model at its tuned threshold: ```bash LMLITE_TEST_EMBEDDING_MODEL=Xenova/all-MiniLM-L6-v2 LMLITE_PARITY_MARGIN=0.05 pixi run native-parity ``` #### Task Pipeline Smoke Tests The opt-in `tokenizer-smoke` task checks `tokenizer()` in Chromium. It compares Transformers.js ids with reference ids from the Rust `tokenizers` library for a small bundled Unigram/Metaspace tokenizer (`tests/fixtures/models/lmlite/tiny-unigram/`). It also checks that no weight file or Hub request is made, and that `encode()` returns plain Python ints in Pyodide, which it loads from the jsDelivr CDN: ```bash pixi run tokenizer-smoke ``` `xeus-tokenizer-smoke` runs the same checks in a real xeus-python kernel. It builds a JupyterLite xeus site from the current `src/lmlite` into a temporary directory, so it needs the `xeus-site` environment and network access to emscripten-forge: ```bash pixi run -e xeus-site xeus-tokenizer-smoke ``` Regenerate the tokenizer and its expected ids, with `tokenizers` pinned, after changing the spec or test texts: ```bash pixi run --environment model-fixture generate-tokenizer-fixture ``` **WebGPU in the tests.** Headless Chromium gives WebGPU a software adapter (SwiftShader: no `shader-f16`, 1 GB buffers), so the tests that pass `backend="webgpu"` run functionally but not on your GPU, and their float16 cases skip. Set `LMLITE_WEBGPU_ARGS` to the flags that select the GPU, for example on macOS `LMLITE_WEBGPU_ARGS="--enable-unsafe-webgpu --enable-gpu --use-angle=metal --ignore-gpu-blocklist"`; then `onnx-smoke` and `task-smoke` run on it and the float16 parity test with native onnxruntime passes. The opt-in `wasm-memory-smoke` task (needs the built site: `LITE_SITES=voici bash scripts/lite-build.sh`) makes Chromium refuse a shared WebAssembly memory above 1 GB, as an iPad did in #45, and checks that the onnxruntime-web files the site serves still start. `scripts/lite-build.sh` patches their `new WebAssembly.Memory({initial:256,maximum:65536,shared:!0})` to try 4, 2, 1 GB and 512 MB, and stops if onnxruntime-web changes that line. The same task also checks that DistilGPT-2 q8 loads and generates when the heap is limited to 1 GB (a Pyodide page with a script that makes shared memory behave like that iPad: it downloads 85 MB). `lmlite.js` then loads with weight packing off (`disable_prepacking`), which needs a heap of 768 MB to 1 GB for that model and, in my measurement, costs no speed; with packing on, the session needs more than 1 GB and fails with `std::bad_alloc`. It checks by trying to create a 2 GB shared memory, once per page: packing cannot be switched off after a failed attempt, which leaves the heap used. The site build also writes `vendor/transformers/version.txt`, a hash of the vendored files. `lmlite.js` reads it with a revalidating request and loads each file as `...?rev=`, so that a browser which kept an old copy of `transformers.min.js` or an onnxruntime-web file fetches the new one at once, while an unchanged file stays cached. `voici-smoke` checks that the camera app requests every vendored file that way. The opt-in `image-size-smoke` task loads the real DETR (43 MB) with and without `image_size=480` on the two-cats photo and checks the same objects in under 70% of the time (about 2.7x faster on an Apple M-series Mac). ## The camera app as a Hugging Face Space (pilot, #86) GitHub Pages cannot send the `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` headers, so the apps run without cross-origin isolation and WebAssembly stays single-threaded. A Hugging Face **Static Space** can send them (`custom_headers` in its `README.md`; only COEP, COOP and CORP are allowed, so not `Cache-Control`). Served with them, the camera app in headless Chromium on a 12-core Mac took 0.58 to 0.66 s per photo instead of 1.88 to 1.94 s (about 3x), with the same objects found and `self.crossOriginIsolated` true. That is a desktop with many cores: a phone has fewer, and ONNX Runtime's thread count depends on them, so the gain there is not known. To make the folder (the speech app is left out: its voice, MMS-TTS, is non-commercial): ``` VOICI_APPS=camera-objects LITE_SITES=voici bash scripts/lite-build.sh bash scripts/make-space.sh build/space ``` `build/space` is the apps site (about 170 MB), a small `camera-objects.html` at the top that takes the visitor to the app, and a `README.md` with `sdk: static`, `app_file: camera-objects.html` and three headers: COEP, COOP and `cross-origin-resource-policy: cross-origin`. The last is needed because the Space page on huggingface.co is itself isolated and refuses to embed a document without it: with only the first two, the app area of the Space page was blank in Chromium and Firefox. The entry file has to be at the top: a Static Space serves relative to the directory of `app_file`, and with the app's own nested path every other file was a 404 (found on the first upload). Create a Space of type Static on Hugging Face, upload the folder (`hf upload / build/space . --repo-type space`), then open the **direct URL** of the Space (`https://-.static.hf.space/`, the `host` that the Space's API shows) rather than the Space page, which embeds it in a frame. To check, take a photo with Debug ticked and read `self.crossOriginIsolated` in the browser console; compare the detection time with the GitHub Pages app on the same device. Record the browser, the permission behaviour and the time on a phone in #86. The opt-in `space-smoke` task (`pixi run space-smoke`, after the camera-only build) serves that folder with the headers its `README.md` names and checks that the page is cross-origin isolated, that the app finds the objects, and that the speech app is not in the folder. The pilot Space is `decitre/lmlite-camera-objects` (https://huggingface.co/spaces/decitre/lmlite-camera-objects). Hugging Face does send both headers (`curl -I` shows them on every response), and the app ran on it in headless Chromium on a 12-core Mac: isolated, no failed request, the same objects, 0.60 to 0.67 s per photo against about 1.9 s without the headers. On the Space page that embeds it, the app renders in Chromium and the frame is cross-origin isolated. Playwright's Firefox does not get past "Starting up kernel" on the Space page or on its direct URL, nor on GitHub Pages: that is the service-worker problem described above, and with service workers blocked the direct URL of the Space is ready. Not checked: a stock Firefox or Safari, the camera inside the embedded frame, and phones. The opt-in `onnx-map-smoke` task runs `OnnxModel.map()` through the real bridge: a lazy generator with a wrong-dtype input returned in its place (`on_error="return"`), results equal to one `run()` per input, progress, and cancelling, in Pyodide on WASM and WebGPU and (with `pixi run -e xeus-site onnx-map-smoke`) in xeus-python. The opt-in `lab-smoke` task (`pixi run -e xeus-site lab-smoke`, needs network access) opens notebooks in the real JupyterLab UI of the xeus-python site, which is what a reader gets and what the REPL-page kernel tests do not cover. It runs all cells of the image-outputs, speech and microphone notebooks and checks what is on the page: every `` decoded, the audio players decode, the `anywidget` recorder renders and records from a fake microphone, no error output. It runs in Chromium and in Firefox (Playwright's build, 155.0 when this was written). In Firefox it blocks service workers: JupyterLite's service worker answers every cross-origin GET itself with `fetch(request)`, and in that Firefox build a kernel's download of a model from huggingface.co then never completes (`LLM.tokenizer`, `LLM.pipeline` hang; the same fetch works with service workers blocked, in Chromium, and in a plain worker without JupyterLite). That has not been checked in a stock Firefox, where speech to text is reported to work, so it may be a property of the test build. Safari is not covered. The xeus ONNX tests (`xeus-onnx-smoke`, `onnx-map-smoke`) also run on WebGPU, and cover a hosted ID, the SHA-256 check, the Cache API and float16 (the float16 WebGPU case needs a GPU with `shader-f16`: see `LMLITE_WEBGPU_ARGS`). The opt-in `text-to-image-smoke` task runs the cells of `ch20_text-to-image.ipynb` on a hardware GPU in Pyodide and (with `pixi run -e xeus-site text-to-image-smoke`) xeus-python, against a local copy of the 2.4 GB SD-Turbo files named by `LMLITE_SD_TURBO_DIR` (non-commercial research licence, `schmuell/sd-turbo-ort-web`); it skips without them. It checks a 512 x 512 PNG that is not flat, that two seeds differ, and that the adapter has `shader-f16`. The opt-in `image-output-smoke` task runs the four tasks that return images with the models in `MODELS.md`: in Chromium, the PNG files and their sizes, the PNG encoding inside a Web Worker, and in Pyodide and (with `pixi run -e xeus-site image-output-smoke`) xeus-python the Python results, `as_array=True` and `map()`. Override the models with `LMLITE_TEST_BACKGROUND_REMOVAL_MODEL`, `LMLITE_TEST_DEPTH_MODEL`, `LMLITE_TEST_SEGMENTATION_MODEL` and `LMLITE_TEST_IMAGE_TO_IMAGE_MODEL`. The opt-in `vision-notebook-smoke` task runs the object-detection cells of `ch13_vision.ipynb` (random Commons photos, `map()`, the contact sheets) in Pyodide and, with `pixi run -e xeus-site vision-notebook-smoke`, in xeus-python, runs the picking cell twice, and checks that boxes were drawn onto the photos and that the second pick repeats none of the first. It needs network access. Loading a FreeType font hangs in xeus-python (Pillow 13 in the browser), which is why the notebook draws its labels with the built-in bitmap font. The opt-in `audio-smoke` task records with Chromium's fake microphone (a repeating beep): the recorder in `lmlite.js`, the widget's JavaScript on a page without lmLite, and (with `pixi run -e xeus-site audio-smoke`) the widget in a real xeus-python kernel, from a click on Record and Stop to `await recorder.wait()`. No real microphone, tablet or Safari is involved, so those stay untested. The opt-in `camera-smoke` task takes a photo with the camera widget's JavaScript on a page, with Chromium's fake camera playing a photo of two cats (`--use-file-for-fake-video-capture`, one JPEG as a still picture), and checks the JPEG, its size, that Stop camera releases the camera, and that object detection on the photo finds two cats and a couch. `lab-smoke` runs the camera notebook in the real Lab UI, in Chromium (the cats) and Firefox (its fake camera is a pattern, so only the photo is checked). The opt-in `audio-classification-smoke` task runs `audio-classification` with the instrument model (override with `LMLITE_TEST_AUDIO_CLASSIFICATION_MODEL`) in Pyodide and, with `pixi run -e xeus-site audio-classification-smoke`, in xeus-python: WAV bytes, a list of samples and `map()`, on a synthetic tone, checking the result format and not the instrument. `lab-smoke` records twice in the microphone notebook, the second time for the instrument cell. The opt-in `embedder-smoke` task runs `Embedder` (MiniLM: the vector's size and norm, `similarity_search()`), `Classifier` (a sentiment model) and that `LLM.create(embedding_model=...)` is refused, in Pyodide and, with `pixi run -e xeus-site embedder-smoke`, in xeus-python. The opt-in `backend-fallback-smoke` task loads a small classifier with `backend="webgpu"` in headless Chromium without WebGPU and checks that it runs on WASM (`Classifier.backend`), and that `backend_fallback=False` fails instead. With `pixi run -e xeus-site backend-fallback-smoke` and a browser that has a WebGPU adapter (`LMLITE_WEBGPU_ARGS`), it also makes WebGPU compute pipelines fail in the xeus-python kernel and checks that a WASM load afterwards still runs. The opt-in `speech-smoke` task runs text to speech with `Xenova/mms-tts-eng` (override with `LMLITE_TEST_SPEECH_MODEL`): the samples crossing the bridge as one buffer in Chromium, `model_info()` for the task, and the `Speech` object in Pyodide (without NumPy) and, with `pixi run -e xeus-site speech-smoke`, in xeus-python (with NumPy). It also downloads the model's files once into a temporary hosted tree, served with CORS headers by a local server, and loads the pipeline from it in Chromium, Pyodide and xeus-python, checking that no request goes to huggingface.co. The opt-in `map-smoke` task checks `Pipeline.map()` with real models: batches against single calls, progress, `on_error` and cancelling in Chromium, and the bridge's progress callback in Pyodide and (with `pixi run -e xeus-site map-smoke`) in xeus-python. The opt-in `onnx-smoke` task runs a 150-byte model (`tests/fixtures/onnx/scale_add.onnx`, regenerated with `uv run --with onnx python scripts/generate_onnx_fixture.py`) through `OnnxModel`'s browser code on WASM and WebGPU, and through the Python bridge in Pyodide. It downloads onnxruntime-web from jsDelivr. `xeus-onnx-smoke` runs the same model through the xeus-python bridge (`pixi run -e xeus-site xeus-onnx-smoke`); it shares one site build with `xeus-tokenizer-smoke` when both run in one session. `onnx-notebook-smoke` (`pixi run -e xeus-site onnx-notebook-smoke`) runs the code of `ch19_onnx-models.ipynb` in Pyodide and in xeus-python, with a seeded random photo from Wikimedia Commons, the UltraFace model from GitHub and the xeus environment's NumPy and Pillow, so it needs network access. The opt-in `task-smoke` task loads each `pipeline()` task (zero-shot classification, translation, speech recognition, and the four vision tasks) through the browser runtime, with real models downloaded from the Hub: ```bash pixi run task-smoke ``` It runs each task on WASM and WebGPU. WebGPU runs are skipped when Chromium exposes no WebGPU adapter. Set `LMLITE_TEST_TASK_BACKENDS=wasm` to restrict backends. Override the models with `LMLITE_TEST_ZERO_SHOT_MODEL`, `LMLITE_TEST_TRANSLATION_MODEL`, `LMLITE_TEST_ASR_MODEL`, `LMLITE_TEST_IMAGE_CLASSIFICATION_MODEL`, `LMLITE_TEST_ZERO_SHOT_IMAGE_MODEL`, `LMLITE_TEST_IMAGE_FEATURES_MODEL` and `LMLITE_TEST_OBJECT_DETECTION_MODEL`. Set `LMLITE_MODEL_TIMEOUT_MS` to adjust the inference wait limit (default: 900000 ms). None of the browser smoke tasks run in the default non-browser test suite. ### Building a Wheel ```bash pixi run wheel ``` ### Version Management Set a specific package version in README.md and `src/lmlite/version.py` without creating a commit or tag: ```bash pixi run set-version ..

``` ## Building JupyterLite Demo ```bash pixi run jupyterlite ``` Follow the instructions provided by the command. ### Hosting Models in JupyterLite Model bundling is opt-in and applies to both the Xeus and Pyodide sites. Download models into a Hugging Face-style `models///` directory, then build with `-m`: The `hf` Pixi task downloads a complete model repository into that layout, including its `onnx/` files; no `--include` option is needed: ```bash pixi run hf Xenova/gpt2 pixi run jupyterlite -m ``` For a specific ONNX variant, select the required files explicitly: ```bash pixi run hf HuggingFaceTB/SmolLM2-360M-Instruct -- \ config.json generation_config.json tokenizer.json tokenizer_config.json \ special_tokens_map.json vocab.json merges.txt onnx/model_q4.onnx pixi run jupyterlite -m ``` Download the configuration, tokenizer assets, and the ONNX variant you intend to run—not only the ONNX weight file. Include any external ONNX data files required by the model. For models stored elsewhere, pass their containing `//` tree with `-M`; keep that source outside `workspace/`, which the build recreates: ```bash pixi run jupyterlite -M /path/to/models ``` The `-m`/`-M` options copy individual model files into each built site, at its HTTP `files/models///` URLs. They are added after `jupyter lite build` rather than to its contents, so the xeus kernel doesn't pack them into its mounted files, and they don't appear in the file browser. Every file of each model is hosted, including all its ONNX variants: download only the ones you load, or set `MODEL_DTYPES` to host only the ONNX weights of the first listed dtype each model has, e.g. `MODEL_DTYPES="q8 int8 fp32" pixi run jupyterlite -m` (the runtime's default order). The build prints the dtypes hosted for each model. A `files/models/manifest.json` lets `LLM.create(...)` discover the hosted models and load their files directly over HTTP with browser caching and download progress, bypassing the `/drive` filesystem. Missing files in a hosted model produce an error rather than downloading a different copy from Hugging Face. Every build also self-hosts Transformers.js: the version `src/lmlite/lmlite.js` pins (`TRANSFORMERS_VERSION`) and the onnxruntime-web files it loads (plus the `ort.webgpu.min.mjs` frontend that `OnnxModel` uses) go into each site's `vendor/transformers/`, downloaded once into `~/.cache/jl-forge/lmlite-transformers/`. `lmlite.js` imports them from the site, and falls back to jsDelivr outside such a site. With `-m`, a site built this way makes no request to another host: `pytest tests/browser/test_self_hosted_site.py -m browser` checks it, generating with the hosted model in both sites while blocking every other host. The site steps come from [jl-forge](https://github.com/decitre/jl-forge), pinned in `scripts/lite-build.sh` as `JL_FORGE_VERSION="~=0.8.0"` (it makes breaking changes only in minor releases before 1.0, so a bump needs a look at its release notes). Three things follow from 0.7 and 0.8: `pyodide-wheels` solves the dependencies with uv, so the Pyodide venv installs `uv` (the `pyodide` extra does the same, but the script writes `jl-forge$JL_FORGE_VERSION` on one line, because jl-forge's weekly `consumers.yml` rewrites that line to test its own commit against this script); `pyodide-dist --wheels-dir` keeps the Pyodide packages that the bundled wheels need (`typing_extensions` for `anywidget`), so the Pyodide site fetches nothing from PyPI; and the Pyodide build venv installs the `audio` extra, because the build copies the widget frontend of `anywidget` from the venv while piplite only installs the Python package in the browser. The `images` and `audio` extras are passed to every jl-forge call that reads `pyproject.toml`. The build requires individual model directories containing configuration, tokenizer assets, and the selected ONNX weights. For hosted files, enable gzip or Brotli **HTTP compression** on your hosting server when supported. Serve the original filenames with the appropriate `Content-Encoding` header; browsers decompress them transparently. This build does not generate `.gz` filenames or configure your server. Python's simple HTTP server works with the uncompressed files. Hosting models increases site size and requires a source outside `workspace/`. See [MODELS.md](MODELS.md#downloading-and-bundling-models) for download filtering and matching the selected ONNX variant to `LLM.create(...)`. ### Preparing Models for Another Hosted Site The installed package includes `lmlite-models`; no repository checkout is required. It copies individual assets from a `//` source tree and writes `manifest.json`, excluding download metadata and backup files: ```bash lmlite-models --source-dir /path/to/models --output-dir /path/to/site/files/models ``` `--dtype q8 int8 fp32` hosts only the ONNX weights of the first listed dtype each model has, plus all its other assets; a model with none of them fails. When a model has `onnx/model*.onnx` files, only those decide which dtypes it has, as Transformers.js loads them and not the legacy `decoder_model*` exports. `--model Xenova/multilingual-e5-small:q8 --model HuggingFaceTB/SmolLM2-360M-Instruct:q4` hosts only the listed models, each at its own dtype (a bare `--model ID` uses `--dtype`, or hosts every variant); `manifest.json` lists exactly the hosted models, and a model missing from the source fails. A model with no ONNX weights fails, in both formats, instead of being listed and failing to load in the browser. Symlinks are copied as their target file when it lies inside the model directory; others (such as a Hugging Face cache `snapshots/` tree pointing into `blobs/`) are skipped and named. Dereference those first, for example with `cp -rL`. The output must be outside the source directory. Publish it over HTTP and pass its URL as `hosted_models_url` when automatic discovery does not apply. Use `--format zip` explicitly to prepare portable model archives instead; ZIP mode caches archives in the source directory and reuses them on subsequent runs. The same CLI is available through `python -m lmlite.model_assets`. Python callers can use `host_models` and `pack_models` from `lmlite.model_assets`. The JupyterLite build invokes `lmlite-models` directly with `--format files`, and `--dtype $MODEL_DTYPES` when set. When using `-m` or `-M`, lmLite must be installed and `lmlite-models` must be available on `PATH`; builds without model hosting do not require the CLI. The build script does not invoke Pixi. ## Troubleshooting ### Models downloading every time? Check browser console for Cache API availability. Some privacy settings may disable caching. ### Out of memory errors? Try smaller models like `distilgpt2` or reduce `max_new_tokens`. ### CORS errors? Ensure you're running from `http://localhost` or a proper HTTPS domain, not `file://`. ### "Failed to load text-generation model 'undefined'" on Pyodide? This error indicates the configuration parameters aren't being properly passed to the JavaScript layer. This was a known issue with dictionary conversion in older versions. The fix is included in the latest version. If you encounter this issue: 1. Ensure you're running the latest version of lmlite 2. Clear your browser cache (IndexedDB and Cache API) 3. Restart the kernel and try again