微信扫码
与创始人交个朋友
我要投稿
谷歌最近发布了9B和27B大小的 Gemma 2模型[1],这是其 Gemma 模型系列的最新型号。根据其技术报告,未来几天将开源一个 Gemma-2-2b 模型。技术报告还显示,Gemma-2-9B模型在多个基准测试中的表现超过了 Mistral-7B、Llama-3-8B和 Gemma 1.5模型。
如果想一键在你的计算机上运行 Gemma-9b-Chat,可以在终端中运行以下命令
bash <(curl -sSfL 'https://raw.githubusercontent.com/LlamaEdge/LlamaEdge/main/run-llm.sh') —model gemma-2-9b-it
本文将以 Gemma-2-9B 为例,手把手教你轻松
我们将使用 LlamaEdge[2] (Rust + Wasm技术栈)开发并部署该模型的应用。无需安装复杂的 Python 包或 C++ 工具链!了解我们为什么选择 Rust + Wasm[3]。
在你自己的设备上运行 Gemma-2-9B第一步:用下面的命令行安装 WasmEdge[4].
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install_v2.sh | bash -s -- -v 0.13.5
第二步:下载 Gemma-2-9B-it model GGUF 模型[5]文件。模型有6.40 GB,所以下载可能需要一定时间
curl -LO https://huggingface.co/second-state/gemma-2-9b-it-GGUF/resolve/main/gemma-2-9b-it-Q5_K_M.gguf
第三步:下载一个跨平台的可移植 Wasm 文件,是个聊天应用。该应用让你能在命令行中与模型聊天。该应用的 Rust 源代码戳这里[6]。
curl -LO https://github.com/LlamaEdge/LlamaEdge/releases/latest/download/llama-chat.wasm
就是这样。可以通过输入以下命令在终端与模型聊天。
wasmedge --dir .:. --nn-preload default:GGML:AUTO:gemma-2-9b-it-Q5_K_M.gguf llama-chat.wasm -p gemma-instruct -c 4096
这个可移植的Wasm应用会自动利用设备上的硬件加速器(例如GPU)。
[You]:
Tell me what is gemma?
[Bot]:
Gemma is an open-weights AI assistant developed by Google DeepMind.
Here are some key things to know about Gemma:
* **Open Weights:** This means the underlying code and model weights are freely accessible to the public. Anyone can inspect, modify, or build upon Gemma.
* **Text-Only:** Gemma is designed primarily for text-based interactions. It can understand and generate human-like text but doesn't have capabilities like image recognition or voice synthesis.
* **Focus on Research & Development:** Gemma is intended as a tool for researchers and developers to explore and experiment with different AI models and techniques.
**Why is Gemma significant?**
* **Transparency and Collaboration:** Open-weights nature promotes transparency in AI development and encourages collaboration among researchers worldwide.
* **Customization:** Users can adapt Gemma to their specific needs by fine-tuning it on their own datasets.
* **Accessibility:** Makes advanced AI technology accessible to a wider range of individuals and organizations, beyond those with large resources.
**Keep in mind:**
* Gemma is still under development and may have limitations compared to more mature, closed-source models.
* Its capabilities are primarily focused on text processing.
一个兼容 OpenAI 的API 使得 Llama-3-8B-Chinese 能够与不同的开发框架和工具无缝集成,比如 flows.network[8], LangChain and LlamaIndex等等,提供更广泛的应用可能。大家也可以参考其代码自己写自己的API服务器或者其它大模型应用。想要启动 API 服务,请按以下步骤操作:下载这个 API 服务器应用。它是一个跨平台的可移植 Wasm 应用,可以在各种 CPU 和 GPU 设备上运行。
curl -LO https://github.com/LlamaEdge/LlamaEdge/releases/latest/download/llama-api-server.wasm
然后,下载聊天机器人 Web UI,从而通过聊天机器人 UI 与模型进行交互。
curl -LO https://github.com/LlamaEdge/chatbot-ui/releases/latest/download/chatbot-ui.tar.gz
tar xzf chatbot-ui.tar.gz
rm chatbot-ui.tar.gz
接下来,使用以下命令行启动模型的 API 服务器。然后,打开浏览器访问 http://localhost:8080[9] 开始聊天!
wasmedge --dir .:. --nn-preload default:GGML:AUTO:gemma-2b-it-Q5_K_M.gguf llama-api-server.wasm -p gemma-instruct -c 4096
另外打开一个终端窗口, 可以使用 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":"Gemma-2b-it"}'
就是这样啦。WasmEdge 是运行 LLM 应用最简单、最快、最安全的方式[10]。快来试试看吧!
9B和27B大小的Gemma 2模型: https://ai.google.dev/gemma/docs
[2]Image: image.png]我们将使用 [LlamaEdge: https://github.com/second-state/LlamaEdge/
[3]了解我们为什么选择 Rust + Wasm: https://www.secondstate.io/articles/fast-llm-inference/
[4]WasmEdge: https://github.com/WasmEdge/WasmEdge
[5]Gemma-2-9B-it model GGUF 模型: https://huggingface.co/second-state/gemma-2-9b-it-GGUF
[6]这里: https://github.com/second-state/llama-utils/tree/main/chat
[7]Gemma-2-9b-it: https://www.secondstate.io/articles/gemma-2-9b/#create-an-openai-compatible-api-service-for-gemma-2-9b-it
[8]flows.network: https://flows.network/
[9]http://localhost:8080: http://localhost:8080/
[10]运行 LLM 应用最简单、最快、最安全的方式: https://www.secondstate.io/articles/fast-llm-inference/
关于 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
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-07-07
2024-06-24
2024-06-06
2024-04-02
2024-04-27
2024-04-02
2024-05-08
2024-05-04
2024-04-19
2024-05-15