Downloads · 30 days
12
20% of all-time downloads
hassanshka/Biomni-R0-32B-PTQ-INT8
Biomni-R0-32B-PTQ-INT8 is a text generation model from hassanshka. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a Post-Training Quantization (PTQ) INT8 version of Biomni-R0-32B-Preview.
Downloads · 30 days
12
20% of all-time downloads
All-time downloads
61
Public
Parameters
32.8B
33.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors33.6 GB · 100%
How the weights are stored.
I832B · 98%
From the Hugging Face model README
This is a Post-Training Quantization (PTQ) INT8 version of Biomni-R0-32B-Preview.
| Parameter | Value |
|---|---|
| Scheme | INT8 (8-bit weights and activations) |
| Method | Post-Training Quantization (PTQ) |
| Backend | Optimum Quanto |
| Calibration Samples | 120 |
| Model Size | ~8-10 GB (vs ~60 GB original BF16) |
| Memory Reduction | ~83-87% compared to BF16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"hassanshka/Biomni-R0-32B-PTQ-INT8",
device_map="auto",
torch_dtype="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("hassanshka/Biomni-R0-32B-PTQ-INT8")
# Inference
messages = [{"role": "user", "content": "Your medical question here"}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0]))
The quantization may be applied at serving time by vLLM for optimal performance:
from vllm import LLM, SamplingParams
llm = LLM(
model="hassanshka/Biomni-R0-32B-PTQ-INT8",
quantization="awq", # or appropriate quantization method
trust_remote_code=True
)
sampling_params = SamplingParams(temperature=0.7, top_p=0.95)
prompts = ["Your medical question here"]
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
print(output.outputs[0].text)
This model was quantized using Optimum Quanto with post-training quantization:
from optimum.quanto import quantize, qint8
from transformers import AutoModelForCausalLM
# Load the base model
model = AutoModelForCausalLM.from_pretrained(
"biomni/Biomni-R0-32B-Preview",
torch_dtype=torch.float16
)
# Quantize to INT8
quantize(model, weights=qint8, activations=qint8)
# Save the quantized model
model.save_pretrained("./Biomni-R0-32B-PTQ-INT8")
This model was quantized from the original Biomni-R0-32B-Preview model using:
Apache 2.0 (same as base model)
If you use this model, please cite the original Biomni model:
@misc{{biomni-r0-32b-preview,
title={{Biomni-R0-32B-Preview}},
author={{Biomni Team}},
year={{2024}},
url={{https://huggingface.co/biomni/Biomni-R0-32B-Preview}}
}}