Python tools for building and inspecting LiteRT-LM file formats.
Project description
LiteRT-LM Builder
Python tools for building, inspecting, and unpacking LiteRT-LM (.litertlm) container files.
Usage
The package provides two main Command Line Interfaces (CLIs): litert-lm-builder and litert-lm-peek.
🛠️ Build a LiteRT-LM File (litert-lm-builder)
Use litert-lm-builder to package various components into a single .litertlm file. There are two ways to use this tool:
Method 1: Build using a TOML Configuration
Specify all the components and metadata in a TOML file, then run:
litert-lm-builder toml --path config.toml output --path model.litertlm
Example TOML File (config.toml):
[system_metadata]
entries = [
{ key = "author", value_type = "String", value = "Authors" }
]
[[section]]
section_type = "LlmMetadata"
data_path = "path/to/llm_metadata.pb"
[[section]]
section_type = "SP_Tokenizer"
data_path = "path/to/sp.model"
[[section]]
section_type = "TFLiteModel"
model_type = "PREFILL_DECODE"
data_path = "path/to/model.tflite"
additional_metadata = [
{ key = "model_version", value_type = "String", value = "1.0.1" }
]
Method 2: Build via Command Line Arguments
You can construct the file by chaining subcommands in the terminal. The order of the subcommands determines the order of the sections in the generated file.
litert-lm-builder \
system_metadata --str author "Authors" \
llm_metadata --path path/to/llm_metadata.pb \
sp_tokenizer --path path/to/sp.model \
tflite_model --path path/to/model.tflite --model_type prefill_decode --str_metadata model_version "1.0.1" \
output --path model.litertlm
Subcommands and Options Reference:
output(Required): Specifies the output file path.--path PATH: Path to save the built.litertlmfile.
toml: Load configuration from a TOML file.--path PATH: Path to the.tomlfile.
system_metadata: Add global system metadata.--str KEY VALUE: Add a string key-value pair (can be specified multiple times).--int KEY VALUE: Add an integer key-value pair (can be specified multiple times).
llm_metadata: Add LLM-specific configuration.--path PATH: Path to the LLM metadata (text or binary proto).
tflite_model: Add a TFLite model.--path PATH: Path to the.tflitefile.--model_type TYPE: e.g.,embedder,prefill_decode.--backend_constraint BACKEND: (Optional) Backend constraint (e.g.,gpu,cpu,npu).--prefer_activation_type TYPE: (Optional) Preferred activation type (fp16,fp32,fp32_fp16).--str_metadata KEY VALUE: (Optional) String metadata for this model section.
sp_tokenizer: Add a SentencePiece tokenizer.--path PATH: Path to the.modelfile.--str_metadata KEY VALUE: (Optional) String metadata.
hf_tokenizer: Add a Hugging Face tokenizer.--path PATH: Path to thetokenizer.jsonfile.--str_metadata KEY VALUE: (Optional) String metadata.
🔍 Inspect and Unpack a LiteRT-LM File (litert-lm-peek)
Use litert-lm-peek to inspect the contents of a .litertlm file or extract all its packaged files.
litert-lm-peek --litertlm_file model.litertlm [options]
Options Reference:
--litertlm_file PATH(Required): The path to the.litertlmfile to inspect.--dump_files_dir PATH(Optional): The directory where all packaged files (models, tokenizers, weights) should be extracted/unpacked. If not provided, the tool will only print the metadata and section structures to the console without extracting files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litert_lm_builder-0.12.0-py3-none-any.whl.
File metadata
- Download URL: litert_lm_builder-0.12.0-py3-none-any.whl
- Upload date:
- Size: 48.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80f2b85314207eb6a387762066ac919ff0f05f56c7e4d5c9e3ff8f40473efc5
|
|
| MD5 |
3dee8885401fc584cf727378378a0722
|
|
| BLAKE2b-256 |
a2c39225d5685f36232cf810e1e6e7fd9adb25d9086fd19837744c2ef3c8c7c2
|