detector_benchmark.generation.prompt_paraphrasing_attack¶

Classes¶

ParaphrasingAttack

Helper class that provides a standard way to create an ABC using

PromptParaphrasingAttack

Helper class that provides a standard way to create an ABC using

Module Contents¶

class detector_benchmark.generation.prompt_paraphrasing_attack.ParaphrasingAttack(gen_model: detector_benchmark.generation.generator.LLMGenerator, gen_config: detector_benchmark.utils.configs.ModelConfig, gen_prompt_config: detector_benchmark.utils.configs.PromptConfig, max_sample_len: int, watermarking_scheme: detector_benchmark.watermark.auto_watermark.AutoWatermark = None)¶

Bases: detector_benchmark.generation.article_generator.ArticleGenerator

Helper class that provides a standard way to create an ABC using inheritance.

paraphrase(texts, nb_paraphrasing=1, batch_size=1) list¶
class detector_benchmark.generation.prompt_paraphrasing_attack.PromptParaphrasingAttack(gen_model: detector_benchmark.generation.generator.LLMGenerator, gen_config: detector_benchmark.utils.configs.ModelConfig, gen_prompt_config: detector_benchmark.utils.configs.PromptConfig, paraphraser_model: detector_benchmark.generation.generator.LLMGenerator, paraphraser_config: detector_benchmark.utils.configs.ModelConfig, paraphraser_prompt_config: detector_benchmark.utils.configs.PromptConfig, max_sample_len: int, watermarking_scheme: detector_benchmark.watermark.auto_watermark.AutoWatermark = None)¶

Bases: detector_benchmark.generation.article_generator.ArticleGenerator

Helper class that provides a standard way to create an ABC using inheritance.

paraphraser_model¶
paraphraser_prompt_config¶
model_config¶
attack_name = 'paraphrasing_attack'¶
paraphrase(texts: list[str], nb_paraphrasing: int = 1, batch_size: int = 1) list[str]¶

Paraphrasing function used after the initial text generation.

Parameters:¶

texts: list

Initial generated texts to be paraphrased.

nb_paraphrasing: int

Number of recursive paraphrasing to be done.

batch_size: int

The batch size to use for generation.

Returns:¶

list

A list of paraphrased generated texts.

generate_adversarial_text(prefixes: list[str], batch_size: int = 1) list[str]¶

Generate text with paraphrasing.

Parameters:¶

prefixes: list

A list of input contexts for text generation.

batch_size: int

The batch size to use for generation.

Returns:¶

list

A list of generated text.