Deploying and Using an ONNX Model in Oracle Vector Search

Introduction

Oracle Vector Search supports ONNX models for AI-powered vector search and machine learning workflows. This guide provides a step-by-step approach to downloading an ONNX model, uploading it to Oracle Object Storage, creating secure credentials, validating credentials, retrieving the model, loading it into Oracle Vector Search, validating the model, and executing vector embedding queries.

Oracle Autonomous Database 23ai: AI-Powered Vector Search and Machine Learning

Oracle Autonomous Database 23ai is purpose-built for AI workloads, offering high-performance Vector Search, Machine Learning, and AI Model Inference. It is optimized for AI-driven analytics, real-time recommendations, and large-scale vector embeddings.

Key AI-Powered Features

  • Oracle Vector Search – Delivers fast, scalable similarity searches for unstructured data (text, images, and audio).
  • Native ONNX Model Support – Enables seamless deployment of pre-trained AI models inside Oracle databases.
  • Oracle Machine Learning (OML) – Provides in-database AI model training, inference, and automation.
  • Fully Autonomous AI Engine – Self-tuning, self-scaling, and auto-optimizing database operations.
  • Hybrid AI Data Processing – Supports structured, semi-structured, and vectorized AI models.
  • Enterprise Security & Compliance – End-to-end encryption, automated data masking, and built-in AI governance.

Step 1: Download the ONNX Model from Oracle

Before proceeding, download an ONNX model from Oracle’s Official ONNX Documentation.

Step 2: Upload the ONNX Model to Oracle Object Storage

  1. Log in to OCI Console
  2. Navigate to Object Storage and create a new bucket (e.g., ****).
  3. Upload your ONNX model file (e.g., all_MiniLM_L12_v2.onnx).
  4. Copy and save the Object Storage URL, which will be used in the database.

Step 3: Create a Credential for Oracle Object Storage

Check if a DBMS_CLOUD credential exists for Object Storage access:

SELECT credential_name, username FROM dba_credentials;

If missing, create one:

BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'LOAD_MODE',
username => 'your_oci_user@example.com',
password => 'your_auth_token'
);
END;
/

Step 4: Validate the Credential

Confirm that the credential is valid by listing the objects in the storage bucket:

SELECT * FROM DBMS_CLOUD.LIST_OBJECTS(
credential_name => 'LOAD_MODE',
location_uri => 'https://objectstorage.****.oraclecloud.com/n/****/b/****/'
);

If objects are listed successfully, the credential is working correctly.

Step 5: Retrieve and Load the ONNX Model in Oracle Vector Search

5.1 Retrieve the ONNX Model from Oracle Object Storage

Validate that the model is retrievable from Oracle Object Storage before loading it into the database.

SET SERVEROUTPUT ON;
DECLARE
model_source BLOB;
BEGIN
model_source := DBMS_CLOUD.GET_OBJECT(
credential_name => 'LOAD_MODE',
object_uri => 'https://objectstorage.****.oraclecloud.com/n/****/b/****/o/all_MiniLM_L12_v2.onnx'
);

-- Check if retrieval was successful
IF model_source IS NOT NULL THEN
DBMS_OUTPUT.PUT_LINE('Model retrieved successfully.');
ELSE
DBMS_OUTPUT.PUT_LINE('Failed to retrieve model.');
END IF;
END;
/

5.2 Load the ONNX Model into Oracle Vector Search

Once the model is retrieved, load it into Oracle Vector Search for AI-powered vector embedding.

DECLARE
model_source BLOB;
metadata JSON;
BEGIN
-- Retrieve ONNX model as a BLOB
model_source := DBMS_CLOUD.GET_OBJECT(
credential_name => 'LOAD_MODE',
object_uri => 'https://objectstorage.****.oraclecloud.com/n/****/b/****/o/all_MiniLM_L12_v2.onnx'
);

-- Define ONNX model metadata for embedding search
metadata := JSON('{"function": "embedding"}');

-- Load ONNX model into Oracle Vector Search
DBMS_VECTOR.LOAD_ONNX_MODEL(
model_name => 'DOC_MODEL',
model_data => model_source,
metadata => metadata
);

DBMS_OUTPUT.PUT_LINE('ONNX Model Successfully Loaded into Oracle Vector Search!');
END;
/

5.3 Verify the ONNX Model

Use Oracle Data Mining Views to confirm successful model registration:

SELECT MODEL_NAME, MINING_FUNCTION, ALGORITHM, ALGORITHM_TYPE, MODEL_SIZE
FROM USER_MINING_MODELS
WHERE MODEL_NAME = 'DOC_MODEL';

Check the model attributes:

SELECT MODEL_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, DATA_TYPE, VECTOR_INFO
FROM USER_MINING_MODEL_ATTRIBUTES
WHERE MODEL_NAME = 'DOC_MODEL';

Step 6: Execute Vector Search Queries on ONNX AI Model

6.1 Generate AI-Powered Vector Embeddings

Use Oracle’s vector embedding function to process text input into AI-powered vector representations.

SELECT TO_VECTOR(VECTOR_EMBEDDING(DOC_MODEL USING 'hello' AS INPUT)) AS embedding;

Fixing Common Errors: If you encounter ORA-54421: Missing mining attribute: INPUT, verify the correct input attribute:

SELECT MODEL_NAME, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, DATA_TYPE, VECTOR_INFO
FROM USER_MINING_MODEL_ATTRIBUTES
WHERE MODEL_NAME = 'DOC_MODEL';

Update the query with the correct attribute name if needed.

Step 7: Inspect All ONNX Model Attributes

SELECT * FROM USER_MINING_MODEL_ATTRIBUTES;

Conclusion: AI-Driven Search & Vector Embedding with Oracle 23ai

You have successfully downloaded an ONNX model, uploaded it to Oracle Object Storage, created secure AI credentials, validated the credentials, retrieved, loaded, and executed vector search queries in Oracle Vector Search.

Oracle 23ai provides a scalable, AI-driven, and high-performance solution for real-time AI inference, intelligent search, and machine learning integration—outpacing traditional databases like PostgreSQL, MySQL, MongoDB, and Elasticsearch.

Next Steps:

  • Deploy Large-Scale AI Models: Integrate transformers, deep learning models, and vectorized embeddings.
  • Leverage Oracle AI Services: Use OCI Data Science, OML AutoML, and Oracle AI Infrastructure.
  • Optimize AI Workloads: Run GPU-accelerated AI inference on Oracle Cloud.

Oracle 23ai is the future of AI-powered databases—providing seamless AI integration, advanced vector search, and enterprise-grade security for modern AI applications. oci adw

Author: Rohit Mishri

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *