Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ def generate_text(prompt):
|
|
| 10 |
input_ids = tokenizer.encode(prompt, return_tensors="pt")
|
| 11 |
attention_mask = torch.ones(input_ids.shape, dtype=torch.bool)
|
| 12 |
|
| 13 |
-
max_length = model.config.n_positions if len(input_ids[0]) > model.config.n_positions else len(input_ids[0]) +
|
| 14 |
beam_output = model.generate(
|
| 15 |
input_ids,
|
| 16 |
attention_mask=attention_mask,
|
|
@@ -20,8 +20,8 @@ def generate_text(prompt):
|
|
| 20 |
no_repeat_ngram_size=2,
|
| 21 |
early_stopping=True,
|
| 22 |
temperature=0.9,
|
| 23 |
-
top_p=0.
|
| 24 |
-
top_k=
|
| 25 |
length_penalty=2.0,
|
| 26 |
do_sample=True,
|
| 27 |
eos_token_id=tokenizer.eos_token_id,
|
|
@@ -30,22 +30,22 @@ def generate_text(prompt):
|
|
| 30 |
|
| 31 |
text = tokenizer.decode(beam_output[0], skip_special_tokens=True)
|
| 32 |
return text
|
| 33 |
-
|
| 34 |
css = """
|
| 35 |
body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
|
| 36 |
-
.gradio_app { max-width: 600px; margin: 50px auto; }
|
| 37 |
.gradio_interface { box-shadow: 0 0 20px rgba(0,0,0,0.1); }
|
| 38 |
.gradio_input_container { width: 100%; }
|
| 39 |
.gradio_output_container { width: 100%; margin-bottom: 25px; }
|
| 40 |
-
.
|
| 41 |
-
.
|
| 42 |
button { border-radius: 20px; }
|
| 43 |
"""
|
| 44 |
|
| 45 |
iface = gr.Interface(
|
| 46 |
fn=generate_text,
|
| 47 |
-
inputs=gr.Textbox(placeholder="Type a message..."),
|
| 48 |
-
outputs="
|
| 49 |
css=css
|
| 50 |
)
|
| 51 |
|
|
@@ -53,3 +53,4 @@ iface.launch()
|
|
| 53 |
|
| 54 |
|
| 55 |
|
|
|
|
|
|
| 10 |
input_ids = tokenizer.encode(prompt, return_tensors="pt")
|
| 11 |
attention_mask = torch.ones(input_ids.shape, dtype=torch.bool)
|
| 12 |
|
| 13 |
+
max_length = model.config.n_positions if len(input_ids[0]) > model.config.n_positions else len(input_ids[0]) + 20
|
| 14 |
beam_output = model.generate(
|
| 15 |
input_ids,
|
| 16 |
attention_mask=attention_mask,
|
|
|
|
| 20 |
no_repeat_ngram_size=2,
|
| 21 |
early_stopping=True,
|
| 22 |
temperature=0.9,
|
| 23 |
+
top_p=0.90,
|
| 24 |
+
top_k=50,
|
| 25 |
length_penalty=2.0,
|
| 26 |
do_sample=True,
|
| 27 |
eos_token_id=tokenizer.eos_token_id,
|
|
|
|
| 30 |
|
| 31 |
text = tokenizer.decode(beam_output[0], skip_special_tokens=True)
|
| 32 |
return text
|
| 33 |
+
|
| 34 |
css = """
|
| 35 |
body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
|
| 36 |
+
.gradio_app { display: flex; flex-direction: column-reverse; max-width: 600px; margin: 50px auto; }
|
| 37 |
.gradio_interface { box-shadow: 0 0 20px rgba(0,0,0,0.1); }
|
| 38 |
.gradio_input_container { width: 100%; }
|
| 39 |
.gradio_output_container { width: 100%; margin-bottom: 25px; }
|
| 40 |
+
.gradio_text_input { height: 50px; border-radius: 20px; }
|
| 41 |
+
.gradio_text_output { height: calc(100vh - 150px); border-radius: 20px; overflow-y: auto; }
|
| 42 |
button { border-radius: 20px; }
|
| 43 |
"""
|
| 44 |
|
| 45 |
iface = gr.Interface(
|
| 46 |
fn=generate_text,
|
| 47 |
+
inputs=gr.Textbox(lines=2, placeholder="Type a message...", label="Your Message"),
|
| 48 |
+
outputs=gr.Textbox(label="Löwolf Chat Responses", placeholder="Responses will appear here...", interactive=False, lines=10),
|
| 49 |
css=css
|
| 50 |
)
|
| 51 |
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
+
|