From d6aeb9fa1552939e7444d845a9d0f5e9225daf02 Mon Sep 17 00:00:00 2001 From: rainred <107027757+gryffindor-rr@users.noreply.github.com> Date: Thu, 22 Aug 2024 05:28:35 +0800 Subject: [PATCH] [Feature] Add a function to convert sampling_params to kwargs (#1170) Co-authored-by: lzhang --- python/sglang/srt/sampling_params.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/sglang/srt/sampling_params.py b/python/sglang/srt/sampling_params.py index 6a8823cc4..712827d79 100644 --- a/python/sglang/srt/sampling_params.py +++ b/python/sglang/srt/sampling_params.py @@ -123,3 +123,17 @@ class SamplingParams: else: stop_str_max_len = max(stop_str_max_len, len(stop_str)) self.stop_str_max_len = stop_str_max_len + + def to_srt_kwargs(self): + return { + "max_new_tokens": self.max_new_tokens, + "stop": self.stop_strs, + "stop_token_ids": list(self.stop_token_ids), + "temperature": self.temperature, + "top_p": self.top_p, + "top_k": self.top_k, + "frequency_penalty": self.frequency_penalty, + "presence_penalty": self.presence_penalty, + "ignore_eos": self.ignore_eos, + "regex": self.regex, + }