legacy-datasets/c4
Updated • 9.56k • 242
How to use MoritzMo123/kfac-svd_lems_mistral-7b_0.7 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MoritzMo123/kfac-svd_lems_mistral-7b_0.7", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("MoritzMo123/kfac-svd_lems_mistral-7b_0.7", trust_remote_code=True, dtype="auto")How to use MoritzMo123/kfac-svd_lems_mistral-7b_0.7 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MoritzMo123/kfac-svd_lems_mistral-7b_0.7"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MoritzMo123/kfac-svd_lems_mistral-7b_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/MoritzMo123/kfac-svd_lems_mistral-7b_0.7
How to use MoritzMo123/kfac-svd_lems_mistral-7b_0.7 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MoritzMo123/kfac-svd_lems_mistral-7b_0.7" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MoritzMo123/kfac-svd_lems_mistral-7b_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "MoritzMo123/kfac-svd_lems_mistral-7b_0.7" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MoritzMo123/kfac-svd_lems_mistral-7b_0.7",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use MoritzMo123/kfac-svd_lems_mistral-7b_0.7 with Docker Model Runner:
docker model run hf.co/MoritzMo123/kfac-svd_lems_mistral-7b_0.7
This model was compressed using kfac_svd with lems rank search starting from unsloth/mistral-7b as base model. You may check out our publication and project page for details on kfac-svd and our LEMS rank search.
| Metric | Value |
|---|---|
| Base Model | unsloth/mistral-7b |
| Method | kfac_svd |
| Search Method | lems |
| Target Ratio | 0.7 |
| Compression Metric | params |
| Recommended Dtype | float16 |
| Compressed Layers | 146 |
| Total Parameters | 5,147,357,330 |
The checkpoint records its recommended dtype in config.json; no explicit torch_dtype argument should be needed with this remote-code wrapper. For standard Transformers models, torch_dtype="auto" is the portable fallback.
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"MoritzMo123/kfac-svd_lems_mistral-7b_0.7",
trust_remote_code=True,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("MoritzMo123/kfac-svd_lems_mistral-7b_0.7")
inputs = tokenizer('Hello, ', return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
| Dataset | Perplexity |
|---|---|
| wikitext2 | 7.42 |
| ptb | 67.95 |
| c4 | 18.25 |
| Layer | Rank |
|---|---|
model.layers.0.mlp.gate_proj |
1840 |
model.layers.0.mlp.up_proj |
1976 |
model.layers.0.self_attn.k_proj |
280 |
model.layers.0.self_attn.o_proj |
912 |
model.layers.0.self_attn.q_proj |
616 |
model.layers.1.mlp.gate_proj |
1912 |
model.layers.1.mlp.up_proj |
2432 |
model.layers.1.self_attn.k_proj |
296 |
model.layers.1.self_attn.q_proj |
624 |
model.layers.10.mlp.down_proj |
1488 |
model.layers.10.mlp.gate_proj |
1360 |
model.layers.10.mlp.up_proj |
1824 |
model.layers.10.self_attn.k_proj |
752 |
model.layers.10.self_attn.o_proj |
1096 |
model.layers.10.self_attn.q_proj |
672 |
model.layers.11.mlp.down_proj |
1304 |
model.layers.11.mlp.gate_proj |
1264 |
model.layers.11.mlp.up_proj |
1688 |
model.layers.11.self_attn.k_proj |
600 |
model.layers.11.self_attn.o_proj |
1176 |
model.layers.11.self_attn.q_proj |
624 |
model.layers.12.mlp.down_proj |
1208 |
model.layers.12.mlp.gate_proj |
1224 |
model.layers.12.mlp.up_proj |
1544 |
model.layers.12.self_attn.k_proj |
712 |
model.layers.12.self_attn.o_proj |
1352 |
model.layers.12.self_attn.q_proj |
680 |
model.layers.13.mlp.down_proj |
1320 |
model.layers.13.mlp.gate_proj |
1208 |
model.layers.13.mlp.up_proj |
1424 |
model.layers.13.self_attn.k_proj |
528 |
model.layers.13.self_attn.o_proj |
1352 |
model.layers.13.self_attn.q_proj |
632 |
model.layers.14.mlp.down_proj |
1536 |
model.layers.14.mlp.gate_proj |
1160 |
model.layers.14.mlp.up_proj |
1512 |
model.layers.14.self_attn.k_proj |
504 |
model.layers.14.self_attn.o_proj |
1184 |
model.layers.14.self_attn.q_proj |
640 |
model.layers.15.mlp.down_proj |
1656 |
model.layers.15.mlp.gate_proj |
1184 |
model.layers.15.mlp.up_proj |
1832 |
model.layers.15.self_attn.k_proj |
568 |
model.layers.15.self_attn.q_proj |
648 |
model.layers.16.mlp.down_proj |
1864 |
model.layers.16.mlp.gate_proj |
1544 |
model.layers.16.mlp.up_proj |
2168 |
model.layers.16.self_attn.k_proj |
488 |
model.layers.16.self_attn.o_proj |
1256 |
model.layers.16.self_attn.q_proj |
648 |
model.layers.17.mlp.down_proj |
2264 |
model.layers.17.mlp.gate_proj |
1752 |
model.layers.17.mlp.up_proj |
2240 |
model.layers.17.self_attn.k_proj |
584 |
model.layers.17.self_attn.o_proj |
1216 |
model.layers.17.self_attn.q_proj |
616 |
model.layers.18.mlp.gate_proj |
2048 |
model.layers.18.mlp.up_proj |
2160 |
model.layers.18.self_attn.k_proj |
576 |
model.layers.18.self_attn.o_proj |
1112 |
model.layers.18.self_attn.q_proj |
624 |
model.layers.19.mlp.gate_proj |
2120 |
model.layers.19.mlp.up_proj |
2024 |
model.layers.19.self_attn.k_proj |
616 |
model.layers.19.self_attn.o_proj |
1264 |
model.layers.19.self_attn.q_proj |
680 |
model.layers.2.self_attn.o_proj |
992 |
model.layers.2.self_attn.q_proj |
960 |
model.layers.20.mlp.gate_proj |
2032 |
model.layers.20.mlp.up_proj |
2040 |
model.layers.20.self_attn.k_proj |
480 |
model.layers.20.self_attn.o_proj |
1032 |
model.layers.20.self_attn.q_proj |
640 |
model.layers.21.mlp.gate_proj |
2080 |
model.layers.21.mlp.up_proj |
1864 |
model.layers.21.self_attn.k_proj |
520 |
model.layers.21.self_attn.o_proj |
784 |
model.layers.21.self_attn.q_proj |
624 |
model.layers.22.mlp.gate_proj |
2016 |
model.layers.22.mlp.up_proj |
1856 |
model.layers.22.self_attn.k_proj |
544 |
model.layers.22.self_attn.o_proj |
616 |
model.layers.22.self_attn.q_proj |
640 |
model.layers.23.mlp.up_proj |
1976 |
model.layers.23.self_attn.k_proj |
528 |
model.layers.23.self_attn.o_proj |
680 |
model.layers.23.self_attn.q_proj |
656 |
model.layers.23.self_attn.v_proj |
752 |
model.layers.24.mlp.gate_proj |
2168 |
model.layers.24.mlp.up_proj |
1816 |
model.layers.24.self_attn.k_proj |
400 |
model.layers.24.self_attn.o_proj |
632 |
model.layers.24.self_attn.q_proj |
616 |
model.layers.24.self_attn.v_proj |
696 |
model.layers.25.mlp.down_proj |
2216 |
model.layers.25.mlp.up_proj |
1840 |
model.layers.25.self_attn.k_proj |
424 |
model.layers.25.self_attn.o_proj |
648 |
model.layers.25.self_attn.q_proj |
632 |
model.layers.25.self_attn.v_proj |
704 |
model.layers.26.mlp.down_proj |
1800 |
model.layers.26.mlp.up_proj |
1864 |
model.layers.26.self_attn.k_proj |
304 |
model.layers.26.self_attn.o_proj |
616 |
model.layers.26.self_attn.q_proj |
616 |
model.layers.27.mlp.down_proj |
1624 |
model.layers.27.mlp.up_proj |
1912 |
model.layers.27.self_attn.k_proj |
424 |
model.layers.27.self_attn.o_proj |
624 |
model.layers.27.self_attn.q_proj |
616 |
model.layers.27.self_attn.v_proj |
592 |
model.layers.28.mlp.down_proj |
1800 |
model.layers.28.mlp.gate_proj |
2112 |
model.layers.28.mlp.up_proj |
1656 |
model.layers.28.self_attn.k_proj |
360 |
model.layers.28.self_attn.o_proj |
624 |
model.layers.28.self_attn.q_proj |
616 |
model.layers.28.self_attn.v_proj |
704 |
model.layers.29.mlp.up_proj |
2048 |
model.layers.29.self_attn.k_proj |
704 |
model.layers.29.self_attn.o_proj |
768 |
model.layers.29.self_attn.q_proj |
632 |
model.layers.3.self_attn.q_proj |
632 |
model.layers.30.self_attn.k_proj |
456 |
model.layers.30.self_attn.o_proj |
632 |
model.layers.30.self_attn.q_proj |
640 |
model.layers.31.self_attn.k_proj |
424 |
model.layers.31.self_attn.o_proj |
808 |
model.layers.31.self_attn.q_proj |
632 |
model.layers.4.self_attn.o_proj |
1112 |
model.layers.4.self_attn.q_proj |
624 |
model.layers.5.self_attn.q_proj |
640 |
model.layers.6.self_attn.o_proj |
1240 |
model.layers.6.self_attn.q_proj |
632 |
model.layers.7.self_attn.k_proj |
712 |
model.layers.7.self_attn.o_proj |
1408 |
model.layers.7.self_attn.q_proj |
656 |
model.layers.8.mlp.down_proj |
2088 |
model.layers.8.mlp.gate_proj |
2088 |
model.layers.8.self_attn.o_proj |
1024 |
model.layers.8.self_attn.q_proj |
640 |
model.layers.9.mlp.down_proj |
1752 |
model.layers.9.mlp.gate_proj |
1544 |
model.layers.9.mlp.up_proj |
2088 |
model.layers.9.self_attn.o_proj |
1208 |
model.layers.9.self_attn.q_proj |
616 |
| Config Field | Value |
|---|---|
| Model | unsloth/mistral-7b |
| SVD Method | kfac_svd |
| Search Method | lems |
| Compression Target | 0.7 |
| Target Metric | params |
| Calibration Dataset | wikitext2 |
| Sequence Length | 2048 |
| Seed | 42 |
Base model
unsloth/mistral-7b