|
13 | 13 | <img alt="Swagger API documentation" src="https://img.shields.io/badge/API-Swagger-informational"> |
14 | 14 | </a> |
15 | 15 |
|
16 | | -A Rust, Python and gRPC server for text generation inference. Used in production at [HuggingFace](https://huggingface.co) |
| 16 | +A Rust, Python and gRPC server for text generation inference. Used in production at [Hugging Face](https://huggingface.co) |
17 | 17 | to power Hugging Chat, the Inference API and Inference Endpoint. |
18 | 18 |
|
19 | 19 | </div> |
@@ -42,14 +42,15 @@ Text Generation Inference (TGI) is a toolkit for deploying and serving Large Lan |
42 | 42 | - Tensor Parallelism for faster inference on multiple GPUs |
43 | 43 | - Token streaming using Server-Sent Events (SSE) |
44 | 44 | - Continuous batching of incoming requests for increased total throughput |
| 45 | +- [Messages API](https://huggingface.co/docs/text-generation-inference/en/messages_api) compatible with Open AI Chat Completion API |
45 | 46 | - Optimized transformers code for inference using [Flash Attention](https://github.com/HazyResearch/flash-attention) and [Paged Attention](https://github.com/vllm-project/vllm) on the most popular architectures |
46 | 47 | - Quantization with : |
47 | 48 | - [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) |
48 | 49 | - [GPT-Q](https://arxiv.org/abs/2210.17323) |
49 | 50 | - [EETQ](https://github.com/NetEase-FuXi/EETQ) |
50 | 51 | - [AWQ](https://github.com/casper-hansen/AutoAWQ) |
51 | 52 | - [Marlin](https://github.com/IST-DASLab/marlin) |
52 | | - - [fp8]() |
| 53 | + - [fp8](https://developer.nvidia.com/blog/nvidia-arm-and-intel-publish-fp8-specification-for-standardization-as-an-interchange-format-for-ai/) |
53 | 54 | - [Safetensors](https://github.com/huggingface/safetensors) weight loading |
54 | 55 | - Watermarking with [A Watermark for Large Language Models](https://arxiv.org/abs/2301.10226) |
55 | 56 | - Logits warper (temperature scaling, top-p, top-k, repetition penalty, more details see [transformers.LogitsProcessor](https://huggingface.co/docs/transformers/internal/generation_utils#transformers.LogitsProcessor)) |
@@ -94,6 +95,29 @@ curl 127.0.0.1:8080/generate_stream \ |
94 | 95 | -H 'Content-Type: application/json' |
95 | 96 | ``` |
96 | 97 |
|
| 98 | +You can also use [TGI's Messages API](https://huggingface.co/docs/text-generation-inference/en/messages_api) to obtain Open AI Chat Completion API compatible responses. |
| 99 | + |
| 100 | +```bash |
| 101 | +curl localhost:3000/v1/chat/completions \ |
| 102 | + -X POST \ |
| 103 | + -d '{ |
| 104 | + "model": "tgi", |
| 105 | + "messages": [ |
| 106 | + { |
| 107 | + "role": "system", |
| 108 | + "content": "You are a helpful assistant." |
| 109 | + }, |
| 110 | + { |
| 111 | + "role": "user", |
| 112 | + "content": "What is deep learning?" |
| 113 | + } |
| 114 | + ], |
| 115 | + "stream": true, |
| 116 | + "max_tokens": 20 |
| 117 | +}' \ |
| 118 | + -H 'Content-Type: application/json' |
| 119 | +``` |
| 120 | + |
97 | 121 | **Note:** To use NVIDIA GPUs, you need to install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html). We also recommend using NVIDIA drivers with CUDA version 12.2 or higher. For running the Docker container on a machine with no GPUs or CUDA support, it is enough to remove the `--gpus all` flag and add `--disable-custom-kernels`, please note CPU is not the intended platform for this project, so performance might be subpar. |
98 | 122 |
|
99 | 123 | **Note:** TGI supports AMD Instinct MI210 and MI250 GPUs. Details can be found in the [Supported Hardware documentation](https://huggingface.co/docs/text-generation-inference/supported_models#supported-hardware). To use AMD GPUs, please use `docker run --device /dev/kfd --device /dev/dri --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:2.2.0-rocm --model-id $model` instead of the command above. |
@@ -122,7 +146,7 @@ For example, if you want to serve the gated Llama V2 model variants: |
122 | 146 | or with Docker: |
123 | 147 |
|
124 | 148 | ```shell |
125 | | -model=meta-llama/Llama-2-7b-chat-hf |
| 149 | +model=meta-llama/Meta-Llama-3.1-8B-Instruct |
126 | 150 | volume=$PWD/data # share a volume with the Docker container to avoid downloading weights every run |
127 | 151 | token=<your cli READ token> |
128 | 152 |
|
@@ -234,14 +258,16 @@ text-generation-launcher --model-id mistralai/Mistral-7B-Instruct-v0.2 |
234 | 258 |
|
235 | 259 | ### Quantization |
236 | 260 |
|
237 | | -You can also quantize the weights with bitsandbytes to reduce the VRAM requirement: |
| 261 | +You can also run pre-quantized weights (AWQ, GPTQ, Marlin) or on-the-fly quantize weights with bitsandbytes, EETQ, fp8, to reduce the VRAM requirement: |
238 | 262 |
|
239 | 263 | ```shell |
240 | 264 | text-generation-launcher --model-id mistralai/Mistral-7B-Instruct-v0.2 --quantize |
241 | 265 | ``` |
242 | 266 |
|
243 | 267 | 4bit quantization is available using the [NF4 and FP4 data types from bitsandbytes](https://arxiv.org/pdf/2305.14314.pdf). It can be enabled by providing `--quantize bitsandbytes-nf4` or `--quantize bitsandbytes-fp4` as a command line argument to `text-generation-launcher`. |
244 | 268 |
|
| 269 | +Read more about quantization in the [Quantization documentation](https://huggingface.co/docs/text-generation-inference/en/conceptual/quantization). |
| 270 | + |
245 | 271 | ## Develop |
246 | 272 |
|
247 | 273 | ```shell |
|
0 commit comments