Urgent.News

What's breaking now, across hundreds of outlets.

AI

How to Deploy Hugging Face Models in Production

There's a moment every ML engineer hits the first time they try to put a Hugging Face model behind a real API. You grab transformers , you wrap it in FastAPI, you pipeline("text-generation", model=...) , you curl it once, it works, you push to prod, and at peak traffic your GPU OOMs and the latency goes to 30 seconds. That's the moment you learn that serving a model is not the same as running a…

Serving Hugging Face models in production is a challenge that every machine learning engineer faces. The article discusses four options to deploy Hugging Face models, and the importance of continuous batching.

The first option is HF Inference Endpoints, which is a managed service that provides an OpenAI-compatible endpoint quickly. It's suitable for prototypes, internal tools, low-traffic production, or when you don't have a platform team. However, it's not recommended for high-traffic production, regulated environments, or when you need custom inference logic. Pricing is based on cloud GPU rate plus a markup, billed per second.

The second option is TGI (Text Generation Inference), which is the production LLM server that powers Inference Endpoints internally. It's launched as a Docker image and can be tuned with various flags. It's a good option for production LLM serving with high compute and infrastructure.

The third option is vLLM, which is the open-source throughput king. It generally provides 1.2-2x faster performance than TGI. Continuous batching, which inserts new requests into the batch at every token step, is the single biggest optimization for LLM serving. vLLM supports various quantization methods and tensor parallelism for multi-GPU serving.

Finally, the article advises against wrapping AutoModelForCausalLM in FastAPI and calling model.generate() per request, as it results in poor throughput and out-of-memory issues under load. Continuous batching is the key to maximizing LLM serving throughput.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in AI

Cellular Data Cost per Device for Streaming LLM Audio

Raw 16-bit PCM at 16 kHz uses 1.92 MB per audio minute, and at 24 kHz it uses 2.88 MB. Opus at 16 to 20 kbit/s uses 0.12 to 0.15 MB.

  • Raw 16-bit PCM at 16 kHz consumes 1.92 MB per minute.
  • Opus at 20 kbit/s both ways reduces monthly cost to $1.35.
  • Monthly data cost formula includes minutes, format, price, and SIM charge.

How much does AI integration cost? Read the drivers before the quote

If you're trying to work out how much an AI integration will cost, you've probably noticed that nobody will answer without a call, and that quotes for what sounds like the same job can be far apart.

  • Identify systems as readers or writers to determine integration cost.
  • Consider data quality issues and permissions for additional expenses.
  • Evaluate building, buying, or using existing AI capabilities for cost-effectiveness.

More from Friday 27 November →