
OrionStar-Yi-34B-Chat-Llama[1] 基于开源的 Yi-34B 模型。OrionStar 团队在海量的中/英文语料库上进行了微调,以提供出色的交互式用户体验。Yi系列以基准性能著称,OrionStar的进一步微调将其进行了提升。尽管适用某些协议和 Yi 许可证,但它可以免费用于学术研究。
本文中,我们将介绍:
在自己的设备上运行 OrionStar-Yi-34B-Chat-Llama
为 OrionStar-Yi-34B-Chat-Llama 大模型创建一个与 OpenAI 兼容的 API 服务
我们将使用 LlamaEdge[2](Rust + Wasm 技术栈)开发和部署此模型的应用程序。不需要安装复杂的 Python 包或 C++ 工具链!了解我们选择这个技术栈的原因。[3]
步骤1:通过以下命令行安装 WasmEdge[4]。
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --plugin wasi_nn-ggml
步骤2:下载 OrionStar-Yi-34B-Chat-Llama model GGUF[5] 文件。由于模型的大小为 24.3 GB,下载可能需要一定时间。
curl -LO https://huggingface.co/second-state/OrionStar-Yi-34B-Chat-Llama-GGUF/resolve/main/OrionStar-Yi-34B-Chat-Llama-Q5_K_M.gguf
步骤 3:下载聊天应用程序的跨平台可移植 Wasm 文件。该应用程序让你能用命令行与模型聊天。该应用程序的Rust 源代码在这里[6]。
curl -LO https://github.com/second-state/LlamaEdge/releases/latest/download/llama-chat.wasm
完成啦!可以通过输入以下命令在终端与模型进行聊天。
wasmedge --dir .:. --nn-preload default:GGML:AUTO:OrionStar-Yi-34B-Chat-Llama-Q5_K_M.gguf llama-chat.wasm -p human-assistant
该可移植 Wasm 应用程序会自动利用设备上的硬件加速器(如 GPU)。
[You]:
春节都有什么习俗?
[Bot]:
贴春联、贴窗花和倒福、放鞭炮、吃团圆饭,给压岁钱等。
[You]:
你能写一个针对龙年的春联吗?
[Bot]:
可以的。上联:龙腾虎跃人间景,下联:凤舞燕飞天下春。横批:龙年大吉。
与 OpenAI 兼容的 Web API 让该模型可与不同的 LLM 工具和代理框架(如 flows.network、LangChain 、LlamaIndex 等)一起工作。
下载一个 API 服务器应用程序。它也是一个跨平台可移植的 Wasm 应用程序,可以在各种不同 CPU 和 GPU 设备上运行。戳此查看该 app 的 Rust 源代码。[7]
curl -LO https://github.com/second-state/LlamaEdge/releases/latest/download/llama-api-server.wasm
然后,下载聊天机器人 Web UI,以通过聊天机器人 UI 与模型进行交互。
curl -LO https://github.com/second-state/LlamaEdge/releases/latest/download/llama-api-server.wasm
curl -LO https://github.com/second-state/chatbot-ui/releases/latest/download/chatbot-ui.tar.gz
tar xzf chatbot-ui.tar.gz
rm chatbot-ui.tar.gz
接下来,使用以下命令行启动模型的 API 服务器。然后,用浏览器访问 http://localhost:8080[8] 就能开始聊天了。
wasmedge --dir .:. --nn-preload default:GGML:AUTO:OrionStar-Yi-34B-Chat-Llama-Q5_K_M.gguf llama-api-server.wasm -p human-assistant
还可以从另一个终端使用 curl 与 API 服务器交互。
curl -X POST http://localhost:8080/v1/chat/completions \
-H 'accept:application/json' \
-H 'Content-Type: application/json' \
-d '{"messages":[{"role":"system", "content": "You are a sentient, superintelligent artificial general intelligence, here to teach and assist me."}, {"role":"user", "content": "Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world."}], "model":"OrionStar-Yi-34B-Chat-Llama"}'
就这样。WasmEdge 是运行 LLM 应用程序最简单、最快速、最安全的方式[9]。尝试一下吧!
加入 WasmEdge Discord[10]和小伙伴们一起讨论。如果对运行这个模型有任何疑问,请访问 second-state/llamaedge[11] 提 issue,或预约 demo[12]。
参考资料
[1]
OrionStar-Yi-34B-Chat-Llama: https://huggingface.co/OrionStarAI/OrionStar-Yi-34B-Chat-Llama
[2]
LlamaEdge: https://github.com/second-state/LlamaEdge/
[3]
了解我们选择这个技术栈的原因。: https://www.secondstate.io/articles/fast-llm-inference/
[4]
WasmEdge: https://github.com/WasmEdge/WasmEdge
[5]
OrionStar-Yi-34B-Chat-Llama model GGUF: https://huggingface.co/second-state/OrionStar-Yi-34B-Chat-Llama-GGUF
[6]
Rust 源代码在这里: https://github.com/second-state/llama-utils/tree/main/chat
[7]
戳此查看该 app 的 Rust 源代码。: https://github.com/second-state/llama-utils/tree/main/api-server
[8]
http://localhost:8080: http://localhost:8080/
[9]
运行 LLM 应用程序最简单、最快速、最安全的方式: https://www.secondstate.io/articles/fast-llm-inference/
[10]
加入 WasmEdge Discord: https://discord.com/invite/U4B5sFTkFc
[11]
second-state/llamaedge: https://github.com/second-state/LlamaEdge
[12]
demo: https://code.flows.network/webhook/vvAtEBUk6QMhVVLuw7IU
关于 WasmEdge
WasmEdge 是轻量级、安全、高性能、可扩展、兼容OCI的软件容器与运行环境。目前是 CNCF 沙箱项目。WasmEdge 被应用在 SaaS、云原生,service mesh、边缘计算、边缘云、微服务、流数据处理、LLM 推理等领域。
GitHub:https://github.com/WasmEdge/WasmEdge
官网:https://wasmedge.org/
Discord 群:https://discord.gg/U4B5sFTkFc
文档:https://wasmedge.org/docs