LOAD_ONNX_MODEL_CLOUD
This procedure enables you to load an ONNX-format embedding model from Oracle Object Storage into your database.
Syntax
DBMS_VECTOR.LOAD_ONNX_MODEL_CLOUD (
model_name IN VARCHAR2,
credential IN VARCHAR2,
uri IN VARCHAR2,
metadata IN JSON DEFAULT JSON('{"function" : "embedding", '||
'"embeddingOutput" : "embedding", "input": {"input":["DATA"]}}')
);Parameters
Table 12-9 LOAD_ONNX_MODEL_CLOUD Procedure Parameters
| Parameter | Description |
|---|---|
|
|
The user-defined name of the model in the form
|
|
|
The name of the credential to be used to access Oracle Object Storage. |
|
|
The URI of the ONNX model. When the value of |
|
|
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. |
Examples
The following example includes a code snippet that uses the
DBMS_VECTOR.LOAD_ONNX_MODEL_CLOUD procedure.
EXECUTE DBMS_VECTOR.LOAD_ONNX_MODEL_CLOUD(
model_name => 'database',
credential => 'MYCRED',
uri => 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o/all-MiniLM-L6-v2.onnx',
metadata => JSON('{"function" : "embedding", "embeddingOutput" : "embedding" , "input": {"input": ["DATA"]}}')
);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_CLOUD( model_name => 'database', credential => 'MYCRED', uri => 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o/all-MiniLM-L6-v2.onnx' ); - To use ONNX models with external initializers, follow these steps:
- Create an Oracle Object Storage bucket.
- Create an ONNX model with OML4Py.
- Upload the model to the object storage bucket. If the model is a single-file model,
there is only the one
.onnxfile to upload. If the model has external data, upload the.onnxfile,.jsonmetadata file, and.datafiles into the same bucket. - Create a pre-authenticated request (PAR). In case of external data, the PAR must be
valid either for the entire bucket or for the prefix that matches all of the uploaded
files. You can skip this step and use credentials instead, in which case you must
provide a valid
credentialalong with the full URL to the.onnxfile in the next step. - Call the
LOAD_ONNX_MODEL_CLOUDprocedure withcredentialset toNULLanduriset to the full URL to the.onnxfile (from the PAR).
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
Parent topic: DBMS_VECTOR