Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
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
|