0Pricing
NLP Academy · درس

حفظ النموذج وتحميله

احفظه باستخدام joblib لإعادة استخدامه

حفظ النموذج وتحميله درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Save a Model?

Training can take minutes or hours. Saving the fitted model lets you reuse it instantly, with no need to retrain every time. 💾

Serialization in Plain Words

Serialization turns your in-memory model into bytes you can write to disk. Loading reverses it back into a working object.

Meet joblib

For scikit-learn models, joblib is the recommended tool. It handles the large numpy arrays inside your model efficiently.

import joblib

Save With dump

Call dump with your fitted pipeline and a filename. That single line writes the entire model to disk.

joblib.dump(pipe, "models/sentiment.joblib")

Load With load

Later, restore the model with load. You get back the exact same object, ready to predict right away.

model = joblib.load("models/sentiment.joblib")

Save the Whole Pipeline

Always save the full pipeline, not just the classifier. The vectorizer must travel with it, or new text will not be encoded correctly.

joblib vs pickle

Plain pickle works too, but joblib is faster for the big arrays scikit-learn models contain. Prefer joblib for these models.

Pin the Version

A model saved with one scikit-learn version may fail to load on another. Record the library version beside your saved file.

Trust Only Your Files

Loading runs code, so a malicious file can harm you. Only load model files from sources you fully trust. ⚠️

Keep Models Out of Git

Saved models are large binaries. Add the models folder to gitignore and store big files in proper storage instead.

# .gitignore
models/

Verify After Loading

After loading, run a quick prediction on a known example. If the output looks right, your saved model is intact and ready.

print(model.predict(["this movie was great"]))

Quick Check

Think about which object you must persist to disk.

Recap

You used joblib to dump and load the full pipeline, pinned the version, kept models out of git, and verified with a test prediction. 🎉

الأسئلة الشائعة

هل درس «حفظ النموذج وتحميله» مجاني؟

نعم — نص درس «حفظ النموذج وتحميله» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.

ماذا ستتعلم في «حفظ النموذج وتحميله»؟

احفظه باستخدام joblib لإعادة استخدامه تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟

لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «حفظ النموذج وتحميله»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟

نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. هيكلة مشروع NLP حقيقي
  2. مسارات scikit-learn من البداية إلى النهاية
  3. حفظ النموذج وتحميله
  4. التنبؤ على نص جديد تمامًا
← العودة إلى NLP Academy