u1jodi1q 发表于 2024-8-22 13:57:45

告别 OpenAI,一个命令行跨平台运行开源百川大模型 Baichuan2-13B-Chat


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想要快速<span style="color: black;">起始</span>,只需在自己的设备上运行下面的命令行<span style="color: black;">就可</span>与 Baichuan2-13B-Chat 交互。这个命令行工具会自动下载并安装 WasmEdge 运行时、模型文件和用于推理的完全可移植 Wasm 应用。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">bash &lt;(curl -sSfL https://code.flows.network/webhook/iwYN1SdN3AmPgR5ao5Gt/run-llm.sh)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Baichuan2-13B-Chat 大模型</span><span style="color: black;">是由于</span>百川智能<span style="color: black;">研发</span>的 13B 大语言模型(LLM),其灵感来自于离线强化学习。据百川团队<span style="color: black;">叫作</span>,这种<span style="color: black;">办法</span><span style="color: black;">准许</span>模型在<span style="color: black;">无</span>偏好标签的<span style="color: black;">状况</span>下从混合质量的数据中学习,使其能够<span style="color: black;">供给</span><span style="color: black;">乃至</span><span style="color: black;">能够</span>与<span style="color: black;">繁杂</span>的 ChatGPT 模型相媲美的卓越性能。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">本文中,<span style="color: black;">咱们</span>将介绍:</p><span style="color: black;">怎样</span>在自己的设备上运行 &nbsp;Baichuan2-13B-Chat 大模型<span style="color: black;">怎样</span>为 Baichuan2-13B-Chat 大模型创建一个与 OpenAI 兼容的 API 服务<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span>将<span style="color: black;">运用</span> Rust + Wasm 技术栈<span style="color: black;">研发</span>和<span style="color: black;">安排</span>此模型的应用程序。不需要安装<span style="color: black;">繁杂</span>的 Python 包或 C++ 工具链!<span style="color: black;"><span style="color: black;">认识</span><span style="color: black;">咱们</span><span style="color: black;">选取</span>这个技术栈的<span style="color: black;">原由</span></span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/3rGIVvYeu4CLZg0DIULxsIAvT636oSfnxbDSnpmHz96C3H4odr958d22W5Vibgicib7hRPd4VpqcqQ3rcalLp5TuQ/640?wx_fmt=png&amp;from=appmsg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">在自己的设备上运行 Baichuan2-13B-Chat 大模型</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">过程</span>1:<span style="color: black;">经过</span>以下命令行安装 <span style="color: black;">WasmEdge</span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-sSf&nbsp;https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh&nbsp;|&nbsp;bash&nbsp;-s&nbsp;--&nbsp;--plugin&nbsp;wasi_nn-ggml</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">过程</span>2:下载该模型的<span style="color: black;">GGUF 文件</span>。<span style="color: black;">因为</span>模型的<span style="color: black;">体积</span>为几个 GB,下载可能需要一<span style="color: black;">按时</span>间。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-LO&nbsp;https://huggingface.co/second-state/Baichuan2-13B-Chat-GGUF/resolve/main/Baichuan2-13B-Chat-ggml-model-q4_0.gguf</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">过程</span> 3:下载聊天应用程序的跨平台可移植 Wasm 文件。该应用程序让你能用命令行与模型聊天。该应用程序的<span style="color: black;">Rust 源代码在<span style="color: black;">这儿</span></span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-LO&nbsp;https://github.com/second-state/LlamaEdge/releases/latest/download/llama-chat.wasm</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">完成啦!<span style="color: black;">能够</span><span style="color: black;">经过</span>输入以下命令在终端与模型进行聊天。</p>wasmedge&nbsp;--dir&nbsp;.:.&nbsp;--nn-preload&nbsp;default:GGML:AUTO:Baichuan2-13B-Chat-ggml-model-q4_0.gguf&nbsp;llama-chat.wasm&nbsp;-p&nbsp;baichuan-2&nbsp;-r<span style="color: black;">用户:</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">可移植 Wasm 应用程序会自动利用我设备上的硬件加速器(如 GPU)。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在我 M1 32G 内存的 Mac 上,速度约为每秒 7.85 个 token。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">:一个苹果5元钱,2个苹果多少钱?</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">:两个苹果需要支付10元钱。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">:</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">为百川大模型创建与 OpenAI 兼容的 API 服务</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">与 OpenAI 兼容的 Web API 让该模型可与<span style="color: black;">区别</span>的 LLM 工具和代理框架(如 flows.network、LangChain 、LlamaIndex 等)<span style="color: black;">一块</span>工作。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载一个 API 服务器应用程序。它<span style="color: black;">亦</span>是一个跨平台可移植的 Wasm 应用程序,<span style="color: black;">能够</span>在<span style="color: black;">各样</span><span style="color: black;">区别</span> CPU 和 GPU 设备上运行。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-LO&nbsp;https://github.com/second-state/LlamaEdge/releases/latest/download/llama-api-server.wasm</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而后</span>,下载聊天<span style="color: black;">设备</span>人 Web UI,以<span style="color: black;">经过</span>聊天<span style="color: black;">设备</span>人 UI 与模型进行交互。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-LO&nbsp;https://github.com/second-state/chatbot-ui/releases/download/v0.1.0/chatbot-ui.tar.gz</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">tar&nbsp;xzf&nbsp;chatbot-ui.tar.gz</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">rm&nbsp;chatbot-ui.tar.gz</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">接下来,<span style="color: black;">运用</span>以下命令行<span style="color: black;">起步</span>模型的 API 服务器。<span style="color: black;">而后</span>,打开浏览器<span style="color: black;">拜访</span> <span style="color: black;">起始</span>聊天!</p>wasmedge&nbsp;--dir&nbsp;.:.&nbsp;--nn-preload&nbsp;default:GGML:AUTO:Baichuan2-13B-Chat-ggml-model-q4_0.gguf&nbsp;llama-api-server.wasm&nbsp;-p&nbsp;baichuan-2&nbsp;-r<span style="color: black;">用户:</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">还<span style="color: black;">能够</span>从另一个终端<span style="color: black;">运用</span> curl 与 API 服务器交互。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">curl&nbsp;-X&nbsp;POST&nbsp;http://localhost:8080/v1/chat/completions&nbsp;\</p>&nbsp;&nbsp;-H&nbsp;<span style="color: black;">accept:application/json</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;\</p>&nbsp;&nbsp;-H&nbsp;<span style="color: black;">Content-Type:&nbsp;application/json</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;\</p>&nbsp;&nbsp;-d&nbsp;<span style="color: black;">{"messages":[{"role":"system",&nbsp;"content":&nbsp;"You&nbsp;are&nbsp;a&nbsp;helpful&nbsp;assistant."},&nbsp;{"role":"user",&nbsp;"content":&nbsp;"李白是谁"}],&nbsp;"model":"Baichuan2-13B-Chat"}</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">就<span style="color: black;">这般</span>。WasmEdge 是<span style="color: black;">运行 LLM 应用程序最简单、最快速、最安全的方式</span>。尝试一下吧!</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">加入 <span style="color: black;">WasmEdge Discord</span> 提问和分享见解。<span style="color: black;">倘若</span>在运行这个模型时有任何问题,请<span style="color: black;">拜访</span> <span style="color: black;">second-state/LlamaEdge</span> 提 issue,或预约 <span style="color: black;">demo</span>。</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">参考资料</span></h3><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Baichuan2-13B-Chat 大模型: https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">认识</span><span style="color: black;">咱们</span><span style="color: black;">选取</span>这个技术栈的<span style="color: black;">原由</span>: https://www.secondstate.io/articles/fast-llm-inference/</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">WasmEdge: https://github.com/WasmEdge/WasmEdge</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">GGUF 文件: https://huggingface.co/second-state/Baichuan2-13B-Chat-GGUF/tree/main</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Rust 源代码在<span style="color: black;">这儿</span>: https://github.com/second-state/llama-utils/tree/main/chat</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">运行 LLM 应用程序最简单、最快速、最安全的方式: https://www.secondstate.io/articles/fast-llm-inference/</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">WasmEdge Discord: https://discord.com/invite/U4B5sFTkFc</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">second-state/LlamaEdge: https://github.com/second-state/LlamaEdge/</p>
    </span><span style="color: black;"><span style="color: black;"></span>
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">demo: https://code.flows.network/webhook/vvAtEBUk6QMhVVLuw7IU</p>
    </span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">关于 WasmEdge</span></strong></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">WasmEdge 是轻量级、安全、高性能、可扩展、兼容OCI的软件容器与运行环境。<span style="color: black;">日前</span>是 CNCF 沙箱项目。WasmEdge 被应用在 SaaS、云原生,service mesh、边缘计算、边缘云、微服务、流数据处理、LLM 推理等<span style="color: black;">行业</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">GitHub</span></strong><span style="color: black;">:https://github.com/WasmEdge/WasmEdge</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">官网</span></strong><span style="color: black;">:https://wasmedge.org/</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">‍‍Discord&nbsp;</span><strong style="color: blue;"><span style="color: black;">群:</span></strong><span style="color: black;">https://discord.gg/U4B5sFTkFc</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">文档</span></strong><span style="color: black;">:https://wasmedge.org/docs</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">文案</span>转载自<span style="color: black;">Second State</span>。</span><a style="color: black;"><span style="color: black;">点击<span style="color: black;">这儿</span>阅读原文<span style="color: black;">认识</span><span style="color: black;">更加多</span></span></a><span style="color: black;">。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/GpkQxibjhkJyxMiaEmkhpdPs5vYIH2rJiaOZP88GAQr4tcseIibcdgBlWCFiaiaZ16kNG7iaepO9g28z6Jic0h9CGh2PTg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">CNCF概况(幻灯片)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/GpkQxibjhkJxyapkOjiazruKNQ7DZ6t8TSh0QSYM4DlI86xnXiayciayIgBUaG8q8lFZ3FsibPJiaeCqAahrKicB220aA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">扫描二维码联系<span style="color: black;">咱们</span>!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">CNCF (Cloud Native Computing Foundation)成立于2015年12月,隶属于Linux &nbsp;Foundation,是非营利性组织。&nbsp;</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><strong style="color: blue;">CNCF</strong></strong><strong style="color: blue;">(</strong><strong style="color: blue;"><strong style="color: blue;">云原生计算基金会</strong>)致力于培育和<span style="color: black;">守护</span>一个厂商中立的开源生态系统,来推广云原生技术。<span style="color: black;">咱们</span><span style="color: black;">经过</span>将最前沿的模式民主化,让这些创新为<span style="color: black;">公众</span>所用。请关注CNCF<span style="color: black;">微X</span>公众号。</strong></span></p>




qzmjef 发表于 2024-10-12 20:08:31

哈哈、笑死我了、太搞笑了吧等。

nykek5i 发表于 2024-11-9 17:51:49

你的见解独到,让我受益匪浅,非常感谢。
页: [1]
查看完整版本: 告别 OpenAI,一个命令行跨平台运行开源百川大模型 Baichuan2-13B-Chat