GreedySampler
類別keras_hub.samplers.GreedySampler(**kwargs)
貪婪取樣器類別。
此取樣器基於貪婪搜尋實作,亦即,總是挑選機率最大的詞符作為下一個詞符。
範例
causal_lm = keras_hub.models.GPT2CausalLM.from_preset("gpt2_base_en")
# Pass by name to compile.
causal_lm.compile(sampler="greedy")
causal_lm.generate(["Keras is a"])
# Pass by object to compile.
sampler = keras_hub.samplers.GreedySampler()
causal_lm.compile(sampler=sampler)
causal_lm.generate(["Keras is a"])