Azure / PyRIT

The Python Risk Identification Tool for generative AI (PyRIT) is an open access automation framework to empower security professionals and machine learning engineers to proactively find risks in their generative AI systems.
MIT License
1.91k stars 366 forks source link

FEAT: Add Diacritics Converter #518

Closed KutalVolkan closed 2 weeks ago

KutalVolkan commented 3 weeks ago

Overview

This PR introduces a new DiacriticConverter class under pyrit.prompt_converter to enable transformations using diacritical marks on specified characters. This converter is inspired by techniques outlined in resources such as Bypassing Azure AI Content Safety Guardrails, where diacritical marks can be applied to bypass content filters. The converter provides an effective tool for testing the resilience of AI content safety mechanisms against such techniques.

Work Completed

  1. Implemented DiacriticConverter:

    • Located in pyrit.prompt_converter.
    • Transforms text by applying specified diacritical marks (e.g., acute, grave) to target characters, supporting content safety testing.
  2. Edge Case Handling:

    • Leaves text unmodified if target_chars is empty.
    • Defaults to "aeiou" for target_chars if unspecified.
  3. Test Suite:

    • Added pytest tests covering default and custom targets, empty target_chars, and invalid accent handling.

Related Issue

Resolves FEAT add diacritics converter #515

romanlutz commented 2 weeks ago

Wow that was (once again) very fast! Just tiny comments, and I agree with @rdheekonda 's comments as well, of course. Thanks a ton!

KutalVolkan commented 2 weeks ago

Wow that was (once again) very fast! Just tiny comments, and I agree with @rdheekonda 's comments as well, of course. Thanks a ton!

You're welcome! Thanks to you guys, I'm still learning a ton of stuff, so I'm just giving something back. :)