Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.83 KB

File metadata and controls

66 lines (47 loc) · 1.83 KB

Huggingface

模型下载

安装 huggingface_hub

pip install huggingface_hub hf-transfer
# uv add --dev huggingface_hub hf-transfer

设置环境变量

export HF_ENDPOINT=https://hf-mirror.com
export HF_HUB_ENABLE_HF_TRANSFER=1

下载模型

hf download Qwen/Qwen3-Embedding-0.6B-GGUF --include Qwen3-Embedding-0.6B-Q8_0.gguf
# 下载 Qwen3-Embedding-4B-Q4_K_M.gguf
#hf download Qwen/Qwen3-Embedding-4B-GGUF --include Qwen3-Embedding-4B-Q4_K_M.gguf

创建 Ollama 模型

Qwen3-Embedding-4B-Q4_K_M.gguf 相同目录创建 Modelfile 文件,内容如下:

# 模型文件路径(与 Modelfile 同目录)
FROM Qwen3-Embedding-4B-Q4_K_M.gguf

目录路径示例: /Users/yangjing/.cache/huggingface/hub/models--Qwen--Qwen3-Embedding-4B-GGUF/snapshots/f4602530db1d980e16da9d7d3a70294cf5c190be

通过 ollama create 命令创建并导入模型:

#ollama create Qwen/Qwen3-Embedding-0.6B -f Modelfile
ollama create Qwen/Qwen3-Embedding-4B -f Modelfile

测试嵌入模型:

curl http://localhost:11434/api/embed \
  -X POST \
  -d '{
        "model": "Qwen/Qwen3-Embedding-4B",
        "input": ["The quick brown fox jumps over the lazy dog."]
      }'

huggingface-cli 下载的模型路径类似如下:/Users/yangjing/.cache/huggingface/hub/models--Qwen--Qwen3-Embedding-0.6B-GGUF/snapshots/370f27d7550e0def9b39c1f16d3fbaa13aa67728

使用 llama.cpp

docker pull ghcr.io/ggml-org/llama.cpp:server
docker run -d --name=llama-cpp-server -v $HOME/.cache/huggingface/hub:/cache -p 8888:8888 ghcr.io/ggml-org/llama.cpp:server -m /cache/models--Qwen--Qwen3-Embedding-0.6B-GGUF/snapshots/370f27d7550e0def9b39c1f16d3fbaa13aa67728/Qwen3-Embedding-0.6B-Q8_0.gguf --embeddings --pooling mean --port 8888 --host 0.0.0.0 -n 32768