Spaces:
Running
Running
File size: 2,038 Bytes
5f923cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | # 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:
```bash
./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
```bash
litertlm-builder [options]
```
The tool supports two options: Subcommand Chaining (passing options directly) and TOML Configuration.
#### Example: Subcommand Chaining (Direct Arguments)
```bash
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
```bash
litertlm-builder toml --path example.toml output --path real_via_toml.litertlm
```
### litertlm-peek
```bash
litertlm-peek [options]
```
#### Example Usage
To inspect a `.litertlm` file:
```bash
litertlm-peek --litertlm_file real.litertlm
```
To extract (dump) the contents of a `.litertlm` file:
```bash
litertlm-peek --litertlm_file real.litertlm --dump_files_dir ./extracted_files
```
|