LiteRT-LM / schema /py /README.md
SeaWolf-AI's picture
Upload full LiteRT-LM codebase
5f923cd verified

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:

  1. Stage the files in a temporary directory.
  2. Build Protobuf and FlatBuffer bindings using Bazel.
  3. Rewrite imports to match the package structure.
  4. 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