vllm/cacheflow/models/model_utils.py

15 lines
375 B
Python
Raw Normal View History

2023-02-13 09:36:12 +00:00
import torch.nn as nn
from cacheflow.worker.models.opt import OPTForCausalLM
MODEL_CLASSES = {
'opt': OPTForCausalLM,
}
def get_model(model_name: str) -> nn.Module:
2023-02-13 22:51:03 +00:00
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}')