JohanBeytell commited on
Commit
0073aa4
·
verified ·
1 Parent(s): 27a3bf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -75,10 +75,10 @@ def generate_random_name(interpreter, vocab_size, sp, max_length=10, temperature
75
  next_index = int(next_index)
76
  next_token = sp.id_to_piece(next_index)
77
 
78
- generated_name += next_token
79
 
80
  # Decode the generated subword tokens into a string
81
- decoded_name = sp.decode_pieces(generated_name.split())
82
 
83
  # Stop if end token is predicted (optional)
84
  if next_token == '' or len(decoded_name) > max_length:
 
75
  next_index = int(next_index)
76
  next_token = sp.id_to_piece(next_index)
77
 
78
+ generated_name = sp.decode_pieces(sp.encode_as_pieces(generated_name) + [next_token])
79
 
80
  # Decode the generated subword tokens into a string
81
+ decoded_name = sp.decode_pieces(sp.encode_as_pieces(generated_name))
82
 
83
  # Stop if end token is predicted (optional)
84
  if next_token == '' or len(decoded_name) > max_length: