davanstrien HF Staff commited on
Commit
a687b33
·
verified ·
1 Parent(s): 3aaea68

Inline code in prose

Browse files
Files changed (1) hide show
  1. README.md +24 -24
README.md CHANGED
@@ -15,7 +15,7 @@ The Hugging Face CLI is a powerful tool for interacting with the Hub. It allows
15
 
16
  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!
17
 
18
- 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. The four recipes that set variables carry a fish line, and the substitutions are listed under Patterns. Listings take `--json`, `--format quiet`, `--sort` and `--limit`; the default limit is 30 on models and datasets, 100 on jobs, 10 on collections.
19
 
20
  ## Lineage: walk the graph between models, datasets, papers, and providers
21
 
@@ -55,7 +55,7 @@ Which papers is a model tagged with? Usually its own report, sometimes a related
55
  hf models info Qwen/Qwen3-8B --json | jq -r '.tags[] | select(startswith("arxiv:"))'
56
  ```
57
 
58
- Everything on the Hub that cites a paper. Set a large --limit before counting (default is 30).
59
 
60
  ```bash
61
  hf models ls --filter arxiv:2505.09388 --limit 5000 --format quiet | wc -l
@@ -64,7 +64,7 @@ hf datasets ls --filter arxiv:2505.09388 --limit 100 --format quiet
64
 
65
  Returns 2400+ for the Qwen3 report.
66
 
67
- Combine filters: models tagged with this paper that an inference provider is serving right now (--warm), by likes.
68
 
69
  ```bash
70
  hf models ls --filter arxiv:2505.09388 --warm --sort likes --limit 10 --format quiet
@@ -86,7 +86,7 @@ Only models an inference provider is serving right now
86
  hf models ls --pipeline-tag text-generation --warm --sort trending_score --limit 20 --format quiet
87
  ```
88
 
89
- What can I run with vLLM or llama.cpp under 9B? Repeat --apps to OR them.
90
 
91
  ```bash
92
  hf models ls --apps vllm --apps llama.cpp --num-parameters max:9B --sort downloads --limit 10 --format quiet
@@ -98,7 +98,7 @@ What does one provider serve, ranked by downloads.
98
  hf models ls --inference-provider fireworks-ai --sort downloads --limit 10 --format quiet
99
  ```
100
 
101
- 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.
102
 
103
  ```bash
104
  D=$(date -v-3m +%F 2>/dev/null || date -d '3 months ago' +%F)
@@ -114,7 +114,7 @@ hf models ls --pipeline-tag image-text-to-text --sort created_at --limit 1000 --
114
  | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.id)"'
115
  ```
116
 
117
- Tag namespaces --filter accepts but --help never lists: license:, dataset:, arxiv:, base_model:, plus bare language codes and library names.
118
 
119
  ```bash
120
  hf models ls --filter license:apache-2.0 --filter automatic-speech-recognition --sort trending_score --limit 10 --format quiet
@@ -138,7 +138,7 @@ hf models info meta-llama/Llama-3.1-8B-Instruct --expand gated --json | jq '.gat
138
 
139
  "manual", "auto" or false
140
 
141
- Which providers serve a given model, and whether each is live. The reverse of --inference-provider.
142
 
143
  ```bash
144
  hf models info deepseek-ai/DeepSeek-V4-Flash --expand inferenceProviderMapping --json | jq -r '.inference_provider_mapping[] | "\(.provider)\t\(.status)\t\(.task)"'
@@ -228,7 +228,7 @@ hf datasets ls --filter language:la --filter modality:image --sort downloads --l
228
 
229
  DuckDB reads only the bytes a query touches, so you can count, sample and aggregate a large parquet without downloading it.
230
 
231
- Every config and split with its parquet URL and size, or one split. Feed them to DuckDB, Polars, or curl -r.
232
 
233
  ```bash
234
  hf datasets parquet openai/gsm8k
@@ -242,7 +242,7 @@ hf datasets sql "SELECT COUNT(*) FROM 'hf://datasets/openai/gsm8k@~parquet/main/
242
  hf datasets sql "SELECT question FROM 'hf://datasets/openai/gsm8k@~parquet/main/test/*.parquet' USING SAMPLE 3"
243
  ```
244
 
245
- Schema, splits and first rows without a download. Needs the hf-ds extension: hf extensions install davanstrien/hf-ds
246
 
247
  ```bash
248
  hf ds inspect openai/gsm8k
@@ -280,7 +280,7 @@ hf jobs uv run --flavor a10g-small --timeout 15m --secrets HF_TOKEN \
280
  uv-scripts/ocr-demo your-username/ocr-demo-results
281
  ```
282
 
283
- 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.
284
 
