Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enhance safety tests with promptguard #1119

Merged

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
3 checks passed
@chakravarthik27 chakravarthik27 linked an issue Sep 19, 2024 that may be closed by this pull request
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
1 participant