Views
No views yet

1from huggingface_hub import snapshot_download
2from vllm import LLM, SamplingParams
3
4# Consider toggling "enforce_eager" to False if you want to load the model quicker, at the expense of tokens per second.
5repo = snapshot_download(repo_id="Staticaliza/Reya-Human", allow_patterns=["*.json", "*.bin", "*.safetensors"])
6llm = LLM(model=repo, dtype="auto", tensor_parallel_size=torch.cuda.device_count(), enforce_eager=True, trust_remote_code=True)
7
8# ChatML is suggested
9input = """<|im_start|>system
10You are Reya.<|im_end|>
11<|im_start|>user
12Hi.<|im_end|>
13<|im_start|>assistant
14"""
15
16params = SamplingParams(
17 max_tokens=256,
18 temperature=1,
19 top_p=0.35,
20 top_k=50,
21 min_p=0.05,
22 presence_penalty=0,
23 frequency_penalty=0,
24 repetition_penalty=1,
25 stop=["<|im_end|>"],
26 seed=42,
27)
28
29result = llm.generate(input, params)[0].outputs[0].text
30print(result)