← Catalog

pi-onnx

Run Hugging Face onnx-community models locally inside pi: registers a chat provider for ONNX text-generation models and a set of tools (embeddings, classification, ASR) backed by @huggingface/transformers and onnxruntime-node.

ExtensionProvider

Install

Install with PiG

pig install npm:pi-onnx

Install with Pi

pi install npm:pi-onnx
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.4 (README.md). PiG does not review it.

pi-onnx

Runs Hugging Face onnx-community models locally inside the pi coding agent using @huggingface/transformers.

Implements a chat provider and several tool calls:

  • onnx_embed({ texts: string[] }): array of vectors (and dimensionality).
  • onnx_classify({ text, labels? }): top-K labels with scores; when labels is provided, runs zero-shot classification.
  • onnx_transcribe({ path, language?, task? }): transcript text and segments.

Install

pi install npm:pi-onnx

Configure

Copy example-config.json from this package as a starting point:

cp example-config.json ~/.pi/agent/pi-onnx.json

Top-level

FieldTypeDefaultNotes
cacheDirstring | nullnull (HF default)Forwarded to env.cacheDir.
device"cpu" | "webgpu" | "wasm" | "gpu""cpu"onnxruntime execution provider hint.
defaultDtypeDtype"q4"Per-model dtype overrides this.
preloadDefaultModelbooleanfalsePreload the first configured model on session start.
modelsModelEntry[][Qwen2.5-Coder-0.5B-Instruct]Each entry becomes a onnx-community/<id> chat model.
discoveryobjectenabled, limit 50Append compatible onnx-community/* models from the HF Hub.
toolsobjectembed onlyToggles for onnx_embed / _classify / _transcribe.

Dtype is one of "fp32", "fp16", "q8", "int8", "uint8", "q4", "bnb4", "q4f16".

models[]

FieldTypeDefaultNotes
idstring—Hugging Face repo path (onnx-community/ prefixed).
namestringidDisplay name shown in the model picker.
contextWindownumber—Context window size in tokens.
maxTokensnumber1024Default max_new_tokens for completions.
dtypeDtypedefaultDtypeQuantization for this model only.

Only id is required; the onnx-community/ prefix is added if missing. Pinned models are checked against the Hugging Face Hub when possible. Repositories that are not compatible with @huggingface/transformers text generation, such as onnxruntime-genai image-text-to-text exports, are skipped instead of being offered as broken chat models.

Example:

{
  "id": "onnx-community/Qwen3-0.6B-ONNX",
  "name": "Qwen3-0.6B (ONNX, q4)",
  "contextWindow": 32768,
  "maxTokens": 2048,
  "dtype": "q4"
}

discovery

FieldTypeDefaultNotes
enabledbooleantrueAppend discovered models to models[].
limitnumber50Per pipeline tag.
pipelineTagsPipelineTag[]["text-generation"]Hugging Face pipeline tags to scan.

Discovery only registers transformers.js text-generation repositories that expose a supported onnx/model*.onnx file. It also records the matching dtype, so models such as gpt-oss-20b-ONNX use q4f16 instead of the global default q4. If a discovered model is also pinned in models without an explicit dtype, discovery fills in that dtype automatically.

tools.embed

FieldTypeDefaultNotes
enabledbooleantrueToggles onnx_embed.
modelstringonnx-community/all-MiniLM-L6-v2Any feature-extraction model.
pooling"mean" | "cls""mean"Pooling strategy.
normalizebooleantrueL2-normalize output vectors.

tools.classify

FieldTypeDefaultNotes
enabledbooleanfalseToggles onnx_classify.
modelstringonnx-community/distilbert-base-uncased-finetuned-sst-2-englishClassifier or NLI model (zero-shot).
topKnumber5Maximum labels returned.

tools.transcribe

FieldTypeDefaultNotes
enabledbooleanfalseToggles onnx_transcribe.
modelstringonnx-community/whisper-tinyAny ASR model.
languagestring | nullnullDefault language hint (e.g. "en").
task"transcribe" | "translate""transcribe"Default ASR task.
maxDecodedBytesnumber268435456Maximum decoded f32 audio bytes to buffer in RAM.

Limitations

  • No tool calling support for ONNX chat models.
  • Tokens are approximated from the tokenizer.
  • First call to a model blocks while weights download.
  • onnx_transcribe shells out to ffmpeg (must be on PATH) to decode the input audio file to a Float32Array before inference, capped by maxDecodedBytes.

License

pi-onnx is licensed under MIT. See LICENSE for more information.