Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions keras_nlp/models/gpt2/gpt2_causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GPT2CausalLM(Task):
gpt2_lm.generate("I want to say", max_length=30)

gpt2_lm.compile(sampler=keras_nlp.samplers.BeamSampler(num_beams=2))
gpt2_lm.generate("I want to say", max_length=30, sampler=sampler)
gpt2_lm.generate("I want to say", max_length=30)
```

Map raw string to languages model logit predictions.
Expand Down Expand Up @@ -331,15 +331,13 @@ def generate(

This method generates text based on given `prompt`. Generation will
continue until `max_length` is met, and all tokens generated after
`end_token` will be truncated. The sampling approach used can be
controlled via the sampler argument.
`end_token` will be truncated. The sampling strategy can be set in
the `compile` method.

Args:
prompt: a string, string Tensor or string RaggedTensor. The prompt
text for generation.
max_length: int. The max length of generated sequence.
sampler: a string or `keras_nlp.samplers.Sampler` instance. The
sampler to be used for text generation.
"""
if self.preprocessor is None:
raise ValueError(
Expand Down