Samurai719214 commited on
Commit
d8cb255
·
verified ·
1 Parent(s): 8d6c1d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -24,13 +24,13 @@ def generate_full_story(excerpt: str) -> str:
24
  # Generate tokens. Here, we set parameters to control length and creativity.
25
  output = model.generate(
26
  encoded_input["input_ids"],
27
- attention_mask=encoded_input["attention_mask"],
28
- max_new_tokens=200, # Generate 200 new tokens on top of the input.
29
- do_sample=True,
30
- temperature=0.8,
31
- top_p=0.95,
32
- no_repeat_ngram_size=2,
33
- return_dict_in_generate=True
34
  )
35
 
36
  # Decode the generated sequence.
@@ -40,20 +40,19 @@ def generate_full_story(excerpt: str) -> str:
40
 
41
  # Build the Gradio interface.
42
  interface = gr.Interface(
43
- fn=generate_full_story,
44
- inputs=gr.Textbox(
45
- lines=5,
46
- label="Incomplete Story Excerpt",
47
- placeholder="Enter your incomplete story excerpt here..."
48
  ),
49
- outputs=gr.Textbox(label="Complete Story with Details"),
50
  title="Mythology Storyteller",
51
  description=(
52
  "Enter an incomplete story excerpt. "
53
- "The model will generate a complete output that includes the chapter (Parv), key event, section, "
54
- "and the full story continuation."
55
  )
56
  )
57
 
58
  # Launch the Gradio app.
59
- interface.launch(share=True)
 
24
  # Generate tokens. Here, we set parameters to control length and creativity.
25
  output = model.generate(
26
  encoded_input["input_ids"],
27
+ attention_mask = encoded_input["attention_mask"],
28
+ max_new_tokens = 200, # Generate 200 new tokens on top of the input.
29
+ do_sample = True,
30
+ temperature = 0.8,
31
+ top_p = 0.95,
32
+ no_repeat_ngram_size = 2,
33
+ return_dict_in_generate = True
34
  )
35
 
36
  # Decode the generated sequence.
 
40
 
41
  # Build the Gradio interface.
42
  interface = gr.Interface(
43
+ fn = generate_full_story,
44
+ inputs = gr.Textbox(
45
+ lines = 5,
46
+ label = "Incomplete Story Excerpt",
47
+ placeholder = "Enter your incomplete story excerpt here..."
48
  ),
49
+ outputs=gr.Textbox(label = "Complete Story with Details"),
50
  title="Mythology Storyteller",
51
  description=(
52
  "Enter an incomplete story excerpt. "
53
+ "The model will generate a complete the complete chapter."
 
54
  )
55
  )
56
 
57
  # Launch the Gradio app.
58
+ interface.launch(share = True)