Loewolf commited on
Commit
8954938
·
1 Parent(s): 0858488

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
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) # Erstelle eine Attention-Mask, die überall '1' ist
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, # Mindestlänge der Antwort
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, # EOS Token setzen
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
- .gradio_container { max-width: 700px; margin: auto; padding-top: 50px; }
37
- .gradio_header { display: none; }
38
- .gradio_input_box { border-radius: 10px; }
39
- .gradio_output_box { border-radius: 10px; }
40
- button { background-color: #29B3FF; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; }
41
- button:hover { background-color: #106ba3; }
 
42
  """
43
 
44
  iface = gr.Interface(
45
  fn=generate_text,
46
- inputs=gr.Textbox(label="Schreibe hier...", placeholder="Stelle deine Frage..."),
47
- outputs=gr.Textbox(label="Antwort"),
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
+