File size: 1,833 Bytes
13c5606
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Fetch the bundled `linear_spec_lora` adapter from the public HF model repo
# into `miscs/linear_spec_lora/`. The safetensors weights are gitignored
# (too large for github), so this script is needed before the first
# `eval.sh --mode linear_spec --lora` run.
#
# Usage:
#   bash scripts/fetch_bundled_lora.sh
#   bash scripts/fetch_bundled_lora.sh --model nvidia/Nemotron-Labs-Diffusion-3B   # different size
#   bash scripts/fetch_bundled_lora.sh --subfolder linear_spec_lora_v2             # different variant
set -euo pipefail

MODEL="nvidia/Nemotron-Labs-Diffusion-8B"
SUBFOLDER="linear_spec_lora"

_usage() {
    cat <<EOF
Usage: $(basename "$0") [--model HF_ID] [--subfolder NAME]

Pulls a LoRA adapter from a HuggingFace model repo into miscs/linear_spec_lora/.

Options:
  --model HF_ID       HuggingFace model id (default: $MODEL)
  --subfolder NAME    Subfolder of the model repo holding the adapter
                      (default: $SUBFOLDER)
  -h, --help          Show this help and exit
EOF
}

while [[ $# -gt 0 ]]; do
    case "$1" in
        --model)     MODEL="$2"; shift 2 ;;
        --subfolder) SUBFOLDER="$2"; shift 2 ;;
        -h|--help)   _usage; exit 0 ;;
        *) echo "Unknown arg: $1" >&2; _usage >&2; exit 1 ;;
    esac
done

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEST="$SCRIPT_DIR/../miscs/linear_spec_lora"
mkdir -p "$DEST"

AUTH_HEADER=()
if [[ -n "${HF_TOKEN:-}" ]]; then
    AUTH_HEADER=(-H "Authorization: Bearer $HF_TOKEN")
fi

echo "Fetching ${MODEL}/${SUBFOLDER}/ → ${DEST}/ ..."
for f in adapter_config.json adapter_model.safetensors; do
    curl -fSL "${AUTH_HEADER[@]}" \
        "https://huggingface.co/${MODEL}/resolve/main/${SUBFOLDER}/${f}" \
        -o "$DEST/$f"
done
ls -lh "$DEST"
echo "Done. Use it with: bash eval.sh --mode linear_spec --lora"