Skip to main content

onnx2oracle

Load ONNX embedding models into Oracle AI Database with one command.

CI Docs PyPI License: MIT

pip install onnx2oracle
onnx2oracle docker up
onnx2oracle load all-MiniLM-L6-v2 --target local
onnx2oracle verify --target local

Embeddings run entirely in-database via Oracle's VECTOR_EMBEDDING (no external API calls, no network round-trips, no serving layer).

How it works

onnx2oracle downloads a sentence-transformer model from HuggingFace, wraps its tokenizer as ONNX ops, merges it with the transformer body, and appends pooling + L2 normalization. The resulting single-graph ONNX is uploaded to Oracle via DBMS_VECTOR.LOAD_ONNX_MODEL, after which you can query it with:

SELECT VECTOR_EMBEDDING(ALL_MINILM_L6_V2 USING 'hello world' AS DATA) FROM dual;

Architecture

See Architecture Diagram (Excalidraw, open at excalidraw.com) and Architecture Overview for visual documentation of how the pieces fit together.

The augmented ONNX pipeline is the interesting bit. HuggingFace ships a Python tokenizer; Oracle needs an ONNX graph it can call directly. pipeline.py wraps the fast tokenizer as ONNX ops via onnxruntime-extensions, welds it onto the transformer body, bolts mean- or CLS-pooling on top, appends L2 normalization, and emits a single graph that goes string to float32 vector. That's what gets uploaded via DBMS_VECTOR.LOAD_ONNX_MODEL.

Directory Structure

src/onnx2oracle/
├── cli.py            # Typer commands: load, verify, presets, docker, config
├── presets.py        # 6 curated ModelSpecs
├── connection.py     # DSN resolution (CLI > env > toml > target > prompt)
├── pipeline.py       # HF model -> augmented ONNX bytes
├── loader.py         # DBMS_VECTOR.LOAD_ONNX_MODEL wrapper
└── verify.py         # Smoke test via VECTOR_EMBEDDING
docker/
└── docker-compose.yml  # Oracle 26ai Free (gvenzl fallback documented)
docs/                 # GitHub Pages site + architecture docs
tests/                # Unit + integration (needs --run-integration)

Presets

Preset Dims Size Pooling
all-MiniLM-L6-v2 384 90 MB mean
all-MiniLM-L12-v2 384 130 MB mean
all-mpnet-base-v2 768 420 MB mean
bge-small-en-v1.5 384 130 MB cls
nomic-embed-text-v1 768 540 MB mean

Any sentence-transformer-style HuggingFace model also works via --from-huggingface.

Common tasks

# List all presets
onnx2oracle presets

# Load into a cloud ADB
onnx2oracle load all-mpnet-base-v2 --dsn 'app/pass@adb.region.oraclecloud.com:1522/xxx_high'

# Load a non-preset model
onnx2oracle load --from-huggingface BAAI/bge-base-en-v1.5 \
  --pooling cls --normalize --dims 768 --name BGE_BASE_EN_V1_5

# End-to-end verification
onnx2oracle verify --target local

Requirements

  • Python 3.10+
  • Docker (for the local Oracle 26ai Free path) or any Oracle 23ai/26ai instance
  • ~2 GB free RAM during model augmentation
  • ~1 GB DB storage per preset

Documentation

Full guide at jasperan.github.io/onnx2oracle.

Development

git clone https://github.com/jasperan/onnx2oracle
cd onnx2oracle
conda create -n onnx2oracle python=3.12 -y
conda activate onnx2oracle
pip install -e ".[dev]"
pytest tests/ -v -m "not slow and not integration"

License

MIT.

Metadata

Release files for onnx2oracle 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onnx2oracle 0.1.1
File Size Uploaded Provenance Actions
onnx2oracle-0.1.1.tar.gz 19.6 kB Without provenance Details for onnx2oracle-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for onnx2oracle 0.1.1
File Interpreter ABI Platform Actions
onnx2oracle-0.1.1-py3-none-any.whl Python 3 none any Details for onnx2oracle-0.1.1-py3-none-any.whl

Total release size: 36.5 kB

Release files / onnx2oracle-0.1.1.tar.gz

Download URL onnx2oracle-0.1.1.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
787522d5f2673d8f039756b122edefd8f10e4b64631d4b990d8fb31d9d23c05f
BLAKE2b-256 checksum
How to use checksums
4de477e8ee7cc88ca414ab1f0c7491cf7421c735c323cd3910f7557ab8d2d834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / onnx2oracle-0.1.1-py3-none-any.whl

Download URL onnx2oracle-0.1.1-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcbfc2c3db2ca389fb6a75bfe19c692873c78e44d16aede538ca8793206d564c
BLAKE2b-256 checksum
How to use checksums
d5ce0d72ff8ab1e2c5075e8e4bf1a1a84df511b98d4daf0ddf911af6a959f54d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for onnx2oracle 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page