tskolm commited on
Commit
4d73d74
·
1 Parent(s): fd88ce0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -17,10 +17,16 @@ def generate(tokenizer, model, text, features):
17
  )
18
  decoded = tokenizer.decode(sample_outputs[0], skip_special_tokens=False)
19
  print(decoded, file=sys.stderr)
20
- if '<|authornameend|>' not in decoded:
21
- continue
22
 
23
- author, text = decoded.split('<|authornamebegin|>')[-1].split('<|authornameend|>')
 
 
 
 
 
 
 
 
24
 
25
  count += 1
26
  st.markdown('**' + author.strip() + '**: ' + text.replace('<|endoftext|>', '').replace('<|pad|>', '').strip())
 
17
  )
18
  decoded = tokenizer.decode(sample_outputs[0], skip_special_tokens=False)
19
  print(decoded, file=sys.stderr)
 
 
20
 
21
+ if '<|authornamebegin|>' not in decoded:
22
+ continue
23
+
24
+ raw = decoded.split('<|authornamebegin|>')[-1]
25
+
26
+ if '<|authornameend|>' not in raw:
27
+ continue
28
+
29
+ author, text = raw.split('<|authornameend|>')
30
 
31
  count += 1
32
  st.markdown('**' + author.strip() + '**: ' + text.replace('<|endoftext|>', '').replace('<|pad|>', '').strip())