#!/bin/bash
# download_model.sh - 下载BGE-M3模型文件（可在本地Windows运行后上传到服务器）

MODEL_DIR="bge-m3-model"
MODEL_URL="https://modelscope.cn/models/Xorbits/bge-m3/resolve/master"

echo "========================================"
echo "下载 BGE-M3 模型文件"
echo "========================================"
echo ""
echo "目标目录: $MODEL_DIR"
echo ""

# 创建目录
mkdir -p "$MODEL_DIR"

# 下载模型文件
FILES=(
    "config.json"
    "model.safetensors"
    "tokenizer.json"
    "tokenizer_config.json"
    "special_tokens_map.json"
    "vocab.txt"
    "sentencepiece.bpe.model"
)

for file in "${FILES[@]}"; do
    echo "下载: $file"
    wget -c "$MODEL_URL/$file" -O "$MODEL_DIR/$file" || curl -L "$MODEL_URL/$file" -o "$MODEL_DIR/$file"
done

echo ""
echo "========================================"
echo "下载完成！"
echo "========================================"
echo ""
echo "模型文件列表:"
ls -lh "$MODEL_DIR"
echo ""
echo "下一步："
echo "1. 将 $MODEL_DIR 目录上传到服务器"
echo "2. 在服务器上放置到: ~/.cache/huggingface/hub/models--BAAI--bge-m3/snapshots/main/"
echo ""