File size: 10,636 Bytes
8889bbb
 
 
 
 
988983d
8889bbb
 
 
 
 
 
 
 
 
988983d
8889bbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8aed7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
988983d
c8aed7a
 
 
 
 
988983d
c8aed7a
 
 
 
 
 
 
 
 
 
 
 
a273e68
c8aed7a
988983d
 
a273e68
fb10dcf
c8aed7a
988983d
 
fb10dcf
 
 
 
 
 
 
988983d
8889bbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3c19b3
 
 
8889bbb
 
 
 
c8aed7a
8889bbb
c8aed7a
a273e68
c8aed7a
 
 
 
 
 
 
 
 
 
 
 
 
 
a273e68
 
 
 
 
c8aed7a
 
 
 
a273e68
 
 
 
8889bbb
c8aed7a
8889bbb
 
 
fb10dcf
8889bbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb6719e
 
 
 
 
 
 
 
 
8889bbb
 
 
 
 
 
 
 
 
d3c19b3
8889bbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb6719e
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import os

# ! UI Markdown information

MODEL_TITLE = """
<img src="file/seal_logo.png" style="
    max-width: 10em;
    max-height: 5%;
    height: 3em;
    width: 3em;
">
<div class="text" style="
loat: left;
padding-bottom: 2%;
">
SeaLLMs - Large Language Models for Southeast Asia
</div>
"""

# <a href='https://huggingface.co/spaces/SeaLLMs/SeaLMMM-7b'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a> 
# <a href='https://huggingface.co/SeaLLMs/SeaLLM-7B-v2'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue'></a> 
# 
MODEL_DESC = f"""
<div style='display:flex; gap: 0.25rem; '>
<a href='https://github.com/damo-nlp-sg/seallms'><img src='https://img.shields.io/badge/Github-Code-success'></a>
<a href='https://huggingface.co/spaces/SeaLLMs/SeaLLM-7B'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a> 
<a href='https://huggingface.co/SeaLLMs/SeaLMMM-7B-early'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue'></a> 
</div>
<span style="font-size: larger">
<a href="https://huggingface.co/SeaLLMs/SeaLMMM-7B-early" target="_blank">SeaLMMM-7B-early</a> - multilingual multimodal assistant for Southeast Asia. It handles <b>both</b> text-only (<a href="https://huggingface.co/SeaLLMs/SeaLLM-7B-v2" target="_blank">LLMs</a> and vision instructions (LVMs). <span style="color: red">SeaLMMM-7B has not finished training.</span>
</span>
<br>
<span>
<span style="color: red">The chatbot may produce false and harmful content!</span>
By using our service, you are required to agree to our <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b/blob/main/LICENSE" target="_blank" style="color: red">Terms Of Use</a>
</span>
""".strip()


MODEL_TITLE = """
<img src="file/seal_logo.png" style="
    max-width: 10em;
    max-height: 5%;
    height: 3em;
    width: 3em;
">
<div class="text" style="
    float: left;
    padding-left: 2%;
    font-size: larger;
    margin-bottom: -1em;
    margin-top: -1em;
">
SeaLLMs - Large Language Models for Southeast Asia
<div style='display:flex; gap: 0.25rem; '>
<a href='https://damo-nlp-sg.github.io/SeaLLMs/'><img class="tag" src='https://img.shields.io/badge/Blog-red'></a>
<a href='https://github.com/damo-nlp-sg/seallms'><img class="tag" src='https://img.shields.io/badge/Code-success'></a>
<a href='https://huggingface.co/spaces/SeaLLMs/SeaLLM-7B-v2.5'><img class="tag" src='https://img.shields.io/badge/%F0%9F%A4%97-Spaces-blue'></a> 
<a href='https://huggingface.co/SeaLLMs/SeaLLM-7B-v2.5'><img class="tag" src='https://img.shields.io/badge/%F0%9F%A4%97-Model-blue'></a> 
<a href='https://arxiv.org/pdf/2312.00738.pdf'><img class="tag" src='https://img.shields.io/badge/Paper-red'></a>
</div>
</div>
"""

