From d7ba7d855cfb4367d11d70237273433cde591165 Mon Sep 17 00:00:00 2001 From: eaidova Date: Fri, 2 Aug 2024 12:34:26 +0400 Subject: [PATCH] use chat mode --- notebooks/llm-chatbot/genai_gradio_helper.py | 70 +-- .../llm-chatbot-generate-api.ipynb | 538 ++++++++---------- utils/llm_config.py | 6 +- 3 files changed, 268 insertions(+), 346 deletions(-) diff --git a/notebooks/llm-chatbot/genai_gradio_helper.py b/notebooks/llm-chatbot/genai_gradio_helper.py index 84a8a2c0b0c..6b73c800c9d 100644 --- a/notebooks/llm-chatbot/genai_gradio_helper.py +++ b/notebooks/llm-chatbot/genai_gradio_helper.py @@ -1,10 +1,5 @@ -import re -from pathlib import Path from typing import Any -import numpy as np from queue import Queue -import openvino_tokenizers -from openvino_genai import StreamerBase import openvino as ov from uuid import uuid4 from threading import Event, Thread @@ -43,6 +38,26 @@ ["人工知能と「OpenVINOの利点」について100語程度のブログ記事を書いてください。"], ] +DEFAULT_SYSTEM_PROMPT = """\ +You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. +If a question does not make any sense or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\ +""" + +DEFAULT_SYSTEM_PROMPT_CHINESE = """\ +你是一个乐于助人、尊重他人以及诚实可靠的助手。在安全的情况下,始终尽可能有帮助地回答。 您的回答不应包含任何有害、不道德、种族主义、性别歧视、有毒、危险或非法的内容。请确保您的回答在社会上是公正的和积极的。 +如果一个问题没有任何意义或与事实不符,请解释原因,而不是回答错误的问题。如果您不知道问题的答案,请不要分享虚假信息。另外,答案请使用中文。\ +""" + +DEFAULT_SYSTEM_PROMPT_JAPANESE = """\ +あなたは親切で、礼儀正しく、誠実なアシスタントです。 常に安全を保ちながら、できるだけ役立つように答えてください。 回答には、有害、非倫理的、人種差別的、性差別的、有毒、危険、または違法なコンテンツを含めてはいけません。 回答は社会的に偏見がなく、本質的に前向きなものであることを確認してください。 +質問が意味をなさない場合、または事実に一貫性がない場合は、正しくないことに答えるのではなく、その理由を説明してください。 質問の答えがわからない場合は、誤った情報を共有しないでください。\ +""" + + +def get_system_prompt(model_language): + return DEFAULT_SYSTEM_PROMPT_CHINESE if (model_language == "Chinese") else DEFAULT_SYSTEM_PROMPT_JAPANESE if (model_language == "Japanese") else DEFAULT_SYSTEM_PROMPT + + class TextQueue: def __init__(self) -> None: self.text_queue = Queue() @@ -74,10 +89,7 @@ def get_gradio_helper(pipe, model_configuration, model_id, model_language): max_new_tokens = 256 - start_message = model_configuration["start_message"] - history_template = model_configuration.get("history_template") - current_message_template = model_configuration.get("current_message_template") - + start_message = get_system_prompt(model_language) def get_uuid(): """ @@ -85,39 +97,6 @@ def get_uuid(): """ return str(uuid4()) - - def convert_history_to_input(history): - """ - function for conversion history stored as list pairs of user and assistant messages to tokens according to model expected conversation template - Params: - history: dialogue history - Returns: - history in token format - """ - new_prompt = f"{start_message}" - if history_template is None: - for user_msg, model_msg in history: - new_prompt += user_msg + "\n" + model_msg + "\n" - return new_prompt - else: - new_prompt = "".join(["".join([history_template.format(num=round, user=item[0], assistant=item[1])]) for round, item in enumerate(history[:-1])]) - new_prompt += "".join( - [ - "".join( - [ - current_message_template.format( - num=len(history) + 1, - user=history[-1][0], - assistant=history[-1][1], - ) - ] - ) - ] - ) - - return new_prompt - - def default_partial_text_processor(partial_text: str, new_text: str): """ helper for updating partially generated answer, used by default @@ -162,10 +141,12 @@ def bot(message, history, temperature, top_p, top_k, repetition_penalty): config.do_sample = temperature > 0.0 config.max_new_tokens = max_new_tokens config.repetition_penalty = repetition_penalty + history = history or [] + if not history: + pipe.start_chat(system_message=start_message) - # history = [['message', 'chatbot answer'], ...] history.append([message, ""]) - new_prompt = convert_history_to_input(history) + new_prompt = message stream_complete = Event() @@ -197,6 +178,7 @@ def stop_chat(streamer): def stop_chat_and_clear_history(streamer): if streamer is not None: streamer.end() + pipe.finish_chat() return None, None examples = chinese_examples if (model_language == "Chinese") else japanese_examples if (model_language == "Japanese") else english_examples diff --git a/notebooks/llm-chatbot/llm-chatbot-generate-api.ipynb b/notebooks/llm-chatbot/llm-chatbot-generate-api.ipynb index d07b3fe0086..1c6853141dd 100644 --- a/notebooks/llm-chatbot/llm-chatbot-generate-api.ipynb +++ b/notebooks/llm-chatbot/llm-chatbot-generate-api.ipynb @@ -71,19 +71,7 @@ "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "^C\n", - "Note: you may need to restart the kernel to use updated packages.\n", - "\u001b[33mWARNING: Skipping optimum as it is not installed.\u001b[0m\u001b[33m\n", - "\u001b[0m\u001b[33mWARNING: Skipping optimum-intel as it is not installed.\u001b[0m\u001b[33m\n", - "\u001b[0mNote: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "import os\n", "\n", @@ -105,7 +93,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "f39ca954-61d2-45c5-a7f9-7fce1acc277f", "metadata": { "tags": [] @@ -272,7 +260,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "0a9b1fed-d145-4fff-828c-ac93ecce5361", "metadata": { "tags": [] @@ -281,7 +269,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "06330bf4d2134590affb465ac2ab3f44", + "model_id": "4d7d47d24c4a42f699f0a32e81c14fe4", "version_major": 2, "version_minor": 0 }, @@ -289,7 +277,7 @@ "Box(children=(Box(children=(Label(value='Language:'), Dropdown(options=('English', 'Chinese', 'Japanese'), val…" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -303,7 +291,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 17, "id": "906022ec-96bf-41a9-9447-789d2e875250", "metadata": { "tags": [] @@ -313,7 +301,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Selected model qwen2-0.5b-instruct with INT4 compression\n" + "Selected model mistral-7b with INT4 compression\n" ] } ], @@ -397,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "c4ef9112", "metadata": { "collapsed": false, @@ -406,15 +394,7 @@ }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "✅ INT4 qwen2-0.5b-instruct model already converted and can be found in qwen2/INT4_compressed_weights\n" - ] - } - ], + "outputs": [], "source": [ "from llm_config import convert_and_compress_model\n", "\n", @@ -435,20 +415,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "281f1d07-998e-4e13-ba95-0264564ede82", "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Size of model with INT4 compressed weights is 358.86 MB\n" - ] - } - ], + "outputs": [], "source": [ "from llm_config import compare_model_size\n", "\n", @@ -468,28 +440,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "837b4a3b-ccc3-4004-9577-2b2c7b802dea", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a49eaf3eebe94b58b0a48f920f30c558", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Dropdown(description='Device:', options=('CPU', 'AUTO'), value='CPU')" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from notebook_utils import device_widget\n", "\n", @@ -525,22 +481,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "7a041101-7336-40fd-96c9-cd298015a0f3", "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Loading model from qwen2/INT4_compressed_weights\n", - "\n", - " it is the only source of light. What else\n" - ] - } - ], + "outputs": [], "source": [ "from openvino_genai import LLMPipeline\n", "print(f\"Loading model from {model_dir}\\n\")\n", @@ -619,53 +565,23 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "01f8f7f8-072e-45dc-b7c9-18d8c3c47754", "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Running on local URL: http://127.0.0.1:7860\n", - "\n", - "To create a public link, set `share=True` in `launch()`.\n" - ] - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from genai_gradio_helper import get_gradio_helper\n", "\n", - "demo = get_gradio_helper(pipe, model_configuration, model_dir, model_id, lang.value)\n", + "demo = get_gradio_helper(pipe, model_configuration, model_id, lang.value)\n", "\n", "demo.launch()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "id": "7b837f9e-4152-4a5c-880a-ed874aa64a74", "metadata": { "tags": [] @@ -727,57 +643,79 @@ "widgets": { "application/vnd.jupyter.widget-state+json": { "state": { - "06330bf4d2134590affb465ac2ab3f44": { + "067a100f2bd4465f81da4fd9ab3f5adc": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "BoxModel", + "model_name": "DropdownModel", "state": { - "children": [ - "IPY_MODEL_cd9e6ac6c9344caeb44b23abab15db42", - "IPY_MODEL_ae6863b212014cf688433905b8867f92", - "IPY_MODEL_eadc31a26a70405daf0b74a0539b6f6e", - "IPY_MODEL_2c232d3a4e7b4a328e1baf5e4dbc4a86" + "_options_labels": [ + "CPU", + "AUTO" ], - "layout": "IPY_MODEL_6b6ac753a2934de399de04c354d0a681" + "description": "Device:", + "index": 0, + "layout": "IPY_MODEL_53027f0d6b374cb5841140902de60009", + "style": "IPY_MODEL_5db48946f9be480eacb6a06a4c4aec21" } }, - "12ca4066d405469fa03ffa34880d6bd4": { + "0e2af61bbb5b4996822fa9ef3ff61982": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "DescriptionStyleModel", + "model_name": "DropdownModel", "state": { - "description_width": "" + "_options_labels": [ + "English", + "Chinese", + "Japanese" + ], + "index": 1, + "layout": "IPY_MODEL_77a5f36926204d569500ff759046d572", + "style": "IPY_MODEL_ed7fe4055ab24bf7a0c17df02f4f9b82" } }, - "19e0f0a4ee2548fa90b14f1a0f8c3c67": { + "1064af17a7104e6a998e65e864b14510": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LabelModel", + "model_name": "DropdownModel", "state": { - "layout": "IPY_MODEL_a3ab59d2e6d147f38cb0699c00451341", - "style": "IPY_MODEL_d332b45c6a6445f7a276ac6834c42424", - "value": "Use preconverted models:" + "_options_labels": [ + "CPU", + "AUTO" + ], + "description": "Device:", + "index": 0, + "layout": "IPY_MODEL_7b12e62dd6904bbe85813f22eaff95f4", + "style": "IPY_MODEL_4fa495c0d02d45a88f1b978a6fb97672" } }, - "2c232d3a4e7b4a328e1baf5e4dbc4a86": { + "24220aea0f034c0f8b5922eb246c6176": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "323f65aa9e7a455db32de98a018c5eba": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "BoxModel", + "model_name": "LabelStyleModel", "state": { - "children": [ - "IPY_MODEL_19e0f0a4ee2548fa90b14f1a0f8c3c67", - "IPY_MODEL_a0973372ea2e442bb6646adbeaab264b" - ], - "layout": "IPY_MODEL_4c8a191bfa24421ea45d3665e203726b" + "description_width": "", + "font_family": null, + "font_size": null, + "font_style": null, + "font_variant": null, + "font_weight": null, + "text_color": null, + "text_decoration": null } }, - "35534850da02421c88c047665a1a52dc": { + "3560954cbdb1401eb374b120d04eb3ef": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "3e082edeb7e6463f8f9669e876d7d365": { + "4384efc9d084421988415647aa5e2ffb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "DropdownModel", @@ -789,27 +727,90 @@ "FP16" ], "index": 0, - "layout": "IPY_MODEL_ed17db6f468b4afcacaffab979b21c69", - "style": "IPY_MODEL_12ca4066d405469fa03ffa34880d6bd4" + "layout": "IPY_MODEL_9475b177a77843818dc6e133263ff44b", + "style": "IPY_MODEL_6a5821b013fb4cdb912ec1bce8fec625" + } + }, + "44dcc989843e4185b6f21934d54318e7": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "LabelModel", + "state": { + "layout": "IPY_MODEL_24220aea0f034c0f8b5922eb246c6176", + "style": "IPY_MODEL_ef174221ce394b4d9536044121a2014e", + "value": "Language:" + } + }, + "464ac433f7bb48bf8badf59b5402cd9d": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "DropdownModel", + "state": { + "_options_labels": [ + "qwen1.5-0.5b-chat", + "qwen2-1.5b-instruct", + "qwen2-7b-instruct", + "qwen1.5-7b-chat", + "qwen-7b-chat", + "chatglm3-6b", + "glm-4-9b-chat", + "baichuan2-7b-chat", + "minicpm-2b-dpo", + "internlm2-chat-1.8b", + "qwen1.5-1.8b-chat" + ], + "index": 0, + "layout": "IPY_MODEL_d70ae93f79de4b8c91efe096c7f0a1b3", + "style": "IPY_MODEL_bb5331008108429da33c572e220e9cfd" } }, - "3f70816d633f48c09c5b661d7ab98f64": { + "4d7d47d24c4a42f699f0a32e81c14fe4": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "BoxModel", + "state": { + "children": [ + "IPY_MODEL_f6ac7672e6844a61b2a6310765a1b743", + "IPY_MODEL_bc50a1e98bce46b79c3ecb299e91bb34", + "IPY_MODEL_5cdc0a289da0418e855f9067d52455f9", + "IPY_MODEL_76dbadf630504ecfb60d6549ab9a8471" + ], + "layout": "IPY_MODEL_b599bb1053bb405bb0ee9ae49e1019f0" + } + }, + "4fa495c0d02d45a88f1b978a6fb97672": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "DescriptionStyleModel", + "state": { + "description_width": "" + } + }, + "53027f0d6b374cb5841140902de60009": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "545d4571c96740249e0fe869e9c2f145": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "3fd493e0bcc442b487fd85d7d822d0b9": { + "5cdc0a289da0418e855f9067d52455f9": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LabelModel", + "model_name": "BoxModel", "state": { - "layout": "IPY_MODEL_e97a5a9ae376469798e7dd260a9aaf0f", - "style": "IPY_MODEL_bdae50a42140410ea792db1ffe91ab02", - "value": "Compression:" + "children": [ + "IPY_MODEL_e33379d2d81046408230524a621a5188", + "IPY_MODEL_4384efc9d084421988415647aa5e2ffb" + ], + "layout": "IPY_MODEL_bd0fe269b29a40e8b6413da6fcfdca88" } }, - "411918a1354a40d0a9e86aff3d76388b": { + "5db48946f9be480eacb6a06a4c4aec21": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "DescriptionStyleModel", @@ -817,49 +818,75 @@ "description_width": "" } }, - "45ed32597faf48e5a59555dc5e2e50c4": { + "6a5821b013fb4cdb912ec1bce8fec625": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LabelStyleModel", + "model_name": "DescriptionStyleModel", "state": { - "description_width": "", - "font_family": null, - "font_size": null, - "font_style": null, - "font_variant": null, - "font_weight": null, - "text_color": null, - "text_decoration": null + "description_width": "" } }, - "49f08953f4794881997c843fa69f960e": { + "6a8574b1acb347ff85cec4a5761ec9e1": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "76dbadf630504ecfb60d6549ab9a8471": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LabelStyleModel", + "model_name": "BoxModel", "state": { - "description_width": "", - "font_family": null, - "font_size": null, - "font_style": null, - "font_variant": null, - "font_weight": null, - "text_color": null, - "text_decoration": null + "children": [ + "IPY_MODEL_b3e0b54f26474fcbb6e31ca69c034484", + "IPY_MODEL_c56a20c7dd594d2283b5e8f4a7a73401" + ], + "layout": "IPY_MODEL_dca19a43a4c145b8a51302d86dd932aa" } }, - "4c8a191bfa24421ea45d3665e203726b": { + "77a5f36926204d569500ff759046d572": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "7b12e62dd6904bbe85813f22eaff95f4": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "89ce417807834a43b44e79296b75ebd3": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "68bd3ca957344119955f27e0cbed5340": { + "9475b177a77843818dc6e133263ff44b": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "6b6ac753a2934de399de04c354d0a681": { + "9cc5b7cf46634de9b888c9976968f0e6": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "CheckboxStyleModel", + "state": { + "description_width": "" + } + }, + "b3e0b54f26474fcbb6e31ca69c034484": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "2.0.0", + "model_name": "LabelModel", + "state": { + "layout": "IPY_MODEL_6a8574b1acb347ff85cec4a5761ec9e1", + "style": "IPY_MODEL_d9b3c38a73374fa1a9f16f2eb7858aee", + "value": "Use preconverted models:" + } + }, + "b599bb1053bb405bb0ee9ae49e1019f0": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", @@ -874,113 +901,72 @@ "width": "30%" } }, - "72ab8835cbf94d39bb797e121ec8bfa7": { - "model_module": "@jupyter-widgets/base", + "bb5331008108429da33c572e220e9cfd": { + "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": {} + "model_name": "DescriptionStyleModel", + "state": { + "description_width": "" + } }, - "7a0eb403f99e4c6686e65e7a4f99f797": { + "bc50a1e98bce46b79c3ecb299e91bb34": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "DropdownModel", + "model_name": "BoxModel", "state": { - "_options_labels": [ - "qwen2-0.5b-instruct", - "tiny-llama-1b-chat", - "qwen2-1.5b-instruct", - "gemma-2b-it", - "red-pajama-3b-chat", - "qwen2-7b-instruct", - "gemma-7b-it", - "llama-2-chat-7b", - "llama-3-8b-instruct", - "llama-3.1-8b-instruct", - "mpt-7b-chat", - "mistral-7b", - "zephyr-7b-beta", - "notus-7b-v1", - "neural-chat-7b-v3-1", - "phi-3-mini-instruct" + "children": [ + "IPY_MODEL_bdcf34e32aff4678827bdc44b9b1e045", + "IPY_MODEL_464ac433f7bb48bf8badf59b5402cd9d" ], - "index": 0, - "layout": "IPY_MODEL_68bd3ca957344119955f27e0cbed5340", - "style": "IPY_MODEL_411918a1354a40d0a9e86aff3d76388b" + "layout": "IPY_MODEL_89ce417807834a43b44e79296b75ebd3" } }, - "90c71241e2d54b72b8b84ead722f8e4a": { + "bd0fe269b29a40e8b6413da6fcfdca88": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "9343dddbf56746a7a172c879a05bd28b": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": {} - }, - "9fe5415b463940c18004849265df08a0": { + "bdcf34e32aff4678827bdc44b9b1e045": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "LabelModel", "state": { - "layout": "IPY_MODEL_3f70816d633f48c09c5b661d7ab98f64", - "style": "IPY_MODEL_45ed32597faf48e5a59555dc5e2e50c4", + "layout": "IPY_MODEL_545d4571c96740249e0fe869e9c2f145", + "style": "IPY_MODEL_323f65aa9e7a455db32de98a018c5eba", "value": "Model:" } }, - "a0973372ea2e442bb6646adbeaab264b": { + "c246af659ef84e0d84b817b490086474": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "2.0.0", + "model_name": "LayoutModel", + "state": {} + }, + "c56a20c7dd594d2283b5e8f4a7a73401": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "CheckboxModel", "state": { "disabled": false, - "layout": "IPY_MODEL_9343dddbf56746a7a172c879a05bd28b", - "style": "IPY_MODEL_bf95b4b2690d42a0bc7aa6f6afa33423", + "layout": "IPY_MODEL_c246af659ef84e0d84b817b490086474", + "style": "IPY_MODEL_9cc5b7cf46634de9b888c9976968f0e6", "value": true } }, - "a3ab59d2e6d147f38cb0699c00451341": { + "cdee6dee6030420687eac2043dd99b8a": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "a49eaf3eebe94b58b0a48f920f30c558": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "DropdownModel", - "state": { - "_options_labels": [ - "CPU", - "AUTO" - ], - "description": "Device:", - "index": 0, - "layout": "IPY_MODEL_c738281884a240f0af94d72e244b5938", - "style": "IPY_MODEL_e74ff4de536b4cb7b22ff040ecd390a4" - } - }, - "a9649836357d4985b12f4f076dff0716": { + "d70ae93f79de4b8c91efe096c7f0a1b3": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "ae6863b212014cf688433905b8867f92": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "BoxModel", - "state": { - "children": [ - "IPY_MODEL_9fe5415b463940c18004849265df08a0", - "IPY_MODEL_7a0eb403f99e4c6686e65e7a4f99f797" - ], - "layout": "IPY_MODEL_72ab8835cbf94d39bb797e121ec8bfa7" - } - }, - "bdae50a42140410ea792db1ffe91ab02": { + "d9b3c38a73374fa1a9f16f2eb7858aee": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "LabelStyleModel", @@ -995,41 +981,23 @@ "text_decoration": null } }, - "bf95b4b2690d42a0bc7aa6f6afa33423": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "CheckboxStyleModel", - "state": { - "description_width": "" - } - }, - "c1916c1a2c0b4c4f8a710d1770c9af37": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "DescriptionStyleModel", - "state": { - "description_width": "" - } - }, - "c738281884a240f0af94d72e244b5938": { + "dca19a43a4c145b8a51302d86dd932aa": { "model_module": "@jupyter-widgets/base", "model_module_version": "2.0.0", "model_name": "LayoutModel", "state": {} }, - "cd9e6ac6c9344caeb44b23abab15db42": { + "e33379d2d81046408230524a621a5188": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "BoxModel", + "model_name": "LabelModel", "state": { - "children": [ - "IPY_MODEL_d59f0e0e0c7140ffb661db0706ba19f3", - "IPY_MODEL_da8038d580974a03bd35584eed5cd5f7" - ], - "layout": "IPY_MODEL_90c71241e2d54b72b8b84ead722f8e4a" + "layout": "IPY_MODEL_cdee6dee6030420687eac2043dd99b8a", + "style": "IPY_MODEL_ea95d4829c434113ae1a79a54568f984", + "value": "Compression:" } }, - "d332b45c6a6445f7a276ac6834c42424": { + "ea95d4829c434113ae1a79a54568f984": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "LabelStyleModel", @@ -1044,68 +1012,40 @@ "text_decoration": null } }, - "d59f0e0e0c7140ffb661db0706ba19f3": { + "ed7fe4055ab24bf7a0c17df02f4f9b82": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "LabelModel", - "state": { - "layout": "IPY_MODEL_ee14a1abe99e4bb2bd7a063cc08d9289", - "style": "IPY_MODEL_49f08953f4794881997c843fa69f960e", - "value": "Language:" - } - }, - "da8038d580974a03bd35584eed5cd5f7": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "2.0.0", - "model_name": "DropdownModel", + "model_name": "DescriptionStyleModel", "state": { - "_options_labels": [ - "English", - "Chinese", - "Japanese" - ], - "index": 0, - "layout": "IPY_MODEL_35534850da02421c88c047665a1a52dc", - "style": "IPY_MODEL_c1916c1a2c0b4c4f8a710d1770c9af37" + "description_width": "" } }, - "e74ff4de536b4cb7b22ff040ecd390a4": { + "ef174221ce394b4d9536044121a2014e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", - "model_name": "DescriptionStyleModel", + "model_name": "LabelStyleModel", "state": { - "description_width": "" + "description_width": "", + "font_family": null, + "font_size": null, + "font_style": null, + "font_variant": null, + "font_weight": null, + "text_color": null, + "text_decoration": null } }, - "e97a5a9ae376469798e7dd260a9aaf0f": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": {} - }, - "eadc31a26a70405daf0b74a0539b6f6e": { + "f6ac7672e6844a61b2a6310765a1b743": { "model_module": "@jupyter-widgets/controls", "model_module_version": "2.0.0", "model_name": "BoxModel", "state": { "children": [ - "IPY_MODEL_3fd493e0bcc442b487fd85d7d822d0b9", - "IPY_MODEL_3e082edeb7e6463f8f9669e876d7d365" + "IPY_MODEL_44dcc989843e4185b6f21934d54318e7", + "IPY_MODEL_0e2af61bbb5b4996822fa9ef3ff61982" ], - "layout": "IPY_MODEL_a9649836357d4985b12f4f076dff0716" + "layout": "IPY_MODEL_3560954cbdb1401eb374b120d04eb3ef" } - }, - "ed17db6f468b4afcacaffab979b21c69": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": {} - }, - "ee14a1abe99e4bb2bd7a063cc08d9289": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "2.0.0", - "model_name": "LayoutModel", - "state": {} } }, "version_major": 2, diff --git a/utils/llm_config.py b/utils/llm_config.py index c20304011c0..986a8e6250d 100644 --- a/utils/llm_config.py +++ b/utils/llm_config.py @@ -239,7 +239,7 @@ def internlm_partial_text_processor(partial_text, new_text): Answer: <|assistant|>""", }, - "neural-chat-7b-v3-1": { + "neural-chat-7b-v3-3": { "model_id": "Intel/neural-chat-7b-v3-3", "remote_code": False, "start_message": f"[INST] <>\n{DEFAULT_SYSTEM_PROMPT }\n<>\n\n", @@ -270,8 +270,8 @@ def internlm_partial_text_processor(partial_text, new_text): }, }, "Chinese": { - "qwen1.5-0.5b-chat": { - "model_id": "Qwen/Qwen1.5-0.5B-Chat", + "qwen2-0.5b-instruct": { + "model_id": "Qwen/Qwen2-0.5B-Instruct", "remote_code": False, "start_message": DEFAULT_SYSTEM_PROMPT_CHINESE, "stop_tokens": ["<|im_end|>", "<|endoftext|>"],