在MBP上运行推理LLaMA-7B模型

build this repo

# build this repo
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp

obtain the original LLaMA model weights and place them in ./models

# obtain the original LLaMA model weights and place them in ./models
ls ./models
65B 30B 13B 7B tokenizer_checklist.chk tokenizer.model

install Python dependencies

# install Python dependencies
python3 -m pip install torch numpy sentencepiece

convert the 7B model to ggml FP16 format

# convert the 7B model to ggml FP16 format
python3 convert-pth-to-ggml.py models/7B/ 1



# quantize the model to 4-bits
./quantize.sh 7B

quantize the 7B model to 4-bits



量化完之后,模型从15G降低为4G。

convert the 13B model to ggml FP16 format

# convert the 13B model to ggml FP16 format
python3 convert-pth-to-ggml.py models/13B/ 1

quantize the 13B model to 4-bits

# quantize the model to 4-bits
./quantize.sh 13B

run the inference

# run the inference
./main -m ./models/7B/ggml-model-q4_0.bin -t 8 -n 128

互动模式

如果您想要更像ChatGPT的体验,您可以通过传递-i作为参数在交互模式下运行。在此模式下,您始终可以通过按Ctrl+C来中断生成,并输入一行或多行文本,这些文本将被转换为令牌并附加到当前上下文中。您还可以使用参数-r "reverse prompt string"指定反向提示。每当在生成中遇到反向提示字符串的确切令牌时,这将导致用户输入被提示。一个典型的用途是使用提示,使LLaMa模拟多个用户之间的聊天,比如Alice和Bob,并通过-r "Alice:"

这是一个用命令调用的交互示例:

./main -m ./models/7B/ggml-model-q4_0.bin -t 8 -n 256 --repeat_penalty 1.0 --color -i -r "User:" \
-p \
"Transcript of a dialog, where the User interacts with an Assistant named Bob. Bob is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision. User: Hello, Bob.
Bob: Hello. How may I help you today?
User: Please tell me the largest city in Europe.
Bob: Sure. The largest city in Europe is Moscow, the capital of Russia.
User:"



在MBP上运行推理LLaMA-7B&13B模型的更多相关文章

  1. 如何实现在Windows上运行Linux程序,附示例代码

    微软在去年发布了Bash On Windows, 这项技术允许在Windows上运行Linux程序, 我相信已经有很多文章解释过Bash On Windows的原理, 而今天的这篇文章将会讲解如何自己 ...

  2. 在传统.NET Framework 上运行ASP.NET Core项目

    新的项目我们想用ASP.NET Core来开发,但是苦于我们历史的遗产很多,比如<使用 JavaScriptService 在.NET Core 里实现DES加密算法>,我们要估计等到.N ...

  3. Hyper-V上运行的Linux虚拟机验证是否安装了集成服务

    Hyper-V上运行的Linux虚拟机验证是否安装了集成服务 ps aux|grep "hv"root       311  0.0  0.0      0     0 ?     ...

  4. 通过Mono 在 Heroku 上运行 .NET 应用

    英文原文:Running .NET on Heroku 中文原文:在 Heroku 上运行 .NET 应用 自从加入了Heroku之后,我就想在这个平台上运行.NET程序.现在我很高兴向大家宣布,我们 ...

  5. Linux上运行NET

    今天尝试了下Ubuntu上运行NET程序,按照 https://github.com/aspnet/Home 的指引,一步一步来: 1.安装DNVM(原名KVM) Linux控制台下输入 curl - ...

  6. Mono 4.0 Mac上运行asp.net mvc 5.2.3

    Mono 4.0 已经发布,二进制包已经准备好,具体的发布说明参见:http://www.mono-project.com/docs/about-mono/releases/4.0.0/. 今天在Ma ...

  7. ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core

    原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...

  8. 【无私分享:ASP.NET CORE 项目实战(第十章)】发布项目到 Linux 上运行 Core 项目

    目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 ASP.Net Core 给我们带来的最大的亮点就是跨平台,我在我电脑(win7)上用虚拟机建了个 CentOS7 ,来演示下 ...

  9. 玩儿转物联网IoT - 在Beagle Bone Black上运行node.js 程序

    物联网(IoT)技术方兴未艾,智能手环,智能血压计,智能眼镜甚至智能鞋垫都开始进入我们的生活,各种智能设备层出不穷,世界已经到了一个"人有多大胆,地有多大产"的时代,不玩儿点物联网 ...

  10. 不装mono,你的.NET程序照样可以在Linux上运行!

    让.NET应用程序在linux上运行,目前通用的做法就是在Linux上安装mono,然后通过”mono your.exe“命令运行这个程序. 这种运行.net程序的办法有两个弱点,一个是需要客户机安装 ...

随机推荐

  1. Cloth Simulation with Root Finding and Optimization

    目录 0 前言 1 Implicit Method 1.1 Root-finding 1.2 Optimization 1.3 Insight 2 Newton-Raphson Method 3 Ma ...

  2. 如何阅读 CPU 电路图(以 6502 为例)

    开篇 你是否曾对 CPU 的工作原理充满好奇,以及简单的晶体管又是如何组成逻辑门,进而构建出复杂的逻辑电路实现?本文将以知名的 6502 CPU 的电路图为例,介绍如何阅读 CPU 电路图,并向你演示 ...

  3. 借用Ultralytics Yolo快速训练一个物体检测器

    借用Ultralytics Yolo快速训练一个物体检测器 同步发表于 https://www.codebonobo.tech/post/14 大约在16/17年, 深度学习刚刚流行时, Object ...

  4. vue3 + typescript + element-plus 大文件上传

    大文件上传 思路:前端获取 file 文件对象使用 slice 方法截取切片,然后异步上传切片,再合并 技术栈 TypeScript Vue3 Element-plus Nodejs 客户端实现 创建 ...

  5. salesforce零基础学习(一百四十一)刷新dev sandbox需要强制group

    本篇参考:https://help.salesforce.com/s/articleView?id=sf.data_sandbox_selective_access.htm&type=5 背景 ...

  6. linux开启快捷键,牛逼的狠~

    vim env_show #!/bin/bash echo '-----------A------------- XXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX ...

  7. PCI 设备 RTX 驱动开发方法 -5565反射内存

    PCI 设备 RTX 驱动开发方法 RTX 下操作外设时, 需要把设备从 Windows 移动到 RTX 下面,具体移植方法可以参考 RTX Help 文档中间 Converting a Window ...

  8. 鸿蒙NEXT开发案例:指尖轮盘

    [1]引言 "指尖轮盘"是一个简单而有趣的互动游戏(类似抓阄),这个应用通过触摸屏幕的方式,让玩家参与一个激动人心的游戏,最终选出幸运的赢家.未来可以进一步扩展功能,如增加游戏模式 ...

  9. P7563 JOISC 2021 Day4 最悪の記者 4 (Worst Reporter 4)

    P7563 JOISC 2021 Day4 最悪の記者 4 (Worst Reporter 4) 线段树合并好题,通过线段树合并特别的方式优化了树形 dp. 思路 根据图中的不等关系连边建图,不难发现 ...

  10. hyperf的使用

    hyperf是swoole的封装框架,用起来效率还是不错的. 使用方式看手册 https://hyperf.wiki/2.2/#/zh-cn/quick-start/install 其实是靠compo ...