LOAD_ONNX_MODEL
This procedure enables you to load an ONNX-format embedding model into your database.
Syntax
DBMS_VECTOR.LOAD_ONNX_MODEL (
directory IN VARCHAR2,
file_name IN VARCHAR2,
model_name IN VARCHAR2,
metadata IN JSON DEFAULT JSON('{"function" : "embedding", '||
'"embeddingOutput" : "embedding", "input": {"input":["DATA"]}}'),
external_data_file_name IN VARCHAR2 DEFAULT NULL);
DBMS_VECTOR.LOAD_ONNX_MODEL(
model_name IN VARCHAR2,
model_data IN BLOB,
metadata IN JSON DEFAULT JSON('{"function" : "embedding", '||
'"embeddingOutput" : "embedding", "input": {"input":["DATA"]}}'));Parameters
Table 12-8 LOAD_ONNX_MODEL Procedure Parameters
| Parameter | Description |
|---|---|
|
|
The directory name of the data dump. For example,
|
|
|
A |
|
|
The user-defined name of the model in the form
|
|
|
It is a |
|
|
A JSON description of the metadata describing the model. The metadata at minimum must describe the machine learning function supported by the model. The model's metadata parameters are described in JSON Metadata Parameters for ONNX Models. |
external_data_file_name |
A The default value is |
Examples
The following examples illustrates a code snippet that uses the
DBMS_VECTOR.LOAD_ONNX_MODEL procedure. The complete step-by-step example
is illustrated in Import ONNX Models and Generate
Embeddings.
EXECUTE DBMS_VECTOR.LOAD_ONNX_MODEL(
directory => 'DM_DUMP',
file_name => 'my_embedding_model.onnx',
model_name => 'doc_model',
metadata => JSON('{"function" : "embedding",
"embeddingOutput" : "embedding",
"input": {"input": ["DATA"]}}'));
DBMS_VECTOR.LOAD_ONNX_MODEL(
model_name => 'my_embedding_model.onnx',
model_data => :blob_bind_variable,
metadata => JSON('{"function" : "embedding",
"embeddingOutput" : "embedding",
"input":{"input": ["DATA"]}}'));
For a complete example to illustrate how you can define a BLOB variable
and use it in the LOAD_ONNX_MODEL procedure, you can have the
following:
CREATE OR REPLACE MY_LOAD_EMBEDDING_MODEL(embedding_model_name VARCHAR2, onnx_blob BLOB) IS
BEGIN
DBMS_VECTOR.LOAD_ONNX_MODEL(embedding_model_name,
onnx_blob,
JSON('{"function" : "embedding",
"embeddingOutput" : "embedding" ,
"input":{"input": ["DATA"]}}'));
END;
/Usage Notes
- The name of the model follows the same restrictions as those used for other machine
learning models, namely:
- The schema name, if provided, is limited to 128 characters.
- The model name is limited to 123 characters and must follow the rules of unquoted identifiers: they contain only alphanumeric characters, the underscore (_), dollar sign ($), and pound sign (#). The initial character must be alphabetic.
- The model size is limited to 2 GB.
-
There are default input and output names for input and output attributes for models that are prepared by the Python utility. You can load those models without the JSON parameters. For example:
EXECUTE DBMS_VECTOR.LOAD_ONNX_MODEL('DM_DUMP', 'my_embedding_model.onnx', 'doc_model')); - To be loaded as an ONNX model with external initializers, there must exist
in the specified directory a file with the format
<file_name>_external_data.json. If a file with that name does not exist, and theexternal_data_file_nameparameter has not been used to specify an alternate file name, the ONNX model will load without external initializers. If the file does exist, it is verified and the model is imported as an ONNX model with external initializers. The cumulative size of the.onnxfile and each of the external data files can be more than 2 GB. However, loading may fail if there is not enough PGA aggregate memory. For information about the parameter used to control the PGA limit, see PGA_AGGREGATE_LIMIT in Oracle AI Database Reference. - When the
LOAD_ONNX_MODELsyntax using aBLOBformat formodel_datais used, themodel_dataargument can be up to 2 GB in size. Loading may fail if there is not enough PGA aggregate memory to load the model. This version of the procedure syntax can only load a model without external initializers.
See Also:
- Oracle Machine Learning for SQL User’s Guide for examples of using ONNX models for machine learning tasks
- Oracle Machine Learning for SQL User’s Guide for information about external initializers
- JSON Metadata Parameters for ONNX Models
When importing models using theIMPORT_ONNX_MODEL(DBMS_DATA_MINING),LOAD_ONNX_MODEL(DBMS_VECTOR), orLOAD_ONNX_MODEL_CLOUD(DBMS_VECTOR) procedures, you supply metadata as JSON parameters.
Parent topic: DBMS_VECTOR