Skip to main content
Open In ColabOpen on GitHub

OCI Data Science Model Deployment Endpoint

Overviewโ€‹

OCI Data Science is a fully managed and serverless platform for data science teams to build, train, and manage machine learning models in the Oracle Cloud Infrastructure.

This notebooks goes over how to use an embedding model hosted on a OCI Data Science Model Deployment.

To authenticate, oracle-ads has been used to automatically load credentials for invoking endpoint.

Instantiationโ€‹

We will need to install the oracle-ads sdk

!pip3 install -U oracle-ads

Prerequisiteโ€‹

Deploy modelโ€‹

Check Oracle GitHub samples repository on how to deploy your embedding model on OCI Data Science Model deployment.

Policiesโ€‹

Make sure to have the required policies to access the OCI Data Science Model Deployment endpoint.

Setupโ€‹

After having deployed model, you have to set up endpoint: The model HTTP endpoint from the deployed model, e.g. "https://modeldeployment.us-ashburn-1.oci.customer-oci.com/<MD_OCID>/predict" of the OCIModelDeploymentEndpointEmbeddings call.

Authenticationโ€‹

You can set authentication through either ads or environment variables. When you are working in OCI Data Science Notebook Session, you can leverage resource principal to access other OCI resources. Check out here to see more options.

import ads

# Set authentication through ads
# Use resource principal are operating within a
# OCI service that has resource principal based
# authentication configured
ads.set_auth("resource_principal")

Direct Usageโ€‹

from langchain_community.embeddings import OCIModelDeploymentEndpointEmbeddings

# Create an instance of OCI Model Deployment Endpoint
# Replace the endpoint uri with your own
embeddings = OCIModelDeploymentEndpointEmbeddings(
endpoint="https://modeldeployment.us-ashburn-1.oci.customer-oci.com/<MD_OCID>/predict",
)

query = "Hello World!"
embeddings.embed_query(query)
documents = ["This is a sample document", "and here is another one"]
embeddings.embed_documents(documents)

API Referenceโ€‹

For detailed documentation on OCIModelDeploymentEndpointEmbeddings features and configuration options, please refer to the API reference.


Was this page helpful?