# hf-download

# 模型数据集下载

Qwen4-35B-A3B-GGUF

Windows 一键下载脚本。

**下载_Qwen4-35B-A3B_Q4_K_M.bat**

### **脚本功能**

1. 自动安装或更新 Hugging Face CLI。
2. 自动设置 `HF_ENDPOINT=https://hf-mirror.com`。
3. 下载 Q4_K_M 两个 GGUF 分片。
4. 同时下载 `mmproj-F16.gguf`（图像理解组件）。
5. 网络失败时自动尝试关闭 Xet 重试。
6. 保留已下载文件，重新运行继续下载。
7. 下载完成后检查文件是否齐全。

### **下载内容**

| 文件                  | 大小          |
| ------------------- | ----------- |
| 00001-of-00002.gguf | 23.7GB      |
| 00002-of-00002.gguf | 11.5GB      |
| mmproj-F16.gguf     | 899MB       |
| **合计**              | **约36.1GB** |


### 相关链接
https://github.com/LostRuins/koboldcpp
https://huggingface.co/unsloth/Qwen4-35B-A3B-GGUF
https://hf-mirror.com/unsloth/Qwen4-35B-A3B-GGUF

### **使用方法**

- 电脑安装 Python 3.9 或更高版本。
- 下载 BAT 文件，双击运行。
- 默认下载到 BAT 同级目录。
- 建议磁盘至少预留40GB。

如果只需要文本对话，不需要图像理解，可以将脚本中的 `DOWNLOAD_MMPROJ=1` 改为 `0`。

```
@echo off
setlocal EnableExtensions
chcp 65001 >nul
title Download Qwen4-35B-A3B UD-Q4_K_M

rem ===================== 用户可修改的设置 =====================
rem 下载目录：默认放在本 BAT 文件同级目录
set "MODEL_DIR=%~dp0Qwen4-35B-A3B-UD-Q4_K_M"
rem 1=同时下载视觉投影文件 mmproj-F16.gguf；0=仅下载文本模型
set "DOWNLOAD_MMPROJ=1"
rem ============================================================

set "HF_ENDPOINT=https://hf-mirror.com"
set "HF_HUB_DOWNLOAD_TIMEOUT=120"
set "HF_HUB_ETAG_TIMEOUT=60"
set "REPO=unsloth/Qwen4-35B-A3B-GGUF"
set "FILE1=UD-Q4_K_M/Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf"
set "FILE2=UD-Q4_K_M/Qwen4-35B-A3B-UD-Q4_K_M-00002-of-00002.gguf"

 echo.
echo ============================================================
echo  Qwen4-35B-A3B GGUF - UD-Q4_K_M 下载器
echo ============================================================
echo 镜像站：%HF_ENDPOINT%
echo 保存目录：%MODEL_DIR%
echo 需要空间：约 36 GB（建议至少预留 40 GB）
echo.

rem 查找 Python 启动器
set "PY="
where py >nul 2>nul && set "PY=py"
if not defined PY (
    where python >nul 2>nul && set "PY=python"
)
if not defined PY (
    echo [错误] 未找到 Python。请先安装 Python 3.9 或更高版本，并勾选 Add Python to PATH。
    pause
    exit /b 1
)

rem 安装或更新 Hugging Face 官方 CLI
 echo [1/3] 安装/更新 huggingface_hub...
%PY% -m pip install -U huggingface_hub
if errorlevel 1 goto :ERROR

rem 定位 hf.exe，避免 Python Scripts 目录未加入 PATH
set "PY_EXE="
set "PY_DIR="
for /f "delims=" %%I in ('%PY% -c "import sys; print(sys.executable)"') do set "PY_EXE=%%I"
for %%I in ("%PY_EXE%") do set "PY_DIR=%%~dpI"
set "PY_SCRIPTS=%PY_DIR%Scripts"
set "HFCLI=hf"
if defined PY_SCRIPTS if exist "%PY_SCRIPTS%\hf.exe" set "HFCLI=%PY_SCRIPTS%\hf.exe"

if not exist "%MODEL_DIR%" mkdir "%MODEL_DIR%"
if not exist "%MODEL_DIR%" (
    echo [错误] 无法创建下载目录：%MODEL_DIR%
    goto :ERROR
)

 echo.
echo [2/3] 开始下载模型分片...
echo 注意：Q4_K_M 被拆成两个文件，两个分片都必须下载才能加载模型。
echo.
call :DOWNLOAD_FILES
if errorlevel 1 (
    echo.
    echo [提示] 首次下载失败，尝试关闭 Xet，改用普通 HTTP 方式重试。
    echo 如果是网络中断，hf 会复用已下载的文件/缓存；请勿删除下载目录。
    set "HF_HUB_DISABLE_XET=1"
    call :DOWNLOAD_FILES
)
if errorlevel 1 goto :ERROR

 echo.
echo [3/3] 检查下载文件...
if not exist "%MODEL_DIR%\UD-Q4_K_M\Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf" (
    echo [错误] 缺少第 1 分片。
    goto :ERROR
)
if not exist "%MODEL_DIR%\UD-Q4_K_M\Qwen4-35B-A3B-UD-Q4_K_M-00002-of-00002.gguf" (
    echo [错误] 缺少第 2 分片。
    goto :ERROR
)
if "%DOWNLOAD_MMPROJ%"=="1" if not exist "%MODEL_DIR%\mmproj-F16.gguf" (
    echo [错误] 视觉投影文件 mmproj-F16.gguf 未下载完整。
    goto :ERROR
)

echo.
echo ============================================================
echo 下载完成！
echo 模型目录：%MODEL_DIR%
echo ============================================================
echo.
echo 文本模型主文件：
echo %MODEL_DIR%\UD-Q4_K_M\Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf
if "%DOWNLOAD_MMPROJ%"=="1" echo 视觉文件：%MODEL_DIR%\mmproj-F16.gguf
echo.
pause
exit /b 0

:DOWNLOAD_FILES
if "%DOWNLOAD_MMPROJ%"=="1" (
    call "%HFCLI%" download "%REPO%" "%FILE1%" "%FILE2%" "mmproj-F16.gguf" --local-dir "%MODEL_DIR%" --max-workers 2
) else (
    call "%HFCLI%" download "%REPO%" "%FILE1%" "%FILE2%" --local-dir "%MODEL_DIR%" --max-workers 2
)
exit /b %errorlevel%

:ERROR
echo.
echo [失败] 下载未完成。保留当前目录后重新运行本 BAT，可继续尝试。
echo 若提示磁盘空间不足，请至少预留 40 GB。
pause
exit /b 1

```
