Getting Started with JailbreakDetect
Prerequisites
-
A host with Docker Engine. Refer to the instructions from Docker.
-
NVIDIA Container Toolkit installed and configured. Refer to installation in the toolkit documentation.
-
An active subscription to an NVIDIA AI Enterprise product or be an NVIDIA Developer Program member. Access to the containers and models is restricted.
-
An NGC API key. The container uses the key to send inference requests to models NVIDIA API Catalog. Refer to Generating Your NGC API Key in the NVIDIA NGC User Guide for more information.
When you create an NGC API personal key, select at least NGC Catalog from the Services Included menu. You can specify more services to use the key for additional purposes.
Starting the NIM Container
-
Log in to NVIDIA NGC so you can pull the container.
- Export your NGC API key as an environment variable:
- Log in to the registry:
-
Download the container:
-
Export your NVIDIA API key as an environment variable:
-
Start the container:
The container requires several minutes to start and download the model from NGC. You can monitor the progress by running the
docker logs nemoguard-jailbreakdetectcommand. The microservice is ready when the the logs indicateStarting HTTP Inference server. -
Optional: Confirm the service is ready to respond to inference requests:
Example Output
Classify Requests
The classify endpoint returns a JSON payload with two fields:
-
Classify a safe input request:
classify-safe.shExample Output
classify-safe.json -
Classify an unsafe input request.
- Create a text file, such as
input.json, with contents like the following example:
input.json- Send the classification request:
classify-unsafe.shExample Output
classify-unsafe.jsonThe unsafe classification prompt is based on a test from the garak project.
- Create a text file, such as
Caching Models
The first time you start the container, the microservice downloads the model from NGC. You can avoid this download step on future runs by caching the model locally.
-
Create the cache directory on the host machine:
-
Export your NGC CLI API key as an environment variable:
-
Run the container with the cache directory as a volume mount:
Stopping the Container
The following commands stop the container by stopping and removing the running container.