Llama2模型的优化版本:Llama-2-Onnx

Llama2模型的优化版本:Llama-2-Onnx。

Llama-2-Onnx是Llama2模型的优化版本。Llama2模型由一堆解码器层组成。每个解码器层(或变换器块)由一个自注意层和一个前馈多层感知器构成。与经典的变换器相比,Llama模型在前馈层中使用了不同的投影大小。例如,Llama1和Llama2的投影都使用了2.7倍的隐藏大小,而不是标准的4倍隐藏大小。Llama1和Llama2之间的一个关键区别在于注意层的架构变化,Llama2利用了分组查询注意(GQA)机制来提高效率。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Llama 2 Powered By ONNX

This is an optimized version of the Llama 2 model, available from Meta under the Llama Community License Agreement found on this repository. Microsoft permits you to use, modify, redistribute and create derivatives of Microsoft’s contributions to the optimized version subject to the restrictions and disclaimers of warranty and liability in the Llama Community License agreement.

Before You Start

The sub-modules that contain the ONNX files in this repository are access controlled.
To get access permissions to the Llama 2 model, please fill out the Llama 2 ONNX sign up page. If allowable, you will receive GitHub access in the next 48 hours, but usually much sooner.

Cloning This Repository And The Submodules

Before you begin, ensure you have Git LFS installed. Git LFS (Large File Storage) is used to handle large files efficiently. You can find out how to install Git LFS for your operating system at https://git-lfs.com/.

Next, you can choose which version of the Llama 2 model you would like to use by selecting the appropriate submodule.

Chose from the following sub-modules:

  • 7B_FT_float16
  • 7B_FT_float32
  • 7B_float16
  • 7B_float32
  • 13B_FT_float16
  • 13B_FT_float32
  • 13B_float16
  • 13B_float32
git clone https://github.com/microsoft/Llama-2-Onnx.git
cd Llama-2-Onnx
git submodule init <chosen_submodule> 
git submodule update

You can repeate the init command with a different submodule name to initialize multiple submodules. Be careful, the contained files are very large! (7B Float16 models are about 10GB)

What is Llama 2?

Llama 2 is a collection of pretrained and fine-tuned generative text models. To learn more about Llama 2, review the Llama 2 model card.

What Is The Structure Of Llama 2?

Llama 2 model consists of a stack of decoder layers. Each decoder layer (or transformer block) is constructed from one self-attention layer and one feed-forward multi-layer perceptron. Llama models use different projection sizes compared with classic transformers in the feed-forward layer, for instance, both Llama 1 and Llama 2 projection use 2.7x hidden size rather than the standard 4x hidden size. A key difference between Llama 1 and Llama 2 is the architectural change of attention layer, in which Llama 2 takes advantage of Grouped Query Attention (GQA) mechanism to improve efficiency.

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

FAQ

Is There A Simple Code Example Running Llama 2 With ONNX?

There are two examples provided in this repository. There is a minimum working example shown in Llama-2-Onnx/MinimumExample. This is simply a command line program that will complete some text with the chosen version of Llama 2.

Given the following input:

python MinimumExample/Example_ONNX_LlamaV2.py --onnx_file 7B_FT_float16/ONNX/LlamaV2_7B_FT_float16.onnx --embedding_file 7B_FT_float16/embeddings.pth --tokenizer_path tokenizer.model --prompt "What is the lightest element?"

Output:

The lightest element is hydrogen. Hydrogen is the lightest element on the periodic table, with an atomic mass of 1.00794 u (unified atomic mass units).

Is There A More Complete Code Example Running Llama 2 With ONNX?

There is a more complete chat bot interface that is available in Llama-2-Onnx/ChatApp. This is a python program based on the popular Gradio web interface. It will allow you to interact with the chosen version of Llama 2 in a chat bot interface.

An example interaction can be seen here:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

How Do I Use The Fine-tuned Models?

The fine-tuned models were trained for dialogue applications.

To get the expected features and performance for them, a specific formatting needs to be followed, including the INST tag, BOS and EOS tokens, and the whitespaces and breaklines in between (we recommend calling strip() on inputs to avoid double-spaces).

This enables models in chat mode as well as additional safeguards to reduce potentially undesirable output.

Why Is The First Inference Session Slow?

ONNX runtime execution provider might need to generate JIT binaries for the underlying hardware, typically the binary is cache and will be loaded directly in the subsequent runs to reduce the overhead.

Why Is FP16 ONNX Slower Than ONNX FP32 On My Device?

