Back to services

Text Generation Inference

Large Language Model Text Generation Inference

View alternatives to Text Generation Inference
Suggest edit
Open source
Self-hostable
Apache-2.0
Recent reviews

Alternatives

Tech stack

No tech stack added yet. Sign in to suggest some

Overview

Text Generation Inference (TGI) is a toolkit developed by Hugging Face for deploying large language models and serving them for inference. It is written mainly in Rust and Python, and its components communicate with each other over gRPC. Hugging Face's own inference products, such as Inference Endpoints and HuggingChat, have used it to run open-source models.

Note: The official website could not be retrieved when this entry was written, so the content below is compiled from publicly known information about the project. For details such as version, license and maintenance status, please refer to the official documentation and the GitHub repository.

Key Features

  • Simple startup: A single command loads popular models from the Hugging Face Hub and starts the service.
  • Continuous Batching: Incoming requests are dynamically merged into batches, which improves overall throughput.
  • Streaming output: Generated tokens are returned one by one via Server-Sent Events (SSE).
  • Tensor parallelism: A model is split across multiple GPUs to speed up inference.
  • Inference optimizations: Techniques such as Flash Attention and Paged Attention are used in the Transformer inference code.
  • Quantization support: Supports quantization methods such as bitsandbytes, GPTQ and AWQ, which can reduce GPU memory usage.
  • Structured output: The output format can be controlled with JSON Schema or grammar constraints (Guidance).
  • OpenAI-compatible API: Provides a Messages API that plugs directly into the existing OpenAI client ecosystem.
  • Production observability: Supports Prometheus metrics and OpenTelemetry distributed tracing.
  • Other capabilities: Supports Safetensors weight loading, stop sequences, log probability output, and sampling parameters such as temperature, top-p and top-k.

Target Users and Use Cases

  • Companies and teams that need to deploy open-source LLMs privately on their own infrastructure
  • Developers who need to build high-concurrency, low-latency LLM API services
  • Researchers who need to quickly evaluate and compare the performance of different open-source models
  • The backend inference layer for applications such as RAG, chatbots and code assistants

Deployment

The officially recommended way to deploy is with Docker, for example:

model=mistralai/Mistral-7B-Instruct-v0.2
volume=$PWD/data

docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data \
  ghcr.io/huggingface/text-generation-inference:latest \
  --model-id $model

Once the service is running, you can call it through the /generate, /generate_stream or OpenAI-compatible /v1/chat/completions endpoints. You can also access it using InferenceClient from the huggingface_hub Python library.

Technical Requirements

  • Mainly targets NVIDIA GPUs (CUDA), and also supports hardware such as AMD GPUs (ROCm), Intel Gaudi and AWS Inferentia
  • GPU memory requirements depend on the model size and quantization method
  • Docker deployment is recommended; you can also build from source (requires Rust and Python environments)

Notable Characteristics

  • Deeply integrated with the Hugging Face Hub, so models can be pulled directly by model ID
  • Production-oriented features, including batch scheduling, monitoring and tracing
  • Other open-source inference frameworks of this kind include vLLM, SGLang and TensorRT-LLM; you can choose among them based on your hardware and performance needs