SVD-LLM

AIoT-MLSys-LabApache-2.0长期未更新

基于截断 SVD 的大模型压缩方法,通过奇异值分解降低 LLM 参数量与显存占用,同时尽量保住生成质量,已中稿 ICLR 2025。

[ICLR 2025🔥] SVD-LLM & [NAACL 2025🔥] SVD-LLM V2

暂无版本310star47fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
conda create -n compress python=3.9
conda activate compress
git clone https://github.com/AIoT-MLSys-Lab/SVD-LLM.git
pip install -r requirements.txt
硬件要求按 README 说明

README 未说明显存要求;示例脚本以 LLaMA-7B 为目标,需能加载 7B 模型的 GPU 环境

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用截断感知 SVD 压缩大语言模型权重的开源工具,支持 LLaMA、Mistral、OPT 等模型

基于截断 SVD 的大模型压缩方法,通过奇异值分解降低 LLM 参数量与显存占用,同时尽量保住生成质量,已中稿 ICLR 2025。

核心能力

  • 截断感知数据白化后再做 SVD 压缩权重
  • 用 LoRA 对压缩后权重做低秩微调恢复精度
  • 可与 GPTQ-4bit 量化叠加实现更高压缩比
  • 内置困惑度与效率两套评测脚本

容易踩的坑

transformers 必须严格为 4.35.2,压缩版模型结构有改动;Python 需用 3.9,更新版本会破坏依赖;困惑度评测的 c4 数据需从 README 给的 Google Drive 链接手动下载并放入 utils/ 目录

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Introduction

    SVD-LLM: Truncation-aware Singular Value Decomposition for Large Language Model Compression

    Xin Wang1, Yu Zheng2, Zhongwei Wan1, Mi Zhang1
    1The Ohio State University, 2Michigan State University

    International Conference on Learning Representations (ICLR) 2025

    SVD-LLM V2: Optimizing Singular Value Truncation for Large Language Model Compression

    Xin Wang, Samiul Alam, Zhongwei Wan, Hui Shen, Mi Zhang
    The Ohio State University

    Annual Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics (NAACL) 2025

    Quick Start

    Installation

    Please keep the version of the transformers package exactly equal to 4.35.2 since the svd-compressed version of LLM has a slight change of model structure (in the component/. folder). Create and set up a conda environment with python version 3.9 (newer versions break some dependencies)

    conda create -n compress python=3.9
    conda activate compress
    

    Clone and navigate to the repository

    git clone https://github.com/AIoT-MLSys-Lab/SVD-LLM.git
    

    Install requirements.txt

    pip install -r requirements.txt
    

    Quick Example

    bash compress_llama.sh
    

    This script would compress the LLaMA-7B model under 20% compression ratio and automatically run the evaluation code, including both perplexity and efficiency of the compressed model.

    Step-by-Step Instructions of SVD-LLM

    1. Truncation-Aware Data Whitening + SVD Compression

    Under the low compression ratio (recommended ratio <= 0.3), we first run the data whitening of the LLM and saved the weight along with the whitening information.

    python SVDLLM.py \
    --step 1  \
    --ratio COMPRESSION_RATIO \
    --model HUGGINGFACE_MODEL_REPO \
    --whitening_nsamples WHITENING_SAMPLE_NUMBER \
    --dataset WHITENING_DATASET \
    --seed SAMPLING_SEED \
    --model_seq_len MODEL_SEQ_LEN \
    --save_path WHITENING_INFO_SAVING_PATH
    

    2. Parameter Update with Sequential Low-rank Approximation

    We first update the compressed weight matrix U and then V with LoRA fine-tuning.

    python LoRA.py \
    --prune_model COMPRESSED_MODEL_PATH \
    --data_path yahma/alpaca-cleaned \
    --output_dir LORA_OUTPUT_PATH  \
    --lora_r 8 \
    --num_epochs 2 \
    --learning_rate 1e-4 \
    --batch_size 64
    

    3. SVD-LLM + GPTQ

    SVD-LLM can also be integrated with quantization methods to achieve a better compression. Here is the example of how to integrate SVD-LLM (20% compression ratio) with GPTQ-4bit to compress LLaMA-7B

    bash svdllm_gptq.sh
    

    4. Evaluation

    • Perplexity Evaluation:
    python SVDLLM.py \
    --step 4 \
    --model_path COMPRESSD_MODEL_SAVING_PATH  \
    

    We use the same c4 dataset as in SparseGPT. Since the original dowload link is invalid, please directly download it from this link and add the two json files under the utils/. folder.

    • Efficiency Evaluation:
    python SVDLLM.py \
    --step 5 \
    --model_path COMPRESSD_MODEL_SAVING_PATH  \
    

    Citation

    If you find this work useful, please cite

    @inproceedings{wang2025svdllm,
      title={{SVD}-{LLM}: Truncation-aware Singular Value Decomposition for Large Language Model Compression},
      author={Xin Wang and Yu Zheng and Zhongwei Wan and Mi Zhang},
      booktitle={International Conference on Learning Representations (ICLR)},
      year={2025},
      url={https://openreview.net/forum?id=LNYIUouhdt}
    }