Skip to content

bug: Jailbreak detection imports unnecessary dependencies when using NIM #1222

Open
@jeffreyscarpenter

Description

@jeffreyscarpenter

Did you check docs and existing issues?

  • I have read all the NeMo-Guardrails docs
  • I have updated the package to the latest version before submitting this issue
  • (optional) I have used the develop branch
  • I have searched the existing issues of NeMo-Guardrails

Python version (python --version)

Python 3.12.0

Operating system/version

MacOS 15.5

NeMo-Guardrails version (if you must use a specific version and not the latest

0.14.0

Describe the bug

The jailbreak detection module imports heavy dependencies (torch, transformers, sklearn) at module level, even when using the NIM-based approach. This means users need to install these dependencies even if they're not using the local model-based jailbreak detection.

Steps To Reproduce

  1. Install NeMo-Guardrails without torch, transformers, or sklearn
  2. Configure jailbreak detection to use NIM-based approach:
rails:
  config:
    jailbreak_detection:
      nim_url: "your-nim-url"
      nim_port: 8000
  1. Try to use the jailbreak detection feature
  2. Observe that the code fails to import required dependencies

Expected Behavior

When using the NIM-based approach for jailbreak detection, the code should not require torch, transformers, or sklearn to be installed. These dependencies should only be required when using the local model-based approach.

Actual Behavior

The code fails with import errors for torch, transformers, or sklearn even when using the NIM-based approach, because these dependencies are imported at module level rather than being lazy-loaded when needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus: needs triageNew issues that have not yet been reviewed or categorized.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions