pyabsa.tasks.TextAdversarialDefense
Subpackages
pyabsa.tasks.TextAdversarialDefense.configuration
pyabsa.tasks.TextAdversarialDefense.dataset_utils
pyabsa.tasks.TextAdversarialDefense.instructor
pyabsa.tasks.TextAdversarialDefense.models
pyabsa.tasks.TextAdversarialDefense.prediction
pyabsa.tasks.TextAdversarialDefense.trainer
Package Contents
Classes
Trainer class for training PyABSA models |
|
Simple object for storing attributes. |
|
Built-in mutable sequence. |
|
Built-in mutable sequence. |
|
Classification Datasets for adversarial attack defense |
|
- class pyabsa.tasks.TextAdversarialDefense.TADTrainer(config: pyabsa.tasks.TextAdversarialDefense.configuration.tad_configuration.TADConfigManager = None, dataset=None, from_checkpoint: str = None, checkpoint_save_mode: int = ModelSaveOption.SAVE_MODEL_STATE_DICT, auto_device: bool | str = DeviceTypeOption.AUTO, path_to_save=None, load_aug=False)[source]
Bases:
pyabsa.framework.trainer_class.trainer_template.Trainer
Trainer class for training PyABSA models
- class pyabsa.tasks.TextAdversarialDefense.TADConfigManager(args, **kwargs)[source]
Bases:
pyabsa.framework.configuration_class.configuration_template.ConfigManager
Simple object for storing attributes.
Implements equality by attribute names and values, and provides a simple string representation.
- class pyabsa.tasks.TextAdversarialDefense.BERTTADModelList[source]
Bases:
list
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- TADBERT
- class pyabsa.tasks.TextAdversarialDefense.GloVeTADModelList[source]
Bases:
list
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- TADLSTM
- class pyabsa.tasks.TextAdversarialDefense.TADDatasetList[source]
Bases:
list
Classification Datasets for adversarial attack defense
- class pyabsa.tasks.TextAdversarialDefense.TADTextClassifier(checkpoint=None, cal_perplexity=False, **kwargs)[source]
Bases:
pyabsa.framework.prediction_class.predictor_template.InferenceModel
- task_code
- batch_infer(target_file=None, print_result=True, save_result=False, ignore_error=True, defense: str = None, **kwargs)[source]
Batch prediction on an input file. :param target_file: the path of the input file :param print_result: whether to print the prediction results to the console :param save_result: whether to save the prediction results to a file :param ignore_error: whether to ignore errors during inference :param defense: adversarial defense technique to use during inference
- infer(text: str | list = None, print_result=True, ignore_error=True, defense: str = None, **kwargs)[source]
Perform prediction on a single text or a list of texts. :param text: the text(s) to perform prediction on :param print_result: whether to print the prediction results to the console :param ignore_error: whether to ignore errors during inference :param defense: adversarial defense technique to use during inference
- batch_predict(target_file=None, print_result=True, save_result=False, ignore_error=True, defense: str = None, **kwargs)[source]
Predict from a file of sentences. param: target_file: the file path of the sentences to be predicted. param: print_result: whether to print the result. param: save_result: whether to save the result. param: ignore_error: whether to ignore the error when predicting. param: kwargs: other parameters.
- predict(text: str | list = None, print_result=True, ignore_error=True, defense: str = None, **kwargs)[source]
Predict from a sentence or a list of sentences. param: text: the sentence or a list of sentence to be predicted. param: print_result: whether to print the result. param: ignore_error: whether to ignore the error when predicting. param: kwargs: other parameters.
- class pyabsa.tasks.TextAdversarialDefense.Predictor(checkpoint=None, cal_perplexity=False, **kwargs)[source]
Bases:
TADTextClassifier