Tabby 一:如何在Mac配置保姆级教程(本地模型替换hugging face下载)
1. brew安装
mac需要先安装brew,如果本地已经安装过brew这一步可以忽略,遇到问题可以自己ai问
/bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
可能遇到source .zprofile失败,因为默认文件不可见,需要在文件夹下让文件可见,权限问题chmod解决。
2. tabby安装
brew install tabbyml/tabby/tabby
3. 启动服务
官方给的命令如下:无法科学上网的话,这条命令大概率会失败
tabby serve --device metal --model StarCoder-1B --chat-model Qwen2-1.5B-Instruct
错误1:
Library not loaded: /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib
Referenced from: <E16908F1-ECA2-3D1D-8113-B7760B8E3425> /opt/homebrew/Cellar/tabby/0.26.0/bin/tabby
Reason: tried: '/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib' (no such file), '/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib' (no such file)
解决方法:安装openssl@3
brew install openssl@3
ln -s /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib /usr/local/lib/
错误2:
Writing to new file.
File exists. Resuming.
File exists. Resuming.
The application panicked (crashed).
Message: Failed to fetch model 'StarCoder-1B' due to 'Fetching 'https://huggingface.co/TabbyML/models/resolve/main/starcoderbase-1B.Q8_0.gguf' failed: Server returned error sending request for url (https://huggingface.co/TabbyML/models/resolve/main/starcoderbase-1B.Q8_0.gguf) HTTP status'
Location: /Users/runner/work/tabby/tabby/crates/tabby-download/src/lib.rs:210
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
解决办法:
这个是最难解决的,如果实在无法科学上网,这种方法可以替代
从这个魔塔社区找自己想要使用的模型(前提是自己的电脑能跑的起来),选择适合自己的配置的模型,查找对应的gguf后缀的模型
下载下来之后重命名为这种格式model-00001-of-00001.gguf(一定要重命名,有具体含义的,可以找AI问下,跟切片相关的),然后放到以下目录:/<your tabby目录>/TabbyML/<tabby.json中命名的模型名一致>/ggml/model-00001-of-00001.gguf
比如我下载下来的是deepseek-coder-6.7b-base.Q4_K_M.gguf,我的ggml的上一层目录命名为DeepseekCoder-6.7B,然后修改tabby.json中的name与之对应。
我还下载了一个模型:qwen2.5-3b-instruct-q4_k_m.gguf作为chat-model,配置如下
差点忘了,还有一个关键的:embed-text模型也要下载下来,gguf文件同样修改命名方式放到ggml目录即可(一般直接搜索名称有可能很难找到gguf的文件,后面加上-gguf搜索,比如Nomic-Embed-Text-gguf,可以直接找到这样的文件,记得是切换到模型文件才能看到哈)
启动参数需要修改的几个点:
1. --model参数,改成本地目录到TabbyML的下一级目录,比如:DeepseekCoder-6.7B
2. --chat-model参数,改成本地目录到TabbyML的下一级目录,比如:qwen2.5-3b-instruct
3. tabby.json文件修改
参考:
{
"prompt_template": "<PRE>{prefix}<SUF>{suffix}<MID>",
"chat_template": "<s>{% for message in messages %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + '</s> ' }}{% endif %}{% endfor %}",
}
启动命令如下:
tabby serve --device metal --model /Users/xxx/.tabby/models/TabbyML/DeepseekCoder-6.7B --chat-model /Users/xx/.tabby/models/TabbyML/qwen2.5-3b-instruct
终于启动成功了,具体使用我后续再写一个,据说可以把自己的代码离线运用起来