Back to glossary

Term

TGI (Text Generation Inference)

TGI (Text Generation Inference) is an open-source toolkit from Hugging Face for serving large language models efficiently. It provides a production-ready inference server with continuous batching, token streaming and optimised attention methods.

TGI (Text Generation Inference) — explained in detail

Text Generation Inference, or TGI for short, is a toolkit written in Rust and Python by Hugging Face for deploying and serving large language models (LLMs). It provides a server that loads a model and makes it available for requests over an HTTP interface — comparable to a specialised web server for text generation.

TGI’s focus is on efficiency in production. Continuous batching dynamically groups incoming requests and keeps the hardware better utilised than rigid batch inference. Token streaming delivers generated tokens continuously via Server-Sent Events. Optimised attention and decoding methods such as Flash Attention and Paged Attention with KV caching reduce latency and memory usage. TGI also supports quantisation as well as an OpenAI-compatible API and structured outputs via JSON and regex grammars.

TGI supports common open model families such as Llama, Falcon, StarCoder and BLOOM, and is used at Hugging Face itself to power services like the Inference API and Inference Endpoints. Importantly, since late 2025 TGI has been in maintenance mode; for new inference endpoints Hugging Face recommends alternative engines such as vLLM or SGLang.

Example / Practical use

A company that wants to run an open language model on its own GPU hardware can start TGI as a container, specify the desired model and immediately obtain an API endpoint. An application sends prompts to this endpoint and receives the response as a stream. Thanks to continuous batching, the same server can serve many parallel user requests without holding a separate model instance for each.

TGI is an inference server and thus sits alongside vLLM and Ollama. vLLM takes a similar approach with a focus on maximum throughput and, since TGI entered maintenance mode, is often regarded as its successor. Ollama, by contrast, is geared more towards simple local use on individual machines. All three solve the same task — making models available efficiently — but differ in target audience, performance profile and operational convenience.

Entdecke mehr

Themenuebersicht