相信許多人和我一樣,最初接觸 AI 時(shí)也是從Ollama開(kāi)始的,Ollama 之所以這么出色,是因?yàn)樗褂昧?GGML 格式(這是一種'輕量版’的大語(yǔ)言模型,以較低精度運(yùn)行,能夠輕松適配普通硬件),而且它足夠的簡(jiǎn)單,類似于Docker,只需要簡(jiǎn)單的命令就可以拉取鏡像,運(yùn)行鏡像,甚至有Modelfile文件來(lái)自行設(shè)定大模型。
以前不支持Huggingface時(shí),我們需要自行下載GGUF格式大模型,然后根據(jù)Modelfile來(lái)自定義構(gòu)建,很是不方便。
現(xiàn)在,它終于得來(lái)了,它終于支持了Huggingface上的GGUF格式模型了,大約45K個(gè)GGUF模型,隨便你用,而不在局限于它本身的Models列表了,也不用創(chuàng)建Modelfile文件了,這次的步子邁的有點(diǎn)大了。
你需要做的只是一條命令:
1
ollama run hf.co/{username}/{reponame}:latest
例如運(yùn)行: Qwen 2.5 1.5B GGUF大模型:
地址:
https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF
https://hf-mirror.com/Qwen/Qwen2.5-1.5B-Instruct-GGUF
1
2
3
4
5
6
ollama run hf.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF:latest
#或者
ollama run huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF:latest
# 注意
# :latest 可以不加,不加默認(rèn)就是:latest
當(dāng)然這需要有魔法的,對(duì)于國(guó)內(nèi)用戶,請(qǐng)執(zhí)行:
1
ollama run hf-mirror.com/Qwen/Qwen2.5-1.5B-Instruct-GGUF
如果指定了 :latest 或沒(méi)有指定 :latest,默認(rèn)情況下,當(dāng)Q4_K_M量化方案存在于模型存儲(chǔ)庫(kù)中時(shí),將使用該方案。如果沒(méi)有,我們默認(rèn)選擇存儲(chǔ)庫(kù)中存在的一種合理的量化類型。
當(dāng)然如果你想要拉取某個(gè)自定義量化的,只需要添加一個(gè)標(biāo)簽:
1
2
3
4
5
ollama run hf.co/{username}/{repository}:{quantization}
# 或
ollama run huggingface.co/{username}/{repository}:{quantization}
# 國(guó)內(nèi)
ollama run hf-mirror.com/{username}/{repository}:{quantization}
例如上面的:Qwen 2.5 1.5B GGUF大模型
1
ollama run hf-mirror.com/Qwen/Qwen2.5-1.5B-Instruct-GGUF:q4_0
咋樣,是不是感覺(jué)可以把 ollama 的注冊(cè)表 models 丟進(jìn)垃圾箱了。
你不能使用ollama直接加載本地存在的GGUF文件,即使你是從HF拉取的模型文件,因?yàn)閛llama會(huì)重命名為哈希字符串,這意味著你只能重新拉取而不能使用你以前下載下來(lái)的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 格式
ollama run hf.co/{username}/{reponame}:latest
# 示例:
ollama run hf.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF:latest
# 或者
ollama run huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF:latest
# 國(guó)內(nèi)
ollama run hf-mirror.com/Qwen/Qwen2.5-1.5B-Instruct-GGUF
# 自定義量化
# 格式
ollama run hf.co/{username}/{reponame}:{quantization}
ollama run hf-mirror.com/{username}/{repository}:{quantization}
# 國(guó)內(nèi)
ollama run hf-mirror.com/Qwen/Qwen2.5-1.5B-Instruct-GGUF:q4_0
聯(lián)系客服