# ReST-KV: Robust KV Cache Eviction with Layer-wise Output Reconstruction and Spatial-Temporal Smoothing

## Installation

To get started with restkv, follow these steps:

1. Create a new conda environment:
   ```bash
   conda create -n restkv python=3.10
   conda activate restkv
   ```
2. Install torch using conda:
   ```bash
    conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 -c pytorch
    ```
3. Install the required packages:
    ```bash
    pip install -r requirements.txt
    ```

## Usage

We provide a script to run the ReST-KV, you can run it with the following command:

```bash
# longbench
bash scripts/run_longbench.sh

# ruler
bash scripts/run_ruler.sh

# needle in haystack
bash scripts/run_needle_in_haystack.sh
```

Those scripts will run the ReST-KV on the corresponding datasets. You can modify the scripts to change the model and other parameters.

