zhuyiYZU / PLST

Prompt-Learing for Short Text Classification
10 stars 4 forks source link

cpt_Verbalize #4

Open wangqian97 opened 1 year ago

wangqian97 commented 1 year ago

Hi author, your code is very effective, but I have a question about how to create cpt_Verbalizer files for other data sets, I ran the other data set with an error of "File "E: \ ProgramData \ Anaconda3 \ envs \ dl - demo - xy \ lib \ site - packages \ openprompt - - py3.8 1.0.1. Egg \ openprompt \ prompt_base py", line 659, in from_file

assert num_classes==self.num_classes, 'number of classes in the verbalizer file\ "Assert num_classes==self.num_classes, 'number of classes in the verbalizer file\"

nikokks commented 1 year ago

I opened a pull requests to add the generation of cpt_verbalizer file with the algorithm probase.

zhuyiYZU commented 1 year ago

Thank you for concerning.

First, you need to find the "openprompt/data_utils/textclassification_dataset. py" file, and then you need to add a data processor for your own dataset in the file. For details, see AGnews.

Step 2, you need to add your own dataset in datasets/TextClassification according to the existing file format. It is worth noting that the number of categories added in the classes.txt file should be consistent with the self.labels in the previous step.

Step 3: You need to add the corresponding template and Verbalizer in the scripts/TextClassification according to the existing file format.

Finally, import the class you added in the first step in main.py and add your dataset.

    ------------------ Original ------------------ From: @.>; Date:  Tue, Mar 7, 2023 10:32 AM To: @.>; Cc: @.***>; Subject:  [zhuyiYZU/PLST] cpt_Verbalize (Issue #4)

 

Hi author, your code is very effective, but I have a question about how to create cpt_Verbalizer files for other data sets, I ran the other data set with an error of "File "E: \ ProgramData \ Anaconda3 \ envs \ dl - demo - xy \ lib \ site - packages \ openprompt - - py3.8 1.0.1. Egg \ openprompt \ prompt_base py", line 659, in from_file

assert num_classes==self.num_classes, 'number of classes in the verbalizer file\ "Assert num_classes==self.num_classes, 'number of classes in the verbalizer file"

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

CoisiniStar commented 3 months ago

Hello seniors, thank you very much for making your code public, but I have a problem that has not been solved: when I debug the code you gave me (main.py file) the system reports an error: File "/home/nlp/anaconda3/envs/a_PLST/lib/python3.7/site-packages/openprompt/prompt_base.py", line 635, in from_file .format(choice, len(label_words_all))) RuntimeError: choice 0 exceeds the number of verbalizers 0 But I checked the corresponding directory there is a cpt_verbalizer.txt file, how to solve it, thank you for your reply!

pic

zhuyiYZU commented 3 months ago

Hello seniors, thank you very much for making your code public, but I have a problem that has not been solved: when I debug the code you gave me (main.py file) the system reports an error: File "/home/nlp/anaconda3/envs/a_PLST/lib/python3.7/site-packages/openprompt/prompt_base.py", line 635, in from_file .format(choice, len(label_words_all))) RuntimeError: choice 0 exceeds the number of verbalizers 0 But I checked the corresponding directory there is a cpt_verbalizer.txt file, how to solve it, thank you for your reply!

pic

Hello, this issue is caused by your cpt_verbalizer file being empty. First, you need to write the extension words in scripts/TextClassification/your_dataset_folder/cpt_verbalizer.txt. For example, if the current data labels are positive and negative, the cpt_verbalizer.txt should contain two lines: positive, related extension words; negative, related extension words.

Additionally, you need to ensure that the labels in the data processing part of the /home/nlp/anaconda3/envs/a_PLST/lib/python3.7/site-packages/openprompt/data_utils/text_classification_dataset.py file are consistent with this.

CoisiniStar commented 3 months ago

Hello seniors, thank you very much for making your code public, but I have a problem that has not been solved: when I debug the code you gave me (main.py file) the system reports an error: File "/home/nlp/anaconda3/envs/a_PLST/lib/python3.7/site-packages/openprompt/prompt_base.py", line 635, in from_file .format(choice, len(label_words_all))) RuntimeError: choice 0 exceeds the number of verbalizers 0 But I checked the corresponding directory there is a cpt_verbalizer.txt file, how to solve it, thank you for your reply! pic

Hello, this issue is caused by your cpt_verbalizer file being empty. First, you need to write the extension words in scripts/TextClassification/your_dataset_folder/cpt_verbalizer.txt. For example, if the current data labels are positive and negative, the cpt_verbalizer.txt should contain two lines: positive, related extension words; negative, related extension words.

Additionally, you need to ensure that the labels in the data processing part of the /home/nlp/anaconda3/envs/a_PLST/lib/python3.7/site-packages/openprompt/data_utils/text_classification_dataset.py file are consistent with this.

Thank you very much for your reply, I will try to debug with that method.