llama-7B、vicuna-7b-delta-v1.1和vicuna-7b-v1.3——使用体验

Chatgpt的出现给NLP领域带来了让人振奋的消息,可以很逼真的模拟人的对话,回答人们提出的问题,不过Chatgpt参数量,规模,训练代价都很昂贵。

幸运的是,出现了开源的一些相对小的模型,可以在本地或者云端部署体验,

动手体验了下Vicuna-7b,翻译过来是小羊驼」(骆马),拥有70亿参数,据作者实验能达到GPT-4的90%性能。在作者官网发布了三个版本,其中3个月前发布了v1.1,17天前发布了v1.3。

官网:lmsys (Large Model Systems Organization)

环境:

ubuntu18.04

九天毕昇8核32G内存,仅有cpu

时间:2023年7月5号

llama-7B

python3 -m cli --model-path /root/transformer_model_7b  --device cpu
文件:cli是fastchat/serve目录下的cli.py文件

cli.py内容

"""
Chat with a model with command line interface.
Usage:
python3 -m fastchat.serve.cli --model lmsys/vicuna-7b-v1.3
python3 -m fastchat.serve.cli --model lmsys/fastchat-t5-3b-v1.0
Other commands:
- Type "!!exit" or an empty line to exit.
- Type "!!reset" to start a new conversation.
"""
import argparse
import os
import re
import sys
 
from prompt_toolkit import PromptSession
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.history import InMemoryHistory
from prompt_toolkit.key_binding import KeyBindings
from rich.console import Console
from rich.live import Live
from rich.markdown import Markdown
 
from fastchat.model.model_adapter import add_model_args
from fastchat.modules.gptq import GptqConfig
from fastchat.serve.inference import ChatIO, chat_loop
 
 
class SimpleChatIO(ChatIO):
    def prompt_for_input(self, role) -> str:
        return input(f"{role}: ")
 

参数:   --model-path    是指模型权重存放路径,这个目录下包含tokenizer.model文件,请仔细核对

参数:    --device cpu   指定在cpu上运行

开始推理: 输入 who is Musk?    what is baidu?    china

要等待几分钟,看到几个词几个词的蹦出来

看回答,字数还不少,内容只能说是相关

看下cpu使用率

top
可以看到python3进程,推理时cpu使用率在81.1%,一直在波动。

换用v100有时候会到98%,甚至更高,速度会快很多,一次输出一小段文字

vicuna-7b-delta-v1.1

python3 -m cli --model-path /root/vicuna-7b/vicuna-7b-delta-v11 --device cpu
加载模型,中间过程要几分钟

python3 -m cli --model-path /root/vicuna-7b/vicuna-7b-delta-v11  --device cpu
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████| 2/2 [02:58<00:00, 89.16s/it]

开始推理:实现一个python斐波那契函数,可以看到能够写出函数,还简单介绍了怎么用

USER: hello
ASSISTANT: Hello! How can I help you today? Is there something you would like to know or talk about? I'm here to help answer any questions you may have.
USER: implement a python function to compute fibonacci numbers
ASSISTANT: Sure! Here's an implementation of a Python function that computes the Fibonacci sequence:
```python
def fibonacci(n):
    if n <= 1:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)
```
This function takes an integer `n` as input and returns the `n`-th Fibonacci number. The first two numbers in the sequence are 0 and 1, so the function handles these cases separately: if `n` is less than or equal to 1, it returns `n`, and otherwise it computes the sum of the previous two Fibonacci numbers and returns that.

To use the function, you can call it with an integer `n` and it will return the `n`-th Fibonacci number. For example:
```python
>>> fibonacci(5)
13
```
This would compute the 5-th Fibonacci number, which is 13.

USER: china
ASSISTANT: China is a country located in East Asia, bordered by several other countries, including Russia, Mongolia, North Korea, Vietnam, Laos, Myanmar (Burma), Bhutan, India, Nepal, and Pakistan. It is the world's most populous country, with over 1.4 billion people.

China has a long and complex history, dating back over 5,000 years. It is known for its rich cultural heritage, including its cuisine, literature, and arts. The country has a diverse range of landscapes, from the high plateaus in the west to the fertile river valleys in the east, and from the tropical beaches in the south to the frigid deserts in the north.

vicuna-7b-v1.3

 python3 -m cli --model-path /root//vicuna-7b-v13 --device cpu
参数:-m      后面指定cli.py文件,注意【.py】省略。python3 -m cli是python3执行cli.py文件,具体内容,要看cli.py写了什么

加载模型,等待几分钟

python3 -m cli --model-path /root//vicuna-7b-v13 --device cpu
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████| 2/2 [03:17<00:00, 98.73s/it]

推理:

USER: Introduce China

ASSISTANT: China, officially known as the People's Republic of China (PRC), is a sovereign state located in East Asia. It is the world's most populous country, with a population of over 1.4 billion people, and the third-largest country by land area, covering approximately 9.6 million square kilometers.

China has a long and complex history, dating back more than 5,000 years. It has been ruled by various dynasties, including the Zhou, Qin, Han, Tang, Song, Yuan, Ming, and Qing dynasties, among others. 