# Explore <a href="https://huggingface.co/spaces/SeaLLMs/SeaLLM-7B" target="_blank">SeaLMMM-7B</a> - our multi-modal version of SeaLLMs.
# <div style='display:flex; gap: 0.25rem; '>
# <a href='https://damo-nlp-sg.github.io/SeaLLMs/'><img class="tag" src='https://img.shields.io/badge/Blog-red'></a>
# <a href='https://github.com/damo-nlp-sg/seallms'><img class="tag" src='https://img.shields.io/badge/Code-success'></a>
# <a href='https://huggingface.co/spaces/SeaLLMs/SeaLLM-7B-v2.5'><img class="tag" src='https://img.shields.io/badge/%F0%9F%A4%97-Spaces-blue'></a> 
# <a href='https://huggingface.co/SeaLLMs/SeaLLM-7B-v2.5'><img class="tag" src='https://img.shields.io/badge/%F0%9F%A4%97-Model-blue'></a> 
# <a href='https://arxiv.org/pdf/2312.00738.pdf'><img class="tag" src='https://img.shields.io/badge/Paper-red'></a>
# </div>
MODEL_DESC = f"""
<span style="font-size: large">
<a href="https://huggingface.co/SeaLLMs/SeaLLM-7B-v2.5" target="_blank">SeaLLM-7B-v2.5</a> - a helpful assistant for Southeast Asian Languages ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ป๐Ÿ‡ณ ๐Ÿ‡ฎ๐Ÿ‡ฉ ๐Ÿ‡น๐Ÿ‡ญ ๐Ÿ‡ฒ๐Ÿ‡พ ๐Ÿ‡ฐ๐Ÿ‡ญ ๐Ÿ‡ฑ๐Ÿ‡ฆ ๐Ÿ‡ต๐Ÿ‡ญ ๐Ÿ‡ฒ๐Ÿ‡ฒ.
</span>
<br>
<span style="font-size: small">
<span style="color: red">The chatbot may produce false and harmful content!</span>
By using our service, you agree to our <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b/blob/main/LICENSE" target="_blank" style="color: red">Terms Of Use</a>
</span>
""".strip()
# <span>
# <span style="color: red">NOTE: The chatbot may produce false and harmful content and does not have up-to-date knowledge.</span> 
# By using our service, you are required to agree to our <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b/blob/main/LICENSE" target="_blank" style="color: red">Terms Of Use</a>, which includes 
# not to use our service to generate any harmful, inappropriate or illegal content. 
# The service collects user dialogue data for testing and improvement under 
# <a href="https://creativecommons.org/licenses/by/4.0/">(CC-BY)</a> or similar license. So do not enter any personal information!
# </span>

"""
By using our service, you are required to agree to our <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b/blob/main/LICENSE" target="_blank" style="color: red">Terms Of Use</a>, which includes 
not to use our service to generate any harmful, inappropriate or illegal content. 
The service collects user dialogue data for testing and improvement under 
<a href="https://creativecommons.org/licenses/by/4.0/">(CC-BY)</a> or similar license. So do not enter any personal information!
"""

# MODEL_INFO = """
# <h4 style="display: hidden;">Model Name: {model_path}</h4>
# """
MODEL_INFO = ""

CITE_MARKDOWN = """
## Citation
If you find our project useful, hope you can star our repo and cite our paper as follows:
```
@article{damonlpsg2023seallm,
  author = {Xuan-Phi Nguyen*, Wenxuan Zhang*, Xin Li*, Mahani Aljunied*, Weiwen Xu, Hou Pong Chan, 
            Zhiqiang Hu, Chenhui Shen^, Yew Ken Chia^, Xingxuan Li, Jianyu Wang, Qingyu Tan, Liying Cheng, 
            Guanzheng Chen, Yue Deng, Sen Yang, Chaoqun Liu, Hang Zhang, Lidong Bing},
  title = {SeaLLMs - Large Language Models for Southeast Asia},
  year = 2023,
}
```
"""


# .panel-full-width.svelte-1ylopk1.svelte-1ylopk1.svelte-1ylopk1 {
CSS = """
.message-wrap.svelte-1lcyrx4>div.svelte-1lcyrx4  img {
    min-width: 200px;
    min-height: 150px;
    max-height: 600px;
    max-width; 90%;
    width: auto;
    object-fit: contain;
}
.panel-full-width.svelte-1lcyrx4.svelte-1lcyrx4.svelte-1lcyrx4 {
    padding: calc(var(--spacing-xxl) * 1);
    width: 100%
}

.panel-full-width {
    padding: calc(var(--spacing-xxl) * 1);
    width: 100%
}

img.tag {
  max-height: 1.5em;
  width: auto;
}

span.prose {
  font-size: var(--text-lg);
}
"""

USE_PANEL = bool(int(os.environ.get("USE_PANEL", "1")))
CHATBOT_HEIGHT = int(os.environ.get("CHATBOT_HEIGHT", "500"))

ALLOWED_PATHS = ["seal_logo.png"]


DEMOS = os.environ.get("DEMOS", "")

