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