NGUYEN, Xuan Phi commited on
Commit
5100e68
1 Parent(s): e9cbae4
Files changed (1) hide show
  1. app.py +37 -8
app.py CHANGED
@@ -666,14 +666,12 @@ def debug_chat_response_echo(
666
 
667
 
668
  # ============ CONSTANT ============
 
669
  MODEL_TITLE = "DAMO-SeaL-13B - An Assistant for South East Asian Languages"
670
  MODEL_DESC = """
671
  This is a 13B DAMO-SeaL-Chat assistant model built by DAMO Academy, Alibaba Group. It can produce helpful responses in English, Vietnamese, Indonesian and Thai.
672
- """.strip()
673
-
674
-
675
- cite_markdown = """
676
- ## Citation
677
  If you find our project useful, hope you can star our repo and cite our paper as follows:
678
  ```
679
  @article{damonlpsg2023seallm,
@@ -681,6 +679,11 @@ If you find our project useful, hope you can star our repo and cite our paper as
681
  title = {SeaL: A language model for South East Asian Languages},
682
  year = 2023,
683
  }
 
 
 
 
 
684
  """
685
  # journal = {arXiv preprint arXiv:2306.02858}
686
  # url = {https://arxiv.org/abs/2306.02858}
@@ -699,7 +702,6 @@ def launch():
699
  global demo, llm, DEBUG
700
  model_desc = MODEL_DESC
701
  model_path = MODEL_PATH
702
- assert os.path.exists(model_path), f'{model_path} not found'
703
  model_title = MODEL_TITLE
704
  tensor_parallel = TENSOR_PARALLEL
705
  assert tensor_parallel > 0 , f'{tensor_parallel} invalid'
@@ -708,10 +710,11 @@ def launch():
708
  max_tokens = 4096
709
 
710
  if DEBUG:
711
- model_desc += "<br>!!!!! This is in debug mode, responses will be copy original"
712
  response_fn = debug_chat_response_echo
713
  else:
714
  # ! load the model
 
715
  llm = LLM(model=model_path, dtype=dtype, tensor_parallel_size=tensor_parallel)
716
 
717
  print(f'Use system prompt:\n{sys_prompt}')
@@ -723,6 +726,7 @@ def launch():
723
  demo = gr.ChatInterface(
724
  response_fn,
725
  chatbot=ChatBot(
 
726
  bubble_full_width=False,
727
  latex_delimiters=[
728
  { "left": "$", "right": "$", "display": False},
@@ -742,7 +746,32 @@ def launch():
742
  gr.Textbox(value=sys_prompt, label='System prompt', lines=8)],
743
  )
744
 
745
- gr.Markdown(cite_markdown)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  demo.queue()
747
  # demo.launch(server_port=args.port)
748
  demo.launch()
 
666
 
667
 
668
  # ============ CONSTANT ============
669
+ MODEL_NAME = "DAMO-SeaL-13B"
670
  MODEL_TITLE = "DAMO-SeaL-13B - An Assistant for South East Asian Languages"
671
  MODEL_DESC = """
672
  This is a 13B DAMO-SeaL-Chat assistant model built by DAMO Academy, Alibaba Group. It can produce helpful responses in English, Vietnamese, Indonesian and Thai.
673
+ <br>
674
+ #### Citation
 
 
 
675
  If you find our project useful, hope you can star our repo and cite our paper as follows:
676
  ```
677
  @article{damonlpsg2023seallm,
 
679
  title = {SeaL: A language model for South East Asian Languages},
680
  year = 2023,
681
  }
682
+ ```
683
+ """.strip()
684
+
685
+
686
+ cite_markdown = """
687
  """
688
  # journal = {arXiv preprint arXiv:2306.02858}
689
  # url = {https://arxiv.org/abs/2306.02858}
 
702
  global demo, llm, DEBUG
703
  model_desc = MODEL_DESC
704
  model_path = MODEL_PATH
 
705
  model_title = MODEL_TITLE
706
  tensor_parallel = TENSOR_PARALLEL
707
  assert tensor_parallel > 0 , f'{tensor_parallel} invalid'
 
710
  max_tokens = 4096
711
 
712
  if DEBUG:
713
+ model_desc += "\n<br>!!!!! This is in debug mode, responses will be copy original"
714
  response_fn = debug_chat_response_echo
715
  else:
716
  # ! load the model
717
+ assert os.path.exists(model_path), f'{model_path} not found'
718
  llm = LLM(model=model_path, dtype=dtype, tensor_parallel_size=tensor_parallel)
719
 
720
  print(f'Use system prompt:\n{sys_prompt}')
 
726
  demo = gr.ChatInterface(
727
  response_fn,
728
  chatbot=ChatBot(
729
+ # value=MODEL_NAME,
730
  bubble_full_width=False,
731
  latex_delimiters=[
732
  { "left": "$", "right": "$", "display": False},
 
746
  gr.Textbox(value=sys_prompt, label='System prompt', lines=8)],
747
  )
748
 
749
+ # with gr.Blocks() as demo:
750
+ # gr.ChatInterface(
751
+ # response_fn,
752
+ # chatbot=ChatBot(
753
+ # bubble_full_width=False,
754
+ # latex_delimiters=[
755
+ # { "left": "$", "right": "$", "display": False},
756
+ # { "left": "$$", "right": "$$", "display": True},
757
+ # ]
758
+ # ),
759
+ # textbox=gr.Textbox(placeholder='Type message', lines=8, max_lines=128, min_width=200),
760
+ # submit_btn=gr.Button(value='Submit', variant="primary", scale=0),
761
+ # # stop_btn=None,
762
+ # title=f"{model_title}",
763
+ # description=f"{model_desc}",
764
+ # # ! decide if can change the system prompt.
765
+ # additional_inputs=[
766
+ # gr.Number(value=0, label='Temperature (higher -> more random)'),
767
+ # gr.Number(value=max_tokens, label='Max generated tokens (increase if want more generation)'),
768
+ # gr.Number(value=0.4, label='Frequency penalty (> 0 encourage new tokens)'),
769
+ # gr.Textbox(value=sys_prompt, label='System prompt', lines=8)
770
+ # ],
771
+ # )
772
+
773
+ # gr.Markdown(cite_markdown)
774
+
775
  demo.queue()
776
  # demo.launch(server_port=args.port)
777
  demo.launch()