textattack.commands package

TextAttack commands Package

AttackCommand class

class textattack.commands.attack_command.AttackCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack attack module:

A command line parser to run an attack from user specifications.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]

AttackResumeCommand class

class textattack.commands.attack_resume_command.AttackResumeCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack attack resume recipe module:

A command line parser to resume a checkpointed attack from user specifications.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]

AugmentCommand class

class textattack.commands.augment_command.AugmentCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack attack module:

A command line parser to run data augmentation from user specifications.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]

Reads in a CSV, performs augmentation, and outputs an augmented CSV.

Preserves all columns except for the input (augmneted) column.

BenchmarkRecipeCommand class

class textattack.commands.benchmark_recipe_command.BenchmarkRecipeCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack benchmark recipe module:

A command line parser to benchmark a recipe from user specifications.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]

EvalModelCommand class

class textattack.commands.eval_model_command.EvalModelCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack model benchmarking module:

A command line parser to evaluatate a model from user specifications.

get_preds(model, inputs)[source]
static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]
test_model_on_dataset(args)[source]
class textattack.commands.eval_model_command.ModelEvalArgs(dataset_by_model: str = None, dataset_from_huggingface: str = None, dataset_from_file: str = None, dataset_split: str = None, filter_by_labels: list = None, model: str = None, model_from_file: str = None, model_from_huggingface: str = None, random_seed: int = 765, batch_size: int = 32, num_examples: int = 5, num_examples_offset: int = 0)[source]

Bases: textattack.model_args.ModelArgs, textattack.dataset_args.DatasetArgs

batch_size: int = 32
num_examples: int = 5
num_examples_offset: int = 0
random_seed: int = 765

ListThingsCommand class

class textattack.commands.list_things_command.ListThingsCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The list module:

List default things in textattack.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]
static things()[source]

PeekDatasetCommand class

class textattack.commands.peek_dataset_command.PeekDatasetCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The peek dataset module:

Takes a peek into a dataset in textattack.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]

TextAttack CLI main class

textattack.commands.textattack_cli.main()[source]
class textattack.commands.textattack_command.TextAttackCommand[source]

Bases: abc.ABC

abstract static register_subcommand(parser)[source]
abstract run()[source]

TrainModelCommand class

class textattack.commands.train_model_command.TrainModelCommand[source]

Bases: textattack.commands.textattack_command.TextAttackCommand

The TextAttack train module:

A command line parser to train a model from user specifications.

static register_subcommand(main_parser: argparse.ArgumentParser)[source]
run(args)[source]