from __future__ import annotations import base64 from typing import Any, Callable, Iterable, TYPE_CHECKING import torch if TYPE_CHECKING: from torch import Tensor from .base import ModelBase, MmprojModel, gguf, logger from .qwen import QwenModel, Qwen3Model # token ids of the yue2_infer protocol (protocol.py) EOD = 151643 ABC_START, ABC_END = 151847, 151848 MUSIC_START, MUSIC_END = 151851, 151852 CODEC_OFFSET, CODEC_SIZE = 151853, 32768 LATENT_START = 184621 # the VAE is a separate repo (m-a-p/YuE2-Vae), downloaded into this subdir of the model dir VAE_DIR = "vae" INSTRUCTIONS = { "off": "Generate music with codec tokens from the given conditions.", "melody": "Generate a melody-only ABC transcription without chord symbols, then generate music with codec tokens from the given conditions.", "full": "Generate a chord-annotated ABC transcription, then generate music with codec tokens from the given conditions.", } # the text is "[Tags]\n