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

model_name

The user-defined name of the model in the form [schema_name.]model_name. This is the name the model will have in OML as a first-class database object. If you do not specify a schema, then your own schema is used.

credential

The name of the credential to be used to access Oracle Object Storage.

uri

The URI of the ONNX model.

When the value of uri is a pre-authenticated URI, the credential argument should be passed as NULL.

metadata

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:
    1. Create an Oracle Object Storage bucket.
    2. Create an ONNX model with OML4Py.
    3. Upload the model to the object storage bucket. If the model is a single-file model, there is only the one .onnx file to upload. If the model has external data, upload the .onnx file, .json metadata file, and .data files into the same bucket.
    4. 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 credential along with the full URL to the .onnx file in the next step.
    5. Call the LOAD_ONNX_MODEL_CLOUD procedure with credential set to NULL and uri set to the full URL to the .onnx file (from the PAR).

See Also: