Home

Awesome

Instructive Decoding: Instruction-Tuned Large Language Models are Self-Refiner from Noisy Instructions

<a href="https://arxiv.org/abs/2311.00233"><img src="https://img.shields.io/badge/Paper-arXiv:2311.00233-Green"></a> <a href="https://colab.research.google.com/drive/1bHczXzppIF-AouiPyE8H89CQ9gL_0Xa2?usp=sharing"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>

This official repository contains the implementation for the research paper "Instructive Decoding: Instruction-Tuned Large Language Models are Self-Refiner from Noisy Instructions". We provide a tutorial in our Colab Notebook.<br/>

šŸš€ Accepted to ICLR 2024 Spotlight [Link] <br/> šŸŽ‰ Accepted to Instruction Workshop @ NeurIPS 2023 [Link]

Taehyeon Kim*, Joonkee Kim*, Gihun Lee*, Se-Young Yun <br/> *: Equal Contribution

<!-- [Distort, Distract, Decode: Instruction-Tuned Model Can Refine its Response from Noisy Instructions ](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjbndLpuu2CAxWX0GEKHY3dBOUQFnoECBAQAQ&url=https%3A%2F%2Farxiv.org%2Fabs%2F2311.00233&usg=AOvVaw0ZOF7zPWlPT11XCYhPTvrr&opi=89978449) -->

šŸ’” Introduction

<p align="center"> <img src="./figures/overview.png" width="1394"/> </p>

šŸŽ¤ TL;DR: The paper presents "Instructive Decoding" (ID), a method enhancing instruction-following in language models by using "noisy instructions" to refine understanding and adherence to tasks. Tested across multiple models and tasks, ID consistently improves performance, especially in generalizing to new tasks, without needing extra training or parameter updates.

šŸ¤” Getting Started

šŸ’» Environmental setup

1. Create a Conda Environment:

Use Conda to create a new environment specifically for this project. This helps keep dependencies organized and avoids conflicts with other projects. Run the following commands in your terminal:

conda create -n id python=3.9
conda activate id

2. Install Required Packages:

Next, install all the necessary packages. We've listed all the required dependencies in requirements.txt. To install them, simply execute:

pip install -r requirements.txt

šŸ“‘ Data preparation

1. Create the Directories:

Set up the directory structure for downloading and storing the datasets. Run these commands in your terminal:

mkdir -p data/downloads
mkdir -p data

2. SuperNatural Instruction Dataset:

Clone the SuperNatural Instruction dataset (Link) and organize it into the correct directory:

git clone https://github.com/allenai/natural-instructions.git data/downloads
mkdir -p data/supni
mv data/downloads/tasks data/downloads/splits data/supni/
rm -rf data/downloads/natural-instructions

3. MMLU Dataset:

Download and extract the MMLU dataset:

wget -O data/downloads/mmlu_data.tar https://people.eecs.berkeley.edu/~hendrycks/data.tar
mkdir -p data/mmlu
tar -xvf data/downloads/mmlu_data.tar -C data/mmlu
rm -rf data/downloads/mmlu_data.tar

Then, you will have a directory structure as follows šŸ‘‡šŸ»šŸ‘‡šŸ»:

Instructive-Decoding
ā”œā”€ā”€ data
ā”‚   ā”œā”€ā”€ supni
ā”‚   ā”‚   ā”œā”€ā”€ splits
ā”‚   ā”‚   ā””ā”€ā”€ tasks
ā”‚   ā”œā”€ā”€ mmlu
ā”‚   ā”‚   ā”œā”€ā”€ test
ā”‚   ā”‚   ā””ā”€ā”€ ...
ā”œā”€ā”€ scripts
ā”‚   ā”œā”€ā”€ run_sni.sh
ā”‚   ā”œā”€ā”€ run_mmlu.sh
ā”‚   ā””ā”€ā”€ ...
ā”œā”€ā”€ src
ā”‚   ā”œā”€ā”€ run_eval.py
ā”‚   ā”œā”€ā”€ base_generator.py
ā”‚   ā””ā”€ā”€ ...
ā”œā”€ā”€ requirements.txt
ā””ā”€ā”€ ...

šŸ“ How to Use

šŸ’» Prepare the Pretrained Weights

We utilized various models in our paper. You can directly load these models from the Huggingface Hub or use specific weights as required. Here are the relevant links and information:

šŸ’» Run Experiments

To customize and experiment with your own noisy instructions, modify the instructions in the inst_aware_batchify function within xxx_generator.py.

To reproduce our results, execute the following scripts in your terminal:

bash scripts/run_sni.sh
bash scripts/run_mmlu.sh

šŸ’» Key Arguments Explained

šŸ˜ Misc.

Feel free to cite us.

 @article{instructivedecoding,
  title={Instructive Decoding: Instruction-Tuned Large Language Models are Self-Refiner from Noisy Instructions},
  author={Kim, Taehyeon and Kim, Joonkee and Lee, Gihun and Yun, Se-Young},
  journal={arXiv preprint arXiv:2311.00233},
  year={2023}
}