model_utils.py 375 Bytes
Newer Older
Woosuk Kwon's avatar
Woosuk Kwon committed
1
2
3
4
5
6
7
8
9
10
import torch.nn as nn

from cacheflow.worker.models.opt import OPTForCausalLM

MODEL_CLASSES = {
    'opt': OPTForCausalLM,
}


def get_model(model_name: str) -> nn.Module:
Woosuk Kwon's avatar
Woosuk Kwon committed
11
12
13
14
    for model_class, model in MODEL_CLASSES.items():
        if model_class in model_name:
            return model.from_pretrained(model_name)
    raise ValueError(f'Invalid model name: {model_name}')