ffreemt commited on
Commit
2fe65b3
1 Parent(s): 34fa40f

Update prompt_tempalte branch

Browse files
Files changed (1) hide show
  1. app.py +34 -28
app.py CHANGED
@@ -7,6 +7,7 @@ import random
7
  import time
8
  from dataclasses import asdict, dataclass, field
9
  from pathlib import Path
 
10
 
11
  # from types import SimpleNamespace
12
  import gradio as gr
@@ -20,38 +21,11 @@ from examples_list import examples_list
20
 
21
  url = "https://huggingface.co/TheBloke/llama-2-13B-Guanaco-QLoRA-GGML/blob/main/llama-2-13b-guanaco-qlora.ggmlv3.q4_K_S.bin" # 8.14G
22
 
23
- # Prompt template: Guanaco
24
- # {past_history}
25
- prompt_template = """You are a helpful assistant. Let's think step by step.
26
- ### Human:
27
- {question}
28
- ### Assistant:"""
29
- human_prefix = "### Human"
30
- ai_prefix = "### Assistant"
31
- stop_list = [f"{human_prefix}:"]
32
-
33
- prompt_template = """### System:
34
- You are Stable Beluga, an AI that follows instructions extremely well. Help as much as you can.
35
-
36
- ### User: {question}
37
-
38
- ### Assistant:
39
- """
40
- human_prefix = "### User"
41
- ai_prefix = "### Assistant"
42
- stop_list = [f"{human_prefix}:"]
43
-
44
- _ = psutil.cpu_count(logical=False) - 1
45
- cpu_count: int = int(_) if _ else 1
46
- logger.debug(f"{cpu_count=}")
47
-
48
  LLM = None
49
 
50
- if "forindo" in platform.node():
51
  # url = "https://huggingface.co/TheBloke/llama-2-70b-Guanaco-QLoRA-GGML/blob/main/llama-2-70b-guanaco-qlora.ggmlv3.q3_K_S.bin" # 29.7G
52
  # model_loc = "/home/mu2018/github/langchain-llama-2-70b-guanaco-qlora-ggml/models/llama-2-70b-guanaco-qlora.ggmlv3.q3_K_S.bin"
53
- model_loc = "models/stablebeluga2-70b.ggmlv3.q3_K_S.bin"
54
- assert Path(model_loc).exists(), f"Make sure {model_loc=} exists."
55
  _ = """
56
  url = "https://huggingface.co/TheBloke/StableBeluga2-70B-GGML/blob/main/stablebeluga2-70b.ggmlv3.q3_K_S.bin"
57
  try:
@@ -61,8 +35,11 @@ if "forindo" in platform.node():
61
  logger.error(exc_)
62
  raise SystemExit(1) from exc_
63
  # """
 
 
64
  else:
65
  try:
 
66
  model_loc, file_size = dl_hf_model(url)
67
  logger.info(f"done load llm {model_loc=} {file_size=}G")
68
  except Exception as exc_:
@@ -71,6 +48,35 @@ else:
71
 
72
  # raise SystemExit(0)
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  logger.debug(f"{model_loc=}")
75
  LLM = AutoModelForCausalLM.from_pretrained(
76
  model_loc,
 
7
  import time
8
  from dataclasses import asdict, dataclass, field
9
  from pathlib import Path
10
+ from textwrap import dedent
11
 
12
  # from types import SimpleNamespace
13
  import gradio as gr
 
21
 
22
  url = "https://huggingface.co/TheBloke/llama-2-13B-Guanaco-QLoRA-GGML/blob/main/llama-2-13b-guanaco-qlora.ggmlv3.q4_K_S.bin" # 8.14G
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  LLM = None
25
 
26
+ if "forindo" in platform.node(): # deploy 70b model locally
27
  # url = "https://huggingface.co/TheBloke/llama-2-70b-Guanaco-QLoRA-GGML/blob/main/llama-2-70b-guanaco-qlora.ggmlv3.q3_K_S.bin" # 29.7G
28
  # model_loc = "/home/mu2018/github/langchain-llama-2-70b-guanaco-qlora-ggml/models/llama-2-70b-guanaco-qlora.ggmlv3.q3_K_S.bin"
 
 
29
  _ = """
30
  url = "https://huggingface.co/TheBloke/StableBeluga2-70B-GGML/blob/main/stablebeluga2-70b.ggmlv3.q3_K_S.bin"
31
  try:
 
35
  logger.error(exc_)
36
  raise SystemExit(1) from exc_
37
  # """
38
+ model_loc = "models/stablebeluga2-70b.ggmlv3.q3_K_S.bin"
39
+ assert Path(model_loc).exists(), f"Make sure {model_loc=} exists."
40
  else:
41
  try:
42
+ logger.debug(f" dl {url}")
43
  model_loc, file_size = dl_hf_model(url)
44
  logger.info(f"done load llm {model_loc=} {file_size=}G")
45
  except Exception as exc_:
 
48
 
49
  # raise SystemExit(0)
50
 
51
+ # Prompt template: Guanaco
52
+ # {past_history}
53
+ prompt_template = """You are a helpful assistant. Let's think step by step.
54
+ ### Human:
55
+ {question}
56
+ ### Assistant:"""
57
+ human_prefix = "### Human"
58
+ ai_prefix = "### Assistant"
59
+ stop_list = [f"{human_prefix}:"]
60
+
61
+ if "beluga" in model_loc.lower():
62
+ prompt_template = dedent("""
63
+ ### System:
64
+ You are Stable Beluga, an AI that follows instructions extremely well. Help as much as you can.
65
+ Let's think step by step.
66
+
67
+ ### User: {question}
68
+
69
+ ### Assistant:
70
+ """).lstrip()
71
+ human_prefix = "### User"
72
+ ai_prefix = "### Assistant"
73
+ stop_list = [f"{human_prefix}:"]
74
+
75
+ _ = psutil.cpu_count(logical=False) - 1
76
+ cpu_count: int = int(_) if _ else 1
77
+ logger.debug(f"{cpu_count=}")
78
+
79
+
80
  logger.debug(f"{model_loc=}")
81
  LLM = AutoModelForCausalLM.from_pretrained(
82
  model_loc,