__init__.py 799 Bytes
Newer Older
1
from text_generation.models.model import Model
2
3
from text_generation.models.bloom import BLOOMSharded
from text_generation.models.causal_lm import CausalLM
4

5
__all__ = ["Model", "BLOOMSharded", "CausalLM"]
6
7
8
9
10
11
12
13
14


def get_model(model_name: str, sharded: bool, quantize: bool) -> Model:
    if model_name.startswith("bigscience/bloom"):
        if sharded:
            return BLOOMSharded(model_name, quantize)
        else:
            if quantize:
                raise ValueError("quantization is not supported for non-sharded BLOOM")
15
            return CausalLM(model_name)
16
    else:
17
18
19
20
21
        if sharded:
            raise ValueError("sharded is not supported for AutoModel")
        if quantize:
            raise ValueError("quantize is not supported for AutoModel")
        return CausalLM(model_name)