From 5f8186a25873aac1d0db4c904e27321aab769339 Mon Sep 17 00:00:00 2001 From: LBYPatrick Date: Fri, 16 Jun 2023 11:45:42 +0800 Subject: [PATCH 1/3] chore: bump requirement.txt for guanaco support --- pilot/configs/model_config.py | 3 +++ pilot/model/adapter.py | 6 +++--- pilot/server/llmserver.py | 7 ++++++- requirements.txt | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pilot/configs/model_config.py b/pilot/configs/model_config.py index 0dc78af06..e82a459a3 100644 --- a/pilot/configs/model_config.py +++ b/pilot/configs/model_config.py @@ -43,6 +43,9 @@ LLM_MODEL_CONFIG = { "guanaco-33b-merged": os.path.join(MODEL_PATH, "guanaco-33b-merged"), "falcon-40b": os.path.join(MODEL_PATH, "falcon-40b"), "gorilla-7b": os.path.join(MODEL_PATH, "gorilla-7b"), + + # TODO Support baichuan-7b + #"baichuan-7b" : os.path.join(MODEL_PATH, "baichuan-7b"), "gptj-6b": os.path.join(MODEL_PATH, "ggml-gpt4all-j-v1.3-groovy.bin"), "proxyllm": "proxyllm", } diff --git a/pilot/model/adapter.py b/pilot/model/adapter.py index 2c1089cec..2b93c5c9c 100644 --- a/pilot/model/adapter.py +++ b/pilot/model/adapter.py @@ -32,9 +32,9 @@ class BaseLLMAdaper: return True def loader(self, model_path: str, from_pretrained_kwargs: dict): - tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False) + tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False,trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained( - model_path, low_cpu_mem_usage=True, **from_pretrained_kwargs + model_path, low_cpu_mem_usage=True, trust_remote_code=True, **from_pretrained_kwargs ) return model, tokenizer @@ -57,7 +57,7 @@ def get_llm_model_adapter(model_path: str) -> BaseLLMAdaper: raise ValueError(f"Invalid model adapter for {model_path}") -# TODO support cpu? for practise we support gpt4all or chatglm-6b-int4? +# TODO support cpu? for practice we support gpt4all or chatglm-6b-int4? class VicunaLLMAdapater(BaseLLMAdaper): diff --git a/pilot/server/llmserver.py b/pilot/server/llmserver.py index 3e1c80749..68a3545a3 100644 --- a/pilot/server/llmserver.py +++ b/pilot/server/llmserver.py @@ -5,6 +5,7 @@ import asyncio import json import os import sys +import traceback import uvicorn from fastapi import BackgroundTasks, FastAPI, Request @@ -89,10 +90,14 @@ class ModelWorker: ret = {"text": "**GPU OutOfMemory, Please Refresh.**", "error_code": 0} yield json.dumps(ret).encode() + b"\0" except Exception as e: + + msg = "{}: {}".format(str(e),traceback.format_exc()) + ret = { - "text": f"**LLMServer Generate Error, Please CheckErrorInfo.**: {e}", + "text": f"**LLMServer Generate Error, Please CheckErrorInfo.**: {msg}", "error_code": 0, } + yield json.dumps(ret).encode() + b"\0" def get_embeddings(self, prompt): diff --git a/requirements.txt b/requirements.txt index 0604e5130..555592f98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ aiohttp==3.8.4 aiosignal==1.3.1 async-timeout==4.0.2 attrs==22.2.0 -bitsandbytes==0.37.0 +bitsandbytes==0.39.0 cchardet==2.1.7 chardet==5.1.0 contourpy==1.0.7 @@ -27,7 +27,7 @@ python-dateutil==2.8.2 pyyaml==6.0 tokenizers==0.13.2 tqdm==4.64.1 -transformers==4.28.0 +transformers==4.30.0 timm==0.6.13 spacy==3.5.3 webdataset==0.2.48 From 8a049b8af136bebca548ecc41612788605c210fe Mon Sep 17 00:00:00 2001 From: LBYPatrick Date: Fri, 16 Jun 2023 11:49:55 +0800 Subject: [PATCH 2/3] docs: polish docs --- docs/index.rst | 4 ++-- docs/locales/zh_CN/LC_MESSAGES/getting_started/tutorials.po | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 0e34c3c9e..50f1a6214 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -33,11 +33,11 @@ Currently, we have released multiple key features, which are listed below to dem Getting Started ----------------- | How to get started using DB-GPT to interact with your data and environment. -- `Quickstart Guid <./getting_started/getting_started.html>`_ +- `Quickstart Guide <./getting_started/getting_started.html>`_ | Concepts and terminology -- `Concepts and terminology <./getting_started/concepts.html>`_ +- `Concepts and Terminology <./getting_started/concepts.html>`_ | Coming soon... diff --git a/docs/locales/zh_CN/LC_MESSAGES/getting_started/tutorials.po b/docs/locales/zh_CN/LC_MESSAGES/getting_started/tutorials.po index 45163e6ee..c182325a4 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/getting_started/tutorials.po +++ b/docs/locales/zh_CN/LC_MESSAGES/getting_started/tutorials.po @@ -34,19 +34,19 @@ msgid "" msgstr "" #: ../../getting_started/tutorials.md:8 b5e106a97bbd4467b071bb05d837d7d9 -msgid "Introduce" +msgid "Introduction" msgstr "" #: ../../getting_started/tutorials.md:9 9df43436183d4b41a75a09fec15743d7 #, fuzzy msgid "[What is DB-GPT](https://www.youtube.com/watch?v=QszhVJerc0I)" msgstr "" -"###Introduce [什么是DB-" +"###Introduction [什么是DB-" "GPT](https://www.bilibili.com/video/BV1SM4y1a7Nj/?buvid=551b023900b290f9497610b2155a2668&is_story_h5=false&mid=%2BVyE%2Fwau5woPcUKieCWS0A%3D%3D&p=1&plat_id=116&share_from=ugc&share_medium=iphone&share_plat=ios&share_session_id=5D08B533-82A4-4D40-9615-7826065B4574&share_source=GENERIC&share_tag=s_i×tamp=1686307943&unique_k=bhO3lgQ&up_id=31375446)" " by csunny (https://github.com/csunny/DB-GPT)" #: ../../getting_started/tutorials.md:11 3096811f862649bf84ff3cd29cdf14db -msgid "Knowledge" +msgid "Knowledge Base" msgstr "知识库" #: ../../getting_started/tutorials.md:13 ea00f3de8c754bf2950e735a2f14043a From 0bb0246fb1fc8800f6bccf013351400ea4d3f768 Mon Sep 17 00:00:00 2001 From: LBYPatrick Date: Fri, 16 Jun 2023 12:23:28 +0800 Subject: [PATCH 3/3] chore: run black against modified code --- pilot/configs/model_config.py | 3 +-- pilot/model/adapter.py | 9 +++++++-- pilot/server/llmserver.py | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pilot/configs/model_config.py b/pilot/configs/model_config.py index e82a459a3..f6d59e4e1 100644 --- a/pilot/configs/model_config.py +++ b/pilot/configs/model_config.py @@ -43,9 +43,8 @@ LLM_MODEL_CONFIG = { "guanaco-33b-merged": os.path.join(MODEL_PATH, "guanaco-33b-merged"), "falcon-40b": os.path.join(MODEL_PATH, "falcon-40b"), "gorilla-7b": os.path.join(MODEL_PATH, "gorilla-7b"), - # TODO Support baichuan-7b - #"baichuan-7b" : os.path.join(MODEL_PATH, "baichuan-7b"), + # "baichuan-7b" : os.path.join(MODEL_PATH, "baichuan-7b"), "gptj-6b": os.path.join(MODEL_PATH, "ggml-gpt4all-j-v1.3-groovy.bin"), "proxyllm": "proxyllm", } diff --git a/pilot/model/adapter.py b/pilot/model/adapter.py index 2b93c5c9c..9ea80fb7a 100644 --- a/pilot/model/adapter.py +++ b/pilot/model/adapter.py @@ -32,9 +32,14 @@ class BaseLLMAdaper: return True def loader(self, model_path: str, from_pretrained_kwargs: dict): - tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False,trust_remote_code=True) + tokenizer = AutoTokenizer.from_pretrained( + model_path, use_fast=False, trust_remote_code=True + ) model = AutoModelForCausalLM.from_pretrained( - model_path, low_cpu_mem_usage=True, trust_remote_code=True, **from_pretrained_kwargs + model_path, + low_cpu_mem_usage=True, + trust_remote_code=True, + **from_pretrained_kwargs, ) return model, tokenizer diff --git a/pilot/server/llmserver.py b/pilot/server/llmserver.py index 68a3545a3..51339f322 100644 --- a/pilot/server/llmserver.py +++ b/pilot/server/llmserver.py @@ -90,8 +90,7 @@ class ModelWorker: ret = {"text": "**GPU OutOfMemory, Please Refresh.**", "error_code": 0} yield json.dumps(ret).encode() + b"\0" except Exception as e: - - msg = "{}: {}".format(str(e),traceback.format_exc()) + msg = "{}: {}".format(str(e), traceback.format_exc()) ret = { "text": f"**LLMServer Generate Error, Please CheckErrorInfo.**: {msg}",