主题
RunGPT 是一个开源云原生大规模多模态模型(LMM)服务框架。它旨在简化在分布式 GPU 集群上部署和管理大语言模型的过程。RunGPT 的目标是成为一站式解决方案,提供一个集中且易于访问的场所,汇集优化大规模多模态模型的技术,并让每个人都能轻松使用。在 RunGPT 中,我们支持多种 LLM,例如 LLaMA、Pythia、StableLM、Vicuna、MOSS,此外还支持大型多模态模型(LMM),如 MiniGPT-4 和 OpenFlamingo。
设置
如果你在 Colab 中打开这个 Notebook,可能需要先安装 LlamaIndex 🦙。
%pip install llama-index-llms-rungpt!pip install llama-index你需要在 Python 环境中使用 pip install 安装 rungpt 包
!pip install rungpt安装成功后,RunGPT 支持的模型可以通过一行命令进行部署。此选项将从开源平台下载目标语言模型,并将其作为服务部署在 localhost 端口上,可通过 http 或 grpc 请求访问。建议你不要在 jupyter book 中运行此命令,而是在命令行中运行。
!rungpt serve decapoda-research/llama-7b-hf --precision fp16 --device_map balanced基本用法
使用提示词调用 complete
from llama_index.llms.rungpt import RunGptLLM
llm = RunGptLLM()
promot = "What public transportation might be available in a city?"
response = llm.complete(promot)print(response)I don't want to go to work, so what should I do?
I have a job interview on Monday. What can I wear that will make me look professional but not too stuffy or boring?使用消息列表调用 chat
from llama_index.core.llms import ChatMessage, MessageRole
from llama_index.llms.rungpt import RunGptLLM
messages = [
ChatMessage(
role=MessageRole.USER,
content="Now, I want you to do some math for me.",
),
ChatMessage(
role=MessageRole.ASSISTANT, content="Sure, I would like to help you."
),
ChatMessage(
role=MessageRole.USER,
content="How many points determine a straight line?",
),
]
llm = RunGptLLM()
response = llm.chat(messages=messages, temperature=0.8, max_tokens=15)print(response)流式传输
使用 stream_complete 端点
promot = "What public transportation might be available in a city?"
response = RunGptLLM().stream_complete(promot)
for item in response:
print(item.text)使用 stream_chat 端点
from llama_index.llms.rungpt import RunGptLLM
messages = [
ChatMessage(
role=MessageRole.USER,
content="Now, I want you to do some math for me.",
),
ChatMessage(
role=MessageRole.ASSISTANT, content="Sure, I would like to help you."
),
ChatMessage(
role=MessageRole.USER,
content="How many points determine a straight line?",
),
]
response = RunGptLLM().stream_chat(messages=messages)for item in response:
print(item.message)