

<div align="center">
<h1>Adaptive LLM Pruning via Gradient-steered Search</h1>
</div>

## Quick Start
Quick start is based on llama2-7b as an example, other models can change the base model path.
### 1. Installation
```
pip install -r requirement.txt
```

### 2. Generate Optimal Pruning Ratio

```
cd Generator
bash quick_start.sh
```

### 3. Prune and Evaluate the Pruned Model
You need to download [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) and place it in the ```Pruner\lm-evaluation-harness``` folder.
```
cd ../Pruner
bash quick_start.sh
```
### 4. Fine-tuning
You can run the following command to fine-tune the modle on alpaca.
```
cd ../Pruner
bash fintune.sh
```
### 3.Evaluation the Pruned & Tuned Model
You can run the following command to evalute Llama2-7B on BBH (zero-shot), MMLU (3-shot), PPL, and Commonsense (zero-shot). You need to download [LLaMA-Factory-main](https://github.com/hiyouga/LLaMA-Factory) and place it in the ```Pruner``` folder.
```
cd ../Pruner
bash eval.sh
```

