nemoguardrails.library.jailbreak_detection.model_based.checks

View as Markdown

Module Contents

Functions

NameDescription
_ensure_model_downloaded-
check_jailbreakUse embedding-based jailbreak detection model to check for the presence of a jailbreak
initialize_modelInitialize the global classifier model according to the configuration provided.

Data

MODEL_FILENAME

MODEL_REPO_ID

logger

API

nemoguardrails.library.jailbreak_detection.model_based.checks._ensure_model_downloaded(
classifier_path: str
) -> pathlib.Path
nemoguardrails.library.jailbreak_detection.model_based.checks.check_jailbreak(
prompt: str,
classifier = None
) -> dict

Use embedding-based jailbreak detection model to check for the presence of a jailbreak Args: prompt: User utterance to classify classifier: Instantiated JailbreakClassifier object

Raises:

  • RuntimeError: If no classifier is available and EMBEDDING_CLASSIFIER_PATH is not set
nemoguardrails.library.jailbreak_detection.model_based.checks.initialize_model() -> typing.Union[None, JailbreakClassifier]

Initialize the global classifier model according to the configuration provided. Args classifier_path: Path to the classifier model Returns jailbreak_classifier: JailbreakClassifier object combining embedding model and NemoGuard JailbreakDetect RF

nemoguardrails.library.jailbreak_detection.model_based.checks.MODEL_FILENAME = 'snowflake.onnx'
nemoguardrails.library.jailbreak_detection.model_based.checks.MODEL_REPO_ID = 'nvidia/NemoGuard-JailbreakDetect'
nemoguardrails.library.jailbreak_detection.model_based.checks.logger = logging.getLogger(__name__)