SQFT
Collection
SQFT Models (SQFT: Low-cost Model Adaptation in Low-precision Sparse Foundation
Models) • 57 items • Updated • 2
How to use IntelLabs/sqft-phi-3-mini-4k-50-base with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="IntelLabs/sqft-phi-3-mini-4k-50-base", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("IntelLabs/sqft-phi-3-mini-4k-50-base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("IntelLabs/sqft-phi-3-mini-4k-50-base", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use IntelLabs/sqft-phi-3-mini-4k-50-base with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "IntelLabs/sqft-phi-3-mini-4k-50-base"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "IntelLabs/sqft-phi-3-mini-4k-50-base",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/IntelLabs/sqft-phi-3-mini-4k-50-base
How to use IntelLabs/sqft-phi-3-mini-4k-50-base with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "IntelLabs/sqft-phi-3-mini-4k-50-base" \
--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": "IntelLabs/sqft-phi-3-mini-4k-50-base",
"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 "IntelLabs/sqft-phi-3-mini-4k-50-base" \
--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": "IntelLabs/sqft-phi-3-mini-4k-50-base",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use IntelLabs/sqft-phi-3-mini-4k-50-base with Docker Model Runner:
docker model run hf.co/IntelLabs/sqft-phi-3-mini-4k-50-base
Repository: https://github.com/IntelLabs/Hardware-Aware-Automated-Machine-Learning/tree/main/SQFT
Paper:
Refer to the command in SQFT/run_command/phi-3-mini-4k-instruct/sparse_quantization.sh#11.
@inproceedings{munoz-etal-2024-sqft,
title = "{SQFT}: Low-cost Model Adaptation in Low-precision Sparse Foundation Models",
author = "Munoz, Juan Pablo and
Yuan, Jinjie and
Jain, Nilesh",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.findings-emnlp.749",
pages = "12817--12832",
}
Thanks to the work Wanda (paper, code), which provides a simple but effective pruning approach.
Apache-2.0