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://xiahunao.cn/news/2807548.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

MySQL sql注意点

本文列取了常用但是容易遗漏的一些知识点。另外关键词一般大写&#xff0c;为了便于阅读所以很多小写。也为了给自己查缺补漏。 distinct&#xff08;去重&#xff09; 也许你经常对单个字段去重&#xff0c;并且知道不建议用distinct&#xff0c;而是group by&#xff0c;因为…

FL Studio21中文版功能、特点、使用场景及适用人群详解

一、功能介绍 FL Studio21中文版作为一款功能全面的数字音频工作站&#xff08;DAW&#xff09;&#xff0c;提供了从音乐创作到后期混音所需的完整工具集。以下是其主要功能&#xff1a; FL Studio 21.2.3 Win-安装包下载如下: https://wm.makeding.com/iclk/?zoneid55981 …

Vue3_基础使用_3_Hooks模块化

今天主要学习的是hooks, vue3的使用比vue2方便很多了&#xff0c;但是呢各个功能块的逻辑有时候还是会缠绕在一起&#xff0c;这个时候使用hooks进行模块化管理开发&#xff0c;说白了就是将每个单独的业务放到自己的.ts中去写&#xff0c;以后修改就找到这个ts 不用到处去翻…

VsCode的leetcode插件无法登录

前提 想使用VsCode的leetcode插件进行刷题&#xff0c;然后按照网上的教程进行安装下载&#xff0c;但是到了登录这一步&#xff0c;死活也登录不了&#xff0c;然后查看log一直报的错误是invalid password。 解决方法 首先确定在插件中设置的站点是Leetcode中国&#xff0c…

Stable Diffusion 绘画入门教程(webui)-ControlNet(Tile/Blur)

上篇文章介绍了y语义分割Seg&#xff0c;这篇文章介绍下Tile/Blur&#xff08;增加/减少细节&#xff09; Tile用于增加图片细节&#xff0c;一般用于高清修复&#xff0c;Blur用于减少图片细节&#xff08;图片模糊&#xff09;&#xff0c;如下图&#xff0c;用Tile做修复&a…

apidoc接口文档的自动更新与发布

文章目录 一、概述二、环境准备三、接口文档生成1. 下载源码2. 初始化3.执行 四、文档发布五&#xff0c;配置定时运行六&#xff0c;docker运行 一、概述 最近忙于某开源项目的接口文档整理&#xff0c;采用了apidoc来整理生成接口文档。 apidoc是一个可以将源代码中的注释直…

说说设备像素、css像素、设备独立像素、dpr、ppi 之间的区别

文章目录 一、背景二、介绍CSS像素设备像素设备独立像素dprppi 三、总结参考文献 一、背景 在css中我们通常使用px作为单位&#xff0c;在PC浏览器中css的1个像素都是对应着电脑屏幕的1个物理像素 这会造成一种错觉&#xff0c;我们会认为css中的像素就是设备的物理像素 但实…

谷歌连发 Gemini1.5、Gemma两种大模型,Groq让模型输出速度快18倍

本周&#xff0c;我们观察到以下AI领域的新动向和新趋势&#xff1a; 1.谷歌连发Gemini1.5和Gemma两种大模型&#xff0c; 其中Gemini1.5采用MoE架构&#xff0c;并拥有100万token上下文长度&#xff0c;相比Gemini 1.0性能大幅提升。Gemma是谷歌新推出的开源模型&#xff0c;…

精品基于SpringBoot+Vue的常规应急物资管理系统

《[含文档PPT源码等]精品基于SpringBootVue的常规应急物资管理系统[包运行成功]》该项目含有源码、文档、PPT、配套开发软件、软件安装教程、项目发布教程、包运行成功&#xff01; 软件开发环境及开发工具&#xff1a; Java——涉及技术&#xff1a; 前端使用技术&#xff…

手写redux和applyMiddleware中间件react示例

目录 一 核心代码 1.reducer 2.store.js 二 关于context API的使用 1. MyContext 2. createContext 3. ContextProvider 4. connect 三 组件验证效果 1. Todo 2. TodoList 3.TodoItem 4.TodoInput 5. App组件引入Todo组件 一 核心代码 1.reducer // 新增列表数…

企业如何定制化“可靠的”系统,实现数字化转型?

