Case Study

Right-Sizing a BERT Encoder for a Multilingual Support-Ticket Router Without Breaking the Memory Budget

You are leading an ML platform team that must ship a BERT-style encoder (trained with masked language modeling and next sentence prediction) to power a support-ticket router. The model will run in a Kubernetes service with a hard limit of 1.2 GB RAM per pod and must handle English plus a morphologically rich language (many word forms). Product requires that rare product codes and error strings remain distinguishable (they matter for routing), but latency is already borderline.

Two candidate designs are proposed:

Design A ("Bigger vocab, smaller hidden"):

  • Vocabulary size |V| = 120,000
  • Embedding size d_e = 384
  • 12 Transformer layers, all with unique parameters
  • No distillation

Design B ("Smaller vocab, larger hidden + compression"):

  • Vocabulary size |V| = 30,000
  • Embedding size d_e = 768
  • 12 Transformer layers with cross-layer parameter sharing (one layer's parameters reused across all 12)
  • Student model trained via knowledge distillation from a large teacher BERT

Assume the token embedding matrix is a major contributor to model size and scales approximately with |V| × d_e, and that cross-layer parameter sharing primarily reduces the number of unique layer parameters (not the embedding matrix). Also assume distillation can recover some accuracy lost due to compression but adds training complexity.

Which design (A or B) is the better overall choice to meet the RAM limit while preserving routing quality for rare strings, and why? Your answer must explicitly connect (1) the vocabulary-size trade-off, (2) embedding size effects, (3) cross-layer parameter sharing, and (4) knowledge distillation in a single coherent justification, including at least one concrete risk you would monitor after deployment.

0

1

Updated 2026-02-06

Contributors are:

Who are from:

Tags

Data Science

Foundations of Large Language Models Course

Computing Sciences

Ch.1 Pre-training - Foundations of Large Language Models

Foundations of Large Language Models

Ch.2 Generative Models - Foundations of Large Language Models

Related