Spaces:
Running
Running
LiteRT-LM Builder
Python tools for building, inspecting, and unpacking LiteRT-LM files.
This directory contains the source code for the litert-lm-builder Python package.
Project Structure
litertlm_builder.py: Core logic for building LiteRT-LM files.litertlm_builder_cli.py: Command-line interface for the builder.litertlm_peek.py: Core logic for inspecting LiteRT-LM files.litertlm_peek_main.py: Command-line interface for the peek tool.pyproject.toml: PEP 517 configuration for the package.bundle_pypi_package.sh: Script to bundle the package into a PyPI-ready wheel.
Building and Packaging
To build the package and create a wheel, run the bundle script:
./bundle_pypi_package.sh
This script will:
- Stage the files in a temporary directory.
- Build Protobuf and FlatBuffer bindings using Bazel.
- Rewrite imports to match the package structure.
- Build the wheel using
uv.
Usage
After installing the package, you can use the CLI tools:
litertlm-builder
litertlm-builder [options]
The tool supports two options: Subcommand Chaining (passing options directly) and TOML Configuration.
Example: Subcommand Chaining (Direct Arguments)
litertlm-builder \
system_metadata --str Authors "ODML team" --int version 1 \
llm_metadata --path schema/testdata/llm_metadata.pb \
sp_tokenizer --path runtime/components/testdata/sentencepiece.model \
tflite_model --path runtime/components/testdata/dummy_embedding_cpu_model.tflite --model_type embedder \
output --path real.litertlm
Example: Using a TOML Configuration File
litertlm-builder toml --path example.toml output --path real_via_toml.litertlm
litertlm-peek
litertlm-peek [options]
Example Usage
To inspect a .litertlm file:
litertlm-peek --litertlm_file real.litertlm
To extract (dump) the contents of a .litertlm file:
litertlm-peek --litertlm_file real.litertlm --dump_files_dir ./extracted_files