285
  ```bash
286
  hf jobs uv run --flavor cpu-basic --timeout 25m --detach \
@@ -325,7 +325,7 @@ Benchmark numbers from the model card as JSON.
325
  hf models info zai-org/GLM-OCR --expand evalResults --json | jq -r '.eval_results[] | "\(.dataset_id)\t\(.task_id)\t\(.value)"'
326
  ```
327
 
328
- Newest job id and status. --limit 0 lifts the 100-job cap here. max_by selects the newest regardless of list order.
329
 
330
  ```bash
331
  hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | "\(.id) \(.status)"'
@@ -337,14 +337,14 @@ Recent jobs with flavor and start time.
337
  hf jobs ps -a --json --limit 10 | jq -r '.[] | "\(.id)\t\(.status)\t\(.flavor)\t\(.created_at[:16])"'
338
  ```
339
 
340
- Select by name pattern or status, then act. Add --limit 0, or the 100-job cap omits older ones.
341
 
342
  ```bash
343
  hf jobs ps -a --json --limit 0 | jq -r '.[] | select(.name|test("probe")) | .id'
344
  hf jobs ps --status RUNNING --format quiet | xargs -n1 hf jobs cancel
345
  ```
346
 
347
- Tail the newest job. logs -f is a no-op while SCHEDULING; poll inspect until the stage is RUNNING.
348
 
349
  ```bash
350
  J=$(hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | .id')
@@ -359,7 +359,7 @@ J=$(hf jobs uv run --flavor cpu-basic --label run=sweep42 --label model=qwen3-8b
359
  hf jobs ps -a --label run=sweep42 --json | jq -r '.[] | "\(.id)\t\(.status)"'
360
  ```
361
 
362
- Block until every job succeeds, then chain. Exit 0 only if all completed. hf jobs hardware lists flavors with $/hour.
363
 
364
  ```bash
365
  hf jobs ls -q | xargs hf jobs wait --timeout 2h && hf jobs run --detach python:3.12 python eval.py
@@ -369,7 +369,7 @@ hf jobs ls -q | xargs hf jobs wait --timeout 2h && hf jobs run --detach python:3
369
 
370
  An endpoint is a dedicated server for one model with an OpenAI-compatible URL. Most of the setup is discoverable from the CLI.
371
 
372
- Models with a catalog entry: hardware and engine are preset, only --repo and --name are needed. Check it before configuring a deploy manually.
373
 
374
  ```bash
375
  hf endpoints catalog ls --json 2>/dev/null | jq -r '.models[]' | grep -i ocr
@@ -388,7 +388,7 @@ Enough VRAM, cheapest first. gpu_memory_gb is the TOTAL across accelerators, so
388
  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)"'
389
  ```
390
 
391
- 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.
392
 
393
  ```bash
394
  hf endpoints deploy qwen3-8b-vllm --repo Qwen/Qwen3-8B --framework custom --engine vllm --custom-image vllm/vllm-openai:v0.23.0 \
@@ -396,14 +396,14 @@ hf endpoints deploy qwen3-8b-vllm --repo Qwen/Qwen3-8B --framework custom --engi
396
  --type private --min-replica 0 --max-replica 1 --scale-to-zero-timeout 15 --revision main -e VLLM_LOGGING_LEVEL=INFO -s HF_TOKEN
397
  ```
398
 
399
- GGUF on llama.cpp, same shape. --type now defaults to authenticated (previously protected).
400
 
401
  ```bash
402
  hf endpoints deploy qwen3-8b-gguf --repo unsloth/Qwen3-8B-GGUF --framework custom --engine llamacpp \
403
  --vendor aws --region us-east-1 --accelerator gpu --instance-type nvidia-l4 --instance-size x1 --type private
404
  ```
405
 
406
- 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.
407
 
408
  ```bash
409
  E=$(hf endpoints ls --format quiet | head -1)
@@ -443,7 +443,7 @@ hf jobs uv run --flavor l4x1 -s HF_TOKEN \
443
  --label project=ocr-sweep --detach train.py 2>/dev/null | grep -oE '^id=[a-f0-9]+'
444
  ```
445
 
446
- TRL and transformers Trainers pick trackio up automatically. Project = --output_dir, run = --run_name.
447
 
448
  Verify the Space really is private. Older trackio docs and skills omitted private=True.
449
 
@@ -492,7 +492,7 @@ echo '{"ok": true}' | hf buckets cp - hf://buckets/YOU/BUCKET/results.json
492
 
493
  and stdin the other way
494
 
495
- 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.
496
 
497
  ```bash
498
  hf buckets sync ./out hf://buckets/YOU/BUCKET/run42 --dry-run | jq -c 'select(.type=="operation") | {action, path, size}'
@@ -523,7 +523,7 @@ hf papers read 2505.09388 | head -200
523
  hf papers info 2609.11495 --json | jq '{title, summary}'
524
  ```
525
 
526
- 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.
527
 
528
  ```bash
