Skip to content

modosaic.text.generators.factory

modosaic.text.generators.factory

TextGenerationModel

Bases: Enum

Text generator implementations supported by the factory.

TextGeneratorFactory

Factory for text generator implementations.

get staticmethod

get(text_model=TextGenerationModel.INTERN_VL_3_5_2B)

Create a text generator.

Parameters:

Name Type Description Default
text_model TextGenerationModel

Model implementation to instantiate.

INTERN_VL_3_5_2B

Returns:

Type Description
TextGenerator

Configured text generator.

Raises:

Type Description
ValueError

If the model is unsupported.

Source code in modosaic/text/generators/factory.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@staticmethod
def get(text_model: TextGenerationModel = TextGenerationModel.INTERN_VL_3_5_2B) -> TextGenerator:
    """Create a text generator.

    Args:
        text_model: Model implementation to instantiate.

    Returns:
        Configured text generator.

    Raises:
        ValueError: If the model is unsupported.
    """
    logger.debug(f"Creating text generator for model {text_model}")
    match text_model:
        case TextGenerationModel.INTERN_VL_3_5_2B:
            return InternVL352B()
        case TextGenerationModel.INTERN_VL_3_2B:
            return InternVL32B()
        case TextGenerationModel.QWEN_2_5_3B:
            return QWEN253B()
        case TextGenerationModel.QWEN_2_2B:
            return QWEN22B()
        case _:
            raise ValueError(f"Unsupported text generation model: {text_model}")