Views
No views yet


--tensor-parallel-size N to the serving command.localhost:18888 for requests and is compatible with the OpenAI ChatCompletion API specifications. Please refer to the example request below for reference. Additionally, you can use the OpenChat Web UI for a user-friendly experience.--api-keys sk-KEY1 sk-KEY2 ... to specify allowed API keys and --disable-log-requests --disable-log-stats --log-file openchat.log for logging only to a file. For security purposes, we recommend using an HTTPS gateway in front of the server.| Model | Size | Context | Weights | Serving |
|---|---|---|---|---|
| OpenChat-3.6-20240522 | 8B | 8192 | Huggingface | python -m ochat.serving.openai_api_server --model openchat/openchat-3.6-8b-20240522 |
1curl http://localhost:18888/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "openchat_3.6",
5 "messages": [{"role": "user", "content": "You are a large language model named OpenChat. Write a poem to describe yourself"}]
6 }'GPT4 Correct User or GPT4 Correct Assistant<|start_header_id|>GPT4 Correct User<|end_header_id|>\n\nHello<|eot_id|><|start_header_id|>GPT4 Correct Assistant<|end_header_id|>\n\nHi<|eot_id|><|start_header_id|>GPT4 Correct User<|end_header_id|>\n\nHow are you today?<|eot_id|><|start_header_id|>GPT4 Correct Assistant<|end_header_id|>\n\n<|eot_id|> as end of generation token.tokenizer.chat_template, which can be used instead of manually specifying the template:1messages = [
2 {"role": "user", "content": "Hello"},
3 {"role": "assistant", "content": "Hi"},
4 {"role": "user", "content": "How are you today?"}
5]
6tokens = tokenizer.apply_chat_template(messages, add_generation_prompt=True)1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "openchat/openchat-3.6-8b-20240522"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
8
9messages = [
10 {"role": "user", "content": "Explain how large language models work in detail."},
11]
12input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
13
14outputs = model.generate(input_ids,
15 do_sample=True,
16 temperature=0.5,
17 max_new_tokens=1024
18)
19response = outputs[0][input_ids.shape[-1]:]
20print(tokenizer.decode(response, skip_special_tokens=True))@article{wang2023openchat,
title={OpenChat: Advancing Open-source Language Models with Mixed-Quality Data},
author={Wang, Guan and Cheng, Sijie and Zhan, Xianyuan and Li, Xiangang and Song, Sen and Liu, Yang},
journal={arXiv preprint arXiv:2309.11235},
year={2023}
}