ZWEi-P commited on
Commit
8923bc5
1 Parent(s): a143715

max_length calculation change to account for Initial Text length

Browse files

Trying to fix the problem that occurs when inputting a lengthy initial text; either it only outputs a few words, or simply give up and output nothing.

Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -17,7 +17,7 @@ def generate(starting_text):
17
  starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)
18
  print(starting_text)
19
 
20
- response = gpt2_pipe(starting_text, max_length=random.randint(60, 90), num_return_sequences=4)
21
  response_list = []
22
  for x in response:
23
  resp = x['generated_text'].strip()
 
17
  starting_text: str = re.sub(r"[,:\-–.!;?_]", '', starting_text)
18
  print(starting_text)
19
 
20
+ response = gpt2_pipe(starting_text, max_length=(len(starting_text) + random.randint(60, 90)), num_return_sequences=4)
21
  response_list = []
22
  for x in response:
23
  resp = x['generated_text'].strip()