mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-02 09:56:55 +00:00
fix: Allow to set num_beams in HFInvocationLayer (#4731)
Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Co-authored-by: bogdankostic <bogdankostic@web.de>
This commit is contained in:
parent
7fa3591f5f
commit
2be1a68fce
@ -193,7 +193,10 @@ class HFLocalInvocationLayer(PromptModelInvocationLayer):
|
||||
model_input_kwargs["stopping_criteria"] = StoppingCriteriaList([sw])
|
||||
if top_k:
|
||||
model_input_kwargs["num_return_sequences"] = top_k
|
||||
model_input_kwargs["num_beams"] = top_k
|
||||
if "num_beams" not in model_input_kwargs or model_input_kwargs["num_beams"] < top_k:
|
||||
if "num_beams" in model_input_kwargs:
|
||||
logger.warning("num_beams should not be less than top_k, hence setting it to %s", top_k)
|
||||
model_input_kwargs["num_beams"] = top_k
|
||||
# max_new_tokens is used for text-generation and max_length for text2text-generation
|
||||
if is_text_generation:
|
||||
model_input_kwargs["max_new_tokens"] = self.max_length
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user