AQLM
Collection
AQLM quantized LLMs • 21 items • Updated • 46
How to use ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8")
model = AutoModelForCausalLM.from_pretrained("ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8")
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 ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8
How to use ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8" \
--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": "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8",
"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 "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8" \
--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": "ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8 with Docker Model Runner:
docker model run hf.co/ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8")
model = AutoModelForCausalLM.from_pretrained("ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8")
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]:]))Official AQLM quantization of mistralai/Mistral-7B-Instruct-v0.2 .
For this quantization, we used 2 codebooks of 8 bits.
Results:
| Model | Quantization | MMLU (5-shot) | Model size, Gb |
|---|---|---|---|
| mistralai/Mistral-7B-Instruct-v0.2 | None | 0.5912 | 14.5 |
| 2x8 | 0.4384 | 2.3 |
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ISTA-DASLab/Mistral-7B-Instruct-v0.2-AQLM-2Bit-2x8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)