peder commited on
Commit
5ca6dc6
·
2 Parent(s): ba319d5 74f25ec

Merge branch 'main' of https://huggingface.co/spaces/MasterThesisCBS/NorPaca_GPT

Browse files
Files changed (2) hide show
  1. app.py +14 -13
  2. requirements.txt +2 -1
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
@@ -18,9 +19,9 @@ print(
18
  HF_AUTH_TOKEN = "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"
19
  DEVICE = os.environ.get("cuda:0", "cpu") # cuda:0
20
  DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16
21
- MODEL_NAME = os.environ.get("MODEL_NAME", "NbAiLab/nb-gpt-j-6B-norpaca")
22
  MAX_LENGTH = int(os.environ.get("MAX_LENGTH", 256))
23
- print("hello Boys")
24
  HEADER_INFO = """
25
  # CBS_Alpaca-GPT-j
26
  Norwegian GPT-J-6B NorPaca Model.
@@ -203,20 +204,20 @@ def main():
203
  index=int(query_params.get("do_sample", ["true"])[
204
  0].lower()[0] in ("t", "y", "1")),
205
  )
206
- do_clean = st.sidebar.selectbox(
207
- label='Clean text?',
208
- options=(False, True),
209
- help="Whether or not to remove repeated words and trim unfinished last sentences.",
210
- index=int(query_params.get("do_clean", ["true"])[
211
- 0].lower()[0] in ("t", "y", "1")),
212
- )
213
  generation_kwargs = {
214
  "max_length": max_length,
215
  "top_k": top_k,
216
  "top_p": top_p,
217
  "temperature": temperature,
218
  "do_sample": do_sample,
219
- "do_clean": do_clean,
220
  }
221
  st.markdown(HEADER_INFO)
222
  prompts = EXAMPLES + ["Custom"]
@@ -241,8 +242,8 @@ def main():
241
  for _ in range(5):
242
  generated_text = generator.generate(
243
  text, generation_kwargs)
244
- if do_clean:
245
- generated_text = cleaner.clean_txt(generated_text)
246
  if generated_text.strip().startswith(text):
247
  generated_text = generated_text.replace(
248
  text, "", 1).strip()
@@ -273,4 +274,4 @@ def main():
273
 
274
 
275
  if __name__ == '__main__':
276
- 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
 
19
  HF_AUTH_TOKEN = "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"
20
  DEVICE = os.environ.get("cuda:0", "cpu") # cuda:0
21
  DTYPE = torch.float32 if DEVICE == "cpu" else torch.float16
22
+ MODEL_NAME = os.environ.get("MODEL_NAME", "NbAiLab/nb-gpt-j-6B-alpaca")
23
  MAX_LENGTH = int(os.environ.get("MAX_LENGTH", 256))
24
+
25
  HEADER_INFO = """
26
  # CBS_Alpaca-GPT-j
27
  Norwegian GPT-J-6B NorPaca Model.
 
204
  index=int(query_params.get("do_sample", ["true"])[
205
  0].lower()[0] in ("t", "y", "1")),
206
  )
207
+ # do_clean = st.sidebar.selectbox(
208
+ # label='Clean text?',
209
+ # options=(False, True),
210
+ # help="Whether or not to remove repeated words and trim unfinished last sentences.",
211
+ # index=int(query_params.get("do_clean", ["true"])[
212
+ # 0].lower()[0] in ("t", "y", "1")),
213
+ # )
214
  generation_kwargs = {
215
  "max_length": max_length,
216
  "top_k": top_k,
217
  "top_p": top_p,
218
  "temperature": temperature,
219
  "do_sample": do_sample,
220
+ # "do_clean": do_clean,
221
  }
222
  st.markdown(HEADER_INFO)
223
  prompts = EXAMPLES + ["Custom"]
 
242
  for _ in range(5):
243
  generated_text = generator.generate(
244
  text, generation_kwargs)
245
+ # if do_clean:
246
+ # generated_text = cleaner.clean_txt(generated_text)
247
  if generated_text.strip().startswith(text):
248
  generated_text = generated_text.replace(
249
  text, "", 1).strip()
 
274
 
275
 
276
  if __name__ == '__main__':
277
+ main()
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  --find-links https://download.pytorch.org/whl/torch_stable.html
2
  torch
3
  transformers
4
- urllib3
 
 
1
  --find-links https://download.pytorch.org/whl/torch_stable.html
2
  torch
3
  transformers
4
+ urllib3
5
+ pyngrok