529
  hf papers ls --json | jq -r 'sort_by(-.upvotes)[] | "\(.upvotes)\t\(.id)\t\(.title)"'
@@ -652,8 +652,8 @@ Fish: `set SLUG (hf collections create … | jq -r .slug)`
652
 
653
  ## Patterns
654
 
655
- - Fish users: three substitutions cover every line here. `X=$(cmd)` becomes `set X (cmd)`; `a || b` becomes `a; or b`; `for x in …; do …; done` becomes `for x in …; …; end`. `alias`, `$(…)` inside `sh -c '…'`, and `jq --arg d "$D"` work unchanged. Or run any line as `bash -c '…'`.
656
 
657
- - `--format quiet` when the next step is another command. `--json | jq` when you need fields. Human output for the final answer only.
658
  - Sort by `created_at` or `trending_score` before you recommend a model. Default order is not recency.
659
- - Combine the lineage filters: `dataset:` + `--warm`, `arxiv:` + `--num-parameters`, `base_model:finetune:` + `--sort created_at`.
 
15
 
16
  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!
17
 
18
+ 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. The four recipes that set variables carry a fish line, and the substitutions are listed under Patterns. Listings take `--json`, `-`-format quiet``, `--sort` and `--limit`; the default limit is 30 on models and datasets, 100 on jobs, 10 on collections.
19
 
20
  ## Lineage: walk the graph between models, datasets, papers, and providers
21
 
 
55
  hf models info Qwen/Qwen3-8B --json | jq -r '.tags[] | select(startswith("arxiv:"))'
56
  ```
57
 
58
+ Everything on the Hub that cites a paper. Set a large `--limit` before counting (default is 30).
59
 
60
  ```bash
61
  hf models ls --filter arxiv:2505.09388 --limit 5000 --format quiet | wc -l
 
64
 
65
  Returns 2400+ for the Qwen3 report.
66
 
67
+ Combine filters: models tagged with this paper that an inference provider is serving right now (`--warm`), by likes.
68
 
69
  ```bash
70
  hf models ls --filter arxiv:2505.09388 --warm --sort likes --limit 10 --format quiet
 
86
  hf models ls --pipeline-tag text-generation --warm --sort trending_score --limit 20 --format quiet
87
  ```
88
 
89
+ What can I run with vLLM or llama.cpp under 9B? Repeat `--apps` to OR them.
90
 
91
  ```bash
92
  hf models ls --apps vllm --apps llama.cpp --num-parameters max:9B --sort downloads --limit 10 --format quiet
 
98
  hf models ls --inference-provider fireworks-ai --sort downloads --limit 10 --format quiet
99
  ```
100
 
101
+ 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.
102
 
103
  ```bash
104
  D=$(date -v-3m +%F 2>/dev/null || date -d '3 months ago' +%F)
 
114
  | jq -r --arg d "$D" '[.[] | select(.created_at > $d)] | sort_by(-.likes)[:10][] | "\(.likes)\t\(.id)"'
115
  ```
116
 
117
+ Tag namespaces `--filter` accepts but `--help` never lists: `license:`, `dataset:`, `arxiv:`, `base_model:`, plus bare language codes and library names.
118
 
119
  ```bash
120
  hf models ls --filter license:apache-2.0 --filter automatic-speech-recognition --sort trending_score --limit 10 --format quiet
 
138
 
139
  "manual", "auto" or false
140
 
141
+ Which providers serve a given model, and whether each is live. The reverse of `--inference-provider`.
142
 
143
  ```bash
144
  hf models info deepseek-ai/DeepSeek-V4-Flash --expand inferenceProviderMapping --json | jq -r '.inference_provider_mapping[] | "\(.provider)\t\(.status)\t\(.task)"'
 
228
 
229
  DuckDB reads only the bytes a query touches, so you can count, sample and aggregate a large parquet without downloading it.
230
 
231
+ Every config and split with its parquet URL and size, or one split. Feed them to DuckDB, Polars, or curl `-r`.
232
 
233
  ```bash
234
  hf datasets parquet openai/gsm8k
 
242
  hf datasets sql "SELECT question FROM 'hf://datasets/openai/gsm8k@~parquet/main/test/*.parquet' USING SAMPLE 3"
243
  ```
244
 
245
+ Schema, splits and first rows without a download. Needs the hf-ds extension: `hf extensions install` davanstrien/hf-ds
246
 
247
  ```bash
248
  hf ds inspect openai/gsm8k
 
280
  uv-scripts/ocr-demo your-username/ocr-demo-results
281
  ```
282
 
283
+ 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.
284
 
285
  ```bash
286
  hf jobs uv run --flavor cpu-basic --timeout 25m --detach \
 
325
  hf models info zai-org/GLM-OCR --expand evalResults --json | jq -r '.eval_results[] | "\(.dataset_id)\t\(.task_id)\t\(.value)"'
326
  ```