DEMOS = DEMOS.split(",") if DEMOS.strip() != "" else [
    "DocChatInterfaceDemo",
    "ChatInterfaceDemo",
    "TextCompletionDemo",
    # "RagChatInterfaceDemo",
    # "VisionChatInterfaceDemo",
    # "VisionDocChatInterfaceDemo",
]

# DEMOS=DocChatInterfaceDemo,ChatInterfaceDemo,RagChatInterfaceDemo,TextCompletionDemo



# ! server info

DELETE_FOLDER = os.environ.get("DELETE_FOLDER", "")
PORT = int(os.environ.get("PORT", "7860"))
PROXY = os.environ.get("PROXY", "").strip()

# ! backend info

BACKEND = os.environ.get("BACKEND", "debug")

# ! model information
# for RAG
RAG_EMBED_MODEL_NAME = os.environ.get("RAG_EMBED_MODEL_NAME", "sentence-transformers/all-MiniLM-L6-v2")
CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", "1024"))
CHUNK_OVERLAP = int(os.environ.get("CHUNK_SIZE", "50"))


DEFAULT_SYSTEM_PROMPT = """You are a helpful, respectful, honest and safe AI assistant."""
DEFAULT_SYSTEM_PROMPT = """You are SeaLLM, you are a helpful, respectful and honest AI assistant. Based on your internal clock, the current date time: {cur_datetime}.

Your knowledge base was last updated on August 2023. Thus, you should answers questions about events prior to and after August 2023 the way a highly informed individual in August 2023 would if they were talking to someone from the above date, and can let the human know this when relevant.

You should give concise responses to very simple questions, but provide thorough responses to more complex and open-ended questions. You should provide thorough help with writing, analysis, question answering, math, coding, and all sorts of other tasks. It uses markdown for coding."""


SYSTEM_PROMPT = os.environ.get("SYSTEM_PROMPT", DEFAULT_SYSTEM_PROMPT)

MAX_TOKENS = int(os.environ.get("MAX_TOKENS", "2048"))
TEMPERATURE = float(os.environ.get("TEMPERATURE", "0.1"))
# ! these values currently not used
FREQUENCE_PENALTY = float(os.environ.get("FREQUENCE_PENALTY", "0.0"))
PRESENCE_PENALTY = float(os.environ.get("PRESENCE_PENALTY", "0.0"))


# Transformers or vllm
MODEL_PATH = os.environ.get("MODEL_PATH", "SeaLLMs/SeaLLM-7B-v2")
MODEL_NAME = os.environ.get("MODEL_NAME", "Cool-Chatbot")
DTYPE = os.environ.get("DTYPE", "bfloat16")
DEVICE = os.environ.get("DEVICE", "cuda")

# VLLM
GPU_MEMORY_UTILIZATION = float(os.environ.get("GPU_MEMORY_UTILIZATION", "0.9"))
TENSOR_PARALLEL = int(os.environ.get("TENSOR_PARALLEL", "1"))
QUANTIZATION = str(os.environ.get("QUANTIZATION", ""))
STREAM_YIELD_MULTIPLE = int(os.environ.get("STREAM_YIELD_MULTIPLE", "1"))
# how many iterations to perform safety check on response
STREAM_CHECK_MULTIPLE = int(os.environ.get("STREAM_CHECK_MULTIPLE", "0"))

# llama.cpp
DEFAULT_CHAT_TEMPLATE = os.environ.get("DEFAULT_CHAT_TEMPLATE", "chatml")
N_CTX = int(os.environ.get("N_CTX", "4096"))
N_GPU_LAYERS = int(os.environ.get("N_GPU_LAYERS", "-1"))

# llava.llama.cpp


# Multimodal
IMAGE_TOKEN = os.environ.get("IMAGE_TOKEN", "[IMAGE]<|image|>[/IMAGE]")
IMAGE_TOKEN_INTERACTIVE = bool(int(os.environ.get("IMAGE_TOKEN_INTERACTIVE", "0")))
IMAGE_TOKEN_LENGTH = int(os.environ.get("IMAGE_TOKEN_LENGTH", "576"))
MAX_PACHES = int(os.environ.get("MAX_PACHES", "1"))


"""
# claude style
You are SeaLLM, you are a helpful, respectful and honest AI assistant. Based on your internal clock, the current date time: {cur_datetime}.

Your knowledge base was last updated on August 2023. Thus, you should answers questions about events prior to and after August 2023 the way a highly informed individual in August 2023 would if they were talking to someone from the above date, and can let the human know this when relevant.

You should give concise responses to very simple questions, but provide thorough responses to more complex and open-ended questions. You should provide thorough help with writing, analysis, question answering, math, coding, and all sorts of other tasks. It uses markdown for coding.
"""