Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Amazon Science 4 min read Case study mediumAdept

Speeding up language models for travel applications

Combining knowledge distillation with Medusa multi-token decoding let Booking.com replace large LLMs with a 1.1B-parameter TinyLlama student that matches a Llama-3.1 70B teacher while running 10 to 20 times as fast. The student is trained on human-labeled data plus teacher-generated labels, with Medusa heads attached and trained in the same stage. Distillation closed over 90% of the quality gap and gave roughly a 6x speedup. Medusa added another 2 to 3.6x, and the single-stage Medusa-2 variant was preferred for its simpler production pipeline. Across trip planning, smart filters and listing description generation, results included 15x faster p99 responses and descriptions at under one-third the cost of GPT-4.

Related posts

  • Consistency diffusion language models: Up to 14x faster inference without sacrificing quality

    Together AI hardMaster

    Consistency diffusion language models (CDLM) speed up diffusion LLM inference by post-training a block-wise causal student that can finalize multiple tokens per step and use exact block-wise KV caching. Training distills from teacher decoding trajectories using three losses: distillation on newly unmasked tokens, a consistency loss on still-masked tokens, and an auxiliary masked-denoising loss. On Dream-7B-Instruct, refinement steps drop by about 4.1x–7.7x with minor accuracy changes, and latency improves by up to 11.2x on GSM8K-CoT and 14.5x on MBPP. Naively truncating steps without this training sharply degrades accuracy. A roofline analysis shows block-wise DLMs sit between memory-bound AR decoding and compute-bound full-attention DLMs, which makes them efficient at small batch sizes.

  • Making Knowledge Distillation Cheap Enough to Run at Scale

    Hugging Face hardMaster

    Two systems changes make LLM knowledge distillation far cheaper: caching the teacher's top-100 logits offline so the teacher never shares memory with the student, and a fused chunked KL loss that folds the output projection into the loss and recomputes chunks in the backward pass, so the full vocabulary × sequence logits grid is never materialized. On a single H200 at 8K context, offline top-100 distillation matches online training loss while cutting peak memory from 102.8 GB to 58.3 GB. In an isolated loss benchmark at 32K tokens, peak memory drops 15.6× (85.2 to 5.45 GiB), and distilling GPT-OSS 20B at 32K context shrank from four nodes to one with about 5× faster steps. The tradeoff is a repeated output projection that costs some speed at short contexts; the implementation is open-sourced.

  • Gisting: Compressing LLM Agent context to ↑ throughput and ↓ cost

    Shopify Engineering hardMaster

    Shopify compressed the ~6,000-token system prompt of its Sidekick GraphQL agent into ~1,500 learned gist tokens (4:1) without losing prediction quality. The gist embeddings are trained by knowledge distillation (KL divergence between full-prompt teacher logits and gist-prompt student logits) with model weights frozen, then written into the embedding matrix so serving needs no special path. Gisting complements prefix caching because decode still streams the whole KV cache per generated token. At 350 RPM, median TTFT fell 19%, end-to-end latency about 38%, and throughput rose 16%, allowing 14% fewer GPUs. Key recipe findings from an autoresearch loop: initialize gists from mean prompt-chunk embeddings, batch-level loss normalization, and precomputed teacher logits cutting training from 30 to 6 hours.

  • Apriel-H1: The Surprising Key to Distilling Efficient Reasoning Models

    Hugging Face hardMaster

    ServiceNow converted its 15B Apriel reasoning model into a Mamba/attention hybrid via distillation, reaching 2.1x throughput with small benchmark shifts (MATH500 up, GPQA and AIME24 slightly down) using 76.8B tokens. The key finding is that distilling on the teacher's high-quality SFT reasoning traces works, while pretraining data or mixed data degrades reasoning. Reverse KL beat forward KL. A staged procedure does the conversion: leave-one-out layer importance for the first 25 layers, then a dynamic MIL-Mamba-Replacement loss heuristic to progressively reach 30–40 Mamba layers, with the 40-layer variant reaching 3.4x throughput. Training uses the open-source Fast-LLM framework, inference runs on Transformers and vLLM, and the authors warn that hybrid deployment tooling is still immature.

  • Productizing Large Language Models

    Replit mediumAdept

    Replit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable. Nonsense and repetition loops are handled with temperature and frequency penalty tuning, cycle detection, multi-temperature sampling, reranking with a second model, and fine-tuning on user feedback. Quality is tracked with HumanEval, loop and nonsense rates, and A/B tests. Inference cost is cut with FasterTransformer, distillation and quantization, and GPUs are run at 70-80% utilization on Kubernetes so request queues stay bounded while autoscaling has headroom.

The quest for software engineering knowledge.

Look:
Layout: