Tonic commited on
Commit
8e93464
·
verified ·
1 Parent(s): 6a5a0e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -25,7 +25,7 @@ model = AutoModelForCausalLM.from_pretrained( model_path, device_map='cuda', loa
25
  def generate_text(prompt, custom_prompt, temperature, max_length):
26
  structured_input = f"[Title]: {prompt}\n[Content]: {custom_prompt}"
27
  inputs = tokenizer(structured_input, return_tensors='pt').to('cuda')
28
- generated_ids = model.generate(**inputs, max_new_tokens=max_length, temperature=temperature, do_sample=True, pad_token_id=tokenizer.eos_token_id)
29
  generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
30
 
31
  return generated_text
 
25
  def generate_text(prompt, custom_prompt, temperature, max_length):
26
  structured_input = f"[Title]: {prompt}\n[Content]: {custom_prompt}"
27
  inputs = tokenizer(structured_input, return_tensors='pt').to('cuda')
28
+ generated_ids = model.generate(**inputs, max_new_tokens=max_length, temperature=temperature, do_sample=True).split(tokenizer.eos_token)[0])
29
  generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
30
 
31
  return generated_text