sithumonline commited on
Commit
3e93048
1 Parent(s): 6d70ab6

Comment history and stuff

Browse files
Files changed (1) hide show
  1. app.py +29 -14
app.py CHANGED
@@ -14,16 +14,24 @@ llm = Llama(
14
  n_gpu_layers=50, # change n_gpu_layers if you have more or less VRAM
15
  )
16
 
17
- history = []
18
 
19
- system_message = """
20
- You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
 
 
 
21
 
22
- If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
23
- """
24
 
25
-
26
- def generate_text(message, history):
 
 
 
 
 
 
 
27
  temp = ""
28
  input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
29
  for interaction in history:
@@ -33,11 +41,11 @@ def generate_text(message, history):
33
 
34
  output = llm(
35
  input_prompt,
36
- temperature=0.15,
37
- top_p=0.1,
38
- top_k=40,
39
  repeat_penalty=1.1,
40
- max_tokens=1024,
41
  stop=[
42
  "<|prompter|>",
43
  "<|endoftext|>",
@@ -53,14 +61,21 @@ def generate_text(message, history):
53
  temp += stream["choices"][0]["text"]
54
  yield temp
55
 
56
- history = ["init", input_prompt]
 
57
 
58
  demo = gr.ChatInterface(
59
  generate_text,
60
  title="llama-cpp-python on GPU",
61
  description="Running LLM with https://github.com/abetlen/llama-cpp-python",
62
- # examples=[["tell me everything about llamas"]],
63
- cache_examples=True,
 
 
 
 
 
 
64
  retry_btn=None,
65
  undo_btn="Delete Previous",
66
  clear_btn="Clear",
 
14
  n_gpu_layers=50, # change n_gpu_layers if you have more or less VRAM
15
  )
16
 
17
+ # history = []
18
 
19
+ # system_message = """
20
+ # You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
21
+ #
22
+ # If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
23
+ # """
24
 
 
 
25
 
26
+ # def generate_text(message, history):
27
+ def generate_text(
28
+ message,
29
+ history: list[tuple[str, str]],
30
+ system_message,
31
+ max_tokens,
32
+ temperature,
33
+ top_p,
34
+ ):
35
  temp = ""
36
  input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
37
  for interaction in history:
 
41
 
42
  output = llm(
43
  input_prompt,
44
+ temperature=temperature,
45
+ top_p=top_p,
46
+ top_k=40,
47
  repeat_penalty=1.1,
48
+ max_tokens=max_tokens,
49
  stop=[
50
  "<|prompter|>",
51
  "<|endoftext|>",
 
61
  temp += stream["choices"][0]["text"]
62
  yield temp
63
 
64
+ # history = ["init", input_prompt]
65
+
66
 
67
  demo = gr.ChatInterface(
68
  generate_text,
69
  title="llama-cpp-python on GPU",
70
  description="Running LLM with https://github.com/abetlen/llama-cpp-python",
71
+ examples=[
72
+ ['How to setup a human base on Mars? Give short answer.'],
73
+ ['Explain theory of relativity to me like I’m 8 years old.'],
74
+ ['What is 9,000 * 9,000?'],
75
+ ['Write a pun-filled happy birthday message to my friend Alex.'],
76
+ ['Justify why a penguin might make a good king of the jungle.']
77
+ ],
78
+ cache_examples=False,
79
  retry_btn=None,
80
  undo_btn="Delete Previous",
81
  clear_btn="Clear",