vllm icon indicating copy to clipboard operation
vllm copied to clipboard

How to load a local model file?

Open BUAADreamer opened this issue 2 years ago • 10 comments

I want to load a local model which has the same file with the files downloaded from huggingface. However, right now this repository seems to only support load from website.

BUAADreamer avatar Jun 30 '23 06:06 BUAADreamer

The model directory is like follows image

BUAADreamer avatar Jun 30 '23 06:06 BUAADreamer

I also have the same problem.

liulfy avatar Jun 30 '23 06:06 liulfy

@BUAADreamer @liulfy The model argument in LLM or api_server can also take the path to your local directory that contains the weight files.

WoosukKwon avatar Jun 30 '23 07:06 WoosukKwon

But this code seems to request huggingface website

from vllm import LLM, SamplingParams
prompts = [
    "你好,请介绍一下你自己",
    "中国的定义是什么?"
]
sampling_params = SamplingParams(temperature=0.01, top_p=0.01)
llm = LLM(model="/path/to/llama")

BUAADreamer avatar Jun 30 '23 07:06 BUAADreamer

@BUAADreamer Thanks for providing the example. It should not use the remote HF repo if the path is valid. Could you try this and let us know if it works?

from transformers import AutoConfig

config = AutoConfig.from_pretrained("your/path/to/llama")

If this doesn't work, then it means your path is somehow incorrect (or it's a bug in HF).

WoosukKwon avatar Jun 30 '23 07:06 WoosukKwon

I use Build from source and run seccessfully. Thanks! But the Install with pip seems to have some problems

BUAADreamer avatar Jun 30 '23 07:06 BUAADreamer

please describe the solution more detail, very thanks!

Huangyajuan-123 avatar Jun 30 '23 08:06 Huangyajuan-123

Indeed. I built from source: https://github.com/vllm-project/vllm/releases/tag/v0.1.1, and this problem solved.

liulfy avatar Jun 30 '23 08:06 liulfy

https://vllm.readthedocs.io/en/latest/getting_started/installation.html just use the Build from source in this website and run like above, if it only report error, then set tokenizer_mode='slow'

BUAADreamer avatar Jun 30 '23 08:06 BUAADreamer

Indeed. I built from source: https://github.com/vllm-project/vllm/releases/tag/v0.1.1, and this problem solved.

Yes, this version works

BUAADreamer avatar Jun 30 '23 08:06 BUAADreamer