windows本地CPU+6G内存部署类ChatGPT模型(Vicuna 小羊驼)

1.配置介绍

笔记本硬件配置为R7 4800U + 32g内存,但是实际上8g或者16g就够了

操作系统为windows 10,其他操作系统应该也不影响:

环境配置

conda create -n llm python=3.9
conda activate llm
conda install pytorch==1.13.1 cpuonly -c pytorch
pip install llama-cpp-python
提示:python 安装可以参考另外一篇文章

llama-cpp-python是llama.cpp的Python接口,具体介绍看下面链接

llama.cpp
​github.com/abetlen/llama-cpp-python

模型下载

这里我们要下载4-bit量化的Vicuna模型,有7B和13B两个版本,每个版本里面还细分了几个版本,主要是速度和准确率之间的平衡,根据情况自己下载

ggml-vicuna-7b-1.1
huggingface.co/eachadea/ggml-vicuna-7b-1.1
ggml-vicuna-13b-1.1
​huggingface.co/eachadea/ggml-vicuna-13b-1.1

在这里插入图片描述

模型执行

 
from llama_cpp import Llama

#路径替换成你自己的模型路径
llm = Llama(model_path="./models/ggml-vicuna-13b-1.1-q4_2.bin")


while True:
    # Name the planets in the solar system?
    prompt = input("prompt: ")
    # 相关控制参数自己调节
    output = llm(f"Q:{prompt} A:", max_tokens=128, stop=[roles[0]], echo=False)
    print("Answer: ", output["choices"][0]["text"])

测试示例

(1) Implement a Python function to find the longest common subsequence of two input strings using dynamic programming.

Here is an example implementation of a Python function that finds the longest common subsequence of two input strings using dynamic programming:

def lcs(s1, s2):
    n = len(s1)
    m = len(s2)

    # Initialize dp table with not available values
    dp = [[None] * (m+1) for _ in range(n+1)]

    # Fill dp table with starting value of 0
    for i in range(1, n+1):
        dp[i][0] = 0

    # Fill dp table with starting value of 0
    for j in range(1, m+1):
        dp[0][j] = 0

    # Iterate over all possible subsequences of s1 and s2
    for i in range(1, n+1):
        for j in range(1, m+1):
            if s1[i-1] == s2[j-1]:
                # If current characters match, increment dp[i][j] by 1
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1)
            else:
                # If current characters do not match, use the larger of the two options
                dp[i][j] = max(dp[i][j], max(dp[i-1][j], dp[i][j-1]))

    # Return the longest common subsequence
    return dp[n][m]

This function takes two input strings s1 and s2, and returns the longest common subsequence of the two strings.
(2) 锅包肉怎么做

锅包肉是一道非常有名的广东菜,制作方法简单,口感鲜美。以下是一份锅包肉的做法:

所需材料:

  • 猪里脊肉 500克
  • 白蒜 3个
  • 大葱 1根
  • 洋葱 1根
  • 红椒 1个
  • 花椒 1个
  • 生抽 适量
  • 食用油 适量
  • 盐、胡椒粉、蒜泥 适量

步骤:

  1. 将猪里脊肉切成小块,用刀刻上竖直线,保持原有形状。
  2. 將白蒜、大葱和洋葱切成顺序,再将红椒和花椒切成小段。
  3. 在碗中加入生抽,用中火加热,放入肉片后盖上适量的食用油。
  4. 当肉片发达香气时,将白蒜、大葱和洋葱一起加入碗中,用中火燒烂,直到肉片受烧后取出。
  5. 总结
    7B大小的Vicuna模型4-bit量化后,效果感觉不太好,尤其是中文,不如ChatGLM-6B

13B的的Vicuna模型4-bit量化后,效果还可以,英文可能达到了宣称的那样,中文感觉还略差于ChatGLM-6B一点

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@农垦专家

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值