From ae0058bdee2c98eb76e9eaff017ebe655ca45723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller=20=28ChaoticByte=29?= Date: Tue, 30 May 2023 10:55:31 +0200 Subject: [PATCH] Improved profiles by adding 'separator' field to the profile format, improved vicuna-v0 profile, removed default profile from frontend-server cli, updated README --- README.md | 2 +- frontend-server.py | 4 ++-- frontend/static/main.js | 8 ++++---- profiles/koala.json | 1 + profiles/{vicuna.json => vicuna-v0.json} | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) rename profiles/{vicuna.json => vicuna-v0.json} (79%) diff --git a/README.md b/README.md index 2875073..3b2d0f3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ For memory and disk requirements for the different models, see [llama.cpp - Memo ## Supported Models - [🐨 Koala](https://bair.berkeley.edu/blog/2023/04/03/koala/) -- [🦙 Vicuna](https://lmsys.org/blog/2023-03-30-vicuna/) +- [🦙 Vicuna v0](https://lmsys.org/blog/2023-03-30-vicuna/) see `./profiles/` diff --git a/frontend-server.py b/frontend-server.py index e631058..383e110 100644 --- a/frontend-server.py +++ b/frontend-server.py @@ -9,10 +9,9 @@ import uvicorn from frontend.app import app if __name__ == "__main__": - koala_profile_path = Path(__file__).parent / "profiles" / "koala.json" # CLI ap = ArgumentParser() - ap.add_argument("--profile", help="Path to a profile file that includes settings for a specific model (default: ./profiles/koala.json)", type=Path, default=koala_profile_path) + ap.add_argument("--profile", help="Path to a profile file that includes settings for a specific model", type=Path, required=True) ap.add_argument("--host", help="Address to listen on (default: localhost)", type=str, default="localhost") ap.add_argument("--port", help="Port to listen on (default: 8080)", type=int, default=8080) ap.add_argument("--api", help="URL of the API Server (default: 'http://localhost:7331')", type=str, default="http://localhost:7331") @@ -34,6 +33,7 @@ if __name__ == "__main__": "conversation_prefix": profile["conversation_prefix"], "user_keyword": profile["user_keyword"], "assistant_keyword": profile["assistant_keyword"], + "separator": profile["separator"], "stop_sequences": profile["stop_sequences"] } } diff --git a/frontend/static/main.js b/frontend/static/main.js index ebfc0ef..f579035 100644 --- a/frontend/static/main.js +++ b/frontend/static/main.js @@ -111,10 +111,10 @@ fetch("/config") function addMessage(message, role) { if (role == Roles.USER) { conversation.push( - " " + frontend_config.profile.user_keyword + " " - + message + " " + frontend_config.profile.assistant_keyword); + frontend_config.profile.user_keyword + " " + + message + frontend_config.profile.separator + frontend_config.profile.assistant_keyword); } - else { conversation.push(message); } + else { conversation.push(message + frontend_config.profile.separator); } // UI let messageRoleElem = document.createElement("div"); messageRoleElem.classList.add("message-type"); @@ -181,7 +181,7 @@ fetch("/config") let prompt = conversation.join(""); let settings = getSettings(); apiCompletion(prompt, settings).then(r => { - addMessage(r, Roles.ASSISTANT); + addMessage(r.trim(), Roles.ASSISTANT); enableInput(); }); } diff --git a/profiles/koala.json b/profiles/koala.json index 78790f9..056b372 100644 --- a/profiles/koala.json +++ b/profiles/koala.json @@ -3,5 +3,6 @@ "conversation_prefix": "BEGINNING OF CONVERSATION: ", "user_keyword": "USER:", "assistant_keyword": "GPT:", + "separator": " ", "stop_sequences": [""] } \ No newline at end of file diff --git a/profiles/vicuna.json b/profiles/vicuna-v0.json similarity index 79% rename from profiles/vicuna.json rename to profiles/vicuna-v0.json index 2f47f50..2f701ae 100644 --- a/profiles/vicuna.json +++ b/profiles/vicuna-v0.json @@ -1,7 +1,8 @@ { "name": "Vicuna", - "conversation_prefix": "A chat between a curious user and a helpful AI assistant. ", + "conversation_prefix": "A chat between a curious user and a helpful AI assistant.\n\n", "user_keyword": "### Human:", "assistant_keyword": "### Assistant:", + "separator": "\n", "stop_sequences": ["### Human:"] } \ No newline at end of file