The People's Republic of China is a single-party socialist state with a planned economy, guided by the CPC. The country is governed according to the Constitution of the People's Republic of China, which was adopted in 1982. The government is divided into various branches, including the National People's Congress (NPC), the State Council, the Supreme People's Court, and the Central Military Commission.

China has a diverse landscape and culture, encompassing various ethnic groups, including the Han, Tibetans, Uighurs, Mongols, and Manchus, among others. The official language is Standard Chinese (Mandarin), although there are numerous regional languages and dialects spoken throughout the country.

The People's Republic of China is a single-party socialist state with a planned economy, guided by the CPC. The country is governed according to the Constitution of the People's Republic of China, which was adopted in 1982. The government is divided into various branches, including the National People's Congress (NPC), the State Council, the Supreme People's Court, and the Central Military Commission.

China has a diverse landscape and culture, encompassing various ethnic groups, including the Han, Tibetans, Uighurs, Mongols, and Manchus, among others. The official language is Standard Chinese (Mandarin), although there are numerous regional languages and dialects spoken throughout the country.

The economy of China has experienced rapid growth in recent decades, making it the world's second-largest economy by nominal GDP and the largest by purchasing power parity (PPP). The country is a leading global exporter of goods and services, with industries such as electronics, textiles, automobiles, and telecommunications playing a significant role in its economic development.

China has been actively involved in international affairs, participating as a permanent member of the United Nations Security Council and a member of various multilateral organizations, including the World Trade Organization (WTO), the Asia-Pacific Economic Cooperation (APEC), and the Group of 20 (G20) major economies.

USER: china
ASSISTANT: China is a country located in East Asia, covering approximately 9.6 million square kilometers. With a population of over 1.4 billion people, it is the most populous country in the world. The official language is Mandarin Chinese, and the capital city is Beijing. China has a rich history and a diverse cultural heritage, with many different ethnic groups and over 56 recognized ethnic minorities.

目前尚不能支持中文提问和中文回答

提问方式很重要:输入china,回答的只能说是相关,文字就少很多。输入 Introduce China,输出大段的介绍
 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/134649.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

高效接口重试机制的实现

实现一个高效的接口重试机制对于保证系统的稳定性和可靠性至关重要。在面对网络不稳定、服务端故障或者高负载的情况下&#xff0c;接口重试机制能够确保请求的成功执行&#xff0c;同时也需要保证在重试过程中不会造成额外的负担或不必要的延迟。本文将为您介绍高效接口重试机…

pandas教程:Reading and Writing Data in Text Format (以文本格式读取和写入数据)

文章目录 Chapter 6 Data Loading, Storage, and File Formats&#xff08;数据加载&#xff0c;存储&#xff0c;文件格式&#xff09;6.1 Reading and Writing Data in Text Format (以文本格式读取和写入数据)1 Reading Text Files in Pieces&#xff08;读取一部分文本&…

如何提高企业竞争力?CRM管理系统告诉你

随着竞争形势和商业环境的加剧&#xff0c;企业需要迅速适应不断变化的消费需求。不少企业使用CRM客户管理系统来优化业务流程&#xff0c;管理客户信息&#xff0c;实现更多的业绩增长。那么我们来说说&#xff0c;CRM系统如何提高企业竞争力&#xff1f; 强大的数据管理&…

HarmonyOS ArkTS基础知识

概述 上一节&#xff0c;学习了TypeScript的基础语法&#xff0c;而在鸿蒙开发当中&#xff0c;有基于自己的编程语言&#xff0c;便是ArkTS。它是一种声明式UI的编程范式的语言&#xff0c;开发框架如下图所示&#xff1a; 根据框架图&#xff0c;分析&#xff0c;我将它大致…

pycharm pro v2023.2.4(Python开发)

PyCharm是一种Python集成开发环境&#xff08;IDE&#xff09;&#xff0c;PyCharm提供了强大的功能&#xff0c;包括语法突出显示、智能代码完成、代码检查、自动重构和调试等特性&#xff0c;这些都可以帮助Python开发人员更加高效地编写代码。 PyCharm Pro是PyCharm的高级版…

【图】:常用图搜索(图遍历)算法

目录 概念图遍历深度优先搜索 (DFS)DFS 适用场景DFS 优缺点 广度优先搜索 (BFS)BFS 适用场景BFS 优缺点 DFS & BFS 异同点 图搜索Dijkstra算法A*算法Floyd算法Bellman-Ford算法SPFA算法 概念 图遍历和图搜索是解决图论问题时常用的两种基本操作。 图遍历是指从图中的某一个…

JVM 三大性能调优参数

JVM的性能调优是Java应用程序优化的重要部分&#xff0c;其中三大性能调优参数为&#xff1a; jvm三大性能调优参数 1. 堆内存大小(-Xmx和-Xms参数)&#xff1a;堆内存是Java应用程序中最重要的内存区域&#xff0c;存储对象实例和数组等数据。增大堆内存的大小可以提高Java应…

nssm部署nginx

