🎧
Listen to this article
AI-generated narration

Why Publishing Matters

You've spent days training a model. You've watched loss curves, adjusted hyperparameters, and finally have something that works — even if it's not perfect. The model weights are sitting on your GPU rig, and right now they're invisible to the world.

That's a missed opportunity.

Publishing your model to Hugging Face Hub is one of the highest-leverage things you can do as an AI engineer. It's not just about sharing — it's about building credibility, enabling reproducibility, and joining a community of millions of researchers and practitioners.

Think about it this way: when someone reads your blog post about training a model, they can nod along and move on. But when they can download your weights, run inference, and verify your results — that's a fundamentally different level of trust. Published artifacts are proof of work.

In this guide, we'll walk through the entire process using a real example: our IconShop SVG generation model — a 16-layer transformer decoder trained on the FIGR-SVG dataset to generate vector icons from text prompts. We trained it, it works, and now we're going to publish it so anyone can download and reproduce our results.

TL;DR

Publishing to Hugging Face takes four steps: (1) Prepare your artifacts — model weights, config, inference code, and a model card. (2) Create a repository via the Hub UI or CLI. (3) Upload everything using the huggingface_hub Python library. (4) Write a clear model card so people know what your model does and how to use it. The whole process takes about an hour for a first-time publish.

What You Need Before Publishing

Before you create a repository, make sure you have these artifacts ready. If you're missing any, now is the time to prepare them.

📦 Model Weights

The trained model checkpoint files. For PyTorch models, this is typically a pytorch_model.bin or model.safetensors file. If you have multiple checkpoints, publish the best one — or all of them in separate folders.

⚙️ Configuration

A config.json file that describes your model architecture — hidden dimensions, attention heads, number of layers, vocabulary size, etc. This lets others load your model without guessing the architecture.

💻 Inference Code

A modeling.py or inference.py file that shows how to load and run your model. Include a working example that produces output. This is what makes your model actually usable.

📋 Model Card

A README.md that describes what your model does, how it was trained, how to use it, and its limitations. This is the landing page people see — make it clear and honest.

📜 License

A license file (e.g., MIT, Apache 2.0, CC-BY-4.0). Without a license, others cannot legally use or redistribute your model. Choose one that matches your intent.

🔑 HF Token

A Hugging Face access token with write permissions. Get it at huggingface.co/settings/tokens. You'll use it to authenticate uploads.

Our Example: IconShop SVG Model

Let's ground this in a real project. We trained an SVG icon generation model based on the IconShop paper by Ronghuan Wu et al. (2023). Here's what we have:

16
Transformer Layers
1024
Hidden Dims
8
Attention Heads
~200K
Training Steps

The model generates SVG icons from text prompts — you type "bottle" and it produces vector icon SVGs. It's not perfect, but it works, and it was trained on our own GPU rig over two days. We want to publish it so others can download it, run it, and build on it.

Here's our artifact structure before publishing:

iconshop-checkpoint/
├── checkpoint.pth              # Model weights (PyTorch)
├── config.json                 # Architecture config
├── tokenizer.json              # SVG token vocabulary
├── inference.py                # How to load and generate
├── requirements.txt            # Python dependencies
└── samples/                    # Example outputs
    ├── bottle.svg
    └── star.svg

Step 1: Install huggingface_hub and Authenticate

The huggingface_hub library is the official Python client for interacting with the Hugging Face Hub. Install it with pip:

pip install huggingface_hub

Then log in. You can do this via the CLI or programmatically:

# Option A: CLI login (interactive)
huggingface-cli login
# Paste your token when prompted

# Option B: Python (programmatic)
from huggingface_hub import login
login(token="hf_your_token_here")

Important: Never hardcode your token in scripts you'll share. Use environment variables or the CLI login, which stores the token securely in ~/.cache/huggingface/token.

Step 2: Create the Repository

You have two options for creating a model repository:

Option A: Via the Hub UI

Go to huggingface.co/new, select "Model" as the repository type, give it a name (e.g., iconshop-svg-generator), and choose visibility (public or private). Public is recommended for building credibility.

Option B: Via Python

from huggingface_hub import create_repo

create_repo(
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    exist_ok=True
)

This creates https://huggingface.co/yourusername/iconshop-svg-generator. The exist_ok=True flag prevents errors if the repo already exists.

Step 3: Upload Your Artifacts

There are two main approaches to uploading: upload a folder (simplest) or upload files individually (more control).

Approach A: Upload Folder (Recommended for First Publish)

from huggingface_hub import HfApi

api = HfApi()

api.upload_folder(
    folder_path="./iconshop-checkpoint",
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    commit_message="Initial model upload"
)

This uploads everything in the folder in a single commit. Simple and effective.

Approach B: Upload Files Individually

from huggingface_hub import HfApi

api = HfApi()

# Upload model weights
api.upload_file(
    path_or_fileobj="./iconshop-checkpoint/checkpoint.pth",
    path_in_repo="checkpoint.pth",
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    commit_message="Upload model weights"
)

# Upload config
api.upload_file(
    path_or_fileobj="./iconshop-checkpoint/config.json",
    path_in_repo="config.json",
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    commit_message="Upload model config"
)

# Upload inference code
api.upload_file(
    path_or_fileobj="./iconshop-checkpoint/inference.py",
    path_in_repo="inference.py",
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    commit_message="Upload inference code"
)

Individual uploads give you granular commit messages and let you upload files as you prepare them. For larger models, you can also use upload_large_folder() which handles files over 5GB via Git LFS automatically.

Step 4: Write the Model Card

