Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,14 +8,14 @@ model = GPT2LMHeadModel.from_pretrained("Loewolf/GPT_1")
|
|
8 |
|
9 |
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]) + 20
|
14 |
beam_output = model.generate(
|
15 |
input_ids,
|
16 |
attention_mask=attention_mask,
|
17 |
max_length=max_length,
|
18 |
-
min_length=4,
|
19 |
num_beams=5,
|
20 |
no_repeat_ngram_size=2,
|
21 |
early_stopping=True,
|
@@ -24,7 +24,7 @@ def generate_text(prompt):
|
|
24 |
top_k=50,
|
25 |
length_penalty=2.0,
|
26 |
do_sample=True,
|
27 |
-
eos_token_id=tokenizer.eos_token_id,
|
28 |
pad_token_id=tokenizer.eos_token_id
|
29 |
)
|
30 |
|
@@ -32,24 +32,24 @@ def generate_text(prompt):
|
|
32 |
return text
|
33 |
|
34 |
css = """
|
35 |
-
body { font-family: Arial, sans-serif; }
|
36 |
-
.
|
37 |
-
.
|
38 |
-
.
|
39 |
-
.
|
40 |
-
|
41 |
-
|
|
|
42 |
"""
|
43 |
|
44 |
iface = gr.Interface(
|
45 |
fn=generate_text,
|
46 |
-
inputs=gr.Textbox(
|
47 |
-
outputs=
|
48 |
-
title="Löwolf Chat",
|
49 |
-
description="Willkommen beim Löwolf Chat. Stelle deine Fragen und erhalte Antworten vom KI-Chatbot.",
|
50 |
css=css
|
51 |
)
|
52 |
|
53 |
iface.launch()
|
54 |
|
55 |
|
|
|
|
8 |
|
9 |
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]) + 20
|
14 |
beam_output = model.generate(
|
15 |
input_ids,
|
16 |
attention_mask=attention_mask,
|
17 |
max_length=max_length,
|
18 |
+
min_length=4,
|
19 |
num_beams=5,
|
20 |
no_repeat_ngram_size=2,
|
21 |
early_stopping=True,
|
|
|
24 |
top_k=50,
|
25 |
length_penalty=2.0,
|
26 |
do_sample=True,
|
27 |
+
eos_token_id=tokenizer.eos_token_id,
|
28 |
pad_token_id=tokenizer.eos_token_id
|
29 |
)
|
30 |
|
|
|
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 |
+
.gradio_input { border-radius: 20px; }
|
41 |
+
.gradio_output { border-radius: 20px; }
|
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="text",
|
|
|
|
|
49 |
css=css
|
50 |
)
|
51 |
|
52 |
iface.launch()
|
53 |
|
54 |
|
55 |
+
|