ptdataScience
commited on
Commit
·
b3a62f4
1
Parent(s):
8bc3df2
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import random
|
2 |
import os
|
3 |
from urllib.parse import urlencode
|
|
|
4 |
|
5 |
import streamlit as st
|
6 |
import streamlit.components.v1 as components
|
@@ -12,9 +13,9 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
12 |
HF_AUTH_TOKEN = "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"
|
13 |
DEVICE = os.environ.get("cuda:0", "cpu") # cuda:0
|
14 |
DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16
|
15 |
-
MODEL_NAME = os.environ.get("MODEL_NAME", "NbAiLab/nb-gpt-j-6B-
|
16 |
MAX_LENGTH = int(os.environ.get("MAX_LENGTH", 256))
|
17 |
-
|
18 |
HEADER_INFO = """
|
19 |
# CBS_Alpaca-GPT-j
|
20 |
Norwegian GPT-J-6B NorPaca Model.
|
@@ -197,20 +198,20 @@ def main():
|
|
197 |
index=int(query_params.get("do_sample", ["true"])[
|
198 |
0].lower()[0] in ("t", "y", "1")),
|
199 |
)
|
200 |
-
do_clean = st.sidebar.selectbox(
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
)
|
207 |
generation_kwargs = {
|
208 |
"max_length": max_length,
|
209 |
"top_k": top_k,
|
210 |
"top_p": top_p,
|
211 |
"temperature": temperature,
|
212 |
"do_sample": do_sample,
|
213 |
-
"do_clean": do_clean,
|
214 |
}
|
215 |
st.markdown(HEADER_INFO)
|
216 |
prompts = EXAMPLES + ["Custom"]
|
@@ -235,8 +236,8 @@ def main():
|
|
235 |
for _ in range(5):
|
236 |
generated_text = generator.generate(
|
237 |
text, generation_kwargs)
|
238 |
-
if do_clean:
|
239 |
-
|
240 |
if generated_text.strip().startswith(text):
|
241 |
generated_text = generated_text.replace(
|
242 |
text, "", 1).strip()
|
@@ -267,4 +268,4 @@ def main():
|
|
267 |
|
268 |
|
269 |
if __name__ == '__main__':
|
270 |
-
main()
|
|
|
1 |
import random
|
2 |
import os
|
3 |
from urllib.parse import urlencode
|
4 |
+
from pyngrok import ngrok
|
5 |
|
6 |
import streamlit as st
|
7 |
import streamlit.components.v1 as components
|
|
|
13 |
HF_AUTH_TOKEN = "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"
|
14 |
DEVICE = os.environ.get("cuda:0", "cpu") # cuda:0
|
15 |
DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16
|
16 |
+
MODEL_NAME = os.environ.get("MODEL_NAME", "NbAiLab/nb-gpt-j-6B-alpaca")
|
17 |
MAX_LENGTH = int(os.environ.get("MAX_LENGTH", 256))
|
18 |
+
|
19 |
HEADER_INFO = """
|
20 |
# CBS_Alpaca-GPT-j
|
21 |
Norwegian GPT-J-6B NorPaca Model.
|
|
|
198 |
index=int(query_params.get("do_sample", ["true"])[
|
199 |
0].lower()[0] in ("t", "y", "1")),
|
200 |
)
|
201 |
+
# do_clean = st.sidebar.selectbox(
|
202 |
+
# label='Clean text?',
|
203 |
+
# options=(False, True),
|
204 |
+
# help="Whether or not to remove repeated words and trim unfinished last sentences.",
|
205 |
+
# index=int(query_params.get("do_clean", ["true"])[
|
206 |
+
# 0].lower()[0] in ("t", "y", "1")),
|
207 |
+
# )
|
208 |
generation_kwargs = {
|
209 |
"max_length": max_length,
|
210 |
"top_k": top_k,
|
211 |
"top_p": top_p,
|
212 |
"temperature": temperature,
|
213 |
"do_sample": do_sample,
|
214 |
+
# "do_clean": do_clean,
|
215 |
}
|
216 |
st.markdown(HEADER_INFO)
|
217 |
prompts = EXAMPLES + ["Custom"]
|
|
|
236 |
for _ in range(5):
|
237 |
generated_text = generator.generate(
|
238 |
text, generation_kwargs)
|
239 |
+
# if do_clean:
|
240 |
+
# generated_text = cleaner.clean_txt(generated_text)
|
241 |
if generated_text.strip().startswith(text):
|
242 |
generated_text = generated_text.replace(
|
243 |
text, "", 1).strip()
|
|
|
268 |
|
269 |
|
270 |
if __name__ == '__main__':
|
271 |
+
main()
|