The model card is your README.md — it's the first thing people see when they visit your model page. A good model card answers: what does this model do, how was it trained, how do I use it, and what are its limitations?

Here's the model card we wrote for our IconShop model:

# IconShop SVG Icon Generator

A transformer-based model that generates SVG vector icons from text prompts.

## Model Description

- **Architecture:** 16-layer transformer decoder
- **Hidden dimensions:** 1024
- **Attention heads:** 8
- **Training dataset:** FIGR-SVG (icon-style SVGs)
- **Training steps:** ~200,000 (~6 epochs)
- **Framework:** PyTorch

This model is based on [IconShop: Text-Guided Vector Icon Synthesis with Autoregressive Transformers](https://arxiv.org/abs/2304.14400) by Wu et al. (2023).

## Intended Use

Generate SVG icon graphics from natural language text prompts. Useful for prototyping icon sets, generating custom icons for applications, and exploring text-to-vector-graphics generation.

## How to Use

```python
import torch
from inference import load_model, generate_icon

model = load_model("yourusername/iconshop-svg-generator")
svg = generate_icon(model, "a bottle", temperature=0.4, top_p=0.5)
print(svg)
```

## Training Details

- Trained on a rented GPU rig for ~2 days
- 6 epochs, ~200K steps
- Loss was still trending downward at checkpoint — model may benefit from more training

## Limitations

- Simple, common icons (home, search, user) generate cleanly
- Complex or abstract prompts may produce valid SVG that doesn't match intent
- Circular shapes and internal details are challenging
- This is a research/learning project, not a production-ready model

## License

MIT

## Citation

If you use this model in your work, please cite:

```bibtex
@article{wu2023iconshop,
  title={IconShop: Text-Guided Vector Icon Synthesis with Autoregressive Transformers},
  author={Wu, Ronghuan and Su, Wanchao and Ma, Kede and Liao, Jing},
  journal={arXiv preprint arXiv:2304.14400},
  year={2023}
}
```

Upload the model card as README.md:

api.upload_file(
    path_or_fileobj="./README.md",
    path_in_repo="README.md",
    repo_id="yourusername/iconshop-svg-generator",
    repo_type="model",
    commit_message="Add model card"
)

Step 5: Add Tags and Metadata

Hugging Face uses tags to help people discover your model. You can set these in your model card's YAML front matter — add this at the top of your README.md:

---
library_name: pytorch
tags:
- svg
- icon-generation
- text-to-svg
- transformer
- autoregressive
license: mit
datasets:
- figr-svg
---

These tags make your model discoverable when people search for "SVG," "icon generation," or "text-to-svg" on the Hub.

Step 6: Verify and Share

After uploading, visit your model page at https://huggingface.co/yourusername/iconshop-svg-generator and verify:

  • The model card renders correctly
  • All files are listed in the Files & Versions tab
  • The inference code is readable and complete
  • The tags appear under the model title

Then share it. Post it on Twitter/X, share it in relevant Discord or Slack communities, link to it from your blog post, and add it to your portfolio. A published model is a tangible artifact that demonstrates real AI engineering capability.

Best Practices for Publishing

🔬 Be Honest About Limitations

Your first model won't be perfect. That's fine — document what works and what doesn't. Honesty builds more credibility than overclaiming.

📝 Include Working Examples

People won't use your model if they can't figure out how to run it. Include a copy-pasteable inference example that actually works.

📊 Share Training Details

Dataset, epochs, hardware, loss curves — the more training context you provide, the more useful your model is to the community.

🔄 Version Your Uploads

As you improve your model, upload new checkpoints. The Hub tracks file versions automatically, so you can maintain a progression from v1 to v2 to v3.

📜 Choose a Clear License

MIT for permissive open source. Apache 2.0 if you want patent protection. CC-BY-4.0 for creative works. No license = no legal permission to use.

🔗 Link Back to Sources

If your model is based on a paper, link to it. If you used a dataset, credit it. If you built on someone else's code, attribute them. Academic honesty matters.

Beyond the Basics

Once you've published your first model, here are ways to level up:

  • Spaces. Deploy a live demo on Hugging Face Spaces using Gradio or Streamlit. Let people try your model in their browser without downloading anything.
  • Pipelines. If your model works with the Hugging Face transformers library, register it as a pipeline so it appears in the model cards of compatible tasks.
  • Model evaluation. Run your model through automated benchmarks and publish the scores. This adds quantitative credibility to your qualitative claims.
  • Community engagement. Respond to issues and pull requests on your model page. Help people who are trying to use your model. This builds reputation.

The Bottom Line

Publishing your model to Hugging Face is one of the most impactful things you can do as an AI engineer. It transforms a private experiment into a public artifact — something that can be used, built on, and cited by others.

You don't need a state-of-the-art model to publish. You need a model that works, a clear description of what it does, and the willingness to share it imperfectly. The AI community values transparency and reproducibility over perfection.

Every model you publish adds to your credibility as a researcher and engineer. It's not just about the model — it's about the signal you send: "I can train models, and I'm willing to share my work."

That signal is worth more than you think.

References

  1. Hugging Face Hub — Uploading Models — Official documentation
  2. Hugging Face Hub — Model Cards — Guidelines for writing model cards
  3. huggingface_hub Library Documentation — Python API reference
  4. "IconShop: Text-Guided Vector Icon Synthesis with Autoregressive Transformers" — Wu, Su, Ma, Liao (2023)
  5. Training Our First SVG Icon Generation Model — Our hands-on IconShop training post
  6. kingnobro/IconShop — Original IconShop repository