0Pricing
NLP Academy · 课时

评估并保存您的模型

检查指标并推送到 Hub

评估并保存您的模型 是 CoddyKit 上的免费 NLP Academy 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 NLP Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 NLP Academy 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

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. ✅

常见问题解答

「评估并保存您的模型」课时是免费的吗?

是的 — 「评估并保存您的模型」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 NLP Academy 课程的其余内容,请升级到 CoddyKit PRO。 NLP Academy 课程共包含 4 节课。

「评估并保存您的模型」这节课中我会学到什么?

检查指标并推送到 Hub 你通过在浏览器中直接运行的动手代码来练习 NLP Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 NLP Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 NLP Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「评估并保存您的模型」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 NLP Academy 课中编写并运行代码吗?

能。每节 NLP Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. Transformer 库导览
  2. 为 Transformer 模型进行分词
  3. 使用 Trainer API 进行微调
  4. 评估并保存您的模型
← 返回 NLP Academy