The invention discloses a malicious suffix construction method, a controllable jailbreak
attack method and a controllable jailbreak
attack device, the method designs a jailbreak
attack framework in a
diffusion model SD, and the jailbreak attack method is operated from a
text mode and an
image mode. A transferable malicious suffix not containing sensitive words is learned in a
text mode, a cosine
loss function is used, the malicious suffix is close to malicious prompt
semantics containing explicit sensitive words in an
encoder layer, and after the learned malicious suffix is added to a jailbreak object prompted by an input text, the jailbreak object is prompted by the text. And converting the harmless prompt into a sensitive
image generation instruction. And in an
image mode, through a designed security checker loss and text consistent
loss function, carrying out back propagation gradient optimization on the input original image to be edited, so that the generated image passes through the check of the security checker, and an image containing NSFW content is generated. According to the method, the security limitation of a security checker can be bypassed, the jail break attack is realized, the security vulnerabilities existing in the current
text graph model are revealed, and the security protection measures of the model are evaluated.