Large language model chat protocol.
Project description
chatproto
Large Language Model Chat Protocol.
The different chat prompt formats used by different Large Language Models have been a problem for developers. We developed chatproto to output the prompt format for different LLMs through a unified interface.
Compared to the apply_chat_format function in HuggingFace and the version in FastChat, ChatProto can locate the position of each message after applying the template. This makes it very convenient for us to mask out certain conversations during training.
Quick Start
from chatproto.conversation.history import ConversationHistory
from chatproto.registry import list_conv_settings, get_conv_settings
# Print all available settings
all_settings = list_conv_settings()
print(all_settings)
settings = get_conv_settings("openbuddy")
history = ConversationHistory(
"SYSTEM_MESSAGE",
messages=[
(settings.roles[0], "Hello!"),
(settings.roles[1], "Hello! How can I assist you today?"),
],
offset=0,
settings=settings
)
# Apply the template
print(history.get_prompt())
# Get prompt and indices
prompt, indices = history.get_prompt_and_indices()
# Print the start and end offsets of each message in the conversation one by one.
# The start and end offsets here refer to the offsets in the text, not the tokens.
# They do not include any additional characters added in the template.
system_start, system_end = indices[0]
for i, (conv_start, conv_end) in enumerate(indices[1:]):
print((conv_start, conv_end))
Install
Method 1: With pip
pip install chatproto
or:
pip install git+https://github.com/vtuber-plan/chatproto.git
Method 2: From source
- Clone this repository
git clone https://github.com/vtuber-plan/chatproto.git
cd chatproto
- Install the Package
pip install --upgrade pip
pip install .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chatproto-0.0.2.tar.gz.
File metadata
- Download URL: chatproto-0.0.2.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1578a00947d635499376b0a6e7d3204042d91b46c405255bf31cfff389a90852
|
|
| MD5 |
9b8bf503506c9743c5100bd40b5f7e94
|
|
| BLAKE2b-256 |
96d8a52e4ceddb3e142bf675d1e18231505209eb03f1343728467e1a581ba729
|
File details
Details for the file chatproto-0.0.2-py3-none-any.whl.
File metadata
- Download URL: chatproto-0.0.2-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ae27b55a8a8c6a1aa41dbceb12404d661bd8bb270c0df1bbc0762b2142ae27
|
|
| MD5 |
34294148eab435dc247e7cffcff68bac
|
|
| BLAKE2b-256 |
96bb32c89e8a8defa70c873bf4c630a2eec57f27c5fd1003952bcc1dc9759089
|