|
a |
|
b/src/llama-main/download.sh |
|
|
1 |
#!/usr/bin/env bash |
|
|
2 |
|
|
|
3 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
|
|
4 |
# This software may be used and distributed according to the terms of the Llama 2 Community License Agreement. |
|
|
5 |
|
|
|
6 |
set -e |
|
|
7 |
|
|
|
8 |
read -p "Enter the URL from email: " PRESIGNED_URL |
|
|
9 |
echo "" |
|
|
10 |
read -p "Enter the list of models to download without spaces (7B,13B,70B,7B-chat,13B-chat,70B-chat), or press Enter for all: " MODEL_SIZE |
|
|
11 |
TARGET_FOLDER="." # where all files should end up |
|
|
12 |
mkdir -p ${TARGET_FOLDER} |
|
|
13 |
|
|
|
14 |
if [[ $MODEL_SIZE == "" ]]; then |
|
|
15 |
MODEL_SIZE="7B,13B,70B,7B-chat,13B-chat,70B-chat" |
|
|
16 |
fi |
|
|
17 |
|
|
|
18 |
echo "Downloading LICENSE and Acceptable Usage Policy" |
|
|
19 |
wget --continue ${PRESIGNED_URL/'*'/"LICENSE"} -O ${TARGET_FOLDER}"/LICENSE" |
|
|
20 |
wget --continue ${PRESIGNED_URL/'*'/"USE_POLICY.md"} -O ${TARGET_FOLDER}"/USE_POLICY.md" |
|
|
21 |
|
|
|
22 |
echo "Downloading tokenizer" |
|
|
23 |
wget --continue ${PRESIGNED_URL/'*'/"tokenizer.model"} -O ${TARGET_FOLDER}"/tokenizer.model" |
|
|
24 |
wget --continue ${PRESIGNED_URL/'*'/"tokenizer_checklist.chk"} -O ${TARGET_FOLDER}"/tokenizer_checklist.chk" |
|
|
25 |
CPU_ARCH=$(uname -m) |
|
|
26 |
if [ "$CPU_ARCH" = "arm64" ]; then |
|
|
27 |
(cd ${TARGET_FOLDER} && md5 tokenizer_checklist.chk) |
|
|
28 |
else |
|
|
29 |
(cd ${TARGET_FOLDER} && md5sum -c tokenizer_checklist.chk) |
|
|
30 |
fi |
|
|
31 |
|
|
|
32 |
for m in ${MODEL_SIZE//,/ } |
|
|
33 |
do |
|
|
34 |
if [[ $m == "7B" ]]; then |
|
|
35 |
SHARD=0 |
|
|
36 |
MODEL_PATH="llama-2-7b" |
|
|
37 |
elif [[ $m == "7B-chat" ]]; then |
|
|
38 |
SHARD=0 |
|
|
39 |
MODEL_PATH="llama-2-7b-chat" |
|
|
40 |
elif [[ $m == "13B" ]]; then |
|
|
41 |
SHARD=1 |
|
|
42 |
MODEL_PATH="llama-2-13b" |
|
|
43 |
elif [[ $m == "13B-chat" ]]; then |
|
|
44 |
SHARD=1 |
|
|
45 |
MODEL_PATH="llama-2-13b-chat" |
|
|
46 |
elif [[ $m == "70B" ]]; then |
|
|
47 |
SHARD=7 |
|
|
48 |
MODEL_PATH="llama-2-70b" |
|
|
49 |
elif [[ $m == "70B-chat" ]]; then |
|
|
50 |
SHARD=7 |
|
|
51 |
MODEL_PATH="llama-2-70b-chat" |
|
|
52 |
fi |
|
|
53 |
|
|
|
54 |
echo "Downloading ${MODEL_PATH}" |
|
|
55 |
mkdir -p ${TARGET_FOLDER}"/${MODEL_PATH}" |
|
|
56 |
|
|
|
57 |
for s in $(seq -f "0%g" 0 ${SHARD}) |
|
|
58 |
do |
|
|
59 |
wget --continue ${PRESIGNED_URL/'*'/"${MODEL_PATH}/consolidated.${s}.pth"} -O ${TARGET_FOLDER}"/${MODEL_PATH}/consolidated.${s}.pth" |
|
|
60 |
done |
|
|
61 |
|
|
|
62 |
wget --continue ${PRESIGNED_URL/'*'/"${MODEL_PATH}/params.json"} -O ${TARGET_FOLDER}"/${MODEL_PATH}/params.json" |
|
|
63 |
wget --continue ${PRESIGNED_URL/'*'/"${MODEL_PATH}/checklist.chk"} -O ${TARGET_FOLDER}"/${MODEL_PATH}/checklist.chk" |
|
|
64 |
echo "Checking checksums" |
|
|
65 |
if [ "$CPU_ARCH" = "arm64" ]; then |
|
|
66 |
(cd ${TARGET_FOLDER}"/${MODEL_PATH}" && md5 checklist.chk) |
|
|
67 |
else |
|
|
68 |
(cd ${TARGET_FOLDER}"/${MODEL_PATH}" && md5sum -c checklist.chk) |
|
|
69 |
fi |
|
|
70 |
done |