Leveraging ONNX Models for AI Vector Search in Oracle Cloud Database 23ai



Oracle 23ai supports ONNX LLM models.๐Ÿ˜˜
In Oracle 23ai, one of the powerful features is AI Vector Search, which enables semantic search on unstructured data such as text, images, and audio. Oracle supports using ONNX models to convert input data into dense vectors, which are then stored in vector columns for efficient similarity search.

What is ONNX(Open Neural Network Exchange)?
It is an open format for representing machine learning and deep learning models.

How Can we use ONNX model in Oracle Database?
in the first step you should Import ONNX model in your Database.
I am going to use Oracle Cloud and upload my ONNX model in the storage of my cloud.

Step 1: Upload ONNX Model to Oracle Cloud Storage

In Oracle Cloud storage>bucket


Then Upload your onnx file you downloaded



Step 2: Import the ONNX Model into Oracle Database

Use the DBMS_VECTOR package to I mport the ONNX model:

you need to create a credential and for this you need your username and password in oracle cloud 


This is username BUT WHERE IS PASSWORD ??!!๐Ÿ˜Ÿ


For password in User setting > Tokens and Keys > Auth Token > Click Generate Token 

This is your password !!! ๐Ÿ˜‰



BEGIN

 DBMS_CLOUD.DROP_CREDENTIAL(

        credential_name => 'OBJ_STORE_CRED');

    DBMS_CLOUD.CREATE_CREDENTIAL(

        credential_name => 'OBJ_STORE_CRED',

        username => 'gholizadeh.lida@gmail.com',

        password => '******************'

    );

END;

/


BEGIN

    DBMS_VECTOR.DROP_ONNX_MODEL( model_name => 'my_model');

END;

BEGIN

    DBMS_VECTOR.LOAD_ONNX_MODEL_CLOUD(

        model_name => 'my_model',

        CREDENTIAL => 'OBJ_STORE_CRED',

        uri => 'https://[The path of your file in cloud]/my_modelall_MiniLM_L12_v2.onnx' 

    );

END;


SELECT  model_name, algorithm, mining_function

FROM   user_mining_models

WHERE  model_name = 'MY_MODEL'; 

Now I am going to use this model and generate Vectors for this purpose we have an amazing Function in Oracle 23ai called VECTOR_EMBEDDING

VECTOR_EMBEDDING(<model_name> USING <input_value> AS <input_label>)

SELECT  vector_embedding(MY_MODEL USING 'Hello World' AS data) vectors FROM DUAL;


Thanks for your Reading I hope it was useful for you!

Comments

Popular posts from this blog

JavaScript In Oracle APEX (Client Side)

Installation of Oracle Database 23ai and APEX 24.2 and ORDS 24.4 on Windows Step-by-Step

Building a Fully Local AI-Powered Assistant with Oracle APEX and Vector Search #APEXCONN2025 #orclAPEX

Configuration of ORDS: Standalone, Tomcat, and WebLogic on Windows Step-by-Step

✔ RTL Map Region Labels APEX 24.2 & ๐ŸŒGeoCoding

Oracle JET and Oracle APEX are best friends๐Ÿ’•

Vector Tiles in Oracle Spatial 23

Building an AI-Powered Resume Matching System Using Oracle APEX and 23ai Vector Search๐Ÿ˜Ž

What is SYS.ODCI (SYS.ODCINumberList or SYS.ODCIVarchar2List) and How Can Use it in APEX ?

My Experience at Oracle CloudWorld Tour in Frankfurt – April 10, 2025