From 1f410e471414d190c506f915a959c892a2771ef2 Mon Sep 17 00:00:00 2001 From: Guanghua Lu <102669562+Touch-Night@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:24:11 +0800 Subject: [PATCH] Fix max_tokens setting not working for TextGenWebui translator (#828) * Fix max_tokens setting not working for TextGenWebui translator Added "max_tokens": self.config["max_tokens"]. * Update translatorsetting.json --- LunaTranslator/LunaTranslator/translator/TGW.py | 2 ++ LunaTranslator/files/defaultconfig/translatorsetting.json | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/TGW.py b/LunaTranslator/LunaTranslator/translator/TGW.py index 782ef070..7a5573b5 100644 --- a/LunaTranslator/LunaTranslator/translator/TGW.py +++ b/LunaTranslator/LunaTranslator/translator/TGW.py @@ -89,6 +89,7 @@ class TS(basetrans): "top_p": self.config["top_p"], "min_p": self.config["min_p"], "top_k": self.config["top_k"], + "max_tokens": self.config["max_tokens"], "num_beams": self.config["num_beams"], "repetition_penalty": self.config["repetition_penalty"], "repetition_penalty_range": self.config["repetition_penalty_range"], @@ -132,6 +133,7 @@ class TS(basetrans): "top_p": self.config["top_p"], "min_p": self.config["min_p"], "top_k": self.config["top_k"], + "max_tokens": self.config["max_tokens"], "num_beams": self.config["num_beams"], "repetition_penalty": self.config["repetition_penalty"], "repetition_penalty_range": self.config["repetition_penalty_range"], diff --git a/LunaTranslator/files/defaultconfig/translatorsetting.json b/LunaTranslator/files/defaultconfig/translatorsetting.json index 4dc4bc8b..8959e290 100644 --- a/LunaTranslator/files/defaultconfig/translatorsetting.json +++ b/LunaTranslator/files/defaultconfig/translatorsetting.json @@ -718,7 +718,7 @@ "prompt(文本起始)": "将这段文本直接翻译成中文,不要进行任何额外的格式修改,这里是你需要翻译的文本:", "negative_prompt(不懂可以不写)": "", "stop(自定义停止符,多个用逗号隔开)": "", - "max_tokens(单次生成上限)": 200, + "max_tokens": 200, "instruction_template(需要按照模型模板选择)": "", "mode": "instruct", "temperature": 0.6, @@ -762,7 +762,7 @@ "max": 32, "step": 1 }, - "max_tokens(单次生成上限)": { + "max_tokens": { "type": "intspin", "min": 1, "max": 2048, @@ -879,4 +879,4 @@ } } } -} \ No newline at end of file +}