Getting started with the Oracle Private AI Services Container

Oracle recently announced the release of the Oracle Private AI Services Container, this allows you to securely generate vector embeddings outside the Oracle AI Database 26ai, offload the CPU and without any dependency upon the public cloud or the internet.

In this blog post I will share how to set-up the environment, check the health of the Oracle Private AI Services Container, list models, get model details and generate vector embeddings.

Linux Environment

The Private AI Service requires Oracle Linux 8, 9 or 10, OpenSSL and Podman 4.9.4+, I have also installed jq to help with the pretty formatting of JSON output.

Getting the Private AI Services Container

The Oracle Private AI Services Container is available from the Oracle Container Registry (OCR).

Note: Before you can download the container image you will need to visit the Oracle Container Registry and accept the licence agreement. You will also need to generate an authentication token, this will be your podman login password.

Set-up Environment

Copy and paste the below to perform the following:

  • Set-up environmental variables
  • Create required directories
  • Pull container image
  • Extract privateai-setup-25.1.3.0.0.zip from container
  • Unzip setup
  • Configre the Private AI Services Container for https
export AIHOME=/home/oracle/myPrivateAI
export SECRETS_DIR=${AIHOME}/aisecrets
export PRIVATEAI_DIR=${AIHOME}/privateai
export INSTALL_SCRIPT_ZIP=/privateai/scripts/privateai-setup-25.1.3.0.0.zip
mkdir -p ${AIHOME}
mkdir -p ${SECRETS_DIR}
mkdir -p ${PRIVATEAI_DIR}
podman pull container-registry.oracle.com/database/private-ai:latest
export IMAGE_ID=`podman image ls --quiet private-ai`
echo "PrivateAI Image ID is ${IMAGE_ID}"
export CONTAINER_ID=`podman create ${IMAGE_ID}`
echo "Container ID is ${CONTAINER_ID}"
podman cp ${CONTAINER_ID}:${INSTALL_SCRIPT_ZIP} ${AIHOME}
unzip privateai-setup-25.1.3.0.0.zip
# OCR generated token stored in ${AIHOME}/token.txt
cd ./setup
./secretsSetup.sh -s ${SECRETS_DIR} --pass ${AIHOME}/token.txt
./configSetup.sh -d ${PRIVATEAI_DIR} -s ${SECRETS_DIR}
./containerSetup.sh -d ${PRIVATEAI_DIR}
#setup TOKEN
export TOKEN=`cat ${SECRETS_DIR}/api-key`
echo "api-token: ${TOKEN}"

Now check for a running Private AI Services Container with podman ps

OK now we have configure the Private AI Container, let’s give it a try.

Check Health

We can check the health of the Private AI Container Service using a simple REST call, for example with curl –i (–include HTTP response headers in the output):

curl -i --cacert ${SECRETS_DIR}/cert.pem \
--header "Authorization: Bearer ${TOKEN}" \
https://localhost:8443/health

Example output:

List Models

The Private AI Service container ships with six embedding models:

  • all-mpnet-base-v2
  • all-MiniLM-L12-v2
  • multilingual-e5-base
  • multilingual-e5-large
  • clip-vit-base-patch32-txt
  • clip-vit-base-patch32-img

You can also create and download additional embedding models if required.

We can confirm the models installed using a REST GET call, in the example below I am curl -s (–silent silent / quite mode) with jq to pretty print the JSON output.

curl -s --cacert ${SECRETS_DIR}/cert.pem \
--header "Authorization: Bearer ${TOKEN}" \
https://localhost:8443/v1/models | jq

Example output:

Get Model Details

To obtain the details for a model use /v1/models/{id}.

curl -s --cacert ${SECRETS_DIR}/cert.pem \
--header "Authorization: Bearer ${TOKEN}" \
https://localhost:8443/v1/models/{all-minilm-l12-v2} | jq

Example output:

Generate Embedding

And finally we can create an embedding using a model, for example:

curl -s --cacert ${SECRETS_DIR}/cert.pem \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${TOKEN}" \
-d '{"model": "all-minilm-l12-v2", "input": ["A lovestruck Romeo sang the streets a serenade","Laying everybody low with a love song that he made"]}' \
https://localhost:8443/v1/embeddings | jq

Example output:

Summary

In this blog post I have shared how to install and configure the Oracle Private AI Services Container, and then use REST calls to retrieve details, finishing with the generation of an embedding for some text data provided.

Leave a Reply

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

Discover more from Ron Ekins' - Oracle Technology, DevOps and Kubernetes Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading