C.W.K.
Stream
Lesson 04 of 06 · published

Model Cards & YAML Front-Matter

~32 min · hub, model-cards

Level 0Scout
0 XP0/50 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

The README is the API

Every model repo's README.md opens with a YAML front-matter block fenced by --- delimiters. That block is not styling. It's machine-readable metadata that drives: which inference widget renders on the page, which providers list the model, how the search index ranks it, what license shows on the buy/use widget, and what the library_name auto-loader does.

Fields you can't skip

  • library_name — required since Aug 2024. Tells the Hub which loader to use. transformers, diffusers, sentence-transformers, mlx, peft, llama.cpp, etc.
  • pipeline_tag — the task. Drives the inference widget. Examples: text-generation, image-text-to-text, automatic-speech-recognition, feature-extraction.
  • license — SPDX identifier or one of HF's specials (apache-2.0, mit, llama3, llama3.1, gemma). The llama* licenses gate downloads behind a click-through.
  • language — list of ISO 639-1 codes. Controls language facet in search.
  • base_model, base_model_relation — lineage. Relation is one of finetune | adapter | merge | quantized. The Hub renders a tree from this.
  • tags — free-form facets. conversational, code, moe, 4bit, etc.
  • gatedtrue | auto | manual. Gates download behind license acceptance or manual approval.

Reading cards programmatically

Don't curl the README. Use model_info(); it returns a parsed object whose .cardData attribute is the YAML decoded as a dict. The same applies to dataset_info() and space_info().

Code

A real model card front-matter·yaml
---
language:
  - en
  - ko
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
tags:
  - llm
  - conversational
  - korean
base_model: meta-llama/Llama-3.1-8B
base_model_relation: finetune
datasets:
  - HuggingFaceH4/ultrachat_200k
gated: false
---
# My Korean Llama Fine-Tune
This card explains what the model does and how to use it.
Read card metadata without downloading weights·python
from huggingface_hub import model_info

info = model_info("meta-llama/Llama-3.1-8B-Instruct")
print("library:", info.cardData.get("library_name"))
print("pipeline:", info.pipeline_tag)
print("license:", info.cardData.get("license"))
print("base_model:", info.cardData.get("base_model"))
print("tags:", info.tags[:8])
print("downloads:", info.downloads, "likes:", info.likes)
print("siblings (files):", [s.rfilename for s in info.siblings[:5]])

External links

Exercise

Pick three popular models with different licenses (apache-2.0, llama3.1, gemma). For each, fetch model_info(...) and dump the cardData dict to a file. Compare the three cards side by side. Note: which fields are filled out in all three, which only in one, which contradict the README body.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.