Evaluating and Saving Your Model
Check metrics and push to the Hub.
Evaluating and Saving Your Model is a free NLP Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Training Is Not Enough
A trained model is only useful if it generalizes. So your next job is to evaluate it on data it never saw during training.
Run Evaluation
The Trainer can score your validation set in one call and return the metrics you configured, like accuracy and loss.
print(trainer.evaluate())Pick the Right Metric
Accuracy can mislead on skewed data. For uneven classes, lean on F1 so both precision and recall count.
Compute Metrics Cleanly
The evaluate library wraps common scores, so you compute F1 or accuracy without writing the math by hand.
import evaluate
f1 = evaluate.load("f1")Hold Out a Test Set
Keep a separate test set you touch only once. It gives an honest final estimate, free of tuning bias.
Save the Model
Persist the fine-tuned weights to disk so you can reload them anytime without training again. This saves the model and tokenizer.
trainer.save_model("my-model")
tok.save_pretrained("my-model")Reload Anywhere
Loading is the mirror of saving: point from_pretrained at your folder and the full model comes back ready to predict.
m = AutoModelForSequenceClassification.from_pretrained("my-model")Wrap It in a Pipeline
Drop your saved model into a pipeline for instant, simple inference on fresh text without any manual tokenizing.
clf = pipeline("text-classification", model="my-model")Share on the Hub
One push uploads your model to the Hugging Face Hub, so teammates load it by name from anywhere.
trainer.push_to_hub()Version Your Work
The Hub tracks revisions like git, so each checkpoint stays reproducible and you can always roll back.
Document the Model
A model card records your data, metrics, and limits. It helps others trust and reuse what you built. 📋
Quick Check
Why keep a separate test set you evaluate only once?
Recap
Evaluate on unseen data with the right metric, save the model and tokenizer, then reload or push it to the Hub to share. ✅
Frequently asked questions
Is the “Evaluating and Saving Your Model” lesson free?
Yes — the full text of “Evaluating and Saving Your Model” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Evaluating and Saving Your Model”?
Check metrics and push to the Hub. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Evaluating and Saving Your Model” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Transformers Library Tour
- Tokenizing for Transformer Models
- Fine-Tuning With the Trainer API
- Evaluating and Saving Your Model