This repository contains the official implementation of the paper titled "PromptAL: Sample-Aware Dynamic Soft Prompts for Few-Shot Active Learning".
We evaluate the AL algorithms in 6 Natural Language Processing (NLP) datasets:
TREC,IMDB,AGNEWS,DBPEDIA,Yelp-full,Yahoo!Answers
We use
RoBERTa-basefor the experiment, but the code can support any other model (e.g. ,from HuggingFace) .
The experiments were performed on an NVIDIA A100 GPU. you should create a conda environment for the project:
conda env create -f PromptAL_environment.yml
To tune the model, you need to run the
run_AL.pyscript.
AL_method: Different methods- Possible values:
hmask_cluster_calibration_entropy_local_div,hmask_cluster_local_div,hmask_cluster_entropy_local_div,hmask_cluster_calibration_entropy,hmask_cluster_calibration_entropy,hmask_cluster_entropy,entropy,random
- Possible values:
hmask_cluster_calibration_entropy_local_divrepresents the PromptAL method, while the other methods are various ablation variants.
dataset_name: Name of the task to be trained on.- Possible values: dbpedia',
imdb,agnews,yelp,trec,yahoo,dbpedia
- Possible values: dbpedia',
num_virtual_tokens: Task-Specific Prompt sizeinstance_tokens:Sample-Specific Prompt sizemulti_head: The number of attention heads in the self-attention mechanism.
The main script to run any AL experiment is run_AL.py.
Example:
python run_AL.py --dataset_name trec --multi_head 4 --instance_tokens 1 --num_virtual_tokens 4
