Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 36679a5

Browse filesBrowse files
committed
Merge branch 'main' of github.com:abetlen/llama_cpp_python into main
2 parents bd43fb2 + 5a9770a commit 36679a5
Copy full SHA for 36679a5

File tree

Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ Navigate to [http://localhost:8000/docs](http://localhost:8000/docs) to see the
283283
To bind to `0.0.0.0` to enable remote connections, use `python3 -m llama_cpp.server --host 0.0.0.0`.
284284
Similarly, to change the port (default is 8000), use `--port`.
285285

286+
You probably also want to set the prompt format. For chatml, use
287+
288+
```bash
289+
python3 -m llama_cpp.server --model models/7B/llama-model.gguf --chat_format chatml
290+
```
291+
292+
That will format the prompt according to how model expects it. You can find the prompt format in the model card.
293+
For possible options, see [llama_cpp/llama_chat_format.py](llama_cpp/llama_chat_format.py) and look for lines starting with "@register_chat_format".
294+
286295
## Docker image
287296

288297
A Docker image is available on [GHCR](https://ghcr.io/abetlen/llama-cpp-python). To run the server:

‎llama_cpp/llama_chat_format.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_chat_format.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,21 @@ def format_oasst_llama(
456456
return ChatFormatterResponse(prompt=_prompt)
457457

458458

459+
@register_chat_format("baichuan-2")
460+
def format_baichuan2(
461+
messages: List[llama_types.ChatCompletionRequestMessage],
462+
**kwargs: Any,
463+
) -> ChatFormatterResponse:
464+
_system_template = "{system_message}"
465+
_roles = dict(user="<reserved_106>", assistant="<reserved_107>")
466+
_sep = ""
467+
system_message = _get_system_message(messages)
468+
system_message = _system_template.format(system_message=system_message)
469+
_messages = _map_roles(messages, _roles)
470+
_messages.append((_roles["assistant"], None))
471+
_prompt = _format_no_colon_single(system_message, _messages, _sep)
472+
return ChatFormatterResponse(prompt=_prompt)
473+
459474
@register_chat_format("openbuddy")
460475
def format_openbuddy(
461476
messages: List[llama_types.ChatCompletionRequestMessage],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.