Step 3: Create Vector-Ready User
Create a dedicated user and tablespace in PDB.
CREATE BIGFILE TABLESPACE TBS_VECTOR DATAFILE '/opt/oracle/oradata/FREE/FREEPDB1/vector01.dbf' SIZE 256M AUTOEXTEND ON MAXSIZE 2G;
CREATE USER vector_user IDENTIFIED BY "Oracle_4U" DEFAULT TABLESPACE TBS_VECTOR TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON TBS_VECTOR;
GRANT DB_DEVELOPER_ROLE TO vector_user;
GRANT CREATE MINING MODEL TO vector_user;
Check user vector_user connectivity from your local machine. You should see Connected!
Once the new container is running, open Python REPL. This puts you inside the Python REPL (you will see >>> automatically) i.e. interactive mode.
python3
import oracledb
conn = oracledb.connect(user="vector_user", password="Oracle_4U", dsn="localhost:1521/FREEPDB1")
print("Connected!")
Step 4: Load the ONNX Model for Embedding
Load the Pre-built Embedding Generation model for Oracle Database 23ai on your free-pdb instance.
Download and place ONNX model into /mnt/scripts.
curl -O https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/VBRD9P8ZFWkKvnfhrWxkpPe8K03-JIoM5h_8EJyJcpE80c108fuUjg7R5L5O7mMZ/n/adwc4pm/b/OML-Resources/o/all_MiniLM_L12_v2_augmented.zip
unzip all_MiniLM_L12_v2_augmented.zip
Login as sys in PDB and create directory and load the model as vector_user.
CREATE OR REPLACE DIRECTORY DM_DUMP AS '/mnt/scripts';
GRANT READ, WRITE ON DIRECTORY DM_DUMP TO vector_user;
sqlplus VECTOR_USER/Oracle_4U@FREEPDB1;
exec DBMS_VECTOR.DROP_ONNX_MODEL(model_name => 'ALL_MINILM_L12_V2', force => true);
BEGIN
DBMS_VECTOR.LOAD_ONNX_MODEL(
directory => 'DM_DUMP',
file_name => 'all_MiniLM_L12_v2.onnx',
model_name => 'ALL_MINILM_L12_V2'
);
END;
/
col model_name format a20
col mining_function format a12
col algorithm format a12
col attribute_name format a20
col data_type format a20
col vector_info format a30
col attribute_type format a20
set lines 120
SELECT model_name, mining_function, algorithm,
algorithm_type, model_size
FROM user_mining_models
WHERE model_name = 'ALL_MINILM_L12_V2'
ORDER BY model_name;
MODEL_NAME MINING_FUNCT ALGORITHM ALGORITHM_ MODEL_SIZE
ALL_MINILM_L12_V2 EMBEDDING ONNX NATIVE 133322334
SELECT model_name, attribute_name, attribute_type, data_type, vector_info
FROM user_mining_model_attributes
WHERE model_name = 'ALL_MINILM_L12_V2'
ORDER BY attribute_name;
MODEL_NAME ATTRIBUTE_NAME ATTRIBUTE_TYPE DATA_TYPE VECTOR_INFO
ALL_MINILM_L12_V2 DATA TEXT VARCHAR2
ALL_MINILM_L12_V2 ORA$ONNXTARGET VECTOR VECTOR VECTOR(384,FLOAT32)