Skip to main content

ONNX Runtime-backed text generation engine (same API as nxrt.genai)

Project description

onnx-genai

ONNX Runtime-backed text generation for Python.

onnx-genai exposes a small, high-level generation API implemented on ONNX Runtime. It is the ONNX Runtime-compatible counterpart of nxrt.genai: both packages present the same Engine / GenerateResult API, but onnx_genai runs on ONNX Runtime while nxrt.genai runs on the native nxrt runtime.

import onnx_genai

engine = onnx_genai.Engine.from_dir("path/to/model_dir")

result = engine.generate("Hello, world!", max_tokens=64, temperature=0.8)
print(result.text)

# Streaming
def on_token(text, token_id, finish_reason):
    print(text, end="", flush=True)

engine.generate_stream("Tell me a story", on_token, max_tokens=128)

The model directory must contain the ONNX graph(s), tokenizer.json, and model metadata (inference_metadata.yaml or genai_config.json).

Wheels

Distributed as stable-ABI (abi3) wheels tagged cp310-abi3, so a single wheel per platform loads on CPython 3.10 and newer. The bundled ONNX Runtime shared library is vendored into the wheel, so no separate ONNX Runtime installation is required.

Related packages

  • nxrt — the low-level nxrt runtime (inference sessions, eager ops) plus nxrt.genai, the same generation API backed by the native runtime.
  • onnx-genai-server — the onnx-genai command-line tool, including the OpenAI-compatible server (onnx-genai serve).

See https://github.com/justinchuby/onnx-genai.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onnx_genai-0.1.0.dev3.tar.gz (2.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

onnx_genai-0.1.0.dev3-cp310-abi3-win_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10+Windows ARM64

onnx_genai-0.1.0.dev3-cp310-abi3-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

onnx_genai-0.1.0.dev3-cp310-abi3-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

onnx_genai-0.1.0.dev3-cp310-abi3-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file onnx_genai-0.1.0.dev3.tar.gz.

File metadata

  • Download URL: onnx_genai-0.1.0.dev3.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for onnx_genai-0.1.0.dev3.tar.gz
Algorithm Hash digest
SHA256 deeb70eb416f4c50044cc3b3856d487b15cd0b4ee51a9b8ad8a762be4b09e705
MD5 1c2d77e15ceb042ea673d46246ce71ad
BLAKE2b-256 d49e9849d19364f412a569664abf15e88ad5bdf609e36116744b0dac07578206

See more details on using hashes here.

Provenance

The following attestation bundles were made for onnx_genai-0.1.0.dev3.tar.gz:

Publisher: publish.yml on justinchuby/onnx-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onnx_genai-0.1.0.dev3-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for onnx_genai-0.1.0.dev3-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 26fa58352c3114767388fdc8e76e1c4a7aa9f63a3bdd9fabc82f8c86d6d40df3
MD5 b5b5858e5460ab01ce9266c7d17e835d
BLAKE2b-256 00eede8390f6f12d328cc65bb6aa01f1602330ea79efc604d6cca49bc22513f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for onnx_genai-0.1.0.dev3-cp310-abi3-win_arm64.whl:

Publisher: publish.yml on justinchuby/onnx-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onnx_genai-0.1.0.dev3-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for onnx_genai-0.1.0.dev3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c14d997b2bdc0e7b4af66dfd87718784913268706c4a3099fbadadbc31b9c0e1
MD5 d72636a77c1181923d9eb049f96114d7
BLAKE2b-256 7a530fa4edea510e8021cca5ba28cfa71d1367b5ddb87b4ec3f30e7115db17a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for onnx_genai-0.1.0.dev3-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on justinchuby/onnx-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onnx_genai-0.1.0.dev3-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for onnx_genai-0.1.0.dev3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2763551601d66d41b99acd32198a83b9043079a43b15fb82ec6eb676f4523ab1
MD5 7237fee9062e98c3aacfcde448f347b4
BLAKE2b-256 0385d753ff32e811081d7669a6c851803b26615257386f8d760cd71677e5a3b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for onnx_genai-0.1.0.dev3-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on justinchuby/onnx-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onnx_genai-0.1.0.dev3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for onnx_genai-0.1.0.dev3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29fb3a2a7b1a6de1f626c40491175eeb62a8ad19b70eccf596b46e3fe07e3a20
MD5 511d1f35bf92f5ca768993c11edcf37f
BLAKE2b-256 2dcbf36d1ce41e090fd19115d26ca347ca23d985650d81bcbb8ac909ff8b288e

See more details on using hashes here.

Provenance

The following attestation bundles were made for onnx_genai-0.1.0.dev3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on justinchuby/onnx-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page