赞
踩
Windows、Mac、Ubuntu
上直接安装使用,安装步骤简单,这里不再赘述,本文介绍一下在无可视化界面的Linux环境部署调用的流程。
【官网】有更多的信息可以查看,简介:A free-to-use, locally running, privacy-aware chatbot. No GPU or internet required.
特点:
CPU
上本地运行的强大和定制的大型语言模型;# 1.查询操作系统版本
cat /etc/os-release
# 查询结果
NAME="openEuler"
VERSION="22.03 (LTS-SP1)"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 (LTS-SP1)"
ANSI_COLOR="0;31"
也可以使用Anaconda
或Docker
构建运行环境:
# 2.查询python版本
python -V
# 查询结果
Python 3.9.18
# 3.组件版本
torch==2.1.2
gpt4all==2.2.1.post1
transformers==4.32.1
from gpt4all import GPT4All
model = GPT4All("orca-mini-3b-gguf2-q4_0.gguf")
output = model.generate("The capital of France is ", max_tokens=3)
print(output)
实际使用代码:
from gpt4all import GPT4All
def get_answer_form_model(request):
# 参数
req = json.loads(request.body.decode())
model_name = req['model']
max_tokens = req['max_tokens']
question_text = req['question']
# 调用
model = GPT4All(model_name=model_name, model_path="/a_model", allow_download=False)
output = model.generate(question_text, max_tokens=max_tokens)
print(output)
return HttpResponse(output)
{
"model": "orca-mini-3b-gguf2-q4_0.gguf",
"max_tokens": 30,
"question": "The capital of France is "
}
100% Paris.
I hope that helps!
一些离谱的回答:
{
"model": "baichuan2-7b-chat.Q3_K_L.gguf",
"max_tokens": 1200,
"question": "我有6个鸡蛋,碎了2个,煎了2个,吃了2个,还剩下几个?请告诉我为什么?"
}
首先我们要知道这个问题的描述有些矛盾。
根据问题中的表述:“我有 6 个鸡蛋”、“碎了 2 个" 和 "煎了 2 个", 这意味着你已经使用了4个(碎的+煎的)蛋, 所以剩下的应该是1-3.
但是接着又说 “吃了 2 个”,这个信息并没有在问题中给出为什么,所以我们需要重新理解问题的描述。
如果“吃”是指把鸡蛋放在其他食物里的话(比如炒饭、煎饼等) ,那么实际上你仍然使用了4颗蛋黄(煎的)和1颗蛋白 (碎的), 所以剩下的应该是5-6.
因此, 根据不同的解释方式可能剩下几个蛋会有两种情况: 0个或7个。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。