next_token_logits = model(**inputs).logits[:, -1, :]
filter
filtered_next_token_logits = tf_top_k_top_p_filtering(next_token_logits, top_k=50, top_p=1.0)
sample
next_token = tf.random.categorical(filtered_next_token_logits, dtype=tf.int32, num_samples=1)
generated = tf.concat([input_ids, next_token], axis=1)
resulting_string = tokenizer.decode(generated.numpy().tolist()[0])
print(resulting_string)
Hugging Face is based in DUMBO, New York City, and ...
```
This outputs a (hopefully) coherent next token following the original sequence, which in our case is the word is or
features.
In the next section, we show how [generation_utils.GenerationMixin.generate] can be used to
generate multiple tokens up to a specified length instead of one token at a time.
Text Generation
In text generation (a.k.a open-ended text generation) the goal is to create a coherent portion of text that is a
