TLDRocket
Sign in

Best Practices

19 summarised stories about Best Practices, each linking back to the original source. Browse all topics →

Tuesday, 5 April 2022

~Don't~ Repeat Yourself

Hugging Face Blog 4 years ago

Hugging Face's Transformers library deliberately violates the DRY (Don't Repeat Yourself) programming principle by duplicating code across 50+ model files rather than centralizing shared components. The library enforces a "single model file policy" where all code needed to understand a model's forward pass exists in one file, with a "copying mechanism" using # Copied from comments to keep related models synchronized. This design prioritizes contributor accessibility and code readability for the open-source community over traditional maintainability, accepting that machine learning models rarely change after publication.