Oracle 23ai takes search in Oracle APEX to the next level by integrating advanced AI capabilities directly within the database. With no need for external resources, everything from vector embeddings to search calculations is handled natively. This not only simplifies the process but also results in smarter, more accurate search experiences for users, making it easier than ever to incorporate powerful semantic search into your applications.
Background
To better understand how this demo app works, let’s first cover the essential concepts of Vectors and Vector Search.
What are vectors?
In Oracle Database, vectors represent data points in a numerical format that can be efficiently processed to perform complex operations like semantic search, pattern recognition, and recommendations, all handled natively within the database system.
What is ONNX?
ONNX (Open Neural Network Exchange) is an open-source framework that enables the transfer and interoperability of machine learning models between different platforms. It provides a standard format for representing models, making it easy to use models trained in frameworks like PyTorch or TensorFlow across various environments. ONNX also includes ONNX Runtime, an optimized engine for fast and efficient model inference, supporting a wide range of hardware, from CPUs to GPUs. This flexibility makes it ideal for deploying models in diverse production systems.
Implementation
Prerequisites
To implement AI Vector Search and build Semantic Search in your Oracle APEX apps, you’ll need the following:
-
Oracle Database 23ai: AI Vector Search is a feature introduced in Oracle Database 23ai, with initial support starting in version 23.4. However, multi-modal support, essential for this semantic search implementation, was introduced in version 23.7. You must use version 23.7 or higher to enable the vector search capabilities required.
-
Optional: You can Provision an always-free ADB instance with Database 23ai. Learn more here.
-
-
Oracle APEX 24.1: The latest version of Oracle APEX (24.1) is available for download and being rolled out globally across OCI APEX and Autonomous Database Cloud Service regions. Learn more here.
Steps
Import ONNX models
Log in as database admin and run the following:
On-premise
Grant privileges in database
Set your working folder as the data dump directory to load the ONNX embedding model
Grant permissions on the directory
Load ONNX pipeline model on database
Autonomous Database
Upload the ONNX file to object storage

Generate an Auth token to access the file

Grant privileges in database
Create credential to access the file
Load ONNX pipeline model on database
📝 Oracle is providing a Hugging Face all-MiniLM-L12-v2 model in ONNX format, available to download directly to the database.
ℹ️ Query model statistics
You can view model attributes and learn about the model by querying machine learning dictionary views and model detail views.
Convert image description to vectors using the model
We can now use the ONNX model to convert image description into vectors and store them in the database:
⚠️ Vector search precision will entirely depend on how accurate your image descriptions are.
Integrating Vector Search into APEX
Now we are going to create the page with two main regions and other components to make it work:

This is the SQL query used in the card region:
ℹ️ Vector Search is built on the 23ai VECTOR_DISTANCE function, which calculates the distance between two high-dimensional vectors to evaluate their relative position in the latent space.
Demo
This demo shows how an APEX app can find images based on descriptions. Searching for “Asunción” brings up related images, but even if you search “Paraguay,” AI Vector Search will show results for Asunción, as it understands the semantic connection between the two terms.
The same applies to broader categories: searching for terms like “Water,” “Cars,” or “People” will retrieve visually and contextually relevant images.

Summary
You can now search for images using text descriptions. To take it a step further, you can implement a new page that uses vector search based on an uploaded image to find visually similar results.
Leave A Comment