成都公司网站建设/什么时候友情链接
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,输出大段的介绍
相关文章:

llama-7B、vicuna-7b-delta-v1.1和vicuna-7b-v1.3——使用体验
Chatgpt的出现给NLP领域带来了让人振奋的消息,可以很逼真的模拟人的对话,回答人们提出的问题,不过Chatgpt参数量,规模,训练代价都很昂贵。 幸运的是,出现了开源的一些相对小的模型,可以在本地或…...

深入理解JVM虚拟机第十九篇:JVM字节码中方法内部的结构和与局部变量表中变量槽的介绍
大神链接:作者有幸结识技术大神孙哥为好友,获益匪浅。现在把孙哥视频分享给大家。 孙哥链接:孙哥个人主页 作者简介:一个颜值99分,只比孙哥差一点的程序员 本专栏简介:话不多说,让我们一起干翻JVM 本文章简介:话不多说,让我们讲清楚虚拟机栈存储结构和运行原理 文章目…...

windows好玩的cmd命令
颜色 后边的数字查表吧,反正我是喜欢一个随机的数字 color 01MAC getmac /v更新主机IP地址 通过DHCP更新 ipconfig /release ipconfig /renew改标题 title code with 你想要的标题...

线扫相机DALSA--常见问题四:修改相机参数,参数保存无效情况
该问题是操作不当,未按照正常步骤保存参数所致,相机为RAM机制,参数需保存在采集卡的ROM内。 保存参数步骤: ①首先将相机参数保存至User Set1; ②然后回到Board(采集卡)参数设置区,鼠标选中Basic Timing&a…...

linux中用date命令获取昨天、明天或多天前后的日期
在实际操作中,一些脚本中会调用明天,或者昨天,或更多天前的日期,本文将叙述讲述用date命令实现时间的显示。在Linux系统中用man date -d 查询的参数说的比较模糊,以下举例进一步说明: # man date -d, --da…...

【无标题】360压缩软件怎么用?超级好用!
360压缩是一款功能强大的解压缩软件,如何用它压缩文件呢?下面给出了详细的操作步骤。 一、360压缩详细步骤 1、下载软件后,在电脑上右击需要压缩的文件,在弹出的菜单中点击【添加到压缩文件】选项。 2、在360压缩窗口中按需设置相…...

一图搞懂傅里叶变换(FT)、DTFT、DFS和DFT之间的关系
自然界中的信号都是模拟信号,计算机无法处理,因此我们会基于奈奎斯特定理对模拟信号采样得到数字信号。 但是我们发现,即便是经过采样,在时域上得到了数字信号,而在频域上还是连续信号。 因此我们可以在时域中选取N点…...

行情分析——加密货币市场大盘走势(11.7)
大饼昨日下跌过后开始有回调的迹象,现在还是在做指标修复,大饼的策略保持逢低做多。稳健的依然是不碰,目前涨不上去,跌不下来。 以太昨天给的策略,依然有效,现在以太坊开始回调。 目前来看,回踩…...

阿里微服务质量保障系列:故障演练
对于很多大型企业(如阿里巴巴)来说,经过多年的技术演进,系统工具和架构已经高度垂直化,服务器规模也达到了比较大的体量。当服务规模大于一定量(如10000台)时,小概率的硬件故障每天都会发生。这时如果需要人的干预,系统就无法可靠的伸缩。 为此每一层的系统都会面向失…...

基于springboot+vue开发的教师工作量管理系
教师工作量管理系 springboot31 源码合集:www.yuque.com/mick-hanyi/javaweb 源码下载:博主私 摘要 随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成熟。本文介绍了教师工作量管理系统的开发全过程。通过…...

【NI-DAQmx入门】NI-DAQmx之C、C++、VB、VB.net与C#支持
DAQmx应用程序编程接口(API) DAQmx附带数据采集编程所需的API。DAQmx API只是一组库,其中包含关于如何执行所有数据采集操作的函数。这些API支持LabWindows/CVI、C、C、Visual Basic 6.0、VB.NET和C#。 DAQmx API随DAQmx驱动程序一起安装,包含以下参考…...

python转xml为json
以下代码取自获取PA防火墙策略XML文件并转为JSON文件的场景: 通过PA防火墙API获取防火墙策略 防火墙策略xpath为./result/security/rules/entry 以下代码实现将所有entry即策略与策略相关属性转为json对象并存储至文件 import xml.etree.ElementTree as ET import …...

