hanzla commited on
Commit
4581f8a
1 Parent(s): 5e02230
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -16,9 +16,9 @@ pipeline = transformers.pipeline(
16
  )
17
 
18
  @spaces.GPU
19
- def chat_function(message, history):
20
  messages = [
21
- {"role": "system", "content": "You are a helpful assistant!"},
22
  {"role": "user", "content": message},
23
  ]
24
  prompt = pipeline.tokenizer.apply_chat_template(
@@ -32,10 +32,10 @@ def chat_function(message, history):
32
  ]
33
  outputs = pipeline(
34
  prompt,
35
- max_new_tokens=256,
36
  eos_token_id=terminators,
37
  do_sample=True,
38
- temperature=0.6,
39
  top_p=0.9,
40
  )
41
  return outputs[0]["generated_text"][len(prompt):]
@@ -45,6 +45,15 @@ gr.ChatInterface(
45
  chatbot=gr.Chatbot(height=300),
46
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale=7),
47
  title="LLAMA 3 8B Chat",
48
- description="Chat with Meta LLama 3 8 Billion",
 
 
 
 
49
  theme="soft",
 
 
 
 
 
50
  ).launch()
 
16
  )
17
 
18
  @spaces.GPU
19
+ def chat_function(message, history, system_prompt,max_new_tokens,temperature):
20
  messages = [
21
+ {"role": "system", "content": system_prompt},
22
  {"role": "user", "content": message},
23
  ]
24
  prompt = pipeline.tokenizer.apply_chat_template(
 
32
  ]
33
  outputs = pipeline(
34
  prompt,
35
+ max_new_tokens=max_new_tokens,
36
  eos_token_id=terminators,
37
  do_sample=True,
38
+ temperature=temperature,
39
  top_p=0.9,
40
  )
41
  return outputs[0]["generated_text"][len(prompt):]
 
45
  chatbot=gr.Chatbot(height=300),
46
  textbox=gr.Textbox(placeholder="Enter message here", container=False, scale=7),
47
  title="LLAMA 3 8B Chat",
48
+ description="""
49
+ This space is dedicated for chatting with Meta Latest LLM - Llama 8b Instruct. Find this model here: https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct
50
+
51
+ Feel free to play around with different prompt and hyper-parameter
52
+ """,
53
  theme="soft",
54
+ additional_inputs=[
55
+ gr.Textbox("You are helpful AI.", label="System Prompt"),
56
+ gr.Slider(512, 4096, label="Max New Tokens"),
57
+ gr.Slider(0, 1, label="Temperature")
58
+ ]
59
  ).launch()