oumi.core.configs.internal#
Submodules#
oumi.core.configs.internal.internal_model_config module#
- class oumi.core.configs.internal.internal_model_config.InternalFeatureFirstDimAction(value)[source]#
Bases:
Enum
Enum representing how to handle the first feature dimension in datasets.
- DROP_ALWAYS = 'drop_always'#
and must be dropped.
In effect, this operation is applied: x = x[0, …], which reduces x’s rank by 1 (e.g., 3D->2D), and discards the following elements: x[1:, …].
- Type:
The first dimension is commonly dummy (length
- DROP_IF_DUMMY = 'drop_if_dummy'#
1).
- Type:
Drop the first dimension only if it’s dummy (length
- KEEP = 'keep'#
Always preserve the first dimension.
- class oumi.core.configs.internal.internal_model_config.InternalFeatureSpec(name, required, variable_shape, first_dim_action, image_dependent)[source]#
Bases:
NamedTuple
- first_dim_action: InternalFeatureFirstDimAction#
Action to apply to the first feature dimension.
- image_dependent: bool#
Whether the feature depends on image data.
For example, pixel_values, cross_attention_mask.
- name: str#
Feature name.
- required: bool#
Whether the feature must be always present (vs optional).
- variable_shape: bool#
Whether the feature can be of variable shape.
For example, input_ids is normally of variable length.
- class oumi.core.configs.internal.internal_model_config.InternalModelConfig(model_type: str = '', chat_template: str = 'default', tokenizer_pad_token: Optional[str] = None, padding_side: Optional[oumi.core.configs.internal.internal_model_config.InternalPaddingSide] = None, model_input_features: dict[str, oumi.core.configs.internal.internal_model_config.InternalFeatureSpec] = <factory>, label_ignore_index: Optional[int] = -100, sanitize_negative_labels: bool = False, processor_kwargs: dict[str, typing.Any] = <factory>, visual_config: Optional[oumi.core.configs.internal.internal_model_config.InternalVisualModelConfig] = None)[source]#
Bases:
BaseConfig
- chat_template: str = 'default'#
Default chat template.
- label_ignore_index: int | None = -100#
Special label value to be excluded from loss computation.
- model_input_features: dict[str, InternalFeatureSpec]#
Model input features specs.
- model_type: str = ''#
Model type.
- padding_side: InternalPaddingSide | None = None#
Padding side for the model.
- processor_kwargs: dict[str, Any]#
Extra params to pass to processor constructor.
- sanitize_negative_labels: bool = False#
Replace negative label values.
Some VLM processors can generate negative input_ids for image tokens, which can cause problems if a negative integer is used as a label to compute loss e.g., cross-entropy loss may expect [0, num_classes) range.
- tokenizer_pad_token: str | None = None#
The default padding token used by the tokenizer.
If specified in internal model type config and unspecified in ModelParams.tokenizer_pad_token, then this value will be used.
- visual_config: InternalVisualModelConfig | None = None#
Configuration specific to visual models.
- class oumi.core.configs.internal.internal_model_config.InternalPaddingSide(value)[source]#
Bases:
Enum
Enum representing how to do padding for the model.
- PAD_LEFT = 'left'#
Left padding.
- PAD_RIGHT = 'right'#
Right padding.
- class oumi.core.configs.internal.internal_model_config.InternalVisualModelConfig(variable_shape_image_features: bool = False, supports_multiple_images: bool = False)[source]#
Bases:
BaseConfig
- supports_multiple_images: bool = False#
Whether the visual language model supports multiple images in one prompt.
- variable_shape_image_features: bool = False#
Whether image features can be of variable shape.
In this case, the image features can be difficult to collate (torch.stack() requires compatible shapes) and some workaround is needed: either require batch_size=1, or group examples so that each mini-batch only contains same-sized features.
oumi.core.configs.internal.supported_models module#
- oumi.core.configs.internal.supported_models.find_internal_model_config(model_params: ModelParams) InternalModelConfig | None [source]#
Finds an internal model config for supported models using ModelParams.
- Parameters:
model_params – The model parameters.
- Returns:
Model config, or None if model is not recognized.
- oumi.core.configs.internal.supported_models.find_internal_model_config_using_model_name(model_name: str, trust_remote_code: bool) InternalModelConfig | None [source]#
Finds an internal model config for supported models using model name.
- Parameters:
model_name – The model name.
trust_remote_code – Whether to trust external code associated with the model.
- Returns:
Model config, or None if model is not recognized.
- oumi.core.configs.internal.supported_models.find_model_hf_config(model_name: str, *, trust_remote_code: bool)[source]#
Finds HF model config by model name.
- oumi.core.configs.internal.supported_models.get_all_models_map() Mapping[str, _ModelTypeInfo] [source]#
Creates a map of all supported VLMs with related configs.
- oumi.core.configs.internal.supported_models.get_default_vlm_model_config() InternalModelConfig [source]#
Returns default VLM model config.