Your deployed Random Forest is too large in memory to serve. How would you shrink it while preserving accuracy?

Quick Overview

Asks how you would reduce the memory footprint of a deployed Random Forest while keeping its accuracy. Tests whether you can find what drives model size, validate every reduction properly, and weigh retraining, compact storage and replacing the model against each other.

Your deployed Random Forest is too large in memory to serve. How would you shrink it while preserving accuracy?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Your deployed Random Forest is too large in memory to serve. How would you shrink it while preserving accuracy? ```hint Find where the memory goes Write the model's size as a product of a few factors and ask which factor is largest for a forest of fully grown trees. ``` ```hint Measure every cut Decide how you will check that each reduction keeps accuracy, ideally without setting aside more of the training data. ``` ### Clarifying Questions to Ask - What is the memory budget, and is the limit on RAM in the serving process or on the size of the model file? - How much accuracy, and on which metric, are we allowed to give up? - Can we retrain the model, or do we have to work with the fitted forest as it is? - What runtime serves the model (Python with scikit-learn, a JVM service, an edge device), and can it change? - Is this classification or regression, and how many classes are there? ### What a Strong Answer Covers - A breakdown of model size into the number of trees, the nodes per tree and the bytes per node, with a plan for each. - How accuracy is checked after every change (out-of-bag or held-out data) and how the stopping point is chosen. - Ways to shrink the stored representation, and the difference between size on disk and size in memory. - Distillation or a different model family when the forest still does not fit. ### Follow-up Questions - How would you choose a subset of trees from an already trained forest without retraining? - If the binding limit were prediction latency instead of memory, what would change in your plan? - How would you distill the forest, and what inputs would you train the student on? - How do you confirm that a compiled or converted model gives the same predictions as the original?

Overview: Asks how you would reduce the memory footprint of a deployed Random Forest while keeping its accuracy. Tests whether you can find what drives model size, validate every reduction properly, and weigh retraining, compact storage and replacing the model against each other.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Your deployed Random Forest is too large in memory to serve. How would you shrink it while preserving accuracy?

Clarifying Questions to Ask Guidance

  • What is the memory budget, and is the limit on RAM in the serving process or on the size of the model file?
  • How much accuracy, and on which metric, are we allowed to give up?
  • Can we retrain the model, or do we have to work with the fitted forest as it is?
  • What runtime serves the model (Python with scikit-learn, a JVM service, an edge device), and can it change?
  • Is this classification or regression, and how many classes are there?

What a Strong Answer Covers Guidance

  • A breakdown of model size into the number of trees, the nodes per tree and the bytes per node, with a plan for each.
  • How accuracy is checked after every change (out-of-bag or held-out data) and how the stopping point is chosen.
  • Ways to shrink the stored representation, and the difference between size on disk and size in memory.
  • Distillation or a different model family when the forest still does not fit.

Follow-up Questions Guidance

  • How would you choose a subset of trees from an already trained forest without retraining?
  • If the binding limit were prediction latency instead of memory, what would change in your plan?
  • How would you distill the forest, and what inputs would you train the student on?
  • How do you confirm that a compiled or converted model gives the same predictions as the original?