thunlp / OpenPrompt

An Open-Source Framework for Prompt-Learning.
https://thunlp.github.io/OpenPrompt/
Apache License 2.0
4.38k stars 455 forks source link

Bug in soft_template.py #188

Open Celine-hxy opened 2 years ago

Celine-hxy commented 2 years ago

class SoftTemplate,line 50 and 51 should be modified as: self.default_text1= """{"placeholder":"text_a"} {"mask"}""" self.default_text2 = """{"placeholder":"text_a"} {"placeholder":"text_b"} {"mask"}"""

otherwise when setting text=None, “torch.nn.modules.module.ModuleAttributeError: 'SoftTemplate' object has no attribute 'default_text2'” will be reported

Celine-hxy commented 2 years ago

When i use SST2 in openprompt.data_utils.text_classification_dataset as follow,

base_path = "datasets/TextClassification" dataset_name = "SST-2" dataset_path = os.path.join(base_path, dataset_name) processor = PROCESSORS[dataset_name.lower()]() train_dataset = processor.get_train_examples(dataset_path)

the train_dataset's "text_b" is "" instead of None, should the "if example.text_b is None:" be changed to "if example.text_b is None or example.text_b == "": "? (line 68)

BTW, the example given in text_classification_dataset.py, class SST2Processor (line 315), should be "from openprompt.data_utils.text_classification_dataset import PROCESSORS", not "from openprompt.data_utils.lmbff_dataset import PROCESSORS"