alfredplpl commited on
Commit
26f08ee
·
verified ·
1 Parent(s): f490dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -49,7 +49,7 @@ model = AutoModelForCausalLM.from_pretrained("llm-jp/llm-jp-13b-instruct-full-ac
49
  #model=model.eval()
50
 
51
  @spaces.GPU()
52
- def chat_llama3_8b(message: str,
53
  history: list,
54
  temperature: float,
55
  max_new_tokens: int
@@ -70,10 +70,6 @@ def chat_llama3_8b(message: str,
70
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
71
  conversation.append({"role": "user", "content": message})
72
 
73
- # This will enforce greedy generation (do_sample=False) when the temperature is passed 0, avoiding the crash.
74
- if temperature == 0:
75
- generate_kwargs['do_sample'] = False
76
-
77
  tokenized_input = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, tokenize=True, return_tensors="pt").to(model.device)
78
  with torch.no_grad():
79
  output = model.generate(
@@ -95,12 +91,12 @@ with gr.Blocks(fill_height=True, css=css) as demo:
95
  gr.Markdown(DESCRIPTION)
96
  gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
97
  gr.ChatInterface(
98
- fn=chat_llama3_8b,
99
  chatbot=chatbot,
100
  fill_height=True,
101
  additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
102
  additional_inputs=[
103
- gr.Slider(minimum=0,
104
  maximum=1,
105
  step=0.1,
106
  value=0.7,
 
49
  #model=model.eval()
50
 
51
  @spaces.GPU()
52
+ def chat_llm_jp_v2(message: str,
53
  history: list,
54
  temperature: float,
55
  max_new_tokens: int
 
70
  conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
71
  conversation.append({"role": "user", "content": message})
72
 
 
 
 
 
73
  tokenized_input = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, tokenize=True, return_tensors="pt").to(model.device)
74
  with torch.no_grad():
75
  output = model.generate(
 
91
  gr.Markdown(DESCRIPTION)
92
  gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
93
  gr.ChatInterface(
94
+ fn=chat_llm_jp_v2,
95
  chatbot=chatbot,
96
  fill_height=True,
97
  additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
98
  additional_inputs=[
99
+ gr.Slider(minimum=0.1,
100
  maximum=1,
101
  step=0.1,
102
  value=0.7,