Its 268 MB
- User
Its 268 MB
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Its 268 MB
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Ah, 268 MB is quite large for client-side deployment (ideal ONNX models for browsers are usually < 50 MB). This suggests the model is likely in FP32 precision (full 32-bit floating-point weights) rather than quantized to lower precision (e.g., INT8 or FP16).
bert-base) naturally result in bigger ONNX files.Use ONNX Runtime or PyTorch to quantize the model to INT8 or FP16:
from onnxruntime.quantization import quantize_dynamic, QuantType
# Quantize FP32 ONNX model to INT8
quantize_dynamic(
model_input="model.onnx",
model_output="model_int8.onnx",
weight_type=QuantType.QInt8
)
This will reduce the size significantly (e.g., 268 MB → ~60-70 MB).
Remove redundant weights:
import torch.nn.utils.prune as prune
# Example: Prune 30% of weights
for name, module in model.named_modules():
if isinstance(module, torch.nn.Linear):
prune.l1_unstructured(module, name="weight", amount=0.3)
If you’re using a large model (e.g., bert-base), switch to a distilled version like prdev/mini-gte (which should already be small).
Use ONNX Simplifier to optimize and compress:
pip install onnx-simplifier
onnxsim model.onnx model_sim.onnx
| Format | Estimated Size |
|---|---|
| FP32 ONNX | 268 MB |
| Quantized INT8 | 60–70 MB |
| Quantized FP16 | 130–150 MB |
| Compressed | 40–50 MB |
Revise your README.md to reflect the quantization:
## 🚀 Features
- **ONNX Format**: Ready for browser/edge deployment.
- **Quantized**: Reduced to INT8 precision (~60MB).
- **Sentence Embeddings**: Generate embeddings for semantic search, clustering, etc.
After reducing the size, test in the browser:
// Load quantized model
const sess = await ort.InferenceSession.create(
"https://huggingface.co/your-username/mini-gte/resolve/main/model_int8.onnx"
);
Replace the original ONNX file with the quantized one and re-upload:
api.upload_folder(
repo_id="your-username/mini-gte",
folder_path="./model",
commit_message="Add quantized ONNX model (INT8)"
)
If you’re open to non-ONNX formats, convert to GGUF (used by LLaMA.cpp) for sizes as low as 20–30 MB:
pip install gguf
# Convert PyTorch model to GGUF (requires custom script)
Let me know if you want help with this advanced step!