mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-10 20:04:52 +00:00
Initial commit
This commit is contained in:
parent
888c029114
commit
b581eb7151
@ -21,4 +21,6 @@
|
||||
- sections:
|
||||
- local: conceptual/streaming
|
||||
title: Streaming
|
||||
- local: conceptual/quantization
|
||||
title: Quantization
|
||||
title: Conceptual Guides
|
||||
|
@ -4,7 +4,7 @@ Text Generation Inference improves the model in several aspects.
|
||||
|
||||
## Quantization
|
||||
|
||||
TGI supports [bits-and-bytes](https://github.com/TimDettmers/bitsandbytes#bitsandbytes) and [GPT-Q](https://arxiv.org/abs/2210.17323) quantization. To speed up inference with quantization, simply set `quantize` flag to `bitsandbytes` or `gptq` depending on the quantization technique you wish to use. When using GPT-Q quantization, you need to point to one of the models [here](https://huggingface.co/models?search=gptq).
|
||||
TGI supports [bits-and-bytes](https://github.com/TimDettmers/bitsandbytes#bitsandbytes) and [GPT-Q](https://arxiv.org/abs/2210.17323) quantization. To speed up inference with quantization, simply set `quantize` flag to `bitsandbytes` or `gptq` depending on the quantization technique you wish to use. When using GPT-Q quantization, you need to point to one of the models [here](https://huggingface.co/models?search=gptq). To get more information about quantization, please refer to (./conceptual/quantization.md)
|
||||
|
||||
|
||||
## RoPE Scaling
|
||||
|
37
docs/source/conceptual/quantization.md
Normal file
37
docs/source/conceptual/quantization.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Quantization
|
||||
|
||||
TGI offers GPTQ and bits-and-bytes quantization to quantize large language models.
|
||||
|
||||
## Quantization with GPTQ
|
||||
|
||||
GPTQ is a post-training quantization method to make the model smaller. It quantizes each weight by finding a compressed version of that weight, that will yield a minimum mean squared error like below 👇
|
||||
|
||||
Given a layer \(l\) with weight matrix \(W_{l}\) and layer input \(X_{l}\), find quantized weight \(\hat{W}_{l}\):
|
||||
|
||||
\({\hat{W}{l}}^{*} = argmin{\hat{W_{l}}} |W_{l}X-\hat{W}{l}X|^{2}{2}\)
|
||||
|
||||
TGI allows you to both run an already GPTQ quantized model (see available models [here](https://huggingface.co/models?search=gptq)) or quantize a model of your choice using quantization script by simply passing --quantize like below 👇
|
||||
|
||||
```bash
|
||||
docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:latest --model-id $model --quantize gptq
|
||||
```
|
||||
|
||||
Note that TGI's GPTQ implementation is different than [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ).
|
||||
|
||||
To run quantization only with a calibration dataset, simply run
|
||||
|
||||
```bash
|
||||
text-generation-server quantize tiiuae/falcon-40b /data/falcon-40b-gptq
|
||||
# Add --upload-to-model-id MYUSERNAME/falcon-40b to push the created model to the hub directly
|
||||
```
|
||||
|
||||
This will create a new directory with the quantized files which you can use with,
|
||||
|
||||
```bash
|
||||
text-generation-launcher --model-id /data/falcon-40b-gptq/ --sharded true --num-shard 2 --quantize gptq
|
||||
```
|
||||
|
||||
You can learn more about the quantization options by running `text-generation-server quantize --help`.
|
||||
|
||||
If you wish to do more with GPTQ models (e.g. train an adapter on top), you can read about transformers GPTQ integration [here](https://huggingface.co/blog/gptq-integration).
|
||||
You can learn more about GPTQ from the [paper](https://arxiv.org/pdf/2210.17323.pdf).
|
Loading…
Reference in New Issue
Block a user