Skip to content

如何设置模型推理时的参数,如top_k? How to set the generation config of the model, like the temperature. #329

Answered by gaotongxiao
royny asked this question in Q&A
Discussion options

You must be logged in to vote

Note that by default HF uses greedy decoding if no extra kwargs are passed to the generation function, and the evaluation should be fair.

In case you do want to customize the generation parameters, you may modify the HuggingFace class and add generation_kwargs to its __init__ function, which saves the kwargs on construction and then uses it in generate(). With such a modification, you can set these parameters in model configuration as how model_kwargs or tokenizer_kwargs is set.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by tonysy
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants