FEAT: Generalize Colloquial Wordswap Attack Converter #1348
Open
taherakolawala wants to merge 2 commits intoAzure:mainfrom
Open
FEAT: Generalize Colloquial Wordswap Attack Converter #1348taherakolawala wants to merge 2 commits intoAzure:mainfrom
taherakolawala wants to merge 2 commits intoAzure:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
romanlutz
reviewed
Feb 4, 2026
Contributor
romanlutz
left a comment
There was a problem hiding this comment.
Very nice! I am personally not convinced Singaporean should be the default BUT that's what we put in the issue description and it means current users won't be experiencing a breaking change. We may update that in the future, of course. Thanks a ton!
romanlutz
approved these changes
Feb 4, 2026
romanlutz
reviewed
Feb 4, 2026
| ) | ||
| else: | ||
| file_path = ( | ||
| Path(__file__).parent.parent |
Contributor
There was a problem hiding this comment.
We have a paths file under pyrit/common that includes DATASET_PATH which will shorten this
| def __init__( | ||
| self, deterministic: bool = False, custom_substitutions: Optional[Dict[str, List[str]]] = None | ||
| ) -> None: | ||
| def __init__(self, deterministic: bool = False, wordswap_path: Optional[str] = None) -> None: |
Contributor
There was a problem hiding this comment.
Actually this is a breaking change. My gut feeling is that it is better to keep the existing signature but having the files is also not a bad idea (even though the substitutions aren't very many and probably not that meaningful.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In accordance with the Issue #418 the converter in
colloquial_wordswap_converter.pyhas been generalized to use different versions of colloquial word swaps.A new directory has been created in
pyrit/datasets/prompt_converterscalledcolloquial_wordswaps. This directory contains the original default Singaporean word substitutions as wells as a few different regional colloquial word swap YAML examples. TheColloquialWordSwapConverterclass now accepts a new parameter calledwordswap_pathduring initialization. It defaults tosingaporean.yamlhowever the argument can be filled with any YAML file located in thecolloquial_wordswapsdirectory mentioned before.In the same vein, if you want to add a new set of word substitutions, all you need to do is create a new YAML file in the same format as any of the others and add it to the
pyrit/datasets/prompt_converters/colloquial_wordswapsdirectory. Here is an example of how a YAML file must be formatted:The following is an example initialization of the converter with a non-default wordswapper YAML:
People of whom this PR may be of interest to: @eugeniavkim @romanlutz
Closes #418
Tests and Documentation
test_colloquial_wordswap_converter.pyfor the generalizable wordswap converter.test_colloquial_wordswap_converter.pyfor checking multiple word custom word swapper conversions.uv run pytest tests/unit/converter/test_colloquial_wordswap_converter.py