Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ import sentencepiece
|
|
7 |
|
8 |
|
9 |
# Load the model and tokenizer using transformers
|
10 |
-
model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-34B", device_map="auto", torch_dtype="auto", trust_remote_code=True)
|
11 |
-
tokenizer = AutoTokenizer.from_pretrained("01-ai/Yi-34B", trust_remote_code=True)
|
12 |
|
13 |
def run(message, chat_history, system_prompt, max_new_tokens=1024, temperature=0.3, top_p=0.9, top_k=50):
|
14 |
prompt = get_prompt(message, chat_history, system_prompt)
|
@@ -42,18 +42,18 @@ def get_prompt(message, chat_history, system_prompt):
|
|
42 |
texts.append(f"{message} [/INST]")
|
43 |
return ''.join(texts)
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
assumptions, and step-by-step thinking BEFORE you try to answer a question.
|
51 |
"""
|
|
|
52 |
MAX_MAX_NEW_TOKENS = 200000
|
53 |
DEFAULT_MAX_NEW_TOKENS = 100000
|
54 |
MAX_INPUT_TOKEN_LENGTH = 100000
|
55 |
|
56 |
-
DESCRIPTION = "# 👋🏻Welcome to 🙋🏻♂️Tonic's🧑🏻🚀
|
57 |
|
58 |
def clear_and_save_textbox(message): return '', message
|
59 |
|
@@ -152,7 +152,7 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
152 |
top_k,
|
153 |
],
|
154 |
outputs=chatbot,
|
155 |
-
api_name=
|
156 |
)
|
157 |
|
158 |
button_event_preprocess = submit_button.click(
|
@@ -184,7 +184,7 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
184 |
top_k,
|
185 |
],
|
186 |
outputs=chatbot,
|
187 |
-
api_name=
|
188 |
)
|
189 |
|
190 |
retry_button.click(
|
@@ -235,4 +235,4 @@ with gr.Blocks(theme='ParityError/Anime') as demo:
|
|
235 |
api_name=False,
|
236 |
)
|
237 |
|
238 |
-
demo.queue(max_size=32).launch(show_api=
|
|
|
7 |
|
8 |
|
9 |
# Load the model and tokenizer using transformers
|
10 |
+
model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-34B-200K", device_map="auto", torch_dtype="auto", trust_remote_code=True)
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained("01-ai/Yi-34B-200K", trust_remote_code=True)
|
12 |
|
13 |
def run(message, chat_history, system_prompt, max_new_tokens=1024, temperature=0.3, top_p=0.9, top_k=50):
|
14 |
prompt = get_prompt(message, chat_history, system_prompt)
|
|
|
42 |
texts.append(f"{message} [/INST]")
|
43 |
return ''.join(texts)
|
44 |
|
45 |
+
DESCRIPTION = """
|
46 |
+
# 👋🏻Welcome to 🙋🏻♂️Tonic's🧑🏻🚀YI-200K🚀"
|
47 |
+
You can use this Space to test out the current model [Tonic/YI](https://huggingface.co/01-ai/Yi-34B)
|
48 |
+
You can also use 🧑🏻🚀YI-200K🚀 by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/Tonic/YiTonic?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>
|
49 |
+
Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)
|
|
|
50 |
"""
|
51 |
+
|
52 |
MAX_MAX_NEW_TOKENS = 200000
|
53 |
DEFAULT_MAX_NEW_TOKENS = 100000
|
54 |
MAX_INPUT_TOKEN_LENGTH = 100000
|
55 |
|
56 |
+
DESCRIPTION = "# 👋🏻Welcome to 🙋🏻♂️Tonic's🧑🏻🚀Yi-200K🚀"
|
57 |
|
58 |
def clear_and_save_textbox(message): return '', message
|
59 |
|
|
|
152 |
top_k,
|
153 |
],
|
154 |
outputs=chatbot,
|
155 |
+
api_name=Generate,
|
156 |
)
|
157 |
|
158 |
button_event_preprocess = submit_button.click(
|
|
|
184 |
top_k,
|
185 |
],
|
186 |
outputs=chatbot,
|
187 |
+
api_name=Cgenerate,
|
188 |
)
|
189 |
|
190 |
retry_button.click(
|
|
|
235 |
api_name=False,
|
236 |
)
|
237 |
|
238 |
+
demo.queue(max_size=32).launch(show_api=True)
|