Skip to content

Conversation

@chakravarthik27
Copy link
Collaborator

No description provided.

@chakravarthik27 chakravarthik27 self-assigned this Sep 18, 2024
@chakravarthik27 chakravarthik27 changed the title Feature/enhance security tests with promptguard Feature/enhance safety tests with promptguard Sep 18, 2024
This commit refactors the PromptGuard class in the modelhandler/promptguard.py module. The changes include:
- Simplifying the initialization process by using a singleton pattern
- Loading the model and tokenizer from Hugging Face
- Preprocessing the input text to remove spaces and mitigate prompt injection tactics
- Calculating class probabilities for a single or batch of texts
- Adding methods to get jailbreak scores and indirect injection scores for a single input text or a batch of texts
- Processing texts in batches to improve efficiency

The commit also includes changes in the safety.py module:
- Importing the PromptGuard class from the modelhandler/promptguard.py module
- Replacing the pipeline usage with the PromptGuard class to get indirect injection scores

Lastly, the commit includes changes in the output.py and sample.py modules:
- Adding a greater than or equal to comparison method in the MaxScoreOutput class
- Updating the comparison method in the QASample class to use the new comparison method in MaxScoreOutput
@chakravarthik27 chakravarthik27 merged commit d89477a into release/2.4.0 Sep 19, 2024
@chakravarthik27 chakravarthik27 linked an issue Sep 19, 2024 that may be closed by this pull request
@chakravarthik27 chakravarthik27 deleted the feature/enhance-security-tests-with-promptguard branch December 27, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance Security Tests with PromptGuard

2 participants