build()¶
Build an ONNX ModelPackage from a HuggingFace model ID.
from mobius import build
Signature¶
def build(
model_id: str,
task: str | ModelTask | None = None,
*,
module_class: type[nn.Module] | None = None,
dtype: str | ir.DataType | None = None,
load_weights: bool = True,
trust_remote_code: bool = False,
) -> ModelPackage:
Parameters¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
HuggingFace model repository ID (e.g. |
|
|
|
Model task (e.g. |
|
|
|
Custom module class. Auto-detected from registry when |
|
|
|
Target dtype ( |
|
|
|
Whether to download and apply weights from HuggingFace. |
|
|
|
Whether to trust remote code when loading the HF config. |
Returns¶
ModelPackage — A dict-like collection of named ir.Model objects.
Examples¶
from mobius import build
# Auto-detect architecture and task
pkg = build("meta-llama/Llama-3.2-1B")
pkg.save("output/llama/")
# Build without weights (graph only)
pkg = build("meta-llama/Llama-3.2-1B", load_weights=False)
# Override dtype
pkg = build("meta-llama/Llama-3.2-1B", dtype="f16")
# Custom module class
pkg = build("meta-llama/Llama-3.2-1B", module_class=MyCustomModule)
Behavior¶
Downloads the HuggingFace config via
transformers.AutoConfigDetects
model_typeand looks up the module class in the registryFalls back to diffusers pipeline detection if not a transformer model
Builds the ONNX graph via
build_from_module()Downloads and applies weights (if
load_weights=True)