Getting Started with TopicControl
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:
-
Create a model cache directory on the host machine:
-
Run the container with the cache directory as a volume mount:
The container requires several minutes to start and download the model from NGC. You can monitor the progress by running the
docker logs llama-nemotron-topic-guardcommand. -
Optional: Confirm the service is ready to respond to inference requests:
Example Output
Running Inference
You can send requests to the v1/chat/completions endpoint to perform inference.
The following steps demonstrate creating a Python script that performs the following actions:
-
Connects to the container with the microservice and the topic control model.
-
Provides a prompt that provides topic control instructions to the topic control model.
-
Create a development environment and install dependencies:
-
Create a file, such as
topic_control_inference_example.py, with contents like the following example:topic_control_inference_example.py -
Run the script to perform inference:
Stopping the Container
The following commands stop the container by stopping and removing the running container.