As part of a recent AI and RAG proof of concept, I needed to load the all-MiniLM-L12-v2 embedding model directly into Oracle AI Database 26ai. The process was straightforward, although I encountered one small connection issue that is worth documenting.
ONNX stands for Open Neural Network Exchange. It is an open format for representing machine-learning models independently of the framework in which they were created. For example, a model may be trained using PyTorch and then exported to ONNX for optimized inference in another environment. This makes the model more portable and avoids tying it permanently to one machine-learning framework. In Oracle AI Database 26ai, an ONNX embedding model can be loaded as a database object and called directly from SQL. Text can therefore be converted into vectors without sending it to an external AI service.
Running the embedding model inside the database provides several advantages:
- Sensitive text remains inside the database.
- No external REST API or internet connection is required during inference.
- Network latency and API usage costs are avoided.
- Embeddings can be generated directly through SQL and PL/SQL.
- The model can be used consistently for document and search-query embeddings.
- Deployment becomes easier because a separate embedding service is not required.
For this test, I used all-MiniLM-L12-v2. It is a relatively small and efficient English-language model that produces 384-dimensional vectors, making it a good choice for semantic search, document retrieval and lightweight RAG solutions.
A wquick comparison between difference approaches and why and when ONNX can become a preferred choice. ONNX is particularly useful when data privacy, predictable performance and simplified architecture are more important than continuously switching to the latest hosted embedding model.
| Approach | Main advantage | Main consideration |
|---|
| In-database ONNX | Private, fast and no external API dependency | Uses database CPU and memory |
| External embedding API | Easy access to newer hosted models | Network latency, API cost and data-privacy considerations |
| PyTorch/TensorFlow service | Maximum flexibility and fine-tuning options | Requires a separate runtime and serving infrastructure |
Below are the steps to download and load the model … Oracle provides an augmented version of all-MiniLM-L12-v2 that includes the required tokenization and post-processing logic. This is important because a raw ONNX model downloaded directly from Hugging Face may contain only the neural network and may not be sufficient for direct in-database text embedding.
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ ps -ef|grep pmon
oracle 36866 4602 0 03:37 ? 00:00:21 ora_pmon_myaidb
oracle 92325 92163 0 17:14 pts/0 00:00:00 grep --color=auto pmon
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ . oraenv
ORACLE_SID = [oracle] ? myaidb
The Oracle base has been set to /u01/app/oracle
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ !sql
sqlplus / as sysdba
SQL*Plus: Release 23.26.1.0.0 - Production on Tue Aug 11 17:14:11 2026
Version 23.26.1.0.0
Copyright (c) 1982, 2025, Oracle. All rights reserved.
Connected to:
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.0.0 - Production
Version 23.26.1.0.0
SQL>
SQL>
SQL> exit
Disconnected from Oracle AI Database 26ai Enterprise Edition Release 23.26.1.0.0 - Production
Version 23.26.1.0.0
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ sudo mkdir -p /u01/app/oracle/onnx_models
[sudo] password for oracle:
oracle is not in the sudoers file. This incident will be reported.
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ cd /u01/app/oracle/onnx_models
-bash: cd: /u01/app/oracle/onnx_models: No such file or directory
[oracle@fatdba1 ~]$ mkdir -p /u01/app/oracle/onnx_models
[oracle@fatdba1 ~]$
[oracle@fatdba1 ~]$ cd /u01/app/oracle/onnx_models
[oracle@fatdba1 onnx_models]$ wget https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/TtH6hL2y25EypZ0-rrczRZ1aXp7v1ONbRBfCiT-BDBN8WLKQ3lgyW6RxCfIFLdA6/n/adwc4pm/b/OML-ai-models/o/all_MiniLM_L12_v2_augmented.zip
--2026-08-11 17:16:56-- https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/TtH6hL2y25EypZ0-rrczRZ1aXp7v1ONbRBfCiT-BDBN8WLKQ3lgyW6RxCfIFLdA6/n/adwc4pm/b/OML-ai-models/o/all_MiniLM_L12_v2_augmented.zip
Resolving adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com (adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com)... 134.70.24.1, 134.70.32.1, 134.70.28.1
Connecting to adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com (adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com)|134.70.24.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 122537890 (117M) [application/x-zip-compressed]
Saving to: ‘all_MiniLM_L12_v2_augmented.zip’
all_MiniLM_L12_v2_augmented.zip 100%[====================================================================================================>] 116.86M 7.92MB/s in 19s
2026-08-11 17:17:17 (6.09 MB/s) - ‘all_MiniLM_L12_v2_augmented.zip’ saved [122537890/122537890]
[oracle@fatdba1 onnx_models]$
[oracle@fatdba1 onnx_models]$ ls -lh /u01/app/oracle/onnx_models
total 117M
-rw-r--r--. 1 oracle oinstall 117M Oct 30 2025 all_MiniLM_L12_v2_augmented.zip
[oracle@fatdba1 onnx_models]$ unzip all_MiniLM_L12_v2_augmented.zip
Archive: all_MiniLM_L12_v2_augmented.zip
inflating: all_MiniLM_L12_v2.onnx
inflating: LICENSE_ATTRIBUTION.txt
inflating: README-ALL_MINILM_L12_V2-augmented.txt
[oracle@fatdba1 onnx_models]$ ls -ltrh
total 245M
-rw-rw-rw-. 1 oracle oinstall 4.2K Oct 30 2025 README-ALL_MINILM_L12_V2-augmented.txt
-rw-rw-rw-. 1 oracle oinstall 12K Oct 30 2025 LICENSE_ATTRIBUTION.txt
-rw-rw-rw-. 1 oracle oinstall 128M Oct 30 2025 all_MiniLM_L12_v2.onnx
-rw-r--r--. 1 oracle oinstall 117M Oct 30 2025 all_MiniLM_L12_v2_augmented.zip
[oracle@fatdba1 onnx_models]$ sqlplus / as sysdba
SQL*Plus: Release 23.26.1.0.0 - Production on Tue Aug 11 17:20:34 2026
Version 23.26.1.0.0
Copyright (c) 1982, 2025, Oracle. All rights reserved.
Connected to:
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.0.0 - Production
Version 23.26.1.0.0
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 MYYAIDB READ WRITE NO
SQL> ALTER SESSION SET CONTAINER = MYYAIDB;
Session altered.
SQL> SHOW CON_NAME;
CON_NAME
------------------------------
MYYAIDB
SQL> CREATE USER vector_user IDENTIFIED BY oracle90 DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
User created.
SQL> GRANT DB_DEVELOPER_ROLE TO vector_user;
Grant succeeded.
SQL> GRANT CREATE MINING MODEL TO vector_user;
Grant succeeded.
SQL> CREATE OR REPLACE DIRECTORY ONNX_DIR AS '/u01/app/oracle/onnx_models';
Directory created.
SQL> GRANT READ, WRITE ON DIRECTORY ONNX_DIR TO vector_user;
Grant succeeded.
SQL> SELECT directory_name, directory_path
FROM dba_directories
WHERE directory_name = 'ONNX_DIR'; 2 3
DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
ONNX_DIR
/u01/app/oracle/onnx_models
SQL>
SQL> CONNECT vector_user@"//127.0.0.1:1521/myyaidb"
Enter password:
Connected.
SQL>
SQL> SHOW USER;
SHOW CON_NAME;USER is "VECTOR_USER"
SQL>
CON_NAME
------------------------------
MYYAIDB
SQL> BEGIN
DBMS_VECTOR.LOAD_ONNX_MODEL(
directory => 'ONNX_DIR',
file_name => 'all_MiniLM_L12_v2.onnx',
model_name => 'ALL_MINILM_L12_V2'
);
END;
/ 2 3 4 5 6 7 8
PL/SQL procedure successfully completed.
SQL> COLUMN model_name FORMAT A30
COLUMN mining_function FORMAT A20
COLUMN algorithm FORMAT A20
SELECT model_name,
mining_function,
algorithm
FROM user_mining_models
WHERE model_name = 'ALL_MINILM_L12_V2';SQL> SQL> SQL> SQL> 2 3 4 5
MODEL_NAME MINING_FUNCTION ALGORITHM
------------------------------ -------------------- --------------------
ALL_MINILM_L12_V2 EMBEDDING ONNX
SQL> SELECT VECTOR_DIMS(
VECTOR_EMBEDDING(
ALL_MINILM_L12_V2
USING 'Oracle AI Vector Search test' AS DATA
)
) AS dimensions
FROM dual; 2 3 4 5 6 7
DIMENSIONS
----------
384
SQL> SET LONG 100000
SET LINESIZE 200
SELECT VECTOR_EMBEDDING(
ALL_MINILM_L12_V2
USING 'Oracle Database backup and recovery' AS DATA
) AS embedding
FROM dual;SQL> SQL> SQL> 2 3 4 5
EMBEDDING
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[-4.87856008E-002,7.1997717E-002,-2.54948232E-002,-5.70283532E-002,-1.06920907E-002,1.0775161E-002,-5.90280592E-002,4.400618E-002,-4.38417606E-002,-1.99456103E-002,5.76283038E-003,7.40298927E-002,1.31
917335E-002,-3.32452208E-002,-8.51406157E-002,-2.12764088E-002,-8.46216164E-004,6.76434338E-002,-5.09454496E-003,7.59954751E-002,-1.47132769E-001,-7.61819351E-003,4.72804867E-002,-3.58171314E-002,4.77
031525E-003,9.91140381E-002,6.09872341E-002,-4.96129356E-002,-6.89210966E-002,-2.29366459E-002,3.0035438E-002,-8.5439207E-003,-1.87823065E-002,-5.27824089E-002,-5.07728159E-002,5.71492985E-002,-1.0317
5268E-001,2.06469093E-003,-4.94726524E-002,5.38232923E-002,-4.20075236E-003,-5.83661646E-002,-6.939473E-002,4.70481254E-003,-3.57628129E-002,-2.06067171E-002,1.55578945E-002,-3.64977755E-002,1.3607616
5E-002,4.83786911E-002,6.55189529E-002,9.09776092E-002,-3.78638739E-003,4.63182144E-002,1.67185273E-002,-2.0538846E-002,1.88092468E-003,1.13089666E-001,-6.65725395E-002,-5.29151671E-002,7.0534341E-002
,3.82151194E-002,-3.87142561E-002,4.89930958E-002,-3.72733884E-002,4.71422225E-002,-9.42653418E-003,8.30410421E-002,7.23783001E-002,-8.00792221E-003,-1.04699969E-001,1.3227962E-002,2.10432312E-003,-5.
2194491E-002,5.44612296E-002,2.64221951E-002,-6.92174537E-003,3.2788564E-003,-7.07466304E-002,-1.09599065E-002,-2.07525976E-002,6.07146174E-002,-7.14476183E-002,-6.52319693E-004,-2.61781225E-003,1.029
82512E-002,2.22747419E-002,7.84466136E-003,-2.85771638E-002,-7.22757652E-002,1.31514639E-001,-6.92670466E-003,1.05359353E-001,2.31848098E-002,2.36764625E-002,1.93412453E-002,-7.73303732E-002,-3.468839
68E-003,1.3238284E-001,2.77728699E-002,6.44600466E-002,2.86891386E-002,3.98902521E-002,-1.04312496E-002,-1.1179284E-001,1.21374004E-001,5.50982319E-002,-2.86319014E-002,-7.31713325E-002,2.7698854E-002
,-7.78927729E-002,7.7220737E-003,4.11929712E-002,1.38421329E-002,2.2667855E-002,-9.06801131E-003,-1.06181979E-001,-1.63826789E-003,-8.82744044E-002,-1.22012058E-003,1.58981606E-002,-7.58664086E-002,9.
57456082E-002,1.25050836E-003,5.26473019E-003,2.16946639E-002,4.42689583E-002,6.8870157E-002,1.41299153E-002,5.51517941E-002,-5.14429659E-002,-5.23285232E-002,5.11708781E-002,-2.63342485E-002,-2.20014
EMBEDDING
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
565E-002,-1.73898265E-002,-3.62575054E-002,-8.39175209E-002,1.63958769E-003,-6.85187057E-002,2.91524939E-002,-1.2798515E-001,-1.83849374E-003,7.93192387E-002,2.51277834E-002,4.95435148E-002,-4.4572427
9E-002,-3.21206041E-002,-6.48666397E-002,2.0290127E-002,6.15623547E-003,2.16576364E-002,-4.66784462E-003,4.63866107E-002,3.30464952E-002,3.85379605E-002,1.23593844E-002,-4.7582306E-002,-7.36421198E-00
2,-7.33523369E-002,-6.89318478E-002,-7.00623095E-002,-3.05234399E-002,7.80285448E-002,-9.35370028E-002,2.69017499E-002,-1.14727495E-002,-2.12617069E-002,4.35556322E-002,-4.36026894E-004,9.77274105E-00
2,-3.76839899E-002,-8.01233053E-002,-7.22195879E-002,3.63463326E-003,-2.48486884E-002,-2.03172676E-002,-2.47620214E-002,2.27805087E-003,-5.56117743E-002,7.34143425E-003,-5.76570295E-002,-4.28294996E-0
03,5.3869877E-002,2.87791248E-002,5.07858656E-002,-5.34493811E-002,8.79583731E-002,7.63130933E-002,4.32174765E-002,1.31380977E-002,-3.26855257E-002,1.11090411E-002,-4.76806909E-002,-4.36781952E-003,1.
01589016E-003,3.21580544E-002,1.30654527E-002,3.04144267E-002,-3.80649902E-002,-4.27651405E-002,4.52963784E-002,-1.58415572E-003,-1.993821E-002,3.90723571E-002,-4.20001186E-002,-1.84409693E-002,9.7515
6799E-002,-4.25614715E-002,-4.88893613E-002,-4.92014624E-002,9.41627845E-003,8.72373432E-002,4.78187315E-002,-2.54044053E-003,-3.99130322E-002,1.34559376E-002,6.15696721E-002,-2.59792339E-002,-4.70647
514E-002,1.11222304E-001,-6.54862896E-002,9.61392298E-002,2.07331398E-034,-3.65259964E-003,-8.21233988E-002,-1.20636057E-002,1.44557646E-002,-3.51657383E-002,-1.3823634E-002,-1.64992362E-002,4.4988017
5E-002,-4.54784371E-002,-2.92942306E-004,2.15027835E-002,-1.31722605E-002,1.60137545E-002,-6.75500855E-002,-4.15628366E-002,-7.30369315E-002,8.64059255E-002,-5.12768142E-002,-3.84957977E-002,4.5663215
2E-002,6.85658455E-002,4.10435982E-002,7.44328089E-003,8.91532004E-002,2.70864032E-002,3.0453993E-002,-3.20769548E-002,1.2025306E-002,-1.22540602E-002,8.77800658E-002,3.16540003E-002,-8.52044672E-003,
-5.95438443E-002,1.48355916E-001,-3.60100642E-002,-1.0032624E-002,2.08637211E-002,2.84589995E-002,-2.41973568E-002,3.15869339E-002,1.12110479E-002,5.38171502E-004,2.05618907E-002,1.07340226E-002,-1.28
EMBEDDING
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
460256E-003,-5.25169186E-002,2.49615274E-002,1.5979778E-002,7.37336874E-002,-2.18623616E-002,8.46073851E-002,-2.29403824E-002,5.97928651E-002,2.6352426E-002,8.22185166E-003,-3.29606682E-002,9.63416323
E-002,-8.68180543E-002,-4.90903854E-002,2.07517482E-002,-2.32356545E-002,-6.64651319E-002,2.38323156E-002,5.20869419E-002,-1.13063902E-002,-1.03914761E-003,1.15302512E-002,5.39318845E-002,-2.76873186E
-002,-7.64334872E-002,1.62822269E-002,-4.78982665E-002,-7.46970624E-002,4.14117053E-002,1.85170472E-002,1.50091248E-002,-2.5248073E-002,5.56167169E-003,5.31971306E-002,4.19711061E-002,-1.05979659E-001
,-2.56049028E-003,-8.31877738E-002,5.11595644E-002,-3.61793442E-003,2.72909719E-002,2.98573133E-002,-1.31529346E-001,5.84768467E-002,-8.44340324E-002,-2.63655409E-002,-1.02462331E-002,-3.13680619E-002
,2.79930402E-002,7.4749887E-002,-6.41344061E-033,-4.88035977E-002,3.4346763E-002,1.05161041E-001,1.83394493E-003,5.63648827E-002,-1.1864084E-001,2.758242E-002,4.09473255E-002,-3.94932777E-002,-5.41642
867E-002,-8.78240447E-003,5.86595088E-002,3.33358464E-003,9.50002074E-002,-4.01680171E-002,7.73140565E-002,1.7790196E-003,-2.23562624E-002,-1.65800732E-002,-6.10178225E-002,3.96786481E-002,-5.95294759
E-002,4.85839993E-002,-9.53975134E-003,5.50697884E-003,3.7492007E-002,5.52483797E-002,2.59457417E-002,3.2463897E-002,-1.12312446E-004,1.87224504E-002,5.46318106E-002,-1.953681E-002,4.85305414E-002,7.7
0374667E-003,-1.2780644E-001,3.89365392E-004,9.75998677E-003,-8.70148391E-002,2.54446249E-002,8.90563652E-002,7.0743598E-002,-4.44219634E-002,-2.12613344E-002,-5.60087189E-002,2.35729497E-002,2.095438
73E-002,1.70082841E-002,-9.77526943E-005,-4.19775173E-002,2.22535385E-003,7.9500908E-003,-3.70596088E-002,2.16165632E-002,2.07185978E-003,-6.042099E-002,1.44844491E-003,6.97642863E-002,3.27955447E-002
,-5.20859994E-002,3.89892906E-002,4.39782776E-002,-1.08199725E-002,-7.10714981E-002]
SQL>
And that’s it. Its simple. Oracle AI Database 26ai makes it surprisingly easy to bring embedding generation directly to the data. Once the augmented ONNX model is staged and loaded, embeddings can be generated through regular SQL without maintaining a separate Python service or calling an external API.
For organizations building private semantic-search or RAG solutions, in-database ONNX provides a practical balance of security, performance and operational simplicity.
Hope It Helped!
Prashant Dixit




