The practice of sharing pre-trained and fine-tuned models significantly enriches the NLP community. Everyone has the opportunity to share their models with others through the Hugging Face Hub. Models created by the community are readily available for download from the Hub.
With the Trainer API, saving and sharing a model is simple:
trainer.push_to_hub(commit_message="Training completed!")Additionally, the fine-tuned model can be utilized to predict new tweets. Having uploaded our model to the Hub, it’s now accessible for use with the pipeline() function.
from transformers import pipeline
# Change `transformersbook` to your Hub username
model_id = "transformersbook/distilbert-base-uncased-finetuned-emotion"
classifier = pipeline("text-classification", model=model_id)
custom_tweet = "I saw a movie today and it was really good."
preds = classifier(custom_tweet, return_all_scores=True)