Files
qwen3-1.7b-lamini-qlora-ins…/prompt_format.py

21 lines
550 B
Python
Raw Normal View History

# prompt_format.py
from __future__ import annotations
RESPONSE_TAG = "### Response:"
def format_instruction_prompt(instruction: str, inp: str | None = None) -> str:
instruction = (instruction or "").strip()
inp = (inp or "").strip() if inp is not None else ""
if inp:
return (
f"### Instruction:\n{instruction}\n\n"
f"### Input:\n{inp}\n\n"
f"{RESPONSE_TAG}\n"
)
else:
return (
f"### Instruction:\n{instruction}\n\n"
f"{RESPONSE_TAG}\n"
)