模型介绍
中文整理Chat & support: TheBloke's Discord server
Want to contribute? TheBloke's Patreon page
TheBloke's LLM work is generously supported by a grant from andreessen horowitz (a16z)
Qwen 7B Chat - GPTQ
Model creator: Qwen
Original model: Qwen 7B Chat
Description
This repo contains GPTQ model files for Qwen's Qwen 7B Chat.
Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
These files were quantised using hardware kindly provided by Massed Compute.
Repositories available
GPTQ models for GPU inference, with multiple quantisation parameter options.
Qwen's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions
Prompt template: ChatML
Known compatible clients / servers
These GPTQ models are known to work in the following inference servers/webuis.
text-generation-webui
KoboldAI United
LoLLMS Web UI
Hugging Face Text Generation Inference (TGI)
This may not be a complete list; if you know of others, please let me know!
Provided files, and GPTQ parameters
Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
Each separate quant is in a different branch. See below for instructions on fetching from different branches.
Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
Explanation of GPTQ parameters
Bits: The bit size of the quantised model.
GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
Act Order: True or False. Also known as desc act . True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
Branch Bits GS Act Order Damp % GPTQ Dataset Seq Len Size ExLlama Desc
- ----- ---- -- --------- ------ ------------ ------- ---- ------- ----
main 4 128 Yes 0.1 wikitext 8192 4.62 GB No 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy.
gptq-4bit-32g-actorder True 4 32 Yes 0.1 wikitext 8192 5.00 GB No 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage.
gptq-8bit--1g-actorder True 8 None Yes 0.1 wikitext 8192 4.96 GB No 8-bit, with Act Order. No group size, to lower VRAM requirements.
gptq-8bit-128g-actorder True 8 128 Yes 0.1 wikitext 8192 4.98 GB No 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy.
gptq-8bit-32g-actorder True 8 32 Yes 0.1 wikitext 8192 4.96 GB No 8-bit, with group size 32g and Act Order for maximum inference quality.
gptq-4bit-64g-actorder True 4 64 Yes 0.1 wikitext 8192 4.74 GB No 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy.
How to download, including from branches
In text-generation-webui
To download from the main branch, enter TheBloke/Qwen-7B-Chat-GPTQ in the "Download model" box.
To download from another branch, add :branchname to the end of the download name, eg TheBloke/Qwen-7B-Chat-GPTQ:gptq-4bit-32g-actorder True
From the command line
I recommend using the huggingface-hub Python library:
To download the main branch to a folder called Qwen-7B-Chat-GPTQ :
To download from a different branch, add the --revision parameter:
More advanced huggingface-cli download usage
If you remove the --local-dir-use-symlinks False parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: ~/.cache/huggingface ), and symlinks will be added to the specified --local-dir , pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
The cache location can be changed with the HF HOME environment variable, and/or the --cache-dir parameter to huggingface-cli .
For more documentation on downloading with huggingface-cli , please see: HF -> Hub Python Library -> Download files -> Download from the CLI.
To accelerate downloads on fast connections (1Gbit/s or higher), install hf transfer :
And set environment variable HF HUB ENABLE HF TRANSFER to 1 :
Windows Command Line users: You can set the environment variable by running set HF HUB ENABLE HF TRANSFER=1 before the download command.
With git (**not** recommended)
To clone a specific branch with git , use a command like this:
Note that using Git with HF repos is strongly discouraged. It will be much slower than using huggingface-hub , and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the .git folder as a blob.)
How to easily download and use this model in text-generation-webui
Please make sure you're using the latest version of text-generation-webui.
It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
- Click the **Model tab**.
- Under **Download custom model or LoRA**, enter TheBloke/Qwen-7B-Chat-GPTQ .
- To download from a specific branch, enter for example TheBloke/Qwen-7B-Chat-GPTQ:gptq-4bit-32g-actorder True
- see Provided Files above for the list of branches for each option.
- Click **Download**.
- The model will start downloading. Once it's finished it will say "Done".
- In the top left, click the refresh icon next to **Model**.
- In the **Model** dropdown, choose the model you just downloaded: Qwen-7B-Chat-GPTQ
- The model will automatically load, and is now ready for use!
- If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
- Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file quantize config.json .
- Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
Serving this model from Text Generation Inference (TGI)
It's recommended to use TGI version 1.1.0 or later. The official Docker container is: ghcr.io/huggingface/text-generation-inference:1.1.0
Example Docker parameters:
Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
Python code example: inference from this GPTQ model
Install the necessary packages
Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
If you are using PyTorch 2.0, you will need to install AutoGPTQ from source. Likewise if you have problems with the pre-built wheels, you should try building from source:
Example Python code
Compatibility
The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
ExLlama is compatible with Llama and Mistral models in 4-bit. Please see the Provided Files table above for per-file compatibility.
For a list of clients/servers, please see "Known compatible clients / servers", above.
Discord
For further support, and discussions on these models and AI in general, join us at:
TheBloke AI's Discord server
Thanks, and how to contribute
Thanks to the chirper.ai team!
Thanks to Clay from gpus.llm-utils.org!
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
Patreon: https://patreon.com/TheBlokeAI
Ko-Fi: https://ko-fi.com/TheBlokeAI
Special thanks to**: Aemon Algiz.
Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
Thank you to all my generous patrons and donaters!
And thank you again to a16z for their generous grant.
Original model card: Qwen's Qwen 7B Chat
Qwen-7B-Chat
🤗 Hugging Face     🤖 ModelScope      📑 Paper   |   🖥️ Demo
WeChat (微信)   |    DingTalk (钉钉)      Discord  
介绍(Introduction)
通义千问-7B(Qwen-7B)**是阿里云研发的通义千问大模型系列的70亿参数规模的模型。Qwen-7B是基于Transformer的大语言模型, 在超大规模的预训练数据上进行训练得到。预训练数据类型多样,覆盖广泛,包括大量网络文本、专业书籍、代码等。同时,在Qwen-7B的基础上,我们使用对齐机制打造了基于大语言模型的AI助手Qwen-7B-Chat。相较于最初开源的Qwen-7B模型,我们现已将预训练模型和Chat模型更新到效果更优的版本。本仓库为Qwen-7B-Chat的仓库。
如果您想了解更多关于通义千问-7B开源模型的细节,我们建议您参阅GitHub代码库。
Qwen-7B** is the 7B-parameter version of the large language model series, Qwen (abbr. Tongyi Qianwen), proposed by Alibaba Cloud. Qwen-7B is a Transformer-based large language model, which is pretrained on a large volume of data, including web texts, books, codes, etc. Additionally, based on the pretrained Qwen-7B, we release Qwen-7B-Chat, a large-model-based AI assistant, which is trained with alignment techniques. Now we have updated both our pretrained and chat models with better performances. This repository is the one for Qwen-7B-Chat.
For more details about Qwen, please refer to the GitHub code repository.
要求(Requirements)
python 3.8及以上版本
pytorch 1.12及以上版本,推荐2.0及以上版本
建议使用CUDA 11.4及以上(GPU用户、flash-attention用户等需考虑此选项)
python 3.8 and above
pytorch 1.12 and above, 2.0 and above are recommended
CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
依赖项(Dependency)
运行Qwen-7B-Chat,请确保满足上述要求,再执行以下pip命令安装依赖库
To run Qwen-7B-Chat, please make sure you meet the above requirements, and then execute the following pip commands to install the dependent libraries.
另外,推荐安装 flash-attention 库(**当前已支持flash attention 2**),以实现更高的效率和更低的显存占用。
In addition, it is recommended to install the flash-attention library (**we support flash attention 2 now.**) for higher efficiency and lower memory usage.
快速使用(Quickstart)
下面我们展示了一个使用Qwen-7B-Chat模型,进行多轮对话交互的样例:
We show an example of multi-turn interaction with Qwen-7B-Chat in the following code:
关于更多的使用说明,请参考我们的GitHub repo获取更多信息。
For more information, please refer to our GitHub repo for more information.
Tokenizer
注:作为术语的“tokenization”在中文中尚无共识的概念对应,本文档采用英文表达以利说明。
基于tiktoken的分词器有别于其他分词器,比如sentencepiece分词器。尤其在微调阶段,需要特别注意特殊token的使用。关于tokenizer的更多信息,以及微调时涉及的相关使用,请参阅文档。
Our tokenizer based on tiktoken is different from other tokenizers, e.g., sentencepiece tokenizer. You need to pay attention to special tokens, especially in finetuning. For more detailed information on the tokenizer and related use in fine-tuning, please refer to the documentation.
量化 (Quantization)
用法 (Usage)
请注意:我们更新量化方案为基于AutoGPTQ的量化,提供Qwen-7B-Chat的Int4量化模型点击这里。相比此前方案,该方案在模型评测效果几乎无损,且存储需求更低,推理速度更优。**
Note: we provide a new solution based on AutoGPTQ, and release an Int4 quantized model for Qwen-7B-Chat Click here, which achieves nearly lossless model effects but improved performance on both memory costs and inference speed, in comparison with the previous solution.**
以下我们提供示例说明如何使用Int4量化模型。在开始使用前,请先保证满足要求(如torch 2.0及以上,transformers版本为4.32.0及以上,等等),并安装所需安装包:
Here we demonstrate how to use our provided quantized models for inference. Before you start, make sure you meet the requirements of auto-gptq (e.g., torch 2.0 and above, transformers 4.32.0 and above, etc.) and install the required packages:
如安装 auto-gptq 遇到问题,我们建议您到官方repo搜索合适的预编译wheel。
随后即可使用和上述一致的用法调用量化模型:
If you meet problems installing auto-gptq , we advise you to check out the official repo to find a pre-build wheel.
Then you can load the quantized model easily and run inference as same as usual:
效果评测
我们对BF16,Int8和Int4模型在基准评测上做了测试(使用zero-shot设置),发现量化模型效果损失较小,结果如下所示:
We illustrate the zero-shot performance of both BF16, Int8 and Int4 models on the benchmark, and we find that the quantized model does not suffer from significant performance degradation. Results are shown below:
Quantization MMLU CEval (val) GSM8K Humaneval
- ------------ :--------: :----------: :----: :--------:
BF16 55.8 59.7 50.3 37.2
Int8 55.4 59.4 48.3 34.8
Int4 55.1 59.2 49.7 29.9
推理速度 (Inference Speed)
我们测算了不同精度模型以及不同FlashAttn库版本下模型生成2048和8192个token的平均推理速度。如图所示:
We measured the average inference speed of generating 2048 and 8192 tokens with different quantization levels and versions of flash-attention, respectively.
Quantization FlashAttn Speed (2048 tokens) Speed (8192 tokens)
- ------------ :-------: :------------------: :------------------:
BF16 v2 40.93 36.14
Int8 v2 37.47 32.54
Int4 v2 50.09 38.61
BF16 v1 40.75 35.34
Int8 v1 37.51 32.39
Int4 v1 45.98 36.47
BF16 Disabled 37.55 33.56
Int8 Disabled 37.84 32.65
Int4 Disabled 48.12 36.70
具体而言,我们记录在长度为1的上下文的条件下生成8192个token的性能。评测运行于单张A100-SXM4-80G GPU,使用PyTorch 2.0.1和CUDA 11.8。推理速度是生成8192个token的速度均值。
In detail, the setting of profiling is generating 8192 new tokens with 1 context token. The profiling runs on a single A100-SXM4-80G GPU with PyTorch 2.0.1 and CUDA 11.8. The inference speed is averaged over the generated 8192 tokens.
注意:以上Int4/Int8模型生成速度使用autogptq库给出,当前 AutoModelForCausalLM.from pretrained 载入的模型生成速度会慢大约20%。我们已经将该问题汇报给HuggingFace团队,若有解决方案将即时更新。
Note: The generation speed of the Int4/Int8 models mentioned above is provided by the autogptq library. The current speed of the model loaded using "AutoModelForCausalLM.from pretrained" will be approximately 20% slower. We have reported this issue to the HuggingFace team and will update it promptly if a solution is available.
显存使用 (GPU Memory Usage)
我们还测算了不同模型精度编码2048个token及生成8192个token的峰值显存占用情况。(显存消耗在是否使用FlashAttn的情况下均类似。)结果如下所示:
We also profile the peak GPU memory usage for encoding 2048 tokens as context (and generating single token) and generating 8192 tokens (with single token as context) under different quantization levels, respectively. (The GPU memory usage is similar when using flash-attention or not.)The results are shown below.
Quantization Level Peak Usage for Encoding 2048 Tokens Peak Usage for Generating 8192 Tokens
- ----------------- :---------------------------------: :-----------------------------------:
BF16 16.99GB 22.53GB
Int8 11.20GB 16.62GB
Int4 8.21GB 13.63GB
上述性能测算使用此脚本完成。
The above speed and memory profiling are conducted using this script.
模型细节(Model)
与Qwen-7B预训练模型相同,Qwen-7B-Chat模型规模基本情况如下所示:
The details of the model architecture of Qwen-7B-Chat are listed as follows:
Hyperparameter Value
:---------------- :------:
n layers 32
n heads 32
d model 4096
vocab size 151851
sequence length 8192
在位置编码、FFN激活函数和normalization的实现方式上,我们也采用了目前最流行的做法,
即RoPE相对位置编码、SwiGLU激活函数、RMSNorm(可选安装flash-attention加速)。
在分词器方面,相比目前主流开源模型以中英词表为主,Qwen-7B-Chat使用了约15万token大小的词表。
该词表在GPT-4使用的BPE词表 cl100k base 基础上,对中文、多语言进行了优化,在对中、英、代码数据的高效编解码的基础上,对部分多语言更加友好,方便用户在不扩展词表的情况下对部分语种进行能力增强。
词表对数字按单个数字位切分。调用较为高效的tiktoken分词库进行分词。
For position encoding, FFN activation function, and normalization calculation methods, we adopt the prevalent practices, i.e., RoPE rela
优先采用原作者提供的中文模型卡片;仅有英文说明时由闲社AI翻译整理。重要参数、许可证和商用范围请以原文为准。
你将获得什么
完整仓库方式包含该固定版本中的权重、配置、分词器及说明文件;指定版本方式只下载所选文件或整组分片。多模态模型的投影文件、配置等依赖,请按作者说明配齐。
完整仓库可能包含多个权重格式,因此需要的磁盘空间可能大于单一格式的模型大小。下载文件不等于完成模型部署。
使用前须知
运行模型需要的设备、工具与依赖,以原作者说明为准。
是否允许商用、修改和分发,请查看模型许可证。
闲社提供资料与镜像下载方法,不代表已运行模型或完成安全审计。下载的代码应先检查,再执行。
Problem with the information or download?
Sign in to submit feedback.
