~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.