Build Converter Strategy
Build config dataclasses and strategy helpers for modality converter construction.
KwargsBuildConfig(kwargs=dict())
dataclass
Config for building a converter using raw keyword arguments.
build(cls)
Build a converter using raw keyword arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[BaseModalityConverter]
|
The converter class to build. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModalityConverter |
BaseModalityConverter
|
The built converter. |
LMRPBuildConfig(lmrp_config, extra_kwargs=dict())
dataclass
Config for building a converter using an LMRP configuration.
build(cls)
Build a converter using an LMRP configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[BaseModalityConverter]
|
The converter class to build. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModalityConverter |
BaseModalityConverter
|
The built converter. |
PresetBuildConfig(preset, extra_kwargs=dict())
dataclass
Config for building a converter using a named preset.
build(cls)
Build a converter using a named preset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[BaseModalityConverter]
|
The converter class to build. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseModalityConverter |
BaseModalityConverter
|
The built converter. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the class does not implement |
build_config_from_params(strategy, preset, kwargs)
Construct the typed build config for the given strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy
|
ModalityConverterBuildStrategy
|
The build strategy. |
required |
preset
|
str | None
|
The preset name, required for PRESET strategy. |
required |
kwargs
|
dict[str, Any]
|
Remaining keyword arguments from the caller. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ConverterBuildConfig |
ConverterBuildConfig
|
Config instance carrying the build logic for the strategy. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the strategy is unsupported or required params are missing. |
determine_build_strategy(preset, kwargs)
Determine the build strategy from the provided configuration.
Priority by order: 1. LMRP config -> LMRP strategy 2. Preset -> PRESET strategy 3. Fallback -> KWARGS strategy
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preset
|
str | None
|
The preset to use. |
required |
kwargs
|
dict[str, Any]
|
Additional keyword arguments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ModalityConverterBuildStrategy |
ModalityConverterBuildStrategy
|
The determined build strategy. |
determine_transcript_approach(model_id)
Determine the canonical transcription approach based on model metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
ModelId
|
The model ID to inspect. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ModalityConverterApproach |
'ModalityConverterApproach'
|
Canonical approach type ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the approach cannot be determined for the given model ID. |
Example
Determining approach from model ID
from gllm_inference.schema.model_id import ModelId
model_id = ModelId.from_string("google/gemini-1.5-pro")
approach = determine_transcript_approach(model_id)
print(approach) # ModalityConverterApproach.LM_BASED
model_id = ModelId.from_string("prosa/v2")
approach = determine_transcript_approach(model_id)
print(approach) # ModalityConverterApproach.ASR
determine_transcript_provider(model_id)
Determine the transcript provider implied by a model ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
ModelId
|
The model ID to inspect. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Provider name when inferable (e.g. |