PHP Curl请求封装
php 中curl请求模块封装 <?php namespace App\Utils;/*** http 工具类* author Administrator**/ class HttpUtils {private static $_instance;private function __construct(){}public static function getInstance(){if( null self::$_instance ){self::$_instance n…...

java list set 特性
List的常用实现类 ArrayList (常用) JDK1.2 底层数组实现 查询快,增删慢 线程不安全,效率高 LinkedList JDK1.2 底层链表实现 查询慢,增删快 线程不安全,效率高 Vector JDK1.0 底层数组实现 都慢 线程安全,效率低 List 集合名new 实现类(); 常用方法 集合名.方法名(实参列表…...

Docker 用centos 编译安装apache
Docker 用centos 编译安装apache 前提条件: 安装docker 如果想安装docker请查阅:安装docker 环境准备:centos8 拉取centos镜像 [rootlvs docker]# docker pull centos:8 8: Pulling from library/centos a1d0c7532777: Pull complete Di…...

专访虚拟人科技:如何利用 3DCAT 实时云渲染打造元宇宙空间
自古以来,人们对理想世界的探索从未停止,而最近元宇宙的热潮加速了这一步伐,带来了许多新的应用。作为元宇宙的关键入口,虚拟现实(VR)将成为连接虚拟和现实的桥梁。苹果发布的VISION PRO头戴设备将人们对VR…...

第三章:人工智能深度学习教程-基础神经网络(第二节-ANN 和 BNN 的区别)
在本文中,我们将了解单层感知器及其使用 TensorFlow 库在Python中的实现。神经网络的工作方式与我们的生物神经元的工作方式相同。 生物神经元的结构 生物神经元具有三个基本功能 接收外部信号。 处理信号并增强是否需要发送信息。 将信号传递给目标细胞&#x…...

回归模型原理总结及代码实现
前言 本文将介绍回归模型算法,并总结了一些常用的除线性回归模型之外的模型,其中包括一些单模型及集成学习器。 保序回归、多项式回归、多输出回归、多输出K近邻回归、决策树回归、多输出决策树回归、AdaBoost回归、梯度提升决策树回归、人工神经网络、…...

游戏开发中的“御用中介“
点击上方亿元程序员关注和★星标 引言 大家好,我是亿元程序员,一位有着8年游戏行业经验的主程。 本系列是《和8年游戏主程一起学习设计模式》,让糟糕的代码在潜移默化中升华,欢迎大家关注分享收藏订阅。 游戏开发中的"御用…...

flink1.15报错 processElement_split
flink sql 完整报错 Caused by: java.lang.NullPointerExceptionat StreamExecCalc$1148.processElement_split178(Unknown Source) ~[?:?]at StreamExecCalc$1148.processElement(Unknown Source) ~[?:?]at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutp…...

电脑投屏到TCL电视鼠标延迟
问题描述 提示:这里描述项目中遇到的问题: 笔记本电脑使用HDMI投屏到TCL电视,页面显示正常但是鼠标延迟反应太慢了 解决方案: 提示:这里填写该问题的具体解决方案: TCL电视设置中选择图像 → 图像类型改…...

220v插座led指示灯维修
由于220v是交流电,有反向电压的情况,而led反向通电的时候电阻无穷大,所以分压也无穷大,220v一导通就击穿,即使加了很大的电阻也没用,串联电阻只能作用于二极管正向的时候。 目前有两种方案: 方…...

软考-高级-信息系统项目管理师教程 第四版【第19章-配置与变更管理-思维导图】
软考-高级-信息系统项目管理师教程 第四版【第19章-配置与变更管理-思维导图】 课本里章节里所有蓝色字体的思维导图...

javascript自定义事件的观察者模式写法和用法以及继承
<html><head><meta http-equiv"Context-Type:text/html;charsetutf-8"/><title>自定义事件之观察者模式</title><script type"text/javascript" src"common.js"></script></head><body>&…...

蓝桥杯官网练习题(正则问题)
题目描述 考虑一种简单的正则表达式: 只由 x ( ) | 组成的正则表达式。 小明想求出这个正则表达式能接受的最长字符串的长度。 例如 ((xx|xxx)x|(x|xx))xx 能接受的最长字符串是: xxxxxx,长度是 6。 输入描述 一个由 x()| 组成的正则表…...

iOS使用NSURLSession实现后台上传
NSURLSession后台上传的基本逻辑是:首先创建一个后台模式的NSURLSessionConfiguration,然后通过这个configuration创建一个NSURLSession,接着是创建相关的NSURLSessionTask,最后就是处理相关的代理事件。 1、创建NSURLSession -…...

linux之信号
Linux之信号 什么是信号信号的产生方式signalsignactionkill信号集信号屏蔽 什么是信号 信号机制是一种使用信号来进行进程之间传递消息的方法,信号的全称为软中断信号,简称软中断。 信号的本质是软件层次上对中断的一种模拟(软中断ÿ…...

golang工程中间件——redis常用结构及应用(string, hash, list)
Redis 命令中心 【golang工程中间件——redisxxxxx】这些篇文章专门以应用为主,原理性的后续博主复习到的时候再详细阐述 string结构以及应用 字符数组,redis字符串是二进制安全字符串,可以存储图片等二进制数据,同时也可以存…...

Java中数据结构(基本数据类型+引用数据类型)介绍+整理+例子+对比
一、Java数据类型分类 在Java中,数据类型可以分为两大类:内置数据类型(Primitive Data Types)和引用数据类型(Reference Data Types)。 **内置数据类型(Primitive Data Types)**是…...

SpringSecurity原理
Spring Security是Spring框架中的一个安全性框架,用于保护Web应用程序。以下是Spring Security的工作原理: 1.认证 认证是指验证用户身份。Spring Security使用过滤器链来拦截用户的请求。在对请求进行处理之前,它需要对用户进行认证。Spri…...