Welcome to the final part of our series on training and publishing your own Large Language Model with Hugging Face! 🎉
👉 If you’re landing here directly, I recommend first checking out the earlier posts:
In this post, we’ll cover the most exciting part: publishing your model to Hugging Face Hub and sharing it with others.
By the end, your model will be online, accessible to others, and even usable in apps! 🌍
First, install the CLI if you haven’t already:
pip install huggingface_hub
Then log in:
huggingface-cli login
👉 This will ask for your Hugging Face access token. You can get it from your Hugging Face settings.
From Part 2, you already have your model saved locally (my_custom_model
). Let’s upload it:
from huggingface_hub import HfApi, HfFolder, Repository
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "my-username/my-custom-model"
model.push_to_hub(model_name)
tokenizer.push_to_hub(model_name)
Now your model is live on your Hugging Face profile! 🎉
When someone visits your model page, they’ll see a Model Card. This is like documentation for your model. You can edit it directly in the Hugging Face web UI.
Things to include:
A simple starter model card:
# My Custom Model
This is a fine-tuned GPT-2 model trained on my own dataset.
## How to Use
```python
from transformers import pipeline
generator = pipeline("text-generation", model="my-username/my-custom-model")
print(generator("Hello world", max_length=50))
Want others to try your model in their browser? Hugging Face Spaces lets you build small web apps.
Example app.py
using Gradio:
import gradio as gr
from transformers import pipeline
generator = pipeline("text-generation", model="my-username/my-custom-model")
def generate_text(prompt):
return generator(prompt, max_length=100, num_return_sequences=1)[0]['generated_text']
demo = gr.Interface(fn=generate_text, inputs="text", outputs="text")
demo.launch()
Now your model has an interactive demo anyone can use! ✨
Congratulations — your model is now live! You can share the Hugging Face link with:
In this post, you:
🎯 That’s it! You now know how to train, fine-tune, and publish your own LLM using Hugging Face.
This 3-part series showed you the full journey from zero to sharing your AI model with the world. 🌍
Developers often struggle to get actionable results from AI coding assistants. This guide provides 7…
In Part 2 of our Hugging Face series, you’ll fine-tune your own AI model step…
Kickstart your AI journey with Hugging Face. In this beginner-friendly guide, you’ll learn how to…
Discover how the 2017 paper Attention Is All You Need introduced Transformers, sparking the AI…
OpenAI just launched ChatGPT Go, a new low-cost plan priced at ₹399/month—India-only for now. You…
Running large language models (LLMs) locally is easier than ever, but which tool should you…
This website uses cookies.