Formal Algorithms for Model Efficiency