モデルを評価して保存する
指標を確認して Hub にプッシュする
「モデルを評価して保存する」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応の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. ✅
よくある質問
「モデルを評価して保存する」レッスンは無料ですか?
はい。「モデルを評価して保存する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。
「モデルを評価して保存する」で何を学びますか?
指標を確認して Hub にプッシュする ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
NLP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「モデルを評価して保存する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このNLP Academyレッスンでコードを書いて実行できますか?
はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。