nssm install Nginx8098 --安装nginx nssm start Nginx8098 --启用nginx nginx 选择nginx路径&#xff0c;安装

免费API接口集合, 让你的开发无烦恼

六位图片验证码生成&#xff1a;包括纯数字、小写字母、大写字母、大小写混合、数字小写、数字大写、数字大小写等情况。 四位图片验证码生成&#xff1a;四位图片验证码生成&#xff0c;包括纯数字、小写字母、大写字母、大小写混合、数字小写、数字大写、数字大小写等情况。…

易云维®工厂能耗管理平台系统方案,保证运营质量,推动广东制造企业节能减排

我国《关于完整准确全面贯彻新发展理念推进碳达峰碳中和工作的实施意见》出台&#xff0c;提出了推进碳达峰碳中和工作的总体目标。到2025年&#xff0c;广东具备条件的地区、行业和企业率先实现碳达峰&#xff0c;为全省实现碳达峰、碳中和奠定坚实基础&#xff1b;2030年前实…

玩具乐器展示预约小程序的内容是什么

玩具乐器产品的受众非常广&#xff0c;随着互联网电商深入&#xff0c;很多传统线下经营的商家开始转变为线上经营&#xff0c;入驻第三方平台或自建线上商城卖货等&#xff0c;当然除了直接卖产品外&#xff0c;还有产品展示预约咨询场景&#xff0c;因此很多商家也会选择制作…

c#笔记整理

1、【精选】NPOI使用手册 &#xff08;操作Excel&#xff09;-CSDN博客 2、NPOI导入Excel日期格式的处理 - 附类型格式匹配表 https://www.cnblogs.com/keitsi/p/8572093.html 3、[编程工具]使用NPIO(C#)读取xls,xlsx(Excel)表格 http://t.csdnimg.cn/PPiya

redis主从复制玩法全过程笔记(redis7+版本)

目录标题 环境目的实操一主多仆服务器和本地主机配置环境docker 环境配置 薪火相传反客为主 主从复制的流程主从复制的特性主从复制的缺点本篇结语 环境 我的环境介绍window环境VM虚拟机一台并安装centos7&#xff0c;一台阿里云Linux服务器&#xff0c;另一台Linux系统主机并…

Mybatis-Plus使用Wrapper自定义SQL

文章目录 准备工作Mybatis-Plus使用Wrapper自定义SQL注意事项目录结构如下所示domain层Controller层Service层ServiceImplMapper层UserMapper.xml 结果如下所示&#xff1a;单表查询条件构造器单表查询&#xff0c;Mybatis-Plus使用Wrapper自定义SQL联表查询不用&#xff0c;My…

C# OpenCvSharp 去除字母后面的杂线

效果 项目 代码 using OpenCvSharp; using System; using System.Drawing; using System.Windows.Forms;namespace OpenCvSharp_Demo {public partial class frmMain : Form{public frmMain(){InitializeComponent();}string image_path "";private void Form1_Loa…

最近的总结(2023.11.8)

菜鸟本来是不打算写文章的&#xff0c;奈何1500的曝光券让我心痒难耐 菜鸟主要是想把这篇博客&#xff08;平凡人的一生的意义是什么&#xff1f;&#xff09;推出去&#xff0c;看看大家的看法&#xff01; 不过既然写&#xff0c;菜鸟自然要好好写&#xff0c;就来聊聊最近…

如何选择SVM中最佳的【核函数】

参数“kernel"在sklearn中可选以下几种 选项&#xff1a; 接下来我们 就通过一个例子&#xff0c;来探索一下不同数据集上核函数的表现。我们现在有一系列线性或非线性可分的数据&#xff0c;我们希望通过绘制SVC在不同核函数下的决策边界并计算SVC在不同核函数下分类准确…

NeRF神经辐射场渲染过程详解,三维重建渲染过程基本原理_光线采样sample_pdf()和光线渲染render_rays ()代码详解

目录 1 神经辐射场 1.1 基本原理 1.2 基本流程 1.3 数学解释 2 三维场景图像渲染详解 2.1射线采样 2.2 NeRF 模型预测 2.3 体积渲染 3 采样与渲染代码详解 &#xff08;rending.py&#xff09; 3.1 神经体积渲染代码解析 3.2 sample_pdf 函数 3.3 render_rays 函数 …

持续集成交付CICD:Jenkins Pipeline与远程构建触发器

目录 一、实验 1.Jenkins Pipeline本地构建触发器 2.Jenkins Pipeline与远程构建触发器&#xff08;第一种方式&#xff09; 3.Jenkins Pipeline与远程构建触发器&#xff08;第二种方式&#xff09; 4.Jenkins Pipeline与远程构建触发器&#xff08;第三种方式&#xff0…

pytorch 学习率衰减策略

##学习率衰减策略 import torch.nn.functional as F import torch import torch.nn as nn import matplotlib.pyplot as plt#初始化模型 class Net(nn.Module):def __init__(self):super(Net, self).__init__()self.conv1 = nn.Conv2d(1, 10, kernel_size=5)self.conv2 = nn.Co…