Skip to content

vllm_omni.tokenizers.yue2_prompt

Prompt construction for YuE2-3B, mirroring upstream protocol.py.

The driver (offline example or, later, the serving adapter) builds token-id prefixes here and submits them as prompt_token_ids. Both generation phases share one prefix head (instruction + tags + lyrics); the abc phase continues from ABC_START and stops at ABC_END, the semantic phase embeds the ABC score (generated or user-supplied) and continues from MUSIC_START.

INSTRUCTIONS module-attribute

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.",
}

abc_ids_from_generated

abc_ids_from_generated(generated: list[int]) -> list[int]

ABC token ids generated by the abc phase (end token stripped).

abc_prefix_ids

abc_prefix_ids(
    encode, style: str, lyrics: str, cot: str
) -> list[int]

Prompt for the abc phase (cot=full/melody, no external ABC).

semantic_frames

semantic_frames(generated: list[int]) -> list[int]

Codec frame values (0..CODEC_SIZE-1) from semantic-phase output.

semantic_prefix_ids

semantic_prefix_ids(
    encode,
    style: str,
    lyrics: str,
    cot: str,
    abc_ids: list[int] | None = None,
) -> list[int]

Prompt for the semantic phase.

abc_ids are the token ids of the (generated or user-supplied) ABC score. cot=off passes abc_ids=None and skips the span, matching upstream token_prefixes.

song_text

song_text(style: str, lyrics: str, cot: str) -> str