Spaces:
Running
on
Zero
Running
on
Zero
dreamerdeo
commited on
Commit
•
b90b971
1
Parent(s):
d25cf4a
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,9 @@ import torch
|
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
7 |
-
model_path = 'sail/Sailor-7B-Chat'
|
|
|
|
|
8 |
|
9 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
@@ -24,18 +26,28 @@ class StopOnTokens(StoppingCriteria):
|
|
24 |
return False
|
25 |
|
26 |
|
|
|
|
|
|
|
|
|
27 |
system_role= 'system'
|
28 |
-
user_role = '
|
29 |
-
assistant_role =
|
30 |
|
31 |
sft_start_token = "<|im_start|>"
|
32 |
sft_end_token = "<|im_end|>"
|
33 |
ct_end_token = "<|endoftext|>"
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
system_prompt= \
|
36 |
-
'You are an AI assistant named
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
# Function to generate model predictions.
|
41 |
|
@@ -85,18 +97,20 @@ prompt_examples = [
|
|
85 |
'Cách nướng cá'
|
86 |
]
|
87 |
|
88 |
-
placeholder = """
|
89 |
-
<div style="opacity: 0.5;">
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
</div>
|
94 |
-
"""
|
|
|
95 |
|
96 |
-
chatbot = gr.Chatbot(label='
|
97 |
with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as demo:
|
98 |
# gr.Markdown("""<center><font size=8>Sailor-Chat Bot⚓</center>""")
|
99 |
-
gr.Markdown("""<p align="center"><img src="https://github.com/sail-sg/sailor-llm/raw/main/misc/wide_sailor_banner.jpg" style="height: 110px"/><p>""")
|
|
|
100 |
gr.ChatInterface(predict, chatbot=chatbot, fill_height=True, examples=prompt_examples, css=css)
|
101 |
|
102 |
demo.launch() # Launching the web interface.
|
|
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
7 |
+
# model_path = 'sail/Sailor-7B-Chat'
|
8 |
+
model_path = 'sail/Sailor2-20B-Chat'
|
9 |
+
|
10 |
|
11 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
12 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
|
|
26 |
return False
|
27 |
|
28 |
|
29 |
+
# system_role= 'system'
|
30 |
+
# user_role = 'question'
|
31 |
+
# assistant_role = "answer"
|
32 |
+
|
33 |
system_role= 'system'
|
34 |
+
user_role = 'user'
|
35 |
+
assistant_role = 'assistant'
|
36 |
|
37 |
sft_start_token = "<|im_start|>"
|
38 |
sft_end_token = "<|im_end|>"
|
39 |
ct_end_token = "<|endoftext|>"
|
40 |
|
41 |
+
# system_prompt= \
|
42 |
+
# 'You are an AI assistant named Sailor created by Sea AI Lab. \
|
43 |
+
# Your answer should be friendly, unbiased, faithful, informative and detailed.'
|
44 |
+
# system_prompt = f"<|im_start|>{system_role}\n{system_prompt}<|im_end|>"
|
45 |
+
|
46 |
system_prompt= \
|
47 |
+
'You are an AI assistant named Sailor2, created by Sea AI Lab. \
|
48 |
+
As an AI assistant, you can answer questions in English, Chinese, and Southeast Asian languages \
|
49 |
+
such as Burmese, Cebuano, Ilocano, Indonesian, Javanese, Khmer, Lao, Malay, Sundanese, Tagalog, Thai, Vietnamese, and Waray. \
|
50 |
+
Your responses should be friendly, unbiased, informative, detailed, and faithful.'
|
51 |
|
52 |
# Function to generate model predictions.
|
53 |
|
|
|
97 |
'Cách nướng cá'
|
98 |
]
|
99 |
|
100 |
+
# placeholder = """
|
101 |
+
# <div style="opacity: 0.5;">
|
102 |
+
# <img src="https://raw.githubusercontent.com/sail-sg/sailor-llm/main/misc/banner.jpg" style="width:30%;">
|
103 |
+
# <br>Sailor models are designed to understand and generate text across diverse linguistic landscapes of these SEA regions:
|
104 |
+
# <br>🇮🇩Indonesian, 🇹🇭Thai, 🇻🇳Vietnamese, 🇲🇾Malay, and 🇱🇦Lao.
|
105 |
+
# </div>
|
106 |
+
# """
|
107 |
+
placeholder=''
|
108 |
|
109 |
+
chatbot = gr.Chatbot(label='Sailor2', placeholder=placeholder)
|
110 |
with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as demo:
|
111 |
# gr.Markdown("""<center><font size=8>Sailor-Chat Bot⚓</center>""")
|
112 |
+
# gr.Markdown("""<p align="center"><img src="https://github.com/sail-sg/sailor-llm/raw/main/misc/wide_sailor_banner.jpg" style="height: 110px"/><p>""")
|
113 |
+
gr.Markdown("""<p align="center"><img src="https://github.com/sail-sg/sailor2/raw/main/misc/sailor2_wide_banner.jpg" style="height: 110px"/><p>""")
|
114 |
gr.ChatInterface(predict, chatbot=chatbot, fill_height=True, examples=prompt_examples, css=css)
|
115 |
|
116 |
demo.launch() # Launching the web interface.
|