"references/vscode:/vscode.git/clone" did not exist on "bdf16222f7e734f81af0f6ea6a5f413c7b353237"
model_utils.py 368 Bytes
Newer Older
Woosuk Kwon's avatar
Woosuk Kwon committed
1
2
import torch.nn as nn

Woosuk Kwon's avatar
Minor  
Woosuk Kwon committed
3
from cacheflow.models.opt import OPTForCausalLM
Woosuk Kwon's avatar
Woosuk Kwon committed
4
5
6
7
8
9
10

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}')