config¶
- class olmo_core.config.Config[source]¶
Bases:
objectA base class for configuration dataclasses.
Important
When you subclass this you should still decorate your subclasses with
@dataclass. For example:@dataclass class MyConfig(Config): ...
Important
Config classes need to be serializable, so you should only use simple types for your fields. Though you can use nested configs.
- CLASS_NAME_FIELD = '_CLASS_'¶
The name of the class name field inject into the dictionary from
as_dict()oras_config_dict().
- as_dict(*, exclude_none=False, exclude_private_fields=False, exclude=None, include_class_name=False, include_registered_name=False, json_safe=False, recurse=True)[source]¶
Convert into a regular Python dictionary.
- Parameters:
exclude_none (
bool, default:False) – Don’t include values that areNone.exclude_private_fields (
bool, default:False) – Don’t include private fields.exclude (
Optional[Collection[str]], default:None) – A list of field names to exclude.include_class_name (
bool, default:False) – Include a field for the name of the class.include_registered_name (
bool, default:False) – If the config isRegistrable, include the registered name under the key “type”.json_safe (
bool, default:False) – Output only JSON-safe types.recurse (
bool, default:True) – Recurse into fields that are also configs/dataclasses.
- Return type:
- as_config_dict()[source]¶
A convenience wrapper around
as_dict()for creating JSON-safe dictionaries suitable for recording the config.
- merge(dotlist, prefix=None, strict=True)[source]¶
Merge self with fields from a “dotlist”, creating a new object.
- Parameters:
dotlist (
List[str]) – A list of field attributes with dot notation, e.g.foo.bar=1.prefix (
Optional[str], default:None) – Only use override items in the dotlist that start with a given prefix name, and strip that prefix (including the subsequent “.”) before applying the overrides.strict (
bool, default:True) – Parse the dotlist strictly.
- Return type:
Self
- replace(**changes)[source]¶
Creates a new object of the same type, replacing fields with values from
changes.- Return type:
Self
- copy(deep=True)[source]¶
Creates a new object of the same type, with the same values.
- Return type:
Self
- class olmo_core.config.DType(value)[source]¶
Bases:
StrEnumAn enumeration of supported PyTorch data types.
- class olmo_core.config.StrEnum(value)[source]¶
-
This is equivalent to Python’s
enum.StrEnumsince version 3.11. We include this here for compatibility with older version of Python.