Dataset
OpenBackdoor integrates 5 tasks and 11 datasets, which can be downloaded from bash scripts in datasets. We list the tasks and datasets below:
Sentiment Analysis: SST-2, IMDB
Toxic Detection: Offenseval, Jigsaw, HSOL, Twitter
Topic Classification: AG’s News, DBpedia
Spam Detection: Enron, Lingspam
Natural Language Inference: MNLI
APIs
Base class of data processor
- class openbackdoor.DataProcessor(labels: Optional[Sequence[Any]] = None, labels_path: Optional[str] = None)[source]
Base class for data processor.
- Parameters:
labels (
Sequence[Any], optional) – class labels of the dataset. Defaults to None.labels_path (
str, optional) – Defaults to None. If set andlabelsis None, load labels fromlabels_path.
- get_dev_examples(data_dir: Optional[str] = None, shuffle: Optional[bool] = True)[source]
get dev examples from the development file under
data_dir
- abstract get_examples(data_dir: Optional[str] = None, split: Optional[str] = None)[source]
get the
splitof dataset underdata_dirdata_diris the base path of the dataset, for example:training file could be located in
data_dir/train.txt
- get_label_id(label: Any) int[source]
get label id of the corresponding label
- Parameters:
label – label in dataset
- Returns:
the index of label
- Return type:
- get_labels() List[Any][source]
get labels of the dataset
- Returns:
labels of the dataset
- Return type:
List[Any]
- get_num_labels()[source]
get the number of labels in the dataset
- Returns:
number of labels in the dataset
- Return type:
- get_test_examples(data_dir: Optional[str] = None, shuffle: Optional[bool] = True)[source]
get test examples from the test file under
data_dir