• Stars
    star
    209
  • Rank 187,267 (Top 4 %)
  • Language
    Python
  • Created over 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Source code for the paper "Active Prompting with Chain-of-Thought for Large Language Models"

Active-Prompt: Active Prompting with Chain-of-Thought for Large Language Models

This is the official repo of Active Prompting with Chain-of-Thought for Large Language Models

Method

“Actively and judiciously select the most helpful questions for LLMs“

Existing CoT studies largely rely on a fixed set of human-annotated exemplars, which are not necessarily the most effective ones. A good performance requires human prompt engineering which is costly. We identify the human prompt engineering as two complementary components: question selection and prompt template engineering. In this paper, we offer a solution to the key problem of determining which questions are the most important and helpful ones to annotate from a pool of task-specific queries. By borrowing ideas from the related problem of uncertainty-based active learning, we introduce several metrics to characterize the uncertainty so as to select the most uncertain questions for annotation. Experimental results demonstrate the superiority of our proposed method on eight complex reasoning tasks. With text-davinci-002, active-prompt improves upon self-consistency by 7% (67.9->74.9).

The illustration of active-prompt is shown in the figure below.

image info image info

Requirements

pip install openai

Please put your OpenAI API KEY to the API_KEY variable of utils.py.

Then you are good to go : )

Quick Start

For a quick start, you can directly run inference script with our provided prompts (proposed in the paper).

python inference.py --dataset="gsm8k" --model="code-davinci-002" --method="active_cot" --qes_limit=10 --prompt_path="./inference_prompts/gsm8k_k=10" --random_seed=42 --multipath=1 --temperature=0.7 --api_time_interval=2

Reproduce Procedure

First run the uncertainty generation script to get the uncertainty for each question of the dataset

Uncertainty Estimation

python uncertainty_estimation.py --dataset="gsm8k" --model="code-davinci-002" --method="few_shot_cot" --qes_limit=0 --prompt_path="./basic_cot_prompts/math_word_problems" --random_seed=42 --num_trails=10 --sort_by=disagreement

After select the most uncertain questions, you can start annotation. We provide our prompt files for your reference when you are writing your prompt file. Finally, run the inference with your prompt file.

Run inference script

python inference.py --dataset="gsm8k" --model="code-davinci-002" --method="active_cot" --qes_limit=0 --prompt_path="YOUR_PROMPT_FILE_PATH" --random_seed=42 --multipath=40 --temperature=0.7 --api_time_interval=2

Important arguments

  • --dataset: The name of a dataset. choices = [gsm8k, svamp, aqua, csqa, last_letters, strategyqa, asdiv, singleeq, addsub, multiarith].
  • --model: GPT-3 model. choices = [text-davinci-002, code-davinci-002].
  • --method: few-shot-cot or active_cot.
  • --qes_limit: number of test questions.
  • --prompt_path: path of prompt file.
  • --num_trails: number of trails for uncertainty estimation.
  • --sort_by: the metric for uncertainty estimation.
  • --multipath: number of paths during generation.
  • --api_time_interval: the time interval when requesting GPT-3 API. Suggested interval is larger than 1 second.

To reproduce the results in our paper, set --qes_limit=0, --multipath=40

Contact information

For help or issues using active-prompt, please submit a GitHub issue.

For personal communication related to active-prompt, please contact Shizhe Diao ([email protected]).

Citation

If you use or extend our work, please cite the following paper:

@misc{diao2023active,
      title={Active Prompting with Chain-of-Thought for Large Language Models}, 
      author={Shizhe Diao and Pengcheng Wang and Yong Lin and Tong Zhang},
      year={2023},
      eprint={2302.12246},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

More Repositories

1

ChatGPTPapers

Must-read papers, related blogs and API tools on the pre-training and tuning methods for ChatGPT.
315
star
2

R-Tuning

[NAACL 2024 Outstanding Paper] Source code for the NAACL 2024 paper entitled "R-Tuning: Instructing Large Language Models to Say 'I Don't Know'"
Python
80
star
3

awesome-domain-adaptation-NLP

domain adaptation in NLP
51
star
4

DaVinci

Source code for the paper "Prefix Language Models are Unified Modal Learners"
Jupyter Notebook
42
star
5

TILGAN

Source code for the Findings of ACL-IJCNLP 2021 paper entitled "TILGAN: Transformer-based Implicit Latent GAN for Diverse and Coherent Text Generation"
Python
26
star
6

automate-cot

Source code for the paper "Automatic Prompt Augmentation and Selection with Chain-of-Thought from Labeled Data"
20
star
7

T-DNA

Source code for the ACL-IJCNLP 2021 paper entitled "T-DNA: Taming Pre-trained Language Models with N-gram Representations for Low-Resource Domain Adaptation" by Shizhe Diao et al.
Python
19
star
8

BigGAN-PyTorch-TPU-Distribute

Distributed version (multiple-process) for training BigGAN with TPU.
Python
9
star
9

Post-Training-Data-Flywheel

We aim to provide the best references to search, select, and synthesize high-quality and large-quantity data for post-training your LLMs.
Python
9
star
10

awesome-transformers

A curated list of resources dedicated to Transformers.
8
star
11

HashTation

Source code for the paper "Hashtag-Guided Low-Resource Tweet Classification"
Python
5
star
12

Transformers_TPU

transformers_TPU, trying to solve RAM issues with mapping dataset
Python
3
star
13

BigGAN-PyTorch-TPU-Single

Single thread version for training BigGAN with TPU.
Python
3
star
14

SEDST3

SEDST version 3.0 base on the Code for CIKM'18 long paper: Explicit state tracking with semi-supervision for neural dialogue generation.
Python
3
star
15

Doolittle

Source code for the EMNLP 2023 paper entitled "Doolittle: Benchmarks and Corpora for Academic Writing Formalization" by Shizhe Diao et al.
Python
3
star
16

Black-Box-Prompt-Learning

Source code for the paper "Black-Box Prompt Learning for Pre-trained Language Models"
2
star
17

BigGAN-PyTorch-TPU-Parallel

Parallel version (multiple-thread) for training BigGAN with TPU.
Python
2
star
18

TPU-Tutorial

This is a tutorial for beginners who would like to use TPU with Pytorch.
1
star
19

MATH6450-CIFAR10

Course project for MATH6450F training two models onn CIFAR-10 to achieve a good performance. The code is adapted from CIFAR-ZOO (https://github.com/BIGBALLON/CIFAR-ZOO)
Python
1
star