327
 
328
+ Newest job id and status. `--limit 0` lifts the 100-job cap here. max_by selects the newest regardless of list order.
329
 
330
  ```bash
331
  hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | "\(.id) \(.status)"'
 
337
  hf jobs ps -a --json --limit 10 | jq -r '.[] | "\(.id)\t\(.status)\t\(.flavor)\t\(.created_at[:16])"'
338
  ```
339
 
340
+ Select by name pattern or status, then act. Add `--limit 0`, or the 100-job cap omits older ones.
341
 
342
  ```bash
343
  hf jobs ps -a --json --limit 0 | jq -r '.[] | select(.name|test("probe")) | .id'
344
  hf jobs ps --status RUNNING --format quiet | xargs -n1 hf jobs cancel
345
  ```
346
 
347
+ Tail the newest job. logs `-f` is a no-op while SCHEDULING; poll inspect until the stage is RUNNING.
348
 
349
  ```bash
350
  J=$(hf jobs ps -a --json --limit 0 | jq -r 'max_by(.created_at) | .id')
 
359
  hf jobs ps -a --label run=sweep42 --json | jq -r '.[] | "\(.id)\t\(.status)"'
360
  ```
361
 
362
+ Block until every job succeeds, then chain. Exit 0 only if all completed. `hf jobs hardware` lists flavors with $/hour.
363
 
364
  ```bash
365
  hf jobs ls -q | xargs hf jobs wait --timeout 2h && hf jobs run --detach python:3.12 python eval.py
 
369
 
370
  An endpoint is a dedicated server for one model with an OpenAI-compatible URL. Most of the setup is discoverable from the CLI.
371
 
372
+ Models with a catalog entry: hardware and engine are preset, only `--repo` and `--name` are needed. Check it before configuring a deploy manually.
373
 
374
  ```bash
375
  hf endpoints catalog ls --json 2>/dev/null | jq -r '.models[]' | grep -i ocr
 
388
  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)"'
389
  ```
390
 
391
+ 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.
392
 
393
  ```bash
394
  hf endpoints deploy qwen3-8b-vllm --repo Qwen/Qwen3-8B --framework custom --engine vllm --custom-image vllm/vllm-openai:v0.23.0 \
 
396
  --type private --min-replica 0 --max-replica 1 --scale-to-zero-timeout 15 --revision main -e VLLM_LOGGING_LEVEL=INFO -s HF_TOKEN
397
  ```
398
 
399
+ GGUF on llama.cpp, same shape. `--type` now defaults to authenticated (previously protected).
400
 
401
  ```bash
402
  hf endpoints deploy qwen3-8b-gguf --repo unsloth/Qwen3-8B-GGUF --framework custom --engine llamacpp \
403
  --vendor aws --region us-east-1 --accelerator gpu --instance-type nvidia-l4 --instance-size x1 --type private
404
  ```
405
 
406
+ 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.
407
 
408
  ```bash
409
  E=$(hf endpoints ls --format quiet | head -1)
 
443
  --label project=ocr-sweep --detach train.py 2>/dev/null | grep -oE '^id=[a-f0-9]+'
444
  ```
445
 
446
+ TRL and transformers Trainers pick trackio up automatically. Project = `--output_dir`, run = `--run_name`.
447
 
448
  Verify the Space really is private. Older trackio docs and skills omitted private=True.
449
 
 
492
 
493
  and stdin the other way
494
 
495
+ 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.
496
 
497
  ```bash
498
  hf buckets sync ./out hf://buckets/YOU/BUCKET/run42 --dry-run | jq -c 'select(.type=="operation") | {action, path, size}'
 
523
  hf papers info 2609.11495 --json | jq '{title, summary}'
524
  ```
525
 
526
+ 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.
527
 
528
  ```bash
529
  hf papers ls --json | jq -r 'sort_by(-.upvotes)[] | "\(.upvotes)\t\(.id)\t\(.title)"'
 
652
 
653
  ## Patterns
654
 
655
+ - Fish users: three substitutions cover every line here. `X=$(cmd)` becomes `set X (cmd)`; `a || b` becomes `a; or b`; `for x in …; do …; done` becomes `for x in …; …; end`. `alias`, `$(…)` inside `sh `-c` '…'`, and `jq `--arg` d "$D"` work unchanged. Or run any line as `bash `-c` '…'`.
656
 
657
+ - `-`-format quiet`` when the next step is another command. `-`-json` | jq` when you need fields. Human output for the final answer only.
658
  - Sort by `created_at` or `trending_score` before you recommend a model. Default order is not recency.
659
+ - Combine the lineage filters: `dataset:` + `--warm`, `arxiv:` + `--num-parameters`, `base_model:finetune:` + `-`-sort created_at``.