ThomasBlumet commited on
Commit
54f41e4
·
1 Parent(s): 6a2a8e3

change max_length

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -14,7 +14,7 @@ model = AutoModelForCausalLM.from_pretrained(model_name)
14
  # Fonction pour générer du texte
15
  def generate_text(prompt):
16
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
17
- summary_ids = model.generate(inputs["input_ids"], max_length=512, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
18
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
19
 
20
  # #for training the model after the data is collected
@@ -22,7 +22,7 @@ def generate_text(prompt):
22
  # #tokenizer.save_pretrained("model")
23
 
24
  # #for the app functions
25
- # def clear_save_textbox(message):
26
  # return " ", message
27
 
28
  # def show_input_text(message,history:list[tuple[str,str]]):
@@ -42,18 +42,16 @@ def generate_text(prompt):
42
  interface = gr.Interface(fn=generate_text, inputs="text", outputs="text",title="TeLLMyStory",description="Enter your story idea and the model will generate the story based on it.")
43
  # with gr.Blocks() as demo:
44
  # gr.Markdown("TeLLMyStory chatbot")
45
- # #input_text = blocks.text(name="input_text", label="Enter your story idea here", default="Once upon a time, there was")
46
  # with gr.Row():
47
- # input_text = gr.Textbox(label="Enter your story idea here")
48
- # #clear_button = gr.Button("Clear",variant="secondary")
49
- # #clear_button.click(fn=clear_save_textbox, inputs=[input_text])
50
- # #retry_button = gr.Button("Retry", fn=delete_previous_text, inputs=[input_text],variants=["secondary"])
51
 
52
  # with gr.Row():
53
- # gr.Markdown("History of your story ideas")
54
  # gen_story = gr.Textbox(label="History")
55
 
56
- # #send_button = gr.Button(name="send_button", label="Send", fn=show_input_text, inputs=[input_text],outputs=[gen_story],variants=["primary"])
57
-
58
  # # Lancer l'interface
59
  interface.launch()
 
14
  # Fonction pour générer du texte
15
  def generate_text(prompt):
16
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
17
+ summary_ids = model.generate(inputs["input_ids"], max_new_tokens=512, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
18
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
19
 
20
  # #for training the model after the data is collected
 
22
  # #tokenizer.save_pretrained("model")
23
 
24
  # #for the app functions
25
+ # def clear_textbox(message):
26
  # return " ", message
27
 
28
  # def show_input_text(message,history:list[tuple[str,str]]):
 
42
  interface = gr.Interface(fn=generate_text, inputs="text", outputs="text",title="TeLLMyStory",description="Enter your story idea and the model will generate the story based on it.")
43
  # with gr.Blocks() as demo:
44
  # gr.Markdown("TeLLMyStory chatbot")
 
45
  # with gr.Row():
46
+ # input_text = gr.Textbox(label="Enter your story idea here", placeholder="Once upon a time...")
47
+ # clear_button = gr.Button("Clear",variant="secondary")
48
+ # submit_button = gr.Button("Submit", variant="primary")
 
49
 
50
  # with gr.Row():
51
+ # gr.Markdown("And see the story take shape here")
52
  # gen_story = gr.Textbox(label="History")
53
 
54
+ # #submit_button.click(fn=show_input_text, inputs=[input_text],outputs=[gen_story])
55
+ #clear_button.click(fn=clear_textbox, inputs=[input_text])
56
  # # Lancer l'interface
57
  interface.launch()