-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add support for finetune guard classifier #325
base: main
Are you sure you want to change the base?
Add support for finetune guard classifier #325
Conversation
Signed-off-by: Vibhu Jawa <[email protected]>
Signed-off-by: Vibhu Jawa <[email protected]>
Signed-off-by: Vibhu Jawa <[email protected]>
Signed-off-by: Vibhu Jawa <[email protected]>
- Demonstrated strong zero-shot detection capabilities on novel attacks | ||
- Particularly effective at identifying trigger patterns in partially poisoned datasets | ||
|
||
Dataset Format: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Emphasize more about english
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few typo fixes but looks good so far!
When you get a chance can you add it to the examples/
and nemo_curator/scripts/
folders? And to the documentation? You should be able to reference #361 which has all the files that should be created/updated.
class AegisModel(nn.Module): | ||
def __init__( | ||
self, | ||
pretrained_model_name_or_path: str, | ||
peft_model_name_or_path: str, | ||
dtype: torch.dtype, | ||
token: str, | ||
token: Optional[Union[str, bool]], | ||
add_fintune_gaurd: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_fintune_gaurd: bool = False, | |
add_finetune_guard: bool = False, |
): | ||
super().__init__() | ||
base_model = AutoModelForCausalLM.from_pretrained( | ||
pretrained_model_name_or_path, torch_dtype=dtype, token=token | ||
) | ||
self.model = PeftModel.from_pretrained(base_model, peft_model_name_or_path) | ||
self.autocast = autocast | ||
self.add_fintune_gaurd = add_fintune_gaurd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.add_fintune_gaurd = add_fintune_gaurd | |
self.add_finetune_guard = add_finetune_guard |
): | ||
super().__init__() | ||
base_model = AutoModelForCausalLM.from_pretrained( | ||
pretrained_model_name_or_path, torch_dtype=dtype, token=token | ||
) | ||
self.model = PeftModel.from_pretrained(base_model, peft_model_name_or_path) | ||
self.autocast = autocast | ||
self.add_fintune_gaurd = add_fintune_gaurd | ||
if self.add_fintune_gaurd: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.add_fintune_gaurd: | |
if self.add_finetune_guard: |
pad_token_id=0, | ||
) | ||
def _forward(self, batch): | ||
if self.add_fintune_gaurd: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.add_fintune_gaurd: | |
if self.add_finetune_guard: |
if self.config.add_finetune_guard: | ||
if self.config.finetune_guard_path is None: | ||
raise ValueError( | ||
"finetune_guard_path must be provided if add_fine_guard is True" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"finetune_guard_path must be provided if add_fine_guard is True" | |
"finetune_guard_path must be provided if add_finetune_guard is True" |
peft_model_name_or_path=self.config.peft_model_name_or_path, | ||
dtype=self.config.dtype, | ||
token=self.config.token, | ||
add_fintune_gaurd=self.config.add_finetune_guard, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_fintune_gaurd=self.config.add_finetune_guard, | |
add_finetune_guard=self.config.add_finetune_guard, |
This PR adds support for FineTuneGuard Model