ml-collections
ML Collections is a library of Python collections designed for ML usecases.
What it is and what it does
ML Collections provides ConfigDict and FrozenConfigDict—specialized dictionary classes designed for ML workflows. ConfigDict lets you access nested configuration values using dot notation (cfg.learning_rate) instead of bracket syntax, with built-in type checking to catch spelling mistakes and type mismatches. FrozenConfigDict is an immutable, hashable variant useful for passing configs as function arguments or storing them in sets. Both support lazy evaluation through FieldReferences, allowing one field to depend on another and recompute automatically when the source changes.
The library depends on absl-py and PyYAML to handle logging and YAML serialization. It's widely used in ML research and production to centralize experiment hyperparameters, model settings, and training configurations in a single, strongly-typed object that's easier to reason about than plain dictionaries.
Use it for:
- Store and manage experiment hyperparameters with type safety to prevent configuration errors.
- Create immutable, hashable configuration snapshots for reproducible ML experiments using FrozenConfigDict.
- Define dependent configuration fields using lazy evaluation so changing a base value automatically updates derived values.
- Serialize and deserialize experiment configs to YAML for easy version control and sharing across teams.
- Prevent typos in nested config access by using dot notation with locking to catch misspelled field names early.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides dict-like configuration data structures with dot-notation access, type safety, and lazy evaluation for ML experiment and model configuration.
Yes. ML Collections fills a genuine gap in Python ML tooling by providing type-safe, dot-accessible configuration objects with lazy evaluation. Low install friction, active maintenance, permissive license, and no known vulnerabilities make it a straightforward choice for any ML project that needs structured configuration management beyond plain dicts.
Install
ml-collections on PyPI
pip
pip install ml-collectionsuv
uv add ml-collectionspoetry
poetry add ml-collectionsInstalling ml-collections
Before you install
Low friction install with only two lightweight runtime dependencies (absl-py and PyYAML). Active maintenance with recent releases; last commit 2026-07-07 and latest release 2025-04-17 indicate ongoing support.
License in practice
Permissive license (Apache Software License per OSI approval) means you can use, modify, and distribute this package with minimal legal restrictions.
Quickstart
pip install ml-collections
from ml_collections import config_dict
cfg = config_dict.ConfigDict()
cfg.learning_rate = 12.6
cfg.nested = config_dict.ConfigDict()
cfg.nested.string_field = 'tom'
print(cfg.learning_rate)
Requires Python 3.10 or later.
Verify before relying
- Performance characteristics when working with deeply nested or very large ConfigDict structures.
- Compatibility with popular ML frameworks (PyTorch, TensorFlow, JAX) beyond basic configuration storage.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — absl-py, PyYAML |
| Maintenance | actively maintained — 484 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,197,822/month — #3,218 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ml_collections-1.1.0-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
itypesProvides immutable container types (Dict and…
permissive · top 5,000 on PyPI
constantdictProvides an immutable dictionary class that…
permissive · top 15,000 on PyPI
super-collectionsConverts nested JSON and YAML data into Python…
permissive · top 5,000 on PyPI
yacsYACS is a lightweight configuration management…
permissive · top 5,000 on PyPI
fiddleFiddle is a Python-first configuration library…
permissive · top 5,000 on PyPI
jaraco.collectionsProvides specialized collection classes that…
permissive · top 5,000 on PyPI
json-ref-dictProvides a dict-like interface to JSONSchema…
permissive · top 15,000 on PyPI
immutablesProvides an immutable mapping type backed by a…
permissive · top 5,000 on PyPI
frozendictProvides an immutable, hashable dictionary…
copyleft · top 5,000 on PyPI
python-boxBox wraps Python dictionaries to enable…
permissive · top 5,000 on PyPI