It is possible that your device does not support native FP16 math, therefore weights will be cast to FP32 at runtime. Using the FP32 version of the model will avoid the cast overhead.

How Do I Get Better Inference Speed?

It is recommended that inputs/outputs are put on target device to avoid expensive data copies, please refer to the following document for details.

I/O Binding | onnxruntime

What Parameters Should I Test With?

Users can perform temperature and top-p sampling using the model’s output logits. Please refer to Meta’s guidance for the best parameters combination; an example is located here.

How Can I Develop With Llama 2 Responsibly?

In order to help developers innovate responsibly, Meta encourages you to review the Responsible Use Guide for the Llama 2 models.

Microsoft encourages you to learn more about its Responsible AI approach, including many publicly available resources and tools for developers.

参考文献:
[1]http://github.com/microsoft/Llama-2-Onnx

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

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

相关文章

轮转数组

189. 轮转数组 给定一个整数数组 nums&#xff0c;将数组中的元素向右轮转 k 个位置&#xff0c;其中 k 是非负数。 示例 1: 输入: nums [1,2,3,4,5,6,7], k 3 输出: [5,6,7,1,2,3,4] 解释: 向右轮转 1 步: [7,1,2,3,4,5,6] 向右轮转 2 步: [6,7,1,2,3,4,5] 向右轮转 3 步:…

【信息系统项目管理师】--【信息化发展】--【章节练习】

文章目录 一、选择题二、思考题三、参考答案3.1 选择题答案3.2 思考题答案 一、选择题 (1)下列说法正确的是 A.信息只存在家庭中 B.信息只存在图书馆中 C.信息只存在校园里 D.信息无处不在 (2)信息的基础是 A.数据 B.知识 C.事实 D.概念 (3)工业互联网的体系不包括 A.网络 B.平…

YOLOv5算法进阶改进(16)— 更换Neck网络之GFPN(源自DAMO-YOLO)

前言:Hello大家好,我是小哥谈。GFPN(Global Feature Pyramid Network)是一种用于目标检测的神经网络架构,它是在Faster R-CNN的基础上进行改进的,旨在提高目标检测的性能和效果。其核心思想是引入全局特征金字塔,通过多尺度的特征融合来提取更丰富的语义信息。具体来说,…

用Python实现创建十二星座数据分析图表

下面小编提供的代码中&#xff0c;您已经将pie.render()注释掉&#xff0c;并使用了pie.render_to_file(十二星座.svg)来将饼状图渲染到一个名为十二星座.svg的文件中。这是一个正确的做法&#xff0c;如果您想在文件中保存图表而不是在浏览器中显示它。 成功创建图表&#xf…

贪心算法---前端问题

1、贪心算法—只关注于当前阶段的局部最优解,希望通过一系列的局部最优解来推出全局最优----但是有的时候每个阶段的局部最优之和并不是全局最优 例如假设你需要找给客户 n 元钱的零钱&#xff0c;而你手上只有若干种面额的硬币&#xff0c;如 1 元、5 元、10 元、50 元和 100…

P2895 [USACO08FEB] Meteor Shower S题解

题目 贝茜听说一场特别的流星雨即将到来&#xff1a;这些流星会撞向地球&#xff0c;并摧毁它们所撞击的任何东西。她为自己的安全感到焦虑&#xff0c;发誓要找到一个安全的地方&#xff08;一个永远不会被流星摧毁的地方&#xff09;。 如果将牧场放入一个直角坐标系中&…

李宏毅2023机器学习作业1--homework1——python语法

# 定义list del_col del_col [0, 38, 39, 46, 51, 56, 57, 64, 69, 74, 75, 82, 87] # 删除raw_x_train中del_col的列&#xff0c;axis为1代表删除列 raw_x_train np.delete(raw_x_train, del_col, axis1) # numpy数组增删查改方法 # 定义列表get_col get_col [35, 36, 37,…

vector 用法

