
This is the final part of our fine-tuning series. In this article, we’ll explore Hugging Face Evaluate and Share to wrap up our journey.
Now, let’s see how good our model is and share it with the world!
Step 1: Evaluate the Model
The Trainer object we built in Part 2 already has our “test” dataset. We just need to call the .evaluate() method.
# Assuming 'trainer' is your trained Trainer object from Part 2
print("Evaluating model...")
eval_results = trainer.evaluate()
print(eval_results)This will run your model against the 25,000-row test dataset and give you a result like:
{'eval_loss': 0.123, 'eval_accuracy': 0.95, ...}
An accuracy of 0.95 means our model is 95% accurate at classifying movie reviews! We’ve successfully fine-tuned a general-purpose AI to be an expert.
Step 2: Log In to the Hub
To share your model, you need to log in to your Hugging Face account from your terminal.
# 1. Install the CLI tool pip install huggingface_hub # 2. Run the login command huggingface-cli login
This will ask for an “Access Token.” You can generate one from your Hugging Face account settings (under “Access Tokens”).
Step 3: Push to Hub
Once you’re logged in, you can push your model with one command.
# Give your model a name on the hub
model_repo_name = "my-awesome-sentiment-model-v1"
print("Pushing model to the Hub...")
trainer.push_to_hub(model_repo_name)That’s it! Your custom model is now saved on your Hugging Face profile. You (or anyone else) can now load it using the pipeline, just like any official model:
pipeline("sentiment-analysis", model="YourUsername/my-awesome-sentiment-model-v1")





