Skip to content

Commit

Permalink
Add dynamic max_token
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDanShouRouZhouXD committed Apr 17, 2024
1 parent e028865 commit 6b3df6b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion manga_translator/translators/sakura.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ async def _request_translation(self, input_text_list) -> str:
raw_text = "\n".join(input_text_list)
else:
raw_text = input_text_list
raw_lenth = len(raw_text)
max_lenth = 512
max_token_num = max(raw_lenth*2, max_lenth)
extra_query = {
'do_sample': False,
'num_beams': 1,
Expand Down Expand Up @@ -543,7 +546,7 @@ async def _request_translation(self, input_text_list) -> str:
messages=messages,
temperature=self.temperature,
top_p=self.top_p,
max_tokens=1024,
max_tokens=max_token_num,
frequency_penalty=self.frequency_penalty,
seed=-1,
extra_query=extra_query,
Expand Down

0 comments on commit 6b3df6b

Please sign in to comment.