28 lines
945 B
Markdown
28 lines
945 B
Markdown
# Custom Chat Template in SGLang Runtime
|
|
|
|
By default, the server uses the chat template specified in the model tokenizer from Hugging Face. It should just work for most official models such as Llama-2/Llama-3.
|
|
|
|
If needed, you can also override the chat template when launching the server:
|
|
|
|
```
|
|
python -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000 --chat-template llama-2
|
|
```
|
|
|
|
If the chat template you are looking for is missing, you are welcome to contribute it.
|
|
Meanwhile, you can also temporarily register your chat template as follows:
|
|
|
|
```json
|
|
{
|
|
"name": "my_model",
|
|
"system": "<|im_start|>system",
|
|
"user": "<|im_start|>user",
|
|
"assistant": "<|im_start|>assistant",
|
|
"sep_style": "CHATML",
|
|
"sep": "<|im_end|>",
|
|
"stop_str": ["<|im_end|>", "<|im_start|>"]
|
|
}
|
|
```
|
|
|
|
```
|
|
python -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000 --chat-template ./my_model_template.json
|
|
``` |