[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-locuslab--wanda":3,"tool-locuslab--wanda":64},[4,17,25,39,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,14,15],"开发框架","Agent","语言模型","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":10,"last_commit_at":23,"category_tags":24,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,15],{"id":26,"name":27,"github_repo":28,"description_zh":29,"stars":30,"difficulty_score":10,"last_commit_at":31,"category_tags":32,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[33,34,35,36,14,37,15,13,38],"图像","数据工具","视频","插件","其他","音频",{"id":40,"name":41,"github_repo":42,"description_zh":43,"stars":44,"difficulty_score":45,"last_commit_at":46,"category_tags":47,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,3,"2026-04-04T04:44:48",[14,33,13,15,37],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":45,"last_commit_at":54,"category_tags":55,"status":16},519,"PaddleOCR","PaddlePaddle\u002FPaddleOCR","PaddleOCR 是一款基于百度飞桨框架开发的高性能开源光学字符识别工具包。它的核心能力是将图片、PDF 等文档中的文字提取出来，转换成计算机可读取的结构化数据，让机器真正“看懂”图文内容。\n\n面对海量纸质或电子文档，PaddleOCR 解决了人工录入效率低、数字化成本高的问题。尤其在人工智能领域，它扮演着连接图像与大型语言模型（LLM）的桥梁角色，能将视觉信息直接转化为文本输入，助力智能问答、文档分析等应用场景落地。\n\nPaddleOCR 适合开发者、算法研究人员以及有文档自动化需求的普通用户。其技术优势十分明显：不仅支持全球 100 多种语言的识别，还能在 Windows、Linux、macOS 等多个系统上运行，并灵活适配 CPU、GPU、NPU 等各类硬件。作为一个轻量级且社区活跃的开源项目，PaddleOCR 既能满足快速集成的需求，也能支撑前沿的视觉语言研究，是处理文字识别任务的理想选择。",74913,"2026-04-05T10:44:17",[15,33,13,37],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":45,"last_commit_at":62,"category_tags":63,"status":16},2181,"OpenHands","OpenHands\u002FOpenHands","OpenHands 是一个专注于 AI 驱动开发的开源平台，旨在让智能体（Agent）像人类开发者一样理解、编写和调试代码。它解决了传统编程中重复性劳动多、环境配置复杂以及人机协作效率低等痛点，通过自动化流程显著提升开发速度。\n\n无论是希望提升编码效率的软件工程师、探索智能体技术的研究人员，还是需要快速原型验证的技术团队，都能从中受益。OpenHands 提供了灵活多样的使用方式：既可以通过命令行（CLI）或本地图形界面在个人电脑上轻松上手，体验类似 Devin 的流畅交互；也能利用其强大的 Python SDK 自定义智能体逻辑，甚至在云端大规模部署上千个智能体并行工作。\n\n其核心技术亮点在于模块化的软件智能体 SDK，这不仅构成了平台的引擎，还支持高度可组合的开发模式。此外，OpenHands 在 SWE-bench 基准测试中取得了 77.6% 的优异成绩，证明了其解决真实世界软件工程问题的能力。平台还具备完善的企业级功能，支持与 Slack、Jira 等工具集成，并提供细粒度的权限管理，适合从个人开发者到大型企业的各类用户场景。",70612,"2026-04-05T11:12:22",[15,14,13,36],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":79,"owner_email":79,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":91,"forks":92,"last_commit_at":93,"license":94,"difficulty_score":45,"env_os":95,"env_gpu":95,"env_ram":95,"env_deps":96,"category_tags":103,"github_topics":104,"view_count":45,"oss_zip_url":79,"oss_zip_packed_at":79,"status":16,"created_at":107,"updated_at":108,"faqs":109,"releases":139},1095,"locuslab\u002Fwanda","wanda","A simple and effective LLM pruning approach.","Wanda 是一种用于大语言模型（LLM）剪枝的开源工具，通过结合权重大小与输入激活值的乘积，更高效地去除冗余参数。传统方法仅依赖权重绝对值进行剪枝，可能导致模型性能下降，而 Wanda 通过分析权重与激活值的联合影响，实现更精准的剪枝，减少计算资源消耗同时保持模型效果。该工具支持多种剪枝类型，包括无结构化和结构化（如 2:4、4:8）剪枝，并兼容 LLaMA-2 等主流模型，适用于需要优化模型大小与推理效率的场景。其技术亮点在于创新的剪枝策略和对多种模型的广泛支持，降低了大模型部署的门槛。开发者和研究人员可利用 Wanda 快速实现模型压缩，尤其适合在资源受限环境下部署 LLM 的应用。工具提供详细的使用指南和实验脚本，帮助用户高效验证剪枝效果，是大模型优化领域的实用工具。","# Pruning LLMs by Weights and Activations\nOfficial PyTorch implementation of **Wanda** (Pruning by **W**eights **and a**ctivations), as presented in our paper:\n\n**A Simple and Effective Pruning Approach for Large Language Models** \u003C\u002Fbr>\n*Mingjie Sun\\*, Zhuang Liu\\*, Anna Bair, J. Zico Kolter* (* indicates equal contribution) \u003Cbr>\nCarnegie Mellon University, Meta AI Research and Bosch Center for AI  \u003Cbr>\n[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.11695) - [Project page](https:\u002F\u002Feric-mingjie.github.io\u002Fwanda\u002Fhome.html)\n\n```bibtex\n@article{sun2023wanda,\n  title={A Simple and Effective Pruning Approach for Large Language Models}, \n  author={Sun, Mingjie and Liu, Zhuang and Bair, Anna and Kolter, J. Zico},\n  year={2023},\n  journal={arXiv preprint arXiv:2306.11695}\n}\n```\n\n--- \n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Flocuslab_wanda_readme_8f5c7d255a20.png\" width=100% height=100% \nclass=\"center\">\n\u003C\u002Fp>\n\nCompared to magnitude pruning which removes weights solely based on their magnitudes, our pruning approach **Wanda** removes weights on a *per-output* basis, by the product of weight magnitudes and input activation norms.\n\n## Update\n- [x] (9.22.2023) Add [support](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#pruning-llama-2) for LLaMA-2.\n- [x] (9.22.2023) Add [code](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#ablation-on-obs-weight-update) to reproduce the ablation study on OBS weight update in the paper.\n- [x] (10.6.2023) Add new [support](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#ablation-on-obs-weight-update) for the weight update analysis in the ablation study. Feel free to try it out!\n- [x] (10.6.2023) Add [support](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#zero-shot-evaluation) for zero-shot evaluation.\n- [x] (10.20.2023) Add code for pruning OPT models.\n- [x] (10.23.2023) Add code for [LoRA fine-tuning](lora_ft).\n\n## Setup\nInstallation instructions can be found in [INSTALL.md](INSTALL.md).\n\n## Usage\nThe [scripts](scripts) directory contains all the bash commands to replicate the main results (Table 2) in our paper.\n\nBelow is an example command for pruning LLaMA-7B with Wanda, to achieve unstructured 50% sparsity.\n```sh\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type unstructured \\\n    --save out\u002Fllama_7b\u002Funstructured\u002Fwanda\u002F \n```\nWe provide a quick overview of the arguments:  \n- `--model`: The identifier for the LLaMA model on the Hugging Face model hub.\n- `--cache_dir`: Directory for loading or storing LLM weights. The default is `llm_weights`.\n- `--prune_method`: We have implemented three pruning methods, namely [`magnitude`, `wanda`, `sparsegpt`].\n- `--sparsity_ratio`: Denotes the percentage of weights to be pruned.\n- `--sparsity_type`: Specifies the type of sparsity [`unstructured`, `2:4`, `4:8`].\n- `--use_variant`: Whether to use the Wanda variant, default is `False`. \n- `--save`: Specifies the directory where the result will be stored.\n\nFor structured N:M sparsity, set the argument `--sparsity_type` to \"2:4\" or \"4:8\". An illustrative command is provided below:\n```sh\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type 2:4 \\\n    --save out\u002Fllama_7b\u002F2-4\u002Fwanda\u002F \n```\n\n### Pruning LLaMA-2\nFor [LLaMA-2](https:\u002F\u002Fai.meta.com\u002Fllama\u002F) models, replace `--model` with `meta-llama\u002FLlama-2-7b-hf` (take `7b` as an example):\n```sh \npython main.py \\\n    --model meta-llama\u002FLlama-2-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type unstructured \\\n    --save out\u002Fllama2_7b\u002Funstructured\u002Fwanda\u002F\n```\nLLaMA-2 results: (LLaMA-2-34b is not released as of 9.22.2023)\n|sparsity| ppl              | llama2-7b | llama2-13b | llama2-70b |\n|------|------------------|----------|------------|------------|\n|-| dense            | 5.12     | 4.57       | 3.12     |\n|unstructured 50%| magnitude        | 14.89    | 6.37       | 4.98     |\n|unstructured 50%| sparsegpt        | 6.51     | 5.63       | **3.98**  |\n|unstructured 50%| wanda            | **6.42** | **5.56**   | **3.98**  |\n|4:8| magnitude        | 16.48    | 6.76       | 5.58     |\n|4:8| sparsegpt        | 8.12     | 6.60      | 4.59     |\n|4:8| wanda            | **7.97** | **6.55**  | **4.47**     |\n|2:4| magnitude        | 54.59    | 8.33       | 6.33       |\n|2:4| sparsegpt        | **10.17** | 8.32       | 5.40      |\n|2:4| wanda            | 11.02    | **8.27**   | **5.16**     |\n\n### Ablation on OBS weight update\nTo reproduce the analysis on weight update, we provide our implementation for this ablation. All commands can be found in [this script](scripts\u002Fablate_weight_update.sh).\n```sh\nfor method in ablate_mag_seq ablate_wanda_seq ablate_mag_iter ablate_wanda_iter \ndo \nCUDA_VISIBLE_DEVICES=0 python main.py \\\n  --model decapoda-research\u002Fllama-7b-hf \\\n  --sparsity_ratio 0.5 \\\n  --sparsity_type unstructured \\\n  --prune_method ${method} \\\n  --save out\u002Fllama_7b_ablation\u002Funstructured\u002F\ndone \n```\nHere `ablate_{mag\u002Fwanda}_{seq\u002Fiter}` means that we use magnitude pruning or wanda to obtain the pruned mask at each layer, then apply weight update procedure with either a sequential style or an iterative style every 128 input channels. For details, please see Section 5 of our [paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.11695).\n\n### Zero-Shot Evaluation\nFor evaluating zero-shot tasks, we modify the [EleutherAI LM Harness](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Ftree\u002Fmaster) framework so that it could evaluate pruned LLM models. We provide the modified repo in [this link](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1zugbLyGZKsH1L19L9biHLfaGGFnEc7XL\u002Fview?usp=sharing). Make sure to download, extract and install this custom `lm_eval` package from the source code.\n\nFor reproducibility, we used [commit `df3da98`](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Ftree\u002Fdf3da98c5405deafd519c2ddca52bb7c3fe36bef) on the main branch. All tasks were evaluated on task version of 0 except for BoolQ, where the task version is 1.\n\nOn a high level, the functionality we provide is adding two arguments `pretrained_model` and `tokenizer` in this [function](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Fblob\u002Fmaster\u002Flm_eval\u002Fevaluator.py#L17). We can then call this `simple_evaluate` function API from our [codebase](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fblob\u002Fmain\u002Flib\u002Feval.py#L148) to evaluate sparse pruned LLMs. To evaluate zero-shot tasks in addition to the WikiText perplexity, pass the `--eval_zero_shot` argument. \n\n### Speedup Evaluation\nThe pruning speed for each method is evaluated by the cumulated time spent on pruning (for each layer), without the forward passes.\n\nFor inference speedup with structured sparsity, we refer the reader to this [blog post](https:\u002F\u002Fpytorch.org\u002Ftutorials\u002Fprototype\u002Fsemi_structured_sparse.html), where  structured sparsity is supported by `PyTorch >= 2.1`. You can switch between the CUTLASS or CuSPARSELt kernel [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Fblob\u002Fv2.1.0\u002Ftorch\u002Fsparse\u002Fsemi_structured.py#L55).\n\nLast, for pruning image classifiers, see directory [image_classifiers](image_classifiers) for details.\n\n## Acknowledgement\nThis repository is build upon the [SparseGPT](https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fsparsegpt) repository.\n\n## License\nThis project is released under the MIT license. Please see the [LICENSE](LICENSE) file for more information.\n\n## Questions\nFeel free to discuss papers\u002Fcode with us through issues\u002Femails!\n\nmingjies at cs.cmu.edu  \nliuzhuangthu at gmail.com ","# 通过权重和激活进行LLM剪枝\n**Wanda**（通过权重和激活进行剪枝）的官方PyTorch实现，如论文所述：\n\n**一种简单有效的大型语言模型剪枝方法** \u003C\u002Fbr>\n*孙明杰\\*、刘庄\\*、Anna Bair、J. Zico Kolter* （*表示同等贡献） \u003Cbr>\n卡内基梅隆大学、Meta AI研究与博世人工智能中心 \u003Cbr>\n[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.11695) - [项目页面](https:\u002F\u002Feric-mingjie.github.io\u002Fwanda\u002Fhome.html)\n\n```bibtex\n@article{sun2023wanda,\n  title={A Simple and Effective Pruning Approach for Large Language Models}, \n  author={Sun, Mingjie and Liu, Zhuang and Bair, Anna and Kolter, J. Zico},\n  year={2023},\n  journal={arXiv preprint arXiv:2306.11695}\n}\n```\n\n---\n\u003Cp align=\"center\">\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Flocuslab_wanda_readme_8f5c7d255a20.png\" width=100% height=100% \nclass=\"center\">\n\u003C\u002Fp>\n\n与仅基于权重大小的幅度剪枝不同，我们的剪枝方法**Wanda**通过权重大小与输入激活范数的乘积，按输出维度进行权重剪枝。\n\n## 更新\n- [x] (9.22.2023) 增加[对LLaMA-2的支持](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#pruning-llama-2)\n- [x] (9.22.2023) 增加[重现论文中OBS权重更新消融实验的代码](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#ablation-on-obs-weight-update)\n- [x] (10.6.2023) 增加[对消融实验中权重更新分析的新支持](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#ablation-on-obs-weight-update) 可自由尝试！\n- [x] (10.6.2023) 增加[对零样本评估的支持](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda#zero-shot-evaluation)\n- [x] (10.20.2023) 增加对OPT模型剪枝的代码\n- [x] (10.23.2023) 增加[LoRA微调](lora_ft)的代码\n\n## 设置\n安装说明请参见[INSTALL.md](INSTALL.md)\n\n## 使用\n[scripts](scripts)目录包含所有复制论文主结果（表2）的bash命令。\n\n以下是以Wanda剪枝LLaMA-7B实现无结构50%稀疏度的示例命令：\n```sh\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type unstructured \\\n    --save out\u002Fllama_7b\u002Funstructured\u002Fwanda\u002F \n```\n我们提供参数的简要说明：  \n- `--model`: Hugging Face模型库中LLaMA模型的标识符。\n- `--cache_dir`: 加载或存储LLM权重的目录。默认为`llm_weights`。\n- `--prune_method`: 实现了三种剪枝方法，即[`magnitude`, `wanda`, `sparsegpt`].\n- `--sparsity_ratio`: 表示要剪枝的权重百分比。\n- `--sparsity_type`: 指定稀疏度类型 [`unstructured`, `2:4`, `4:8`].\n- `--use_variant`: 是否使用Wanda变体，默认为`False`。 \n- `--save`: 指定结果存储的目录。\n\n对于结构化N:M稀疏度，将参数`--sparsity_type`设置为\"2:4\"或\"4:8\"。以下是一个示例命令：\n```sh\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type 2:4 \\\n    --save out\u002Fllama_7b\u002F2-4\u002Fwanda\u002F \n```\n\n### 剪枝LLaMA-2\n对于[LLaMA-2](https:\u002F\u002Fai.meta.com\u002Fllama\u002F)模型，将`--model`替换为`meta-llama\u002FLlama-2-7b-hf`（以7b为例）：\n```sh \npython main.py \\\n    --model meta-llama\u002FLlama-2-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type unstructured \\\n    --save out\u002Fllama2_7b\u002Funstructured\u002Fwanda\u002F\n```\nLLaMA-2结果：（截至9.22.2023，LLaMA-2-34b尚未发布）\n|稀疏度| ppl              | llama2-7b | llama2-13b | llama2-70b |\n|------|------------------|----------|------------|------------|\n|-| dense            | 5.12     | 4.57       | 3.12     |\n|无结构50%| magnitude        | 14.89    | 6.37       | 4.98     |\n|无结构50%| sparsegpt        | 6.51     | 5.63       | **3.98**  |\n|无结构50%| wanda            | **6.42** | **5.56**   | **3.98**  |\n|4:8| magnitude        | 16.48    | 6.76       | 5.58     |\n|4:8| sparsegpt        | 8.12     | 6.60      | 4.59     |\n|4:8| wanda            | **7.97** | **6.55**  | **4.47**     |\n|2:4| magnitude        | 54.59    | 8.33       | 6.33       |\n|2:4| sparsegpt        | **10.17** | 8.32       | 5.40      |\n|2:4| wanda            | 11.02    | **8.27**   | **5.16**     |\n\n### OBS权重更新消融实验\n为重现权重更新分析，我们提供了该消融实验的实现。所有命令可在[此脚本](scripts\u002Fablate_weight_update.sh)中找到。\n```sh\nfor method in ablate_mag_seq ablate_wanda_seq ablate_mag_iter ablate_wanda_iter \ndo \nCUDA_VISIBLE_DEVICES=0 python main.py \\\n  --model decapoda-research\u002Fllama-7b-hf \\\n  --sparsity_ratio 0.5 \\\n  --sparsity_type unstructured \\\n  --prune_method ${method} \\\n  --save out\u002Fllama_7b_ablation\u002Funstructured\u002F\ndone \n```\n此处`ablate_{mag\u002Fwanda}_{seq\u002Fiter}`表示我们使用幅度剪枝或wanda在每一层获得剪枝掩码，然后每128个输入通道应用权重更新过程（顺序式或迭代式）。详情请参见论文[第5节](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.11695)。\n\n### 零样本评估\n为评估零样本任务，我们修改了[EleutherAI LM Harness](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Ftree\u002Fmaster)框架，使其能够评估剪枝后的LLM模型。我们提供修改后的仓库在[此链接](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1zugbLyGZKsH1L19L9biHLfaGGFnEc7XL\u002Fview?usp=sharing)。请确保从源代码下载、解压并安装此自定义`lm_eval`包。\n\n为保证可复现性，我们使用了主分支上的[commit `df3da98`](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Ftree\u002Fdf3da98c5405deafd519c2ddca52bb7c3fe36bef)。所有任务均在任务版本0上评估，除了BoolQ任务，其任务版本为1。\n\n总体而言，我们提供的功能是在此[函数](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness\u002Fblob\u002Fmaster\u002Flm_eval\u002Fevaluator.py#L17)中新增了两个参数`pretrained_model`和`tokenizer`。我们可以通过[代码库](https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fblob\u002Fmain\u002Flib\u002Feval.py#L148)调用此`simple_evaluate`函数API来评估稀疏剪枝的LLM。若要评估除WikiText外的零样本任务，请传递`--eval_zero_shot`参数。\n\n### 加速评估  \n通过计算每种方法在剪枝过程中所花费的累计时间（每层）来评估剪枝速度，不包含前向传播的时间。\n\n对于结构稀疏性的推理加速，读者可参考这篇[博客文章](https:\u002F\u002Fpytorch.org\u002Ftutorials\u002Fprototype\u002Fsemi_structured_sparse.html)，其中结构稀疏性在 `PyTorch >= 2.1` 中得到支持。您可以通过[此处](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Fblob\u002Fv2.1.0\u002Ftorch\u002Fsparse\u002Fsemi_structured.py#L55)切换 CUTLASS 或 CuSPARSELt 内核。\n\n最后，关于图像分类器的剪枝，请参见目录 [image_classifiers](image_classifiers) 获取详细信息。\n\n## 致谢  \n本仓库基于 [SparseGPT](https:\u002F\u002Fgithub.com\u002FIST-DASLab\u002Fsparsegpt) 仓库构建。\n\n## 许可证  \n本项目采用 MIT 许可证。更多详情请参见 [LICENSE](LICENSE) 文件。\n\n## 问题  \n欢迎通过问题或邮件与我们讨论论文\u002F代码！  \nmingjies@cs.cmu.edu  \nliuzhuangthu@gmail.com","# Wanda 快速上手指南\n\n## 环境准备\n- **系统要求**：Python 3.8+，PyTorch 2.0+\n- **前置依赖**：\n  ```bash\n  pip install torch torchvision torchaudio\n  pip install transformers==4.35.0\n  pip install -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple sentencepiece\n  ```\n\n## 安装步骤\n1. 克隆仓库：\n   ```bash\n   git clone https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\n   cd wanda\n   ```\n2. 安装依赖（参考 INSTALL.md）：\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## 基本使用\n### 最简单示例：LLaMA-7B 无结构50%剪枝\n```bash\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type unstructured \\\n    --save out\u002Fllama_7b\u002Funstructured\u002Fwanda\u002F\n```\n\n### 支持模型\n- LLaMA-2 使用：\n  ```bash\n  --model meta-llama\u002FLlama-2-7b-hf\n  ```\n- OPT 模型剪枝支持\n- LoRA 微调支持（需额外配置）\n\n### 结构化剪枝示例（2:4）\n```bash\npython main.py \\\n    --model decapoda-research\u002Fllama-7b-hf \\\n    --prune_method wanda \\\n    --sparsity_ratio 0.5 \\\n    --sparsity_type 2:4 \\\n    --save out\u002Fllama_7b\u002F2-4\u002Fwanda\u002F\n```","一家科技公司需要部署一个大语言模型用于实时客服对话系统，但发现原始模型体积过大导致推理延迟高，且部署成本居高不下。  \n\n### 没有 wanda 时  \n- 传统权重大小剪枝导致模型性能显著下降，对话响应准确率降低30%  \n- 剪枝后模型体积仍达20GB，部署到边缘设备时内存占用超出硬件限制  \n- 高稀疏度剪枝引发推理延迟，单次对话响应时间从200ms飙升至800ms  \n- 无法灵活调整剪枝策略，既怕模型过小导致质量下降，又怕过大影响实时性  \n- 人工调试剪枝参数耗时数天，且难以平衡精度与效率  \n\n### 使用 wanda 后  \n- 通过权重与激活范数联合评估，保持对话任务准确率仅下降5%，远超传统方法  \n- 结构化剪枝使模型体积压缩至5GB，成功部署到边缘计算设备  \n- 支持unstructured\u002F2:4\u002F4:8等多种稀疏度模式，实时对话场景中延迟稳定在150ms内  \n- 自动化剪枝流程节省80%人工调试时间，通过参数调优快速适配不同业务场景  \n- 剪枝后模型推理速度提升40%，同时保持与原始模型相当的上下文理解能力  \n\n核心价值在于：wanda通过精准的剪枝策略，在保持模型性能的同时实现高效压缩，让大语言模型真正适配边缘计算等资源受限场景。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Flocuslab_wanda_8f5c7d25.png","locuslab","CMU Locus Lab","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Flocuslab_147f21ae.png","Zico Kolter's Research Group",null,"http:\u002F\u002Fwww.zicokolter.com\u002F","https:\u002F\u002Fgithub.com\u002Flocuslab",[83,87],{"name":84,"color":85,"percentage":86},"Python","#3572A5",98.2,{"name":88,"color":89,"percentage":90},"Shell","#89e051",1.8,860,125,"2026-04-03T09:27:37","MIT","未说明",{"notes":97,"python":98,"dependencies":99},"建议使用 conda 管理环境，首次运行需下载约 5GB 模型文件","3.8+",[100,101,102],"torch>=2.0","transformers>=4.30","accelerate",[15],[105,106],"large-language-models","network-pruning","2026-03-27T02:49:30.150509","2026-04-06T06:52:09.819416",[110,115,120,125,130,135],{"id":111,"question_zh":112,"answer_zh":113,"source_url":114},4922,"使用Wanda剪枝Mistral-7B时遇到CUDA内存不足问题如何解决？","用户通过缩短输入序列长度成功压缩模型。具体操作为：在训练时调整输入长度参数，例如将序列长度从默认值缩短至更小的数值，以降低显存占用。参考评论：'I ended up shortening the input sequence length and was able to compress the model.'","https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fissues\u002F68",{"id":116,"question_zh":117,"answer_zh":118,"source_url":119},4923,"Llama-2-13B模型使用Wanda剪枝后PPL异常如何处理？","维护者确认无需特殊参数修改，已多次测试通过。建议直接运行README中提供的命令：`python main.py --model meta-llama\u002FLlama-2-13b-chat-hf --prune_method wanda --sparsity_ratio 0.5`，并确保使用最新版本模型。","https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fissues\u002F54",{"id":121,"question_zh":122,"answer_zh":123,"source_url":124},4924,"是否支持对结合LORA的模型进行剪枝？","理论上可行，但更推荐联合量化和剪枝方案。维护者建议：'joint quantization and pruning'，即先进行量化再进行剪枝，可参考论文中的相关工作实现。","https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fissues\u002F12",{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},4925,"如何自定义数据集用于剪枝训练？","在lib\u002Fdata.py第69行添加自定义数据加载器，示例代码：`def custom_loader(...): ...`。剪枝将基于自定义数据集的激活统计量进行，但需注意不同数据集可能影响激活幅度水平。","https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fissues\u002F5",{"id":131,"question_zh":132,"answer_zh":133,"source_url":134},4926,"tokenizer设置use_fast=False为何会导致错误？","需使用tie_weights方法绑定权重。错误提示'Please use the `tie_weights` method'表明模型权重未绑定，应先调用该方法再使用infer_auto_device函数。","https:\u002F\u002Fgithub.com\u002Flocuslab\u002Fwanda\u002Fissues\u002F4",{"id":136,"question_zh":137,"answer_zh":138,"source_url":129},4927,"如何解决代码中--save_model参数的拼写错误？","参数`--save_model`用于指定保存路径，需确保与代码中定义的变量名一致。若遇到保存失败问题，检查是否混淆了`save`和`save_model`参数，正确用法示例：`--save out\u002Fllama_7b\u002Funstructured\u002Fwanda\u002F --save_model out\u002Fllama_7b\u002Funstructured\u002Fwanda\u002F`。",[]]