|
Download README.md from davanstrien/hf-cli-cheatsheet: direct link, hf CLI and curl.
- Browser
- Download file 31.6 kB
-
https://huggingface.co/datasets/davanstrien/hf-cli-cheatsheet/resolve/main/README.md
- Command line
-
hf download hf://datasets/davanstrien/hf-cli-cheatsheet/README.md
-
curl -L -o README.md https://huggingface.co/datasets/davanstrien/hf-cli-cheatsheet/resolve/main/README.md
31.6 kB
| pretty_name: hf CLI cheat sheet | |
| license: cc-by-4.0 | |
| viewer: false | |
| tags: | |
| - hf-cli | |
| - agents | |
| - cheatsheet | |
| - hf-jobs | |
| # hf CLI one-liners: what the Hub can answer from a terminal | |
| The Hugging Face CLI is a powerful tool for interacting with the Hub. It allows you to search models and datasets, query data without downloading it, run Jobs, deploy endpoints, and move files between [buckets](https://huggingface.co/buckets/) and repos. | |
| Humans and agents can often discover how to use it via the `--help` command and the hints the CLI outputs. However, there are some cool tricks you might not discover straight away. This is a cheat sheet for them! | |
| Notes. Every line was run against `hf` 1.29 on 2026-09-16, with public ids where possible; lines with `YOU/...` need your own ids. Start a session with `hf auth whoami`. Lines are bash and zsh; loops use `xargs`, so most also run in fish unchanged. Blocks that set a variable have a fish twin underneath. Listings take `--json`, `-`-format quiet``, `--sort` and `--limit`; the default limit is 30 on models and datasets, 100 on jobs, 10 on collections. | |
| ## Lineage: walk the graph between models, datasets, papers, and providers | |
| Models are (often) tagged with the datasets, papers and base models they came from. Each tag is a filter, so you can walk the graph in either direction. | |
| Which datasets was this model trained on? Declared in the card's YAML. | |
| ```bash | |
| hf models card allenai/OLMo-2-1124-7B --metadata | jq -r '.datasets[]' | |
| # allenai/dolmino-mix-1124 allenai/olmo-mix-1124 | |
| ``` | |
| ...and what was it fine-tuned from? | |
| ```bash | |
| hf models card HuggingFaceTB/SmolLM3-3B --metadata | jq -r '.base_model[]' | |
| ``` | |
| Which models were trained on this dataset? | |
| ```bash | |
| hf models ls --filter dataset:allenai/dolmino-mix-1124 --sort downloads --limit 10 --format quiet | |
| # allenai/OLMo-2-1124-7B, allenai/OLMoE-1B-7B-0125, allenai/OLMo-2-1124-13B, ... | |
| ``` | |
| Every fine-tune of a base model, newest first. Swap finetune for adapter, merge, or quantized to walk the other edges. The edge is whatever the author declared in the card, so an adapter: result can be a GGUF repo. Check the card. | |
| ```bash | |
| hf models ls --filter base_model:finetune:Qwen/Qwen3-8B --sort created_at --limit 20 --format quiet | |
| hf models ls --filter base_model:adapter:Qwen/Qwen3-8B --sort downloads --limit 10 --format quiet | |
| hf models ls --filter base_model:merge:Qwen/Qwen3-8B --sort downloads --limit 10 --format quiet | |
| ``` | |
| Which papers is a model tagged with? Usually its own report, sometimes a related one. arXiv ids are stored as tags. | |
| ```bash | |
| hf models info Qwen/Qwen3-8B --json | jq -r '.tags[] | select(startswith("arxiv:"))' | |
| ``` | |
| Everything on the Hub that cites a paper. Set a large `--limit` before counting (default is 30). | |
| ```bash | |
| hf models ls --filter arxiv:2505.09388 --limit 5000 --format quiet | wc -l | |
| hf datasets ls --filter arxiv:2505.09388 --limit 100 --format quiet | |
| ``` | |
| Returns 2400+ for the Qwen3 report. | |
| Combine filters: models tagged with this paper that an inference provider is serving right now (`--warm`), by likes. | |
| ```bash | |
| hf models ls --filter arxiv:2505.09388 --warm --sort likes --limit 10 --format quiet | |
| ``` | |
| ## Find models: size, runtime, who serves them, when they shipped | |
| The default listing is not sorted by recency, and agent have a training cutoff so tend to choose older models. These filters get you to models that are new, fit your hardware, and are served right now. | |
| Models in a parameter band. min:/max: syntax, suffixes M and B. | |
| ```bash | |
| hf models ls --num-parameters min:6B,max:30B --sort likes --limit 20 --format quiet | |
| ``` | |
| Only models an inference provider is serving right now | |
| ```bash | |
| hf models ls --pipeline-tag text-generation --warm --sort trending_score --limit 20 --format quiet | |
| ``` | |
| What can I run with vLLM or llama.cpp under 9B? Repeat `--apps` to OR them. | |
| ```bash | |
| hf models ls --apps vllm --apps llama.cpp --num-parameters max:9B --sort downloads --limit 10 --format quiet | |
| ``` | |
| What does one provider serve, ranked by downloads. | |
| ```bash | |
| hf models ls --inference-provider fireworks-ai --sort downloads --limit 10 --format quiet | |
| ``` | |
| Released in the last 3 months, ranked by likes. The API cannot combine a date floor with `--sort likes`, so pull the newest N and rank client-side. Useful for finding models released after an agent's training cutoff. The date line works on macOS and Linux. | |
| ```bash | |
| D=$(date -v-3m +%F 2>/dev/null || date -d '3 months ago' +%F) | |
| hf models ls --search ocr --sort created_at --limit 500 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.created_at[:10])\t\(.id)"' | |
| ``` | |
| Fish: | |
| ```fish | |
| set D (date -v-3m +%F 2>/dev/null || date -d '3 months ago' +%F) | |
| hf models ls --search ocr --sort created_at --limit 500 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.created_at[:10])\t\(.id)"' | |
| ``` | |
| Same idea for a whole task in the last year. | |
| ```bash | |
| D=$(date -v-12m +%F 2>/dev/null || date -d '12 months ago' +%F) | |
| hf models ls --pipeline-tag image-text-to-text --sort created_at --limit 1000 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.id)"' | |
| ``` | |
| Fish: | |
| ```fish | |
| set D (date -v-12m +%F 2>/dev/null || date -d '12 months ago' +%F) | |
| hf models ls --pipeline-tag image-text-to-text --sort created_at --limit 1000 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.id)"' | |
| ``` | |
| Tag namespaces `--filter` accepts but `--help` never lists: `license:`, `dataset:`, `arxiv:`, `base_model:`, plus bare language codes and library names. | |
| ```bash | |
| hf models ls --filter license:apache-2.0 --filter automatic-speech-recognition --sort trending_score --limit 10 --format quiet | |
| hf models ls --filter nl --filter automatic-speech-recognition --sort trending_score --limit 10 --format quiet | |
| hf models ls --author BuzzASR --filter ckb --format quiet | |
| ``` | |
| Keyword search plus a tag, both server-side. | |
| ```bash | |
| hf datasets ls --filter uv-script --search embed --format quiet | |
| hf models ls --search "whisper" --author openai --sort downloads --limit 5 --format quiet | |
| ``` | |
| Ungated only, so a Job can pull the weights without authentication. And the one-call gating check for a specific model. | |
| ```bash | |
| hf models ls --no-gated --pipeline-tag image-text-to-text --sort trending_score --limit 10 --format quiet | |
| hf models info meta-llama/Llama-3.1-8B-Instruct --expand gated --json | jq '.gated' | |
| ``` | |
| "manual", "auto" or false | |
| Which providers serve a given model, and whether each is live. The reverse of `--inference-provider`. | |
| ```bash | |
| hf models info deepseek-ai/DeepSeek-V4-Flash --expand inferenceProviderMapping --json | jq -r '.inference_provider_mapping[] | "\(.provider)\t\(.status)\t\(.task)"' | |
| ``` | |
| Extra fields in one call instead of one info call per model. | |
| ```bash | |
| hf models ls --filter kraken --json --expand siblings,library_name | jq -r '.[] | "\(.id)\t\(.library_name)"' | |
| hf models info Qwen/Qwen3-8B --expand safetensors --json | jq '.safetensors.total' | |
| ``` | |
| param count from the weights, 8190735360 | |
| ## Quants: find a runnable copy of the model you want | |
| These list every quantized copy and the file sizes before you download anything. | |
| All quantized copies of a model, most downloaded first. AWQ, FP8, GGUF, NVFP4 and MLX are all included. | |
| ```bash | |
| hf models ls --filter base_model:quantized:Qwen/Qwen3-8B --sort downloads --limit 10 --json | jq -r '.[] | "\(.downloads)\t\(.id)"' | |
| ``` | |
| Narrow to one format by library tag. | |
| ```bash | |
| hf models ls --filter base_model:quantized:Qwen/Qwen3-8B --filter gguf --sort downloads --limit 5 --format quiet | |
| hf models ls --filter base_model:quantized:Qwen/Qwen3-8B --filter mlx --sort downloads --limit 5 --format quiet | |
| ``` | |
| Which GGUF file fits my VRAM? Sizes per file without downloading. | |
| ```bash | |
| hf models ls unsloth/Qwen3-8B-GGUF --json | jq -r '.[] | select(.path|endswith(".gguf")) | "\(.size/1e9*10|round/10) GB\t\(.path)"' | |
| ``` | |
| GGUF header: architecture, context length, param count. | |
| ```bash | |
| hf models info Qwen/Qwen3-8B-GGUF --expand gguf --json | jq '.gguf | {architecture, context_length, total}' | |
| ``` | |
| Download only the file you sized above, not the whole multi-file repo. | |
| ```bash | |
| hf download unsloth/Qwen3-8B-GGUF Qwen3-8B-Q4_K_M.gguf --local-dir ./models | |
| ``` | |
| ## Tasks: what exists, what is hot, what is big | |
| The Hub publishes a daily snapshot of itself as a dataset. SQL over it answers aggregate questions. | |
| Trending in one task. Swap the pipeline tag. | |
| ```bash | |
| hf models ls --pipeline-tag automatic-speech-recognition --sort trending_score --limit 10 --format quiet | |
| ``` | |
| The 52 pipeline tags, live from the API (the CLI has no list command for these). | |
| ```bash | |
| curl -s https://huggingface.co/api/models-tags-by-type | jq -r '.pipeline_tag[].id' | |
| ``` | |
| How many models per task, from the daily hub-stats snapshot. DuckDB, no download. | |
| ```bash | |
| hf datasets sql "SELECT pipeline_tag, COUNT(*) n FROM 'hf://datasets/cfahlgren1/hub-stats@~parquet/models/train/*.parquet' WHERE pipeline_tag IS NOT NULL GROUP BY 1 ORDER BY n DESC LIMIT 15" | |
| ``` | |
| Which datasets are official leaderboards. Then the scores, as data. | |
| ```bash | |
| hf datasets ls --filter benchmark:official --limit 20 --format quiet | |
| hf datasets leaderboard openai/gsm8k --limit 10 --json | jq -r '.[] | "\(.rank)\t\(.model_id)\t\(.value)"' | |
| ``` | |
| Datasets for a task, in a size band, in a language, with images. | |
| ```bash | |
| hf datasets ls --filter task_categories:image-segmentation --filter "size_categories:1K<n<10K" --sort trending_score --limit 10 --format quiet | |
| hf datasets ls --filter language:la --filter modality:image --sort downloads --limit 10 --format quiet | |
| ``` | |
| ## Datasets: inspect and query without downloading | |
| DuckDB reads only the bytes a query touches, so you can count, sample and aggregate a large parquet without downloading it. | |
| Every config and split with its parquet URL and size, or one split. Feed them to DuckDB, Polars, or curl `-r`. | |
| ```bash | |
| hf datasets parquet openai/gsm8k | |
| hf datasets parquet openai/gsm8k --subset main --split test | |
| ``` | |
| Query a remote parquet. DuckDB reads only the bytes the query touches. | |
| ```bash | |
| hf datasets sql "SELECT COUNT(*) FROM 'hf://datasets/openai/gsm8k@~parquet/main/test/*.parquet'" | |
| hf datasets sql "SELECT question FROM 'hf://datasets/openai/gsm8k@~parquet/main/test/*.parquet' USING SAMPLE 3" | |
| ``` | |
| Schema, splits and first rows without a download. Needs the hf-ds extension: `hf extensions install` davanstrien/hf-ds | |
| ```bash | |
| hf ds inspect openai/gsm8k | |
| hf ds head openai/gsm8k --split test -n 3 | |
| ``` | |
| Repo size in GB without cloning. | |
| ```bash | |
| hf datasets ls HuggingFaceFW/fineweb-edu -R --json | jq '[.[].size] | add / 1e9' | |
| ``` | |
| Tree with human-readable sizes. Then the local cache, to avoid downloading a file twice. | |
| ```bash | |
| hf datasets ls openai/gsm8k --tree -h | |
| hf cache list | |
| ``` | |
| Open PRs and discussions, to check before opening a duplicate. | |
| ```bash | |
| hf discussions ls openai/gpt-oss-120b --type model | |
| ``` | |
| ## Jobs: run a recipe, select, wait, chain | |
| A Job is a script plus a GPU flavor. The uv-scripts org holds ready recipes, and labels turn a batch of jobs into something you can query. | |
| Run a ready-made recipe from the Hub. The uv-scripts org holds 30+ single-file scripts for OCR, embeddings, classification, transcription, object detection, training. Each README has a run command. | |
| ```bash | |
| hf jobs uv run --flavor a10g-small --timeout 15m --secrets HF_TOKEN \ | |
| https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py \ | |
| uv-scripts/ocr-demo your-username/ocr-demo-results | |
| ``` | |
| The transformers PyTorch examples run the same way. 37 of the 42 run_*.py scripts carry a PEP 723 header, so a raw GitHub URL is enough. https://github.com/huggingface/transformers/blob/main/examples/pytorch/README.md The question-answering scripts have no header; add `--with` transformers `--with` datasets `--with` evaluate `--with` accelerate for those. | |
| ```bash | |
| hf jobs uv run --flavor cpu-basic --timeout 25m --detach \ | |
| https://raw.githubusercontent.com/huggingface/transformers/main/examples/pytorch/text-classification/run_classification.py \ | |
| --model_name_or_path google/bert_uncased_L-2_H-128_A-2 --dataset_name stanfordnlp/imdb --text_column_names text --label_column_name label \ | |
| --do_train --do_eval --max_train_samples 64 --max_eval_samples 64 --output_dir /tmp/out --report_to none | |
| # completed in ~2 min; the header installs transformers from git main, so add --flavor and drop the --max_*_samples for a real run | |
| ``` | |
| Find recipes by the uv-script tag, then read a README before running it. | |
| ```bash | |
| hf datasets ls --filter uv-script --sort downloads --limit 20 --format quiet | |
| hf datasets card uv-scripts/embeddings --text | head -80 | |
| ``` | |
| The ocr repo ships a machine-readable catalog. Which script handles German, at what size, with what evidence? | |
| ```bash | |
| curl -s https://huggingface.co/datasets/uv-scripts/ocr/raw/main/models.json \ | |
| | jq -r 'to_entries[] | select(.key!="_meta") | select(.value.languages.named? // [] | index("de")) | "\(.key)\t\(.value.model_id)\t\(.value.params)\t\(.value.backend)\t\(.value.languages.evidence)"' | |
| ``` | |
| Rank recipes by how strong the language claim is, strongest first. A per-language benchmark beats a bare multilingual tag. | |
| ```bash | |
| curl -s https://huggingface.co/datasets/uv-scripts/ocr/raw/main/models.json \ | |
| | jq -r --argjson o '["per-language-benchmark","count-claim","named-list","multilingual-unspecified","english-only","not-stated","not-applicable"]' \ | |
| 'to_entries[] | select(.key!="_meta") | .value.languages.evidence as $e | select($e != null) | [($o | index($e)), $e, .key, .value.params] | @tsv' | sort -n | cut -f2- | |
| ``` | |
| Read a script's docstring and usage without downloading. Then the repo's agent guide. | |
| ```bash | |
| curl -s https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py | head -60 | |
| curl -s https://huggingface.co/datasets/uv-scripts/ocr/raw/main/AGENTS.md | |
| ``` | |
| Benchmark numbers from the model card as JSON. | |
| ```bash | |
| hf models info zai-org/GLM-OCR --expand evalResults --json | jq -r '.eval_results[] | "\(.dataset_id)\t\(.task_id)\t\(.value)"' | |
| ``` | |
| Newest job id and status. `--limit 0` lifts the 100-job cap here. max_by selects the newest regardless of list order. | |
| ```bash | |
| hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | "\(.id) \(.status)"' | |
| ``` | |
| Recent jobs with flavor and start time. | |
| ```bash | |
| hf jobs ps -a --json --limit 10 | jq -r '.[] | "\(.id)\t\(.status)\t\(.flavor)\t\(.created_at[:16])"' | |
| ``` | |
| Select by name pattern or status, then act. Add `--limit 0`, or the 100-job cap omits older ones. | |
| ```bash | |
| hf jobs ps -a --json --limit 0 | jq -r '.[] | select(.name|test("probe")) | .id' | |
| hf jobs ps --status RUNNING --format quiet | xargs -n1 hf jobs cancel | |
| ``` | |
| Tail the newest job. logs `-f` is a no-op while SCHEDULING; poll inspect until the stage is RUNNING. | |
| ```bash | |
| J=$(hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | .id') | |
| hf jobs inspect $J --json | jq -r '.[0].status.stage' | |
| hf jobs logs $J -f | |
| ``` | |
| Fish: | |
| ```fish | |
| set J (hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | .id') | |
| hf jobs inspect $J --json | jq -r '.[0].status.stage' | |
| hf jobs logs $J -f | |
| ``` | |
| Label at launch, filter later. A sweep becomes a queryable set. uv run prints id=... on stdout; extract it. | |
| ```bash | |
| J=$(hf jobs uv run --flavor cpu-basic --label run=sweep42 --label model=qwen3-8b --detach train.py 2>/dev/null | grep -oE '^id=[a-f0-9]+' | cut -d= -f2) | |
| hf jobs ps -a --label run=sweep42 --json | jq -r '.[] | "\(.id)\t\(.status)"' | |
| ``` | |
| Fish: | |
| ```fish | |
| set J (hf jobs uv run --flavor cpu-basic --label run=sweep42 --label model=qwen3-8b --detach train.py 2>/dev/null | grep -oE '^id=[a-f0-9]+' | cut -d= -f2) | |
| hf jobs ps -a --label run=sweep42 --json | jq -r '.[] | "\(.id)\t\(.status)"' | |
| ``` | |
| Block until every job succeeds, then chain. Exit 0 only if all completed. `hf jobs hardware` lists flavors with $/hour. | |
| ```bash | |
| hf jobs ls -q | xargs hf jobs wait --timeout 2h && hf jobs run --detach python:3.12 python eval.py | |
| ``` | |
| ## Endpoints: discover hardware, deploy with an engine, tune without redeploying | |
| An endpoint is a dedicated server for one model with an OpenAI-compatible URL. Most of the setup is discoverable from the CLI. | |
| Models with a catalog entry: hardware and engine are preset, only `--repo` and `--name` are needed. Check it before configuring a deploy manually. | |
| ```bash | |
| hf endpoints catalog ls --json 2>/dev/null | jq -r '.models[]' | grep -i ocr | |
| hf endpoints catalog deploy --repo openai/gpt-oss-20b --name gpt-oss-20b-test | |
| ``` | |
| Valid vendor/region/type/size combinations, with price and your quota. The stderr hint shows the deploy flags for the first row. | |
| ```bash | |
| hf endpoints hardware --accelerator gpu --format json | jq -r 'sort_by(.price_per_hour)[] | select(.status=="available") | "\(.price_per_hour)/h\t\(.gpu_memory_gb)GB\t\(.id)\tquota \(.quota)"' | head -10 | |
| ``` | |
| Enough VRAM, cheapest first. gpu_memory_gb is the TOTAL across accelerators, so l4 x4 (4x24GB) passes an 80 GB filter. | |
| ```bash | |
| hf endpoints hardware --format json 2>/dev/null | jq -r '[.[] | select(.gpu_memory_gb >= 80)] | sort_by(.price_per_hour)[:5][] | "\(.price_per_hour)/h\t\(.id)"' | |
| ``` | |
| Deploy on a managed engine. `--engine` enum: vllm, sglang, llamacpp, tgi, tei, hf-serve, plus vllm-neuron, tgi-neuron, custom. Pin the image, shard across GPUs. | |
| ```bash | |
| hf endpoints deploy qwen3-8b-vllm --repo Qwen/Qwen3-8B --framework custom --engine vllm --custom-image vllm/vllm-openai:v0.23.0 \ | |
| --vendor aws --region us-east-1 --accelerator gpu --instance-type nvidia-l4 --instance-size x4 --tensor-parallel-size 4 \ | |
| --type private --min-replica 0 --max-replica 1 --scale-to-zero-timeout 15 --revision main -e VLLM_LOGGING_LEVEL=INFO -s HF_TOKEN | |
| ``` | |
| GGUF on llama.cpp, same shape. `--type` now defaults to authenticated (previously protected). | |
| ```bash | |
| hf endpoints deploy qwen3-8b-gguf --repo unsloth/Qwen3-8B-GGUF --framework custom --engine llamacpp \ | |
| --vendor aws --region us-east-1 --accelerator gpu --instance-type nvidia-l4 --instance-size x1 --type private | |
| ``` | |
| Tune a live endpoint without redeploying. `--container-args` and `--custom-image` replace the current value; they do not append. Run describe first and pass every value you want to keep. | |
| ```bash | |
| E=$(hf endpoints ls --format quiet | head -1) | |
| hf endpoints describe $E --json | jq '{compute, model: .model.image}' | |
| hf endpoints update $E --min-replica 0 --max-replica 2 --scale-to-zero-timeout 15 | |
| hf endpoints update $E --tensor-parallel-size 2 | |
| hf endpoints update $E --container-args "--enable-auto-tool-choice --tool-call-parser hermes --max-model-len 32768" | |
| hf endpoints scale-to-zero $E | |
| ``` | |
| Fish: | |
| ```fish | |
| set E (hf endpoints ls --format quiet | head -1) | |
| hf endpoints describe $E --json | jq '{compute, model: .model.image}' | |
| hf endpoints update $E --min-replica 0 --max-replica 2 --scale-to-zero-timeout 15 | |
| hf endpoints update $E --tensor-parallel-size 2 | |
| hf endpoints update $E --container-args "--enable-auto-tool-choice --tool-call-parser hermes --max-model-len 32768" | |
| hf endpoints scale-to-zero $E | |
| ``` | |
| or the name you deployed above | |
| State and URL of your endpoints, ready for an OpenAI-compatible client. | |
| ```bash | |
| hf endpoints ls --json | jq -r '.[] | "\(.name)\t\(.status)\t\(.model)\t\(.instance)"' | |
| hf endpoints describe $E --json | jq -r '.status.url' | |
| ``` | |
| Still open from 4314: no `hf endpoints logs`, no dry-run. A failed deploy still says "check the logs" in the browser. | |
| ## Trackio: metrics from Jobs, persisted in a bucket, queried from your laptop | |
| Experiment tracking with no server to run. A Job logs to a Space, and the same CLI queries the runs from your laptop. | |
| In the training script, log to a private Space for the dashboard and a bucket for durable storage: | |
| ```python | |
| trackio.init(project="ocr-sweep", name="run-1", space_id="YOU/ocr-sweep-trackio", bucket_id="YOU/ocr-sweep", private=True) | |
| ``` | |
| Or leave the script alone and set the same things as env vars on the Job. | |
| ```bash | |
| hf jobs uv run --flavor l4x1 -s HF_TOKEN \ | |
| -e TRACKIO_SPACE_ID=YOU/ocr-sweep-trackio -e TRACKIO_BUCKET_ID=YOU/ocr-sweep \ | |
| --label project=ocr-sweep --detach train.py 2>/dev/null | grep -oE '^id=[a-f0-9]+' | |
| ``` | |
| TRL and transformers Trainers pick trackio up automatically. Project = `--output_dir`, run = `--run_name`. | |
| Verify the Space really is private. Older trackio docs and skills omitted private=True. | |
| ```bash | |
| hf spaces info YOU/ocr-sweep-trackio --json | jq '.private' | |
| ``` | |
| Read results without opening a browser. uvx runs the CLI with no install; pin Python 3.12, orjson has no wheel for 3.14t yet. | |
| ```bash | |
| alias trackio='uvx --python 3.12 trackio' | |
| trackio status | |
| trackio list runs --project haiku-zero | |
| trackio get run --project haiku-zero --run v4-350m-sft --json | jq '{last_step, metrics}' | |
| trackio get metric --project haiku-zero --run v4-350m-sft --metric think_near --json | jq '.values[-5:]' | |
| ``` | |
| Read-only SQL against the run database. Metrics sit in a JSON column, so use json_extract. Compare runs in one query. | |
| ```bash | |
| trackio query project --project haiku-zero --sql "SELECT run_name, MAX(step) steps, MIN(json_extract(metrics,'$.think_near')) best FROM metrics GROUP BY run_name ORDER BY best" --json | jq '.rows' | |
| ``` | |
| Freeze a finished project from its live Space into a static Space you can share. | |
| ```bash | |
| trackio freeze --space-id YOU/ocr-sweep-trackio --project ocr-sweep --new-space-id YOU/ocr-sweep-frozen --private | |
| ``` | |
| Push a local db up to a Space, for Jobs that logged locally instead of remotely. | |
| ```bash | |
| trackio sync --project ocr-sweep --space-id YOU/ocr-sweep-trackio | |
| ``` | |
| ## Buckets and repos: the non-obvious moves | |
| Buckets are storage next to your compute. Repos are the published layer. Moving between them is mostly metadata, not a re-upload. | |
| Stream a bucket file to stdout without a temporary file. | |
| ```bash | |
| hf buckets cp hf://buckets/YOU/BUCKET/results.json - | jq . | |
| echo '{"ok": true}' | hf buckets cp - hf://buckets/YOU/BUCKET/results.json | |
| ``` | |
| and stdin the other way | |
| Preview a sync. cp `--recursive` was removed in 1.26; sync is the recursive path now. `--dry-run` emits JSON lines, so pipe to jq. | |
| ```bash | |
| hf buckets sync ./out hf://buckets/YOU/BUCKET/run42 --dry-run | jq -c 'select(.type=="operation") | {action, path, size}' | |
| ``` | |
| Rename or move a repo into an org. Metadata only, redirects kept. Moving a private repo into an org can fail with 402 if the org's private quota is full; make it public first. | |
| ```bash | |
| hf repos move YOU/my-dataset ORG/my-dataset --type dataset | |
| hf repos settings ORG/my-dataset --public | |
| ``` | |
| Every repo you own, ids only. | |
| ```bash | |
| hf repos ls --limit 0 --json | jq -r '.[].id' | |
| ``` | |
| ## Papers and collections: read the literature, publish the result set | |
| Papers are nodes too. Read one into context, jump to the models that cite it, and save results as a collection. | |
| Search papers, then read one straight into context as markdown. If read returns a figure caption instead of the paper, info still has the abstract. | |
| ```bash | |
| hf papers search "historical OCR" --json | jq -r '.[] | "\(.id)\t\(.title)"' | |
| hf papers read 2505.09388 | head -200 | |
| hf papers info 2609.11495 --json | jq '{title, summary}' | |
| ``` | |
| Today's daily papers, most upvoted first. `--week` and `--month` widen the window. `--sort` trending is the all-time trending list, separate from the date filters. | |
| ```bash | |
| hf papers ls --json | jq -r 'sort_by(-.upvotes)[] | "\(.upvotes)\t\(.id)\t\(.title)"' | |
| hf papers ls --month 2026-08 --limit 100 --json | jq -r 'sort_by(-.upvotes)[:10][] | "\(.upvotes)\t\(.id)\t\(.title[:70])"' | |
| ``` | |
| Collections that contain a paper, model or dataset. The web URL uses ?paper=; the CLI uses the papers/ prefix. | |
| ```bash | |
| hf collections ls --item papers/2609.02749 --sort upvotes --limit 10 --format quiet | |
| hf collections ls --item models/Qwen/Qwen3-8B --sort upvotes --limit 10 --format quiet | |
| hf collections ls --owner Qwen --sort upvotes --format quiet | |
| ``` | |
| Save a listing as a collection. | |
| ```bash | |
| SLUG=$(hf collections create "Warm ASR models, Sep 2026" --private --json | jq -r '.slug') | |
| hf models ls --filter automatic-speech-recognition --warm --limit 10 --format quiet \ | |
| | xargs -I{} hf collections add-item $SLUG {} model --format quiet | |
| hf collections info $SLUG --json | jq '[.items[].item_id]' | |
| ``` | |
| Fish: | |
| ```fish | |
| set SLUG (hf collections create "Warm ASR models, Sep 2026" --private --json | jq -r '.slug') | |
| hf models ls --filter automatic-speech-recognition --warm --limit 10 --format quiet \ | |
| | xargs -I{} hf collections add-item $SLUG {} model --format quiet | |
| hf collections info $SLUG --json | jq '[.items[].item_id]' | |
| ``` | |
| ## Recipes: a few lines chained together | |
| Each one was run on 2026-09-16. Change the ids to suit. | |
| **1.** "Which of my org's datasets have been used to train models?" One SQL over the daily Hub snapshot covers every dataset in the org. | |
| ```bash | |
| hf datasets sql "SELECT replace(t, 'dataset:', '') AS dataset, COUNT(*) AS models FROM (SELECT unnest(tags) AS t FROM 'hf://datasets/cfahlgren1/hub-stats@~parquet/models/train/*.parquet') WHERE t LIKE 'dataset:biglam/%' GROUP BY 1 ORDER BY 2 DESC LIMIT 20" | |
| # biglam/loc_beyond_words 10, gutenberg-poetry-corpus 7, on_the_books 6, ... (~10 s; the snapshot is refreshed daily) | |
| ``` | |
| Live from the API instead: top 25 datasets, 8 calls in parallel (~3 s). | |
| ```bash | |
| hf datasets ls --author biglam --sort downloads --limit 25 --format quiet \ | |
| | xargs -P 8 -I{} sh -c 'n=$(hf models ls --filter dataset:{} --limit 100 --format quiet | wc -l | tr -d " "); [ "$n" -gt 0 ] && echo "$n\t{}"' | sort -rn | |
| ``` | |
| **2.** "New OCR models from the last two months that are ungated, under 4B, and run on vLLM." Four filters and a date, one call. | |
| ```bash | |
| D=$(date -v-2m +%F 2>/dev/null || date -d '2 months ago' +%F) | |
| hf models ls --search ocr --no-gated --num-parameters max:4B --apps vllm --sort created_at --limit 300 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.created_at[:10])\t\(.id)"' | |
| ``` | |
| Fish: | |
| ```fish | |
| set D (date -v-2m +%F 2>/dev/null || date -d '2 months ago' +%F) | |
| hf models ls --search ocr --no-gated --num-parameters max:4B --apps vllm --sort created_at --limit 300 --json \ | |
| | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.created_at[:10])\t\(.id)"' | |
| ``` | |
| **3.** "From a paper to a live API." Paper -> most liked model citing it that is warm -> which provider serves it. | |
| ```bash | |
| M=$(hf models ls --filter arxiv:2505.09388 --warm --sort likes --limit 1 --format quiet) | |
| hf models info $M --expand inferenceProviderMapping --json | jq -r '.inference_provider_mapping[] | select(.status=="live") | "\(.provider)\t\(.task)"' | |
| # Qwen/Qwen3-8B on nscale, featherless-ai | |
| ``` | |
| Fish: | |
| ```fish | |
| set M (hf models ls --filter arxiv:2505.09388 --warm --sort likes --limit 1 --format quiet) | |
| hf models info $M --expand inferenceProviderMapping --json | jq -r '.inference_provider_mapping[] | select(.status=="live") | "\(.provider)\t\(.task)"' | |
| # Qwen/Qwen3-8B on nscale, featherless-ai | |
| ``` | |
| **4.** "Which GGUF fits a 16 GB card?" Sizes without downloading, largest that fits first. | |
| ```bash | |
| hf models ls unsloth/Qwen3-8B-GGUF --json | jq -r '.[] | select(.path|endswith(".gguf")) | select(.size < 12e9) | "\(.size/1e9*10|round/10) GB\t\(.path)"' | sort -rn | head -3 | |
| # 10.8 GB Q8_K_XL, 8.7 GB Q8_0, 7.5 GB Q6_K_XL | |
| ``` | |
| **5.** "How fast is a task growing?" Monthly new models for image-text-to-text this year, from the daily Hub snapshot. | |
| ```bash | |
| hf datasets sql "SELECT strftime(createdAt, '%Y-%m') m, COUNT(*) n FROM 'hf://datasets/cfahlgren1/hub-stats@~parquet/models/train/*.parquet' WHERE pipeline_tag='image-text-to-text' AND createdAt >= '2026-01-01' GROUP BY 1 ORDER BY 1" | |
| # Jan 1091 ... Apr 3614 ... Aug 4320 | |
| ``` | |
| **6.** "Which leaderboard models are ungated?" Leaderboard -> gating status per model. | |
| ```bash | |
| hf datasets leaderboard openai/gsm8k --limit 5 --json | jq -r '.[].model_id' \ | |
| | xargs -P 5 -I{} sh -c 'echo "$(hf models info {} --expand gated --json | jq -r .gated)\t{}"' | |
| # false MiMo-V2.5-Pro, manual Llama-3.1-405B, false granite-4.1-30b, ... | |
| ``` | |
| **7.** "Audit an org." Private count, total downloads, in one call. | |
| ```bash | |
| hf datasets ls --author biglam --limit 200 --json --expand private,gated,downloads,likes \ | |
| | jq -r '"\(map(select(.private)) | length) private / \(length) total; downloads: \(map(.downloads) | add)"' | |
| ``` | |
| **8.** "Run a recipe over a dataset and get a dataset back." One Job, no environment. | |
| ```bash | |
| hf jobs uv run --flavor a10g-small --timeout 15m --secrets HF_TOKEN \ | |
| https://huggingface.co/datasets/uv-scripts/ocr/raw/main/glm-ocr.py uv-scripts/ocr-demo YOU/ocr-demo-results | |
| ``` | |
| **9.** "Sweep, wait, collect." Three labelled Jobs from a list, block until all succeed, then pull results from the bucket. | |
| ```bash | |
| for m in Qwen/Qwen3-8B Qwen/Qwen3-4B Qwen/Qwen3-1.7B; do | |
| hf jobs uv run --flavor l4x1 -s HF_TOKEN --label run=sweep42 --label model=$m --detach eval.py $m hf://buckets/YOU/sweep42 2>/dev/null | grep -oE '^id=[a-f0-9]+' | |
| done | |
| hf jobs ps -a --label run=sweep42 --format quiet | xargs hf jobs wait --timeout 2h && hf buckets sync hf://buckets/YOU/sweep42 ./sweep42 | |
| ``` | |
| Fish: | |
| ```fish | |
| for m in Qwen/Qwen3-8B Qwen/Qwen3-4B Qwen/Qwen3-1.7B | |
| hf jobs uv run --flavor l4x1 -s HF_TOKEN --label run=sweep42 --label model=$m --detach eval.py $m hf://buckets/YOU/sweep42 2>/dev/null | grep -oE '^id=[a-f0-9]+' | |
| end | |
| hf jobs ps -a --label run=sweep42 --format quiet | xargs hf jobs wait --timeout 2h && hf buckets sync hf://buckets/YOU/sweep42 ./sweep42 | |
| ``` | |
| **10.** "Which trending papers have a model you can call right now?" Top 100 trending papers -> any warm model citing each. 100 calls, 8 in parallel, about 10 s. | |
| ```bash | |
| # Today's daily papers are too new to be served anywhere, so use the all-time trending sort instead of a date window. | |
| hf papers ls --sort trending --limit 100 --json | jq -r '.[] | "\(.upvotes)\t\(.id)\t\(.title[:60])"' | tr '\n' '\0' \ | |
| | xargs -0 -P 8 -I{} sh -c 'l="{}"; id=$(printf "%s" "$l" | cut -f2); w=$(hf models ls --filter arxiv:$id --warm --sort likes --limit 1 --format quiet 2>/dev/null); [ -n "$w" ] && printf "%s\t%s\n" "$l" "$w"' | sort -rn | |
| # 187 LlamaFactory -> Meta-Llama-3-8B-Instruct-zh-10k, 101 WideSeek-R1 -> RLinf/WideSeek-R1-4b, 41 LongCat-Video, 14 RF-DETR | |
| ``` | |
| **11.** "Save the result as a collection." Any listing becomes a collection for later reuse. | |
| ```bash | |
| SLUG=$(hf collections create "Warm OCR models under 4B, Sep 2026" --private --json | jq -r '.slug') | |
| hf models ls --search ocr --warm --num-parameters max:4B --sort likes --limit 10 --format quiet | xargs -I{} hf collections add-item $SLUG {} model --format quiet | |
| ``` | |
| Fish: | |
| ```fish | |
| set SLUG (hf collections create "Warm OCR models under 4B, Sep 2026" --private --json | jq -r '.slug') | |
| hf models ls --search ocr --warm --num-parameters max:4B --sort likes --limit 10 --format quiet | xargs -I{} hf collections add-item $SLUG {} model --format quiet | |
| ``` | |
| ## Patterns | |
| - Fish users: every block that sets a variable has a fish twin underneath. Everything else runs unchanged; the only bash-isms fish rejects are `X=$(cmd)` and `for … do … done`. | |
| - `-`-format quiet`` when the next step is another command. `-`-json` | jq` when you need fields. Human output for the final answer only. | |
| - Sort by `created_at` or `trending_score` before you recommend a model. Default order is not recency. | |
| - Combine the lineage filters: `dataset:` + `--warm`, `arxiv:` + `--num-parameters`, `base_model:finetune:` + `-`-sort created_at``. | |