新建
10分钟快速搭建自己的LLAMA3 8B 服务器

01

推荐镜像 :ollama:llama3
推荐机型 :c8_m31_1 * NVIDIA T4
赞 2
2
2
目录
Llama 3
迄今为止功能最强大的公开可用大型语言模型。

Meta Llama 3是一组由Meta公司开发的模型家族,它们采用了最新的技术,提供了8B和70B参数规模(预训练或指令调优)的版本。
Llama 3指令调优模型经过精细调整和优化,专为对话/聊天场景设计,在常见基准测试中表现优于许多现有的开源聊天模型。


代码
文本
代码
文本
[1]
# !curl -fsSL https://ollama.com/install.sh | sh
代码
文本
运行ollama的服务端
代码
文本
[1]
%%bash
nohup ollama serve > nohup.out 2>&1 &
代码
文本
运行下面的脚本就可以愉快的和llama3对话啦🤩
代码
文本
[2]
import json
import requests
# NOTE: ollama must be running for this to work, start the ollama app or run `ollama serve`
model = "llama3" # TODO: update this for whatever model you wish to use
def chat(messages):
r = requests.post(
"http://0.0.0.0:11434/api/chat",
json={"model": model, "messages": messages, "stream": True},
)
r.raise_for_status()
output = ""
for line in r.iter_lines():
body = json.loads(line)
if "error" in body:
raise Exception(body["error"])
if body.get("done") is False:
message = body.get("message", "")
content = message.get("content", "")
output += content
# the response streams one token at a time, print that as we receive it
print(content, end="", flush=True)
if body.get("done", False):
message["content"] = output
return message
def main():
messages = []
while True:
user_input = input("Enter a prompt: ")
if not user_input:
exit()
print()
messages.append({"role": "user", "content": user_input})
message = chat(messages)
messages.append(message)
print("\n\n")
if __name__ == "__main__":
main()
Enter a prompt:
😊 你好!我是 Chatbot,欢迎你来到这个聊
Enter a prompt:
天空间!有什么想聊的吗? 🤔
代码
文本
已赞2
推荐阅读
公开
使用Uni-Dock v1.1新版本开展分子对接:持续加速、优化体验、拥抱开源
yuanyn@dp.tech

发布于 2024-02-28
1 赞3 转存文件
公开
OpenAI「终结扩散模型」的 Consistency Model 是什么,又跟 AIGC 和 AI4S 有什么关系
Roger

发布于 2023-07-12
1 赞6 转存文件1 评论