See requirements.txt
python checkpoints/download_models.py
See readme.md in the data folder
Using train_single_attribute_prompt_sentiment.sh/train_single_attribute_prompt_topic.sh
Using train_food_classifier.sh/train_sentiment_classifier.sh
Using test_food_classifier.sh/test_sentiment_classifier.sh
4. Generating single-attribute sentences from given prompts and then evaluating the generating results
Using test_single_attribute_prompt_sentiment.sh/test_single_attribute_prompt_topic.sh
As we mentioned in the paper, each single attribute data sample needs to be labeled again, such as the food single attribute text will get the annotation about the sentiment attribute. Here, we use the attribute classifier trained in the previous step to score the single attribute training data:
- Before starting the annotation, remove the attribute labels for each line in the training dataset file (i.e., each line of the annotation file is a sentence, not a label + space + sentence). Save the file as "train_yelp_sentiment_prompt_without_label.txt" and "train_yelp_food_prompt_without_label.txt".
- After that, we annotate the above two files separately using label_food_data.sh/label_sentiment_data.sh
To facilitate the concatenation of single-attribute prompts, we first extract the single-attribute prompt from the checkpoint file obtained in Step 3. To do this, you need to:
- Slightly change the "get_model(args)" function in main_prefix_gpt2.py. That is, removing the comment signal before the last piece of code.
- After that, use get_food_prompt.sh/get_sentiment_prompt.sh to extract and save them as files like xxx.pkl.
- Merge the files in step 2 by merge_prompts.py