الفصل 2: أطر تقديم النماذج
مقارنة الأطر
| الإطار | الأفضل لـ | دعم GPU | متعدد النماذج |
|---|---|---|---|
| TorchServe | نماذج PyTorch | ✅ | ✅ |
| TF Serving | نماذج TensorFlow | ✅ | ✅ |
| Triton | متعدد الأطر، أداء عالي | ✅ | ✅ |
| BentoML | النماذج الأولية السريعة | ✅ | ✅ |
مثال على TorchServe
# إنشاء أرشيف النموذج
torch-model-archiver \
--model-name churn_model \
--version 1.0 \
--model-file model.py \
--serialized-file model.pth \
--handler handler.py \
--export-path model_store
# بدء الخادم
torchserve --start --model-store model_store \
--models churn_model=churn_model.mar
خادم الاستدلال Triton
model_repository/
├── churn_model/
│ ├── config.pbtxt
│ └── 1/
│ └── model.onnx
# config.pbtxt
name: "churn_model"
platform: "onnxruntime_onnx"
max_batch_size: 64
input [
{ name: "features", data_type: TYPE_FP32, dims: [10] }
]
output [
{ name: "predictions", data_type: TYPE_INT64, dims: [1] }
]