二十大提出高质量发展是首要任务&#xff0c;为顺应数字经济时代的发展&#xff0c;数字化转型正不断赋能各行各业。越来越多的企业管理者也意识到数字化转型是帮助企业提升内部运营效率&#xff0c;提升业务开展效率&#xff0c;减低企业成本的有效手段。 那么如何推动企业数字…

daydayEXP: 支持自定义Poc文件的图形化漏洞利用工具

daydayEXP: 支持自定义Poc文件的图形化漏洞利用工具 基于java fx写的一款支持加载自定义poc文件的、可扩展的的图形化渗透测试框架。支持批量漏洞扫描、漏洞利用、结果导出等功能。 使用 经过测试,项目可在jdk8环境下正常使用。jdk11因为缺少一些必要的组件,所以jdk11版本工…

《凤凰架构》 -分布式事务章节 读书笔记

分布式事务严谨的定义&#xff1a;分布式环境下的事务处理机制 CAP定理&#xff1a;在一个分布式系统中&#xff0c;涉及共享数据问题时&#xff0c;以下三个特性最多只能同时满足两个 一致性&#xff1a;代表数据在任何时刻、任何分布式节点中看到的都是符合预期的&#xff0…

嵌入式按键处理驱动(easy_button)

简介 在嵌入式裸机开发中&#xff0c;经常有按键的管理需求&#xff0c;GitHub上已经有蛮多成熟的按键驱动了&#xff0c;但是由于这样那样的问题&#xff0c;最终还是自己实现了一套。本项目地址&#xff1a;bobwenstudy/easy_button (github.com)。 项目开发过程中参考了如…

基于Java SSM框架实现问卷调查系统项目【项目源码】计算机毕业设计

基于java的SSM框架实现问卷调查系统演示 B/S结构 BROWSER/SERVER程序架构方式是使用电脑中安装的各种浏览器来进行访问和使用的&#xff0c;相比C/S的程序结构不需要进行程序的安装就可以直接使用。BROWSER/SERVER架构的运行方式是在远程的服务器上进行安装一个&#xff0c;然…

《隐私计算简易速速上手小册》第7章:隐私计算与云计算/边缘计算(2024 最新版)

文章目录 7.1 云计算中的隐私保护7.1.1 基础知识7.1.2 主要案例:使用 Python 实现云数据的安全上传和访问7.1.3 拓展案例 1:实现基于角色的访问控制7.1.4 拓展案例 2:使用 Python 保护 API 安全7.2 边缘计算的隐私问题7.2.1 基础知识7.2.2 主要案例:使用 Python 实现边缘设…

Mycat核心教程--mycat实战应用【一】

Mycat核心教程--mycat实战应用 一、MyCat概述1.1.Mycat 是数据库中间件1.2.为什么要用Mycat1.3.数据库中间件对比1.4.Mycat的官网1.4.1.Mycat的官网:[http://www.mycat.org.cn/](http://www.mycat.org.cn/)1.4.2.右上角下载里面有个文件下载服务&#xff0c;点进去发现无法访问…

Golang Redis:构建高效和可扩展的应用程序

利用Redis的闪电般的数据存储和Golang的无缝集成解锁协同效应 在当前的应用程序开发中&#xff0c;高效的数据存储和检索的必要性已经变得至关重要。Redis&#xff0c;作为一个闪电般快速的开源内存数据结构存储方案&#xff0c;为各种应用场景提供了可靠的解决方案。在这份完…

牛客网 HJ10 字符个数统计

思路&#xff1a; 我们创建两个数组&#xff0c;一个数组接受输入的字符&#xff0c;另一个数组用来统计字符种数 同时将该字符作为下标传给另一个数组&#xff0c;如果另一个数组的这个下标对应的值为0&#xff0c;说明该字符没有被统计过&#xff0c;计数器加1&#xff0c;…

Nest.js权限管理系统开发(三)环境变量与配置文件

一般来说数据库的配置包含了一些敏感信息&#xff0c;不宜写在代码中提交到远程仓库&#xff0c;所以我们可以将配置写在配置文件中,然后提交 git 时候将生产环境的配置文件其忽略。我们可以新建.env和.env.prod两个文件分别存放开发与生产环境配置&#xff0c;也可以使用YAML等…