Learning Compressed Embeddings for On-Device Inference

Niketan Pansare, Jay Katukuri, Aditya Arora, Frank Cipollone, Riyaaz Shaik, Noyan Tokgozoglu, Chandru VenkataramanMar 2022

Problem

In recommendation models, an embedding layer maps every entity (app, movie, game) to its own vector, so memory grows with the number of entities. A single category can have hundreds of thousands of entities, and the layer can take gigabytes. That blocks deployment on resource-constrained devices such as smartphones. Plain hashing forces several entities to share one embedding, so the model can no longer tell them apart.

Example from the article: a ranking model over millions of users' interactions with games, compressed 32x with 1% relative loss in nDCG.

Solution in brief

MEmCom (Multi-Embedding Compression) builds each entity's embedding on the fly from two tables. A small hashed table makes several entities share a row. A second table holds one trainable weight per entity, which lets the model tell the sharing entities apart. Both tables are trained jointly.

Questions this case answers
  • How to cut the memory of a large categorical embedding layer by an order of magnitude when the deployment target has a hard memory limit and every category still needs its own representation
  • How to compress a model trained on a high-cardinality categorical input while keeping ranking quality close to the uncompressed model
  • How to shrink a recommender's embedding table so the model fits on a phone without giving up a unique vector per item?
  • How to compress the input embedding layer by 10x or more while losing only a few percent of nDCG?

Tools and methods

  • MEmCom — hashed embedding table plus a per-entity trainable weight, trained jointly
  • Hashing trick — maps entity ids to a small number of shared rows
  • Embedding quantization — half precision or 8-bit on top of MEmCom (per the paper)
  • TensorFlow / TensorFlow Lite — framework of the paper's experiments and on-device runtime benchmark (per the paper)
Continue reading — it's free

Google or a one-time email code. No password.