Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI and new models #2762

Merged
merged 16 commits into from
Dec 9, 2023
3 changes: 3 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
ANTHROPIC_MODEL_LIST = (
"claude-1",
"claude-2",
"claude-2.0",
"claude-2.1",
"claude-instant-1",
"claude-instant-1.2",
)


Expand Down
75 changes: 43 additions & 32 deletions fastchat/model/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def get_model_info(name: str) -> ModelInfo:
"https://platform.openai.com/docs/models/gpt-3-5",
"GPT-3.5-Turbo-1106 by OpenAI",
)
register_model_info(
["gpt-4"], "GPT-4", "https://openai.com/research/gpt-4", "ChatGPT-4 by OpenAI"
)
register_model_info(
["gpt-4-turbo"],
"GPT-4-Turbo",
"https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo",
"GPT-4-Turbo by OpenAI",
)
register_model_info(
["claude-2"],
["gpt-4"], "GPT-4", "https://openai.com/research/gpt-4", "ChatGPT-4 by OpenAI"
)
register_model_info(
["claude-2.1", "claude-2.0"],
"Claude",
"https://www.anthropic.com/index/claude-2",
"Claude 2 by Anthropic",
Expand All @@ -62,16 +62,34 @@ def get_model_info(name: str) -> ModelInfo:
"Claude by Anthropic",
)
register_model_info(
["claude-instant-1"],
["claude-instant-1", "claude-instant-1.2"],
"Claude Instant",
"https://www.anthropic.com/index/introducing-claude",
"Claude Instant by Anthropic",
)
register_model_info(
["palm-2"],
"PaLM 2 Chat",
"https://cloud.google.com/vertex-ai/docs/release-notes#May_10_2023",
"PaLM 2 for Chat (chat-bison@001) by Google",
["openhermes-2.5-mistral-7b"],
"OpenHermes-2.5-Mistral-7B",
"https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B",
"a mistral-based model fine-tuned on 1M GPT-4 outputs",
)
register_model_info(
["starling-lm-7b-alpha"],
"Starling-LM-7B-alpha",
"https://huggingface.co/berkeley-nest/Starling-LM-7B-alpha",
"an open model trained using RLAIF by Berkeley",
)
register_model_info(
["tulu-2-dpo-70b"],
"Tulu 2",
"https://huggingface.co/allenai/tulu-2-dpo-70b",
"Tulu 2 by UW/AllenAI",
)
register_model_info(
["yi-34b-chat", "yi-6b-chat"],
"Yi-Chat",
"https://huggingface.co/01-ai/Yi-34B-Chat",
"A large language model by 01 AI",
)
register_model_info(
[
Expand All @@ -92,6 +110,18 @@ def get_model_info(name: str) -> ModelInfo:
"https://ai.meta.com/llama/",
"open foundation and fine-tuned chat models by Meta",
)
register_model_info(
["chatglm3-6b", "chatglm2-6b", "chatglm-6b"],
"ChatGLM",
"https://chatglm.cn/blog",
"an open bilingual dialogue language model by Tsinghua University",
)
register_model_info(
["openchat-3.5"],
"OpenChat 3.5",
"https://github.com/imoneoi/openchat",
"an open model fine-tuned on Mistral-7B using C-RLFT",
)
register_model_info(
["mistral-7b-instruct"],
"Mistral",
Expand Down Expand Up @@ -158,12 +188,6 @@ def get_model_info(name: str) -> ModelInfo:
"https://huggingface.co/BlinkDL/rwkv-4-raven",
"an RNN with transformer-level LLM performance",
)
register_model_info(
["chatglm-6b", "chatglm2-6b"],
"ChatGLM",
"https://chatglm.cn/blog",
"an open bilingual dialogue language model by Tsinghua University",
)
register_model_info(
["alpaca-13b"],
"Alpaca",
Expand All @@ -183,16 +207,10 @@ def get_model_info(name: str) -> ModelInfo:
"an Open Assistant for everyone by LAION",
)
register_model_info(
["openchat-3.5"],
"OpenChat 3.5",
"https://github.com/imoneoi/openchat",
"OpenChat 3.5 is a versatile, open-source language model fine-tuned using C-RLFT",
)
register_model_info(
["starling-lm-7b-alpha"],
"Starling-LM-7B-alpha",
"https://huggingface.co/berkeley-nest/Starling-LM-7B-alpha",
"an open model trained using RLAIF by Berkeley",
["palm-2"],
"PaLM 2 Chat",
"https://cloud.google.com/vertex-ai/docs/release-notes#May_10_2023",
"PaLM 2 for Chat (chat-bison@001) by Google",
)
register_model_info(
["llama-7b", "llama-13b"],
Expand Down Expand Up @@ -403,10 +421,3 @@ def get_model_info(name: str) -> ModelInfo:
"https://huggingface.co/BAAI/AquilaChat2-34B",
"Chat models developed by BAAI team",
)

register_model_info(
["Yi-34B-Chat", "Yi-6B-Chat"],
"Yi-Chat",
"https://huggingface.co/01-ai",
"A large language model by 01.AI.",
)
45 changes: 32 additions & 13 deletions fastchat/serve/api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def openai_api_stream_iter(
):
import openai

is_azure = False
if "azure" in model_name:
is_azure = True
openai.api_type = "azure"
openai.api_version = "2023-07-01-preview"
else:
openai.api_type = "open_ai"
openai.api_version = None

openai.api_base = api_base or "https://api.openai.com/v1"
openai.api_key = api_key or os.environ["OPENAI_API_KEY"]
if model_name == "gpt-4-turbo":
Expand All @@ -37,21 +46,31 @@ def openai_api_stream_iter(
}
logger.info(f"==== request ====\n{gen_params}")

res = openai.ChatCompletion.create(
model=model_name,
messages=messages,
temperature=temperature,
max_tokens=max_new_tokens,
stream=True,
)
if is_azure:
res = openai.ChatCompletion.create(
engine=model_name,
messages=messages,
temperature=temperature,
max_tokens=max_new_tokens,
stream=True,
)
else:
res = openai.ChatCompletion.create(
model=model_name,
messages=messages,
temperature=temperature,
max_tokens=max_new_tokens,
stream=True,
)
text = ""
for chunk in res:
text += chunk["choices"][0]["delta"].get("content", "")
data = {
"text": text,
"error_code": 0,
}
yield data
if len(chunk["choices"]) > 0:
text += chunk["choices"][0]["delta"].get("content", "")
data = {
"text": text,
"error_code": 0,
}
yield data


def anthropic_api_stream_iter(model_name, prompt, temperature, top_p, max_new_tokens):
Expand Down
77 changes: 53 additions & 24 deletions fastchat/serve/gradio_block_arena_anony.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
acknowledgment_md,
ip_expiration_dict,
get_ip,
get_model_description_md,
)
from fastchat.utils import (
build_logger,
Expand Down Expand Up @@ -163,20 +164,26 @@ def share_click(state0, state1, model_selector0, model_selector1, request: gr.Re
"gpt-4-turbo": 4,
"gpt-3.5-turbo": 2,
"gpt-3.5-turbo-1106": 2,
"claude-2": 8,
"claude-2.1": 4,
"claude-2.0": 2,
"claude-1": 2,
"claude-instant-1": 8,
"claude-instant-1": 4,
"openhermes-2.5-mistral-7b": 2,
"wizardlm-70b": 2,
"starling-lm-7b-alpha": 2,
"tulu-2-dpo-70b": 2,
"yi-34b-chat": 2,
"zephyr-7b-beta": 2,
"openchat-3.5": 2,
"chatglm3-6b": 2,
# tier 1
"deluxe-chat-v1.1": 2,
"deluxe-chat-v1.1": 4,
"palm-2": 1.5,
"llama-2-70b-chat": 1.5,
"llama-2-13b-chat": 1.5,
"codellama-34b-instruct": 1.5,
"vicuna-33b": 8,
"vicuna-33b": 4,
"vicuna-13b": 1.5,
"wizardlm-70b": 1.5,
"wizardlm-13b": 1.5,
"qwen-14b-chat": 1.5,
"mistral-7b-instruct": 1.5,
Expand Down Expand Up @@ -205,14 +212,21 @@ def share_click(state0, state1, model_selector0, model_selector1, request: gr.Re

# target model sampling weights will be boosted.
BATTLE_TARGETS = {
"gpt-4": {"claude-2"},
"gpt-4-turbo": {"gpt-4", "gpt-3.5-turbo"},
"gpt-3.5-turbo": {"claude-instant-1", "gpt-4", "claude-2"},
"claude-2": {"gpt-4", "gpt-3.5-turbo", "claude-1"},
"claude-1": {"claude-2", "gpt-4", "gpt-3.5-turbo"},
"claude-instant-1": {"gpt-3.5-turbo", "claude-2"},
"deluxe-chat-v1.1": {"gpt-4"},
"gpt-4": {"claude-2.1", "gpt-4-turbo"},
"gpt-4-turbo": {"gpt-4", "gpt-3.5-turbo", "gpt-3.5-turbo-1106", "claude-2.1"},
"gpt-3.5-turbo": {"claude-instant-1", "gpt-4", "claude-2.1"},
"gpt-3.5-turbo-1106": {"claude-instant-1", "gpt-3.5-turbo"},
"claude-2.1": {"gpt-4-turbo", "gpt-4", "claude-1"},
"claude-2.0": {"gpt-4-turbo", "gpt-4", "claude-1"},
"claude-1": {"claude-2.1", "gpt-4", "gpt-3.5-turbo"},
"claude-instant-1": {"gpt-3.5-turbo-1106", "claude-2.1"},
"deluxe-chat-v1.1": {"gpt-4", "gpt-4-turbo"},
"openhermes-2.5-mistral-7b": {"gpt-3.5-turbo", "openchat-3.5", "zephyr-7b-beta"},
"starling-lm-7b-alpha": {"gpt-3.5-turbo", "openchat-3.5", "zephyr-7b-beta"},
"tulu-2-dpo-70b": {"gpt-3.5-turbo", "vicuna-33b", "claude-instant-1"},
"yi-34b-chat": {"gpt-3.5-turbo", "vicuna-33b", "claude-instant-1"},
"openchat-3.5": {"gpt-3.5-turbo", "llama-2-70b-chat", "zephyr-7b-beta"},
"chatglm3-6b": {"yi-34b-chat", "qwen-14b-chat"},
"qwen-14b-chat": {"vicuna-13b", "llama-2-13b-chat", "llama-2-70b-chat"},
"zephyr-7b-alpha": {"mistral-7b-instruct", "llama-2-13b-chat"},
"zephyr-7b-beta": {
Expand All @@ -236,10 +250,24 @@ def share_click(state0, state1, model_selector0, model_selector1, request: gr.Re
"palm-2": {"llama-2-13b-chat", "gpt-3.5-turbo"},
}

SAMPLING_BOOST_MODELS = ["openchat-3.5", "gpt-4-turbo", "gpt-3.5-turbo-1106"]
SAMPLING_BOOST_MODELS = [
"tulu-2-dpo-70b",
"yi-34b-chat",
"claude-2.1",
"wizardlm-70b",
"starling-lm-7b-alpha",
"openhermes-2.5-mistral-7b",
"gpt-3.5-turbo-1106",
# "openchat-3.5",
# "gpt-4-turbo",
# "claude-1",
]

# outage models won't be sampled.
OUTAGE_MODELS = []
OUTAGE_MODELS = [
"zephyr-7b-alpha",
"falcon-180b-chat",
]


def get_sample_weight(model):
Expand Down Expand Up @@ -442,6 +470,9 @@ def build_side_by_side_ui_anony(models):
gr.Markdown(notice_markdown, elem_id="notice_markdown")

with gr.Box(elem_id="share-region-anony"):
with gr.Accordion("🔍 Expand to see 20+ Arena players", open=False):
model_description_md = get_model_description_md(models)
gr.Markdown(model_description_md, elem_id="model_description_markdown")
with gr.Row():
for i in range(num_sides):
label = "Model A" if i == 0 else "Model B"
Expand Down Expand Up @@ -470,15 +501,13 @@ def build_side_by_side_ui_anony(models):
)

with gr.Row():
with gr.Column(scale=20):
textbox = gr.Textbox(
show_label=False,
placeholder="👉 Enter your prompt and press ENTER",
container=False,
elem_id="input_box",
)
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Send", variant="primary")
textbox = gr.Textbox(
show_label=False,
placeholder="👉 Enter your prompt and press ENTER",
container=True,
elem_id="input_box",
)
send_btn = gr.Button(value="Send", variant="primary", scale=0)

with gr.Row() as button_row:
clear_btn = gr.Button(value="🎲 New Round", interactive=False)
Expand Down Expand Up @@ -511,7 +540,7 @@ def build_side_by_side_ui_anony(models):
label="Max output tokens",
)

gr.Markdown(acknowledgment_md)
gr.Markdown(acknowledgment_md, elem_id="ack_markdown")

# Register listeners
btn_list = [
Expand Down
28 changes: 13 additions & 15 deletions fastchat/serve/gradio_block_arena_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,7 @@ def build_side_by_side_ui_named(models):
model_selectors = [None] * num_sides
chatbots = [None] * num_sides

model_description_md = get_model_description_md(models)
notice = gr.Markdown(
notice_markdown + model_description_md, elem_id="notice_markdown"
)
notice = gr.Markdown(notice_markdown, elem_id="notice_markdown")

with gr.Box(elem_id="share-region-named"):
with gr.Row():
Expand All @@ -300,6 +297,10 @@ def build_side_by_side_ui_named(models):
show_label=False,
container=False,
)
with gr.Row():
with gr.Accordion("🔍 Expand to see 20+ model descriptions", open=False):
model_description_md = get_model_description_md(models)
gr.Markdown(model_description_md, elem_id="model_description_markdown")

with gr.Row():
for i in range(num_sides):
Expand All @@ -322,19 +323,16 @@ def build_side_by_side_ui_named(models):
)

with gr.Row():
with gr.Column(scale=20):
textbox = gr.Textbox(
show_label=False,
placeholder="Enter your prompt here and press ENTER",
container=False,
elem_id="input_box",
)
with gr.Column(scale=1, min_width=50):
send_btn = gr.Button(value="Send", variant="primary")
textbox = gr.Textbox(
show_label=False,
placeholder="👉 Enter your prompt and press ENTER",
elem_id="input_box",
)
send_btn = gr.Button(value="Send", variant="primary", scale=0)

with gr.Row() as button_row:
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
clear_btn = gr.Button(value="🗑️ Clear history", interactive=False)
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
share_btn = gr.Button(value="📷 Share")

with gr.Accordion("Parameters", open=False) as parameter_row:
Expand Down Expand Up @@ -363,7 +361,7 @@ def build_side_by_side_ui_named(models):
label="Max output tokens",
)

gr.Markdown(acknowledgment_md)
gr.Markdown(acknowledgment_md, elem_id="ack_markdown")

# Register listeners
btn_list = [
Expand Down
Loading