Instructions to use ikimyaii/llama-7b-cws-60pct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ikimyaii/llama-7b-cws-60pct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ikimyaii/llama-7b-cws-60pct")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ikimyaii/llama-7b-cws-60pct") model = AutoModelForCausalLM.from_pretrained("ikimyaii/llama-7b-cws-60pct", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ikimyaii/llama-7b-cws-60pct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ikimyaii/llama-7b-cws-60pct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ikimyaii/llama-7b-cws-60pct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ikimyaii/llama-7b-cws-60pct
- SGLang
How to use ikimyaii/llama-7b-cws-60pct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ikimyaii/llama-7b-cws-60pct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ikimyaii/llama-7b-cws-60pct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ikimyaii/llama-7b-cws-60pct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ikimyaii/llama-7b-cws-60pct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ikimyaii/llama-7b-cws-60pct with Docker Model Runner:
docker model run hf.co/ikimyaii/llama-7b-cws-60pct
LLaMA-7B · CWS 60% sparse
Renamed from
llama-7b-obs-cancel-block-60pcton 2026-10-13 as part of the OBS-cancel → CWS rename; the old URL redirects here.
OpenLLaMA-7B pruned one-shot to 60% weight sparsity with CWS, with the same fraction removed from every output row (semi-structured). This is CWS, the proposed method.
Model details
| Base model | openlm-research/open_llama_7b |
| Method | CWS (block, B = 128) |
| Target / achieved sparsity | 60% / 60.16% |
| Weight correction | OBS (second-order) |
| Retraining | none |
What is pruned: every nn.Linear in the 32 decoder layers (attention q/k/v/o and MLP gate/up/down) plus lm_head, 225 layers in total (see pruning_summary.json). Embeddings and norms stay dense.
Evaluation
WikiText-2 PPL of all five methods at 60% (dense 8.64):
| Method | WikiText-2 PPL ↓ |
|---|---|
| CWS (this model) | 18.58 |
| SparseGPT | 20.76 |
| Wanda | 18.11 |
| RIA | 18.54 |
| AWP | 14.69 |
These are the project's results at the time the checkpoints were uploaded (2026-05-11; results/sparsity_sweep_llama.json @ 6e144ae), with dense PPL 8.64. The repository README now reports these models under a 2048-token protocol (dense 6.61). The README's CWS numbers also come from a later sequential-calibration version of CWS, which is not this checkpoint, and are better (e.g. 8.24 at 50%).
About CWS
CWS (Correlation-aware Weight Sparsity) is a post-training, one-shot pruning method that extends SparseGPT's Optimal Brain Surgeon (OBS) weight correction with a full-Hessian selection criterion.
Per-weight saliency scores (magnitude, Wanda, RIA, SparseGPT's diagonal score)
look at each weight in isolation. They miss cancellation groups: correlated
input channels whose opposite-sign weights partly cancel in the layer output,
so removing them together costs less than their individual scores predict.
For each output row, CWS greedily picks the weight with the smallest marginal
cost δ(j | S) = r_j² / d_j, where r_j and d_j come from the evolving
inverse-Hessian factor (one rank-1 Schur-complement downdate per pick). It then
applies exact OBS corrections to the surviving weights. With H = (2/N) XᵀX,
the first pick is exactly SparseGPT's choice; later picks account for the
cross-weight interactions that a diagonal score ignores.
Two selection scopes appear in this collection:
Block CWS (default): greedy selection is confined to 128-column blocks, and corrections are applied block by block. This is stable on wide layers.
Global CWS (ablation): the whole row is one block (block size → ∞). It captures cross-block cancellation, but it is more prone to numerical drift on large layers.
Method and reference implementation: CWS
Experiments, baselines and raw results for these checkpoints: Sparse-LLMs-on-Loihi
Follow-up work that swaps CWS's layer-wise reconstruction objective for the real next-token loss: Weight-Sparsity-Using-Real-Loss
Usage
import torch
from transformers import AutoModelForCausalLM, LlamaTokenizer
model_id = "ikimyaii/llama-7b-cws-60pct"
tokenizer = LlamaTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
lin = model.model.layers[0].mlp.down_proj
print(f"sparsity: {(lin.weight == 0).float().mean():.3f}")
Limitations
- These are research checkpoints for studying pruning. They are not instruction-tuned or safety-tuned, and they inherit the base model's biases.
- Weights are stored densely, with zeros at the pruned positions. Sparsity alone gives no speedup without a sparse kernel or event-driven hardware.
Citation
The CWS paper is under anonymous review; please cite the code repository for now.
@misc{cws2026,
title = {Semi-Structured Correlation-aware Weight Sparsity (CWS) for Efficient LLM Inference},
year = {2026},
note = {Under review. Code: https://github.com/KimiaGholami/CWS}
}
@inproceedings{frantar2023sparsegpt,
title = {SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot},
author = {Frantar, Elias and Alistarh, Dan},
booktitle = {International Conference on Machine Learning},
year = {2023}
}
- Downloads last month
- 16
Model tree for ikimyaii/llama-7b-cws-60pct
Base model
openlm-research/open_llama_7b