Load Your Own ONNX Model
Use the load model operation to load an embedding or
reranking model into the database.
The load model operation imports a model from object
storage, in ONNX format, for use in embedding generation and reranking operations.
Once loaded, the model can be used for integrated table embeddings or for standalone
inference.
Caution:
After loading an ONNX model using
DBMS_VECTOR_DATABASE, drop the model only by using
DBMS_VECTOR_DATABASE.DROP_MODEL.
Do not drop a model loaded through
DBMS_VECTOR_DATABASE using
DBMS_DATA_MINING.DROP_MODEL,
DBMS_VECTOR, or another database API. Those APIs can
remove the underlying database model without removing the
DBMS_VECTOR_DATABASE metadata that references it.
This can leave an invalid model entry. For example,
DBMS_VECTOR_DATABASE.LIST_MODELS might return a model
whose details are NULL, and subsequent
DBMS_VECTOR_DATABASE operations, such as
UPSERT_VECTORS, can fail when they reference that
model. To remove a model loaded through
DBMS_VECTOR_DATABASE, use the following syntax:
BEGIN
DBMS_VECTOR_DATABASE.DROP_MODEL('<model_name>');
END;
/
See the following for an example of using
load_model to load a models from Oracle Object Storage:
- Load an embedding
model:
from oracle_vecdb import OracleVecDB, Configuration client = OracleVecDB(Configuration( rest_url="https://<host>/ords/<schema>/_/db-api/stable/vecdb/", access_token="<bearer-token>", # or username="<user>", password="<pass>" )) response = client.load_model( model_name='all-MiniLM-L6-v2', url='https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace/b/bucket/o/model.onnx' ) print(response) #verify that the model was loaded using list_models models = client.list_models() print([item.model_name for item in models.items or []]) - Load a reranking
model:
from oracle_vecdb import OracleVecDB, Configuration client = OracleVecDB(Configuration( rest_url="https://<host>/ords/<schema>/_/db-api/stable/vecdb/", access_token="<bearer-token>", # or username="<user>", password="<pass>" )) response = client.load_model( model_name='reranker_model', url='https://objectstorage.example.com/models/reranker_quantized.onnx', model_params={'metadata': {'function': 'regression'}} ) print(response) #verify that the model was loaded using list_models models = client.list_models() print([item.model_name for item in models.items or []])
A JSON response is returned confirming that the model was loaded successfully. An error is raised if the model already exists or if the provided URL is inaccessible.
Example response:
{
"model_name": "SAMPLE_MODEL",
"algorithm": "ONNX",
"mining_function": "EMBEDDING",
"creation_date": "2026-03-12T11:27:21Z",
"attributes": [
{
"name": "DATA",
"value": "TEXT",
"data_type": "VARCHAR2",
"data_length": 32767
},
{
"name": "ORA$ONNXTARGET",
"value": "VECTOR",
"data_type": "VECTOR",
"data_length": 1593,
"vector_info": "VECTOR(384,FLOAT32)"
}
]
}For more information about the load_model
operation, see Python API Reference.
See how POST /vecdb/models/ can be used in the
following examples:
- Load an embedding
model:
curl -X POST \ "https://<host>:<port>/ords/<schema>/_/db-api/stable/vecdb/models/" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ # Choose ONE authentication method: # Option 1: Basic authentication -u "<user>:<password>" \ # Option 2: OAuth Bearer token # -H "Authorization: Bearer <access_token>" \ -d '{ "modelName": "DOC_EMBED_MODEL", "url": "https://objectstorage.example.com/models/doc_embed.onnx" }' - Load a reranking
model:
curl -X POST \ "https://<host>:<port>/ords/<schema>/_/db-api/stable/vecdb/models/" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ # Choose ONE authentication method: # Option 1: Basic authentication -u "<user>:<password>" \ # Option 2: OAuth Bearer token # -H "Authorization: Bearer <access_token>" \ -d '{ "modelName": "RERANK_MODEL", "url": "https://objectstorage.example.com/models/reranker_quantized.onnx", "modelParams": { "metadata": { "function": "regression" } } }'
Responses:
- 201 Created – returns the registered model record with status
information.
{{ "model_name": "DOC_EMBED_MODEL", "algorithm": "ONNX", "mining_function": "EMBEDDING", "creation_date": "2026-05-01T10:00:00.000000+00:00", "attributes": [ { "name": "DATA", "value": "TEXT", "data_type": "VARCHAR2", "data_length": 4000, "vector_info": null } ] } - 400 - the request body included invalid parameters.
- 404 - model not found.
For more information about POST /vecdb/models/, see
REST API Reference.
See how DBMS_VECTOR_DATABASE.LOAD_MODEL can be used
in the following examples.
- Load an embedding
model:
dbms_vector_database.load_model( model_name => 'DOC_EMBED_MODEL', url => 'https://objectstorage.example.com/models/doc_embed.onnx' ); - Load a reranking
model:
dbms_vector_database.load_model( model_name => 'RERANK_MODEL', url => 'https://objectstorage.example.com/models/reranker_quantized.onnx', model_params => JSON('{"metadata": {"function": "regression"}}') );
{
"model_name": "DOC_EMBED_MODEL",
"algorithm": "ONNX",
"mining_function": "EMBEDDING",
"creation_date": "2026-05-01T10:00:00.000000+00:00",
"attributes": [
{
"name": "DATA",
"value": "TEXT",
"data_type": "VARCHAR2",
"data_length": 4000,
"vector_info": null
}
]
}For more information about the PL/SQL implementation, including parameters, see LOAD_MODEL.