Fix hunyuan resolve stop token ids (#3896)
Signed-off-by: zzh <943967662@qq.com>
This commit is contained in:
5 files changed
+199
-3
No files matched your search
@@ -146,6 +146,7 @@ def resolve_stop_token_ids(
|
||||
task: str = "it2i",
|
||||
bot_task: str | None | _DefaultBotTask = _DEFAULT_BOT_TASK,
|
||||
tokenizer: Any | None = None,
|
||||
image_size: str | None = None,
|
||||
) -> list[int]:
|
||||
"""AR stop-token ids for a given (task, bot_task) generation request.
|
||||
|
||||
@@ -171,6 +172,14 @@ def resolve_stop_token_ids(
|
||||
if bot_task not in _BOT_TASK_PRESETS:
|
||||
raise ValueError(f"Unknown bot_task {bot_task!r}. Choose from: {available_bot_tasks()}")
|
||||
if task in ("it2i", "t2i"):
|
||||
need_ratio = image_size is None or image_size == "auto"
|
||||
if not need_ratio:
|
||||
end_of_think_id = HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS["</think>"]
|
||||
end_of_recaption_id = HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS["</recaption>"]
|
||||
if bot_task in ("think_recaption", "recaption"):
|
||||
return [end_of_recaption_id]
|
||||
if bot_task == "think":
|
||||
return [end_of_think_id, end_of_recaption_id]
|
||||
# Main ratio range: <img_ratio_0> .. <img_ratio_32>.
|
||||
start = HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS["<img_ratio_0>"]
|
||||
end = HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS["<img_ratio_32>"]
|
||||
|
||||
Reference in new issue
Block a user