Shears
Collection
Shears Models (Shears: Unstructured Sparsity with Neural Low-rank Adapter Search) • 13 items • Updated • 2
How to use IntelLabs/shears-mpt-7b-50-base with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="IntelLabs/shears-mpt-7b-50-base", trust_remote_code=True) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("IntelLabs/shears-mpt-7b-50-base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("IntelLabs/shears-mpt-7b-50-base", trust_remote_code=True)How to use IntelLabs/shears-mpt-7b-50-base with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "IntelLabs/shears-mpt-7b-50-base"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "IntelLabs/shears-mpt-7b-50-base",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/IntelLabs/shears-mpt-7b-50-base
How to use IntelLabs/shears-mpt-7b-50-base with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "IntelLabs/shears-mpt-7b-50-base" \
--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": "IntelLabs/shears-mpt-7b-50-base",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "IntelLabs/shears-mpt-7b-50-base" \
--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": "IntelLabs/shears-mpt-7b-50-base",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use IntelLabs/shears-mpt-7b-50-base with Docker Model Runner:
docker model run hf.co/IntelLabs/shears-mpt-7b-50-base
The sparsified MPT-7B with 50% sparsity as a base model in Shears.
Repository: https://github.com/IntelLabs/Hardware-Aware-Automated-Machine-Learning/tree/main/Shears
Paper:
@inproceedings{munoz-etal-2024-shears,
title = "Shears: Unstructured Sparsity with Neural Low-rank Adapter Search",
author = "Mu{\~n}oz, J. Pablo and
Yuan, Jinjie and
Jain, Nilesh",
editor = "Yang, Yi and
Davani, Aida and
Sil, Avi and
Kumar, Anoop",
booktitle = "Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 6: Industry Track)",
month = jun,
year = "2024",
address = "Mexico City, Mexico",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.naacl-industry.34",
doi = "10.18653/v1/2024.naacl-industry.34",
pages = "395--405",
}
Thanks to the work Wanda (paper, code), which provides a simple but effective pruning approach.
Apache-2.0