from pathlib import Path from kda.training.eval_mt import _instruction from kda.training.prompts import instruction_prompt _ROOT = Path(__file__).resolve().parents[2] / "data" / "eval" def _lines(name: str) -> list[str]: return [ln.strip() for ln in (_ROOT / name).read_text(encoding="utf-8").splitlines() if ln.strip()] def test_frozen_eval_files_are_aligned(): zh_src, zh_ref = _lines("zh2en.src.txt"), _lines("zh2en.ref.txt") en_src, en_ref = _lines("en2zh.src.txt"), _lines("en2zh.ref.txt") assert len(zh_src) == len(zh_ref) >= 16 assert len(en_src) == len(en_ref) >= 16 assert all("\t" not in s for s in zh_src + en_src) def test_eval_instruction_is_the_sft_template(): assert _instruction("q", "en") == instruction_prompt("q", "en") assert _instruction("q", "zh") == instruction_prompt("q", "zh")