Views
No views yet
Conversation roles must alternate user/assistant/user/assistant/...System role not supportedvllm serve --model dangvansam/gemma-2-2b-it-fix-system-role1curl http://localhost:8000/v1/chat/completions \
2-H "Content-Type: application/json" \
3-d '{
4 "model": "dangvansam/gemma-2-2b-it-fix-system-role",
5 "messages": [
6 {"role": "system", "content": "You are a helpful assistant."},
7 {"role": "user", "content": "Who are you?"}
8 ]
9}'1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3
4model_id = "dangvansam/gemma-2-2b-it-fix-system-role"
5
6sampling_params = SamplingParams(temperature=0.6, top_p=0.9, max_tokens=256)
7
8tokenizer = AutoTokenizer.from_pretrained(model_id)
9
10messages = [
11 {"role": "system", "content": "You are helpfull assistant."},
12 {"role": "user", "content": "Who are you?"}
13]
14
15prompts = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
16
17llm = LLM(model=model_id)
18
19outputs = llm.generate(prompts, sampling_params)
20
21generated_text = outputs[0].outputs[0].text
22print(generated_text)