C++数组是继承C语言的,C++标准库中的vector封装了动态数组,是一个模板类(vector<int>,<>里面可以是各种类型。 定义方式: vector<元素类型> 对象名(长度); (注:vector还有个好处就是,数组定义时长度那里不能包含变量,但是vector定义时长度那里可…

2.23 Qt day4 事件机制+定时器事件+键盘事件+鼠标事件

思维导图&#xff1a; 做一个闹钟&#xff0c;在行编辑器里输入定闹钟的时间&#xff0c;时间到了就语音播报文本里的内容&#xff0c;播报五次 widget.h&#xff1a; #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include<QDebug>//输出类 #include<…

B3623枚举排列

题目描述 今有 n 名学生&#xff0c;要从中选出 k 人排成一列拍照。 请按字典序输出所有可能的排列方式。 输入格式 仅一行&#xff0c;两个正整数 n,k。 输出格式 若干行&#xff0c;每行 k 个正整数&#xff0c;表示一种可能的队伍顺序。 输入输出样例 输入 #1复制 …

聚美优品根据ID取商品详情 API(jumei.item_get)

聚美优品&#xff08;Jumei&#xff09;是一个在线购物平台&#xff0c;提供化妆品、护肤品、服装、食品等多种商品。聚美优品可能有自己的API接口供开发者使用&#xff0c;以便实现与平台的数据交互。不过&#xff0c;请注意&#xff0c;聚美优品的API可能会随着时间的变化而更…

通过 NVIDIA-SMI 统计GPU使用情况

通过 NVIDIA-SMI 统计GPU使用情况 罗列本机显卡 nvidia-smi -L | --list-gpus本示例的输出如下&#xff0c;也就是本机的显卡环境&#xff1a; [namegpu4 code]$ nvidia-smi -L GPU 0: A40 (UUID: GPU-b0f3bdaa-e0e1-aff7-3cc7-9c067db6aea1)nvidia-smi -f | --filename : 将…

网络攻防之ARP欺骗和DNS劫持实验

目录 ARP单向欺骗 ARP双向欺骗 DNS劫持 实验环境&#xff1a; 攻击主机&#xff1a;kali2023虚拟机&#xff0c;IP地址为192.168.133.141 靶机&#xff1a;Windows10虚拟机&#xff0c;IP地址为192.168.133.129 网关地址&#xff1a;192.168.133.2 (1)ARP协议介绍 在以…

java多线程——线程安全同步机制同步代码块、同步机制

用多线程实现电影院三个窗口买票机制 ①同步代码块方式实现 public class MyThread extends Thread{static int sum0;//static Object objectnew Object();Overridepublic void run() {while(true){//同步代码块synchronized (MyThread.class){if(sum<100){try {Thread.sl…

唯品会vip.item_get API:第三方开发者的商品信息获取利器

唯品会&#xff08;VIP.com&#xff09;是中国的一家知名折扣电商平台&#xff0c;提供大量品牌商品的打折销售。对于第三方开发者而言&#xff0c;唯品会提供的API接口可以帮助他们集成唯品会的数据和功能&#xff0c;从而开发出自己的应用或服务。 vip.item_get API是唯品会…

maven 打包命令

Maven是基于项目对象模型(POM project object model)&#xff0c;可以通过一小段描述信息&#xff08;配置&#xff09;来管理项目的构建&#xff0c;报告和文档的软件项目管理工具。 Maven的核心功能便是合理叙述项目间的依赖关系&#xff0c;通俗点讲&#xff0c;就是通过po…

Linux 基本组件与性能优化与根目录

目录 Linux基本组件 Linux性能优化 Linux常见根目录 Linux基本组件 内核&#xff1a;操作系统的核心&#xff0c;管理硬件资源和提供基本服务。 Shell&#xff1a; 用户与系统交互的命令行界面&#xff0c;例如 Bash 或 Zsh。 文件系统&#xff1a; 组织和存储数据的方式&…

Mysql的基本SQl语句

1.DDL 数据定义语言&#xff0c;开发 针对库表对象增删改create 创库创表drop 删库删表alter 修改库表属性 案例1&#xff1a;创建一个数据库&#xff0c;需求如下&#xff1a; 1&#xff09;库名为edu 2&#xff09;字符集为utf8 CREATE DATABASE edu DEFAULT CHARAC…

代码随想录刷题笔记-Day22

1. 修剪二叉搜索树 669. 修剪二叉搜索树https://leetcode.cn/problems/trim-a-binary-search-tree/ 给你二叉搜索树的根节点 root &#xff0c;同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树&#xff0c;使得所有节点的值在[low, high]中。修剪树 不应该 改变保留…

opengles 顶点坐标变换常用的矩阵(九)

文章目录 前言一、opengles 常用的模型矩阵1. 单位矩阵2. 缩放矩阵3. 位移矩阵4. 旋转矩阵二、第三方矩阵数学库1. glm1.1 ubuntu 上安装 glm 库1.2 glm 使用实例1.2.1 生成一个沿Y轴旋转45度的4x4旋转矩阵, 代码实例如下1.2.2 生成一个将物体移到到Z轴正方向坐标为5处的4x4 vi…