界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

hummingbird

hummingbird

【效率与协作】Use Hummingbird to convert trained traditional ML models into tensor backends, validate parity, choose backends, and troubleshoot optional dependencies.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: hummingbird description: "Use Hummingbird to convert trained traditional ML models into tensor backends, validate parity, choose backends, and troubleshoot optional dependencies." disable-model-invocation: true metadata: disco-role: operating license: MIT

Hummingbird repo skill

Use this skill when a task involves the hummingbird-ml Python package: converting trained classical ML models into PyTorch, TorchScript, ONNX, or TVM-style tensor computations; validating prediction parity; saving/loading converted containers; or diagnosing optional model-source/back-end dependencies.

Quick identification

  • Import package: hummingbird, hummingbird.ml.
  • Distribution: hummingbird-ml.
  • Core APIs: hummingbird.ml.convert(...), hummingbird.ml.convert_batch(...), and hummingbird.ml.load(...).
  • Typical source models: scikit-learn estimators/pipelines, optional LightGBM/XGBoost/Prophet sklearn-style models, optional SparkML models, and ONNX-ML ModelProto inputs.
  • Typical targets: "torch"/"pytorch", "torch.jit"/"torchscript", "onnx", and optional "tvm".

Install and smoke-check

Install the package and extras that match the user's workflow:

python -m pip install hummingbird-ml
python -m pip install 'hummingbird-ml[onnx]'      # ONNX output or ONNX-ML input workflows
python -m pip install 'hummingbird-ml[extra]'     # LightGBM, XGBoost, Prophet source workflows
python -m pip install 'hummingbird-ml[sparkml]'   # SparkML source workflows

Run the bundled environment probe before deeper troubleshooting:

python scripts/check_hummingbird_env.py --json

Read repo provenance when deciding whether this skill matches the current package version or should be refreshed.

Route by task

User task shapeRead next
Build a basic convert(...) call, convert a fitted sklearn estimator to PyTorch, or validate predictions quicklycore conversion
Use convert_batch, handle uneven fixed-batch inference, or recover from NotFittedError, MissingBackend, or MissingConverter in the core pathcore conversion
Decide whether a scikit-learn estimator, transformer, Pipeline, ColumnTransformer, or tree strategy is supportedsklearn pipelines and operators
Work with ONNX output, ONNX-ML source models, onnxruntime, onnxmltools, skl2onnx, saved containers, digests, or override_flagONNX and model I/O
Convert LightGBM, XGBoost, SparkML, or Prophet models, or diagnose optional-library install/import failuresoptional source models
Choose TorchScript, TVM, CUDA/GPU, threading, batching, or benchmark/performance optionsadvanced backends and performance

Core operating rules

  1. Hummingbird converts trained models. If the source estimator must be fitted first, route the user to fit/validate it before calling convert.
  2. Prefer backend="torch" for the lowest-friction CPU parity check unless the user explicitly needs ONNX, TorchScript, TVM, or GPU execution.
  3. Provide representative test_input when tracing/exporting (torch.jit, ONNX, TVM), when shapes are not obvious, or when source packages such as XGBoost need feature-count inference.
  4. Validate parity on the method the downstream code will call: predict, predict_proba, transform, decision_function, or score_samples.
  5. Treat CUDA, TVM, SparkML, LightGBM, XGBoost, and Prophet as optional surfaces. Check imports and backend availability before promising runtime behavior.
  6. Do not use benchmark-scale scripts as smoke tests. Use bundled smoke/probe helpers and tiny data unless the user explicitly requests a benchmark run.

Shared references and helpers

  • API overview summarizes package entry points, backend aliases, constants, containers, and dependency surfaces.
  • Cross-cutting troubleshooting covers install/import, backend, optional dependency, parity, and artifact-loading failures.
  • Environment checker reports package version, available backend aliases, optional imports, and torch CUDA status without installing anything.

Verification note

This skill was generated with CPU PyTorch and ONNX workflows verified. CUDA, TVM, SparkML, LightGBM, XGBoost, and Prophet are documented as optional surfaces unless the active environment separately proves those dependencies/backends.

我的收藏