add alpaca support into docker scripts

This commit is contained in:
Bernat Vadell 2023-03-20 16:58:53 +01:00
parent 074bea2eb1
commit 0cc13a2193
2 changed files with 32 additions and 12 deletions

View file

@ -21,6 +21,7 @@ elif [[ $arg1 == '--download' || $arg1 == '-d' ]]; then
elif [[ $arg1 == '--all-in-one' || $arg1 == '-a' ]]; then
echo "Downloading model..."
python3 ./download-pth.py "$1" "$2"
if [[ $2 != 'alpaca' ]]; then
echo "Converting PTH to GGML..."
for i in `ls $1/$2/ggml-model-f16.bin*`; do
if [ -f "${i/f16/q4_0}" ]; then
@ -30,6 +31,7 @@ elif [[ $arg1 == '--all-in-one' || $arg1 == '-a' ]]; then
./quantize "$i" "${i/f16/q4_0}" 2
fi
done
fi;
else
echo "Unknown command: $arg1"
echo "Available commands: "

View file

@ -11,6 +11,26 @@ if len(sys.argv) < 3:
modelsDir = sys.argv[1]
model = sys.argv[2]
resolved_path = os.path.abspath(os.path.join(modelsDir, model))
os.makedirs(resolved_path, exist_ok=True)
if model == 'alpaca':
dest_path = os.path.abspath(os.path.join(resolved_path, "ggml-alpaca-7b-q4.bin"))
if os.path.exists(dest_path):
print(f"Skip file download, it already exists: {dest_path}")
sys.exit(1)
response = requests.get("https://gateway.estuary.tech/gw/ipfs/QmQ1bf2BTnYxq73MFJWu1B7bQ2UD6qG7D7YDCxhTndVkPC", stream=True)
with open(dest_path, 'wb') as f:
with tqdm(unit='B', unit_scale=True, miniters=1, desc="ggml-alpaca-7b-q4.bin") as t:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
t.update(len(chunk))
sys.exit(0)
num = {
"7B": 1,
"13B": 2,
@ -19,7 +39,7 @@ num = {
}
if model not in num:
print(f"Error: model {model} is not valid, provide 7B, 13B, 30B or 65B")
print(f"Error: model {model} is not valid, provide 7B, 13B, 30B, 65B or alpaca")
sys.exit(1)
print(f"Downloading model {model}")
@ -29,8 +49,6 @@ files = ["checklist.chk", "params.json"]
for i in range(num[model]):
files.append(f"consolidated.0{i}.pth")
resolved_path = os.path.abspath(os.path.join(modelsDir, model))
os.makedirs(resolved_path, exist_ok=True)
for file in files:
dest_path = os.path.join(resolved_path, file)