Tonic commited on
Commit
8af3d49
β€’
1 Parent(s): d14a664

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -19,15 +19,12 @@ model = AutoModelForCausalLM.from_pretrained(model_path, device_map='cuda', quan
19
 
20
  @spaces.GPU
21
  def generate_text(usertitle, content, max_length, temperature):
22
- # msg = [{
23
- # 'title': title,
24
- # 'content': content
25
- # }]
26
  input_text = {'title': usertitle, 'content': content}
27
  inputs = tokenizer.apply_chat_template(input_text, return_tensors='pt').cuda()
28
- generated_text = tokenizer.decode(model.generate(inputs, max_new_tokens=max_length, temperature=temperature, skip_special_tokens=True, do_sample=True)[0])#.tokenizer.split(tokenizer.eos_token)[0]
29
-
30
- return generated_text
 
31
 
32
  def gradio_app():
33
  with gr.Blocks() as demo:
 
19
 
20
  @spaces.GPU
21
  def generate_text(usertitle, content, max_length, temperature):
 
 
 
 
22
  input_text = {'title': usertitle, 'content': content}
23
  inputs = tokenizer.apply_chat_template(input_text, return_tensors='pt').cuda()
24
+ generated_text = tokenizer.decode(model.generate(inputs, max_new_tokens=max_length, temperature=temperature, do_sample=True)[0])#.strip().split(tokenizer.eos_token)[0]
25
+ split_text = generated_text.strip().split(tokenizer.eos_token)[0]
26
+
27
+ return split_text
28
 
29
  def gradio_app():
30
  with gr